This is an old revision of the document!
Temperature and Humidity Sensor
Si7021 is an integrated sensor that measures both temperature and relative humidity with good accuracy. The resolution of measured parameters can be selected through software between 8-12 bits for humidity and 12-14 bits for temperature. The sensor uses a digital I2C interface for data transmission, so we can easily interface with it using the Wire library.
Fig. 1: SI7020 and its connections to the the AVR microcontroller
We will need to use a dedicated library written specially for it. Download the library from here and unzip its contents into the folder named Arduino\libraries or use Arduino IDE's Add ZIP Library command.
#include <Wire.h> #include <SHT2x.h> int controlPin = 7; void setup() { pinMode(controlPin, OUTPUT); //sensor on/off control Wire.begin(); Serial.begin(9600); digitalWrite(controlPin, LOW); //enable all sensors } void loop() { Serial.print("Humidity(%RH): "); Serial.print(SHT2x.GetHumidity()); Serial.print(" Temperature(C): "); Serial.println(SHT2x.GetTemperature()); //digitalWrite(controlPin, HIGH); //disable all sensors delay(1000); }