Home Temperature Projects Arduino and Si7021 I2C Humidity and Temperature Sensor

Arduino and Si7021 I2C Humidity and Temperature Sensor

by shedboy71

The Si7021 I2C Humidity and Temperature Sensor is a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital converter, signal processing, calibration data, and an I2C Interface. The patented use of industry-standard, low-K polymeric dielectrics for sensing humidity enables the construction of low-power, monolithic CMOS Sensor ICs with low drift and hysteresis, and excellent long term stability

 

Features

  • Relative Humidity Sensor:
    • Si7013/21: ± 3% RH (maximum) @ 0-80% RH
    • Si7020: ± 4% RH (maximum) @ 0-80% RH
    • Si7006: ± 5% RH (maximum) @ 0-80% RH
  • Temperature Sensor:
    • Si7013/20/21: ±0.4°C accuracy (maximum) @ -10 to +85°C
    • Si7006: ±1.0°C accuracy (maximum) @ -10 to +85°C
  • 0 to 100% RH operating range
  • Up to -40 to +125°C operating range
  • Wide operating voltage range (1.9 to 3.6V)
  • Low Power Consumption: 2.2µW average power at 3.3V and 1 sample per second
  • I2C host interface
  • Integrated on-chip heater
  • 3mm x 3mm QFN package
  • Excellent long term stability
  • Factory calibrated
  • Optional factory-installed filter/cover
    • Lifetime protection during reflow and in operation
    • Protects against contamination from dust, dirt, household chemicals and other liquids
    • AEC-Q100 automotive qualified (Si7013/20/21)

 

Connection

 

Must use 3v3 for Vin

Arduino Pins Module Pins
 3v3  Vin
 Gnd  Gnd
 SDA  SDA
 SCL  SCL

 

 

Code

[codesyntax lang=”cpp”]

#include <Wire.h>
 
const int ADDR =0x40;
int X0,X1,Y0,Y1,Y2,Y3;
double X,Y,X_out,Y_out1,Y_out2;
 
void setup()
{ 
  Serial.begin(9600);   
  Wire.begin();                                   
  delay(100);  
  Wire.beginTransmission(ADDR);
  Wire.endTransmission();                        
}

void loop()
{
  /**Send command of initiating temperature measurement**/
  Wire.beginTransmission(ADDR);
  Wire.write(0xE3);
  Wire.endTransmission();
 
  Serial.print("Temp");
  Serial.print("\t");
  Serial.println("Humidity");
 
  /**Read data of temperature**/
  Wire.requestFrom(ADDR,2);
 
  if(Wire.available()<=2);
  {
    X0 = Wire.read();
    X1 = Wire.read();
    X0 = X0<<8;
    X_out = X0+X1;
  }
 
  /**Calculate and display temperature**/
  X=(175.72*X_out)/65536;                        
  X=X-46.85;
  Serial.print(X);
  Serial.print("C");
  Serial.print("\t");
 
  /**Send command of initiating relative humidity measurement**/
  Wire.beginTransmission(ADDR);                     
  Wire.write(0xE5);
  Wire.endTransmission(); 
 
  /**Read data of relative humidity**/
  Wire.requestFrom(ADDR,2);
  if(Wire.available()<=2);
  {
    Y0 = Wire.read();
    Y2=Y0/100; 
    Y0=Y0%100;
    Y1 = Wire.read();
    Y_out1 = Y2*25600;
    Y_out2 = Y0*256+Y1;
  }
 
  /**Calculate and display relative humidity**/
  Y_out1 = (125*Y_out1)/65536;                     
  Y_out2 = (125*Y_out2)/65536;
  Y = Y_out1+Y_out2;
  Y=Y-6;
  Serial.print(Y);
  Serial.println("%");                     
 delay(300);


Serial.println(); 
delay(1000);

}

[/codesyntax]

 

 

Output

Open the serial monitor, you should see something like this

Temp    Humidity
23.12C    52.83%

Temp    Humidity
24.04C    53.13%

Temp    Humidity
26.28C    53.83%

 

 

 

Links
Humidity Temperature Sensor Breakout Barometric Pressure SI7021 for Arduino GY-21

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More