SHT21
class SHT21
Driver for SHT21 I2C temperature and humidity sensor. More...
Public Functions
Type
Name
SHT21 (I2C * i2c)
float
readTemp ()
float
readHumidity ()
int
reset ()
int
setPrecision (char precision)
Detailed Description
SHT21 Connection class, utilizing a I2C interface Example:
#include "mbed.h"
#include "SHT21_ncleee.h"
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
I2C i2c(p28,p27);
SHT21 sht(&i2c);
int main()
{
pc.printf("Hello World...\n\tTesting temperature Sensor\n");
int temperature = sht.readTemp();
pc.printf("Temperature is: %d \n", temperature);
pc.printf("Experiment complete...\n");
}
Public Functions Documentation
function SHT21
SHT21::SHT21 (
I2C * i2c
)
Constructor - create a connection to a SHT21 temperature and humidity sensor through an I2C interface
Parameters:
*i2c a pointer to the i2c interface that is used for communication
frequency - I2C frequency
function readTemp
float SHT21::readTemp ()
Read the temperature value from the sensor Involves triggering the measuring unit then waiting for 100ms for the measuring to complete before reading the temperature
Parameters:
returns a value representing the temperature in degrees centigrade
function readHumidity
float SHT21::readHumidity ()
Read the humidity value from the sensor Involves triggering the measuring unit then waiting for 100ms for the measuring to complete before reading the humidity
Parameters:
returns the percentage humidity
function reset
int SHT21::reset ()
Perform a soft-reset of the sensor unit.
function setPrecision
int SHT21::setPrecision (
char precision
)
Set the precision of the measuring //Data precision settings //RH 12 T 14 - default
define SHT_PREC_1214 0x00
//RH 8 T 10
define SHT_PREC_0812 0x01
//RH 10 T 13
define SHT_PREC_1013 0x80
//RH 11 T 11
define SHT_PREC_1111 0x81
Parameters:
precision - the precision, refer to above or datasheet.
The documentation for this class was generated from the following file: D:/w/hw-libs/\_libs\_/libraries/SHT21\_ncleee.h
Last updated