SHT1x/SHT2x #
The SHT1x/SHT2x provides calibrated, linearized sensor signals in digital IC2 format (SCL/SDA lines). The SHT1x/SHT2x humidity sensor series contains a capacitive-type humidity sensor, a band-gap temperature sensor, and specialized analog and digital integrated circuits – all on a single CMOSens® chip. This yields superior sensor performance in terms of accuracy and stability as well as minimal power consumption. Its relative humidity calculation accuracy is +/-3%.
An electronic identification code is stored on the chip – which can be read out on command. Furthermore, the resolution of the SHT2x humidity sensor can be changed on command (8/12 bit up to 12/14 bit for RH/T) and a checksum helps to improve communication reliability. With this set of features and its proven reliability and long-term stability, the SHT2x humidity sensor offers an outstanding price-performance ratio.
In the second figure, you can see a water proof version of this sensor for outdoor deployment.
Documentation for this sensor is available here.
Connecting to Arduino #
We will use the Arduino’s default I2C pins: A5 for SCL (clock) and A4 for SDA (data).
Code example #
Note that the code uses pin 9 to power the sensor, so instead of connecting SHT VCC to Arduino 3.3V as illustrated in the figure above, connect it to Arduino pin 9.
#include "Sensirion.h"
#define SHTD_PIN A4
#define SHTC_PIN A5
#define SHT2x
//we can also power the SHT with a digital pin, here pin 9
#define PIN_POWER 9
#ifdef SHT2x
Sensirion sht = Sensirion(SHTD_PIN, SHTC_PIN, 0x40);
#else
Sensirion sht = Sensirion(SHTD_PIN, SHTC_PIN);
#endif
float h;
float t;
int ret;
int retry=0;
void setup() {
delay(3000);
Serial.begin(38400);
//and to power the temperature sensor
pinMode(PIN_POWER,OUTPUT);
}
void loop() {
digitalWrite(PIN_POWER,HIGH);
delay(1000);
while ( (ret != S_Meas_Rdy) ) {
ret=sht.measure(&t, &h);
retry++;
Serial.print("[");
Serial.print(ret);
Serial.print(":");
Serial.print(retry);
Serial.print("] ");
}
if (ret != S_Meas_Rdy) {
Serial.println("Failed to read from SHT sensor!");
}
else {
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius Humidity: ");
Serial.print(h);
Serial.println("%");
}
digitalWrite(PIN_POWER,LOW);
ret=0;
retry=0;
delay(5000);
}
Enjoy!
2018 - Muhammad Ehsan, Mamour Diop & Congduc Pham