SHT1X Temperature and Humidity Sensor.
More...
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.
while (shouldRun) {
sensor.update();
cout << "Temperature: " << sensor.getTemperature() << " C" << endl;
cout << "Humidity: " << sensor.getHumidity() << " RH" << endl;
cout << endl;
upm_delay(2);
}
SHT1X |
( |
unsigned int |
clk_pin, |
|
|
unsigned int |
data_pin |
|
) |
| |
SHT1X object constructor
- Parameters
-
clk_pin | Specify the GPIO pin to use for the clock. |
data_pin | Specify the GPIO pin to use for data. |
Perform a soft reset of the device.
Query the device and store the latest values. You must call this function before querying the temperature or the humidity.
float getTemperature |
( |
void |
| ) |
|
Query the temperature in degrees Celsius. update() must have been called prior to calling this function.
- Returns
- The temperature in Celsius
float getHumidity |
( |
void |
| ) |
|
Query the relative humidity. update() must have been called prior to calling this function.
- Returns
- The relative humidity.
Read the status register.
- Returns
- The contents of the status register.
upm_result_t writeStatus |
( |
uint8_t |
status | ) |
|
Write a value to the status register.
- Parameters
-
status | The uint8_t to write to the register. |
- Returns
- UPM result
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
-
volts | One of the SHT1X_VOLTS_T values. |
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
-
cmd | One of the SHT1X_CMD_T values. |
- Returns
- UPM result
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
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
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
-
value | Pointer to a uint8_t that will hold the received byte. |
- Returns
- UPM result
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
-
value | A uint8_t that will be sent to the device. |
- Returns
- UPM result
The documentation for this class was generated from the following files: