Important: this repository is deprecated - use https://github.com/Sensirion/arduino-sht instead!
Unofficial repository for Sensirion Humidity and temperature sensor support on Arduino
- SHTC1 (and SHTW1/SHTW2, using the SHTC1 driver)
- SHT3x-DIS (I2C)
- SHT3x-ARP (ratiometric analog voltage output)
Download arduino-sht either via git or from the releases page and place it in the Arduino/libraries directory. After restarting the Arduino IDE, you will get menu items under libraries and examples.
Assuming you installed the library as described above, the following steps are necessary:
- Import the Wire library like this: From the menu bar, select Sketch > Import Library > Wire
- Import the arduino-sht library like this: From the menu bar, select Sketch > Import Library > arduino-sht
- Create an instance of the
SHTC1
class - In
setup()
, make sure to init the Wire library withWire.init()
- If you want to use the serial console, remember to initialize the Serial library with
Serial.begin(9600)
- Call
shtc1.readSample()
in theloop()
function, which reads a temperature & humidity sample from the sensor - Use
shtc1.getHumidity()
andshtc1.getTemperature()
to get the values form the last sample
Important: getHumidity()
and getTemperature()
do not read a new sample from the sensor, but return the values read last. To read a new sample, make sure to call readSample()
#include <Wire.h>
#include <shtc1.h>
SHTC1 shtc1;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
shtc1.readSample();
Serial.print("SHTC1:\n");
Serial.print(" RH: ");
Serial.print(shtc1.getHumidity(), 2);
Serial.print("\n");
Serial.print(" T: ");
Serial.print(shtc1.getTemperature(), 2);
Serial.print("\n");
delay(1000);
}