SI7021 #
The Si7021 humidity and temperature sensor is a modern & accurate sensor, readily available on small breakout boards. It is quite similar to the SHT2x and the native sensor’s operating range is 1.9 to 3.6V. You can find it already embedded in a number of recent microcontroller boards as well.
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 #
We will use the very versatile I2C-Sensor-Lib that can support many I2C sensors.
- Austria Microsystems TCS3772: light sensor - RGB and clear
- Silicon Labs SI7021: humidity sensor
- Invensense MPU9250: 9DOF - 3 axis acceleration and gyro PLUS AK8963-IC with magnetic-field sensor
- Freescale MPL3115A2: pressure
- Maxim MAX44009: ambient and lux with incredible wide dynamic
- NXP PCF2127: Realtime-Clock with 2ppm
- Bosch BMP280: pressure
- ST L3G-Series: 3 axis gyro / angular rate
- Freescale MAG3110: 3 axis Compass / Magnetic field
- Freescale MMA8451: 3 axis acceleration
- Fairchild FAN5421: Single-Cell Li-Ion Switching Charger
- STM LPS331: Pressure Sensor
- Maxim MAX17047: Fuel Gauge for various Cells
#include "i2c_SI7021.h"
//we can also power the SHT with a digital pin, here pin 6
#define PIN_POWER 6
float h;
float t;
SI7021 si7021;
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);
Serial.print("Probe SI7021: ");
if (si7021.initialize()) {
Serial.println("SI7021 Sensor found");
} else {
Serial.println("SI7021 Sensor missing");
while (1) {
return;
}
}
si7021.getHumidity(h);
si7021.getTemperature(t);
si7021.triggerMeasurement();
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius Humidity: ");
Serial.print(h);
Serial.println("%");
digitalWrite(PIN_POWER,LOW);
delay(5000);
}
Enjoy!
2021 - Congduc Pham