upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Member Functions | Protected Attributes

SHT1X Temperature and Humidity Sensor. More...

Detailed Description

This driver was tested with a DFRobot SHT10 Temperature and Humidity sensor. This driver should work on all SHT1X devices.

It requires a 10K pull-up resistor connected to the data pin. The sensor can be run at differing voltages from 2.5v to 5v.

// Instantiate a SHT1X sensor using D2 as the clock, and D3 as the
// data pin.
upm::SHT1X sensor(2, 3);
// Every 2 seconds, update and print values
while (shouldRun) {
sensor.update();
cout << "Temperature: " << sensor.getTemperature() << " C" << endl;
cout << "Humidity: " << sensor.getHumidity() << " RH" << endl;
cout << endl;
upm_delay(2);
}

Public Member Functions

 SHT1X (unsigned int clk_pin, unsigned int data_pin)
 
 ~SHT1X ()
 
void reset ()
 
void update ()
 
float getTemperature ()
 
float getHumidity ()
 
uint8_t readStatus ()
 
upm_result_t writeStatus (uint8_t status)
 
void setVolts (SHT1X_VOLTS_T volts)
 

Protected Member Functions

upm_result_t sendCommand (SHT1X_CMD_T cmd)
 
upm_result_t waitForResponse ()
 
void startXmit ()
 
uint8_t read8Bits ()
 
upm_result_t write8Bits (uint8_t byte)
 

Protected Attributes

sht1x_context m_sht1x
 

Constructor & Destructor Documentation

SHT1X ( unsigned int  clk_pin,
unsigned int  data_pin 
)

SHT1X object constructor

Parameters
clk_pinSpecify the GPIO pin to use for the clock.
data_pinSpecify the GPIO pin to use for data.
~SHT1X ( )

SHT1X object destructor

Here is the call graph for this function:

Member Function Documentation

void reset ( )

Perform a soft reset of the device.

Here is the call graph for this function:

void update ( void  )

Query the device and store the latest values. You must call this function before querying the temperature or the humidity.

Here is the call graph for this function:

float getTemperature ( void  )

Query the temperature in degrees Celsius. update() must have been called prior to calling this function.

Returns
The temperature in Celsius

Here is the call graph for this function:

float getHumidity ( void  )

Query the relative humidity. update() must have been called prior to calling this function.

Returns
The relative humidity.

Here is the call graph for this function:

uint8_t readStatus ( )

Read the status register.

Returns
The contents of the status register.

Here is the call graph for this function:

upm_result_t writeStatus ( uint8_t  status)

Write a value to the status register.

Parameters
statusThe uint8_t to write to the register.
Returns
UPM result

Here is the call graph for this function:

void setVolts ( SHT1X_VOLTS_T  volts)

The Vdd voltage the sensor is being driven at can affect the temperature measurements. This function allows you to specify a voltage as close as you are using to power the sensor, so that the appropriate compensation can be made. By default, the coefficients are set for 5v operation.

Parameters
voltsOne of the SHT1X_VOLTS_T values.

Here is the call graph for this function:

upm_result_t sendCommand ( SHT1X_CMD_T  cmd)
protected

Send a command to the device. This is a low level command that should not be used directly unless you know exactly what you are doing.

Parameters
cmdOne of the SHT1X_CMD_T values.
Returns
UPM result

Here is the call graph for this function:

upm_result_t waitForResponse ( )
protected

Wait for the appropriate response when starting a temperature or humidity measurement. This is a low level command that should not be used directly unless you know exactly what you are doing.

Returns
UPM result

Here is the call graph for this function:

void startXmit ( )
protected

Issue the start transmission sequence. This is a low level command that should not be used directly unless you know exactly what you are doing.

Returns
UPM result

Here is the call graph for this function:

uint8_t read8Bits ( )
protected

Read 8 bits (a byte) from the device. This is a low level command that should not be used directly unless you know exactly what you are doing.

Parameters
valuePointer to a uint8_t that will hold the received byte.
Returns
UPM result

Here is the call graph for this function:

upm_result_t write8Bits ( uint8_t  byte)
protected

Write 8 bits (a byte) to the device. This is a low level command that should not be used directly unless you know exactly what you are doing.

Parameters
valueA uint8_t that will be sent to the device.
Returns
UPM result

Here is the call graph for this function:

Collaboration diagram for SHT1X:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: