Temperature and Humidity - SI7021


Introduction: Temperature and Humidity - SI7021

About: www.ICStation.com is a top store of electronic, which specializes in all kinds of IC products, such IC accessories, Module, Robots, Development Board, Transistor, Capacitor and so on. We're located in She...

Reviewed by our friend Enrique. Hope it will be useful for you.


Although sometimes it does not seem we are surrounded by sensors in almost all electronic devices (and some mechanical) that we have around us, you just have to think of a smart phone how many electronic sensors have? Light, accelerometer, camera, gyroscope, magnetometer, thermometers, voltmeter, ammeter, etc. And it is a device that can take wrong decisions if we do not provide Him from the sensors need for you to know that around occurs, thinks only of any of us, what happens if we lose all senses, sight, taste, smell, touch , ear, because at first glance we have very difficult to understand what happens around us.

There are sensors to measure any physical parameter you can think of and many technologies and protocols with which to communicate with them, each will have his.

Step 1:

In this case we analyze the temperature SI7021 hand IcStation and humidity sensor. This sensor will be able to read both physical quantities, transform them into digital values and store them in your memory bank, so that when we ask through I2C one of the two parameters, the module will return 2 bytes that correspond to the value we are asking. As we see in the block diagram that provides the manufacturer of integrated SI7021 circuit, the circuit integrates an ADC to read the values of both sensors and send the reading to the logic block that handles calibrate and store the readings later when ask you for a value, the I2C interface to access the logic module, retrieve the value and return it via I2C.

As you may have been able to find out we will contact integrated through I2C for different bytes containing the values of temperature and humidity, if we analyze carefully the datasheet SI7021 see how each value is made up of 2 bytes ie 16 bits but through I2C we can only transmit 8 bits in a single response and therefore to convey the full value we have to get 2 responses.

Step 2:

This time for a change not use Arduino to communicate with the integrated SI7021 and therefore we must have the wire.h library on which we have already discussed above, the workflow to get, for example, the temperature will be:

1. Start the transmission with the slave device (SI7021)

2. Send 0xE3 byte which indicate the sensor we want the temperature value

3. End transmission

4. Ask the SI7021 2 bytes that make up the temperature value

5. To receive and combine the 2 bytes on a 16-bit word

6. Calculate the temperature value to the equation:

Temperatura =(175.72·Temp code)÷ 65536 - 46.85

Where temperature is in ° C and Tempcore is the word of 16 bits

Humidity = (125 · RH Code)÷ 65536 - 6

Where humidity is in% and Rhode is the word of 16 bits. For RHCode will use the byte 0xE5 0xE3 instead of in step 2.

Obviously you have more integrated I2C we can send commands to obtain or modify different values and all of them can see in this table that provides the manufacturer of the component datasheet.

Table 2C command Source: Silicon Labs

Using it is relatively easy
As you see is fairly easy to use and is based on asking and receiving bytes via I2C, so if you understand the concept is quite likely to understand the code we will use in Arduino.


Arduino Uno A5 A4

Arduino Mega 21 21

Arduino Leonardo 3 2

Arduino Due 21 20

Step 3:

Remember that we are talking about a I2C device therefore
we have to use the corresponding pins of our microcontroller and if we are using the module does not have pullup resistors have to put them. If we look at the module IcStation carefully we see that already included on the plate the two resistors, so it is not necessary to include them on our own and also includes capacitor 0.1 uF you need integrated between Vcc and GND to stabilize its feeding.

A very important fact that you have to consider when connecting the integrated works is that NO 3.3v 5v

Step 4: Code for Arduino

SI7021 to serial port

//General variables

int temp[2], hum[5];

double temp_code, rh_code;

float temperature, RH;

//Direccin del sensor

byte direccion = 0x40;

void setup()


Wire.begin(); //Initialize I2C

Serial.begin(9600); //Initialize Serial Port


void loop()


Wire.beginTransmission(direccion); //Begin comunication with the slave

Wire.write(0xE3); //Send 0xE3 in order to read the temperature


Wire.requestFrom(direccion,2); //Request 2 bytes

if(Wire.available()<=2){ //If bytes are recieved

temp[0] = Wire.read(); //Save it on temp

temp[1] = Wire.read();

//Calc the temperature

temp_code = (temp[0]<<8) + temp[1];

temperature = ((175.72 * temp_code)/65536)-46.85;


Serial.print(" C ");



Wire.write(0xE5); //Ask for Relatative humidity





hum[0] = Wire.read();
hum[1] = Wire.read();

rh_code = (hum[0]<<8) + hum[1];

RH = ((125*rh_code)/65536)-6;


Serial.println(" %");




Step 5:


Let's talk about the accuracy of the readings and no sensor is perfect and always a mistake in this case will normally 0.4 ° C for temperature and between 2 and 3% moisture committed however these values are affected with the progression of readings and this variation we can see thanks to graphics that provides the manufacturer.

In both graphs we see that it is good enough for the applications that we will get to perform with this sensor except when we arrived at the extremes of temperature and humidity reading error increases. So we'd better choose the proper range.

Finally, the sensor sponsor comes from www.icstation.com

The sensor is only $5.99 in the fowllowing week: http://goo.gl/Diyroi

You can have a detailed introduction in the video: https://goo.gl/n6PJS1

If you some awesome ideas about mudule, please feel free to contact us: icstation13@gmail.com



    • Oil Contest

      Oil Contest
    • Clocks Contest

      Clocks Contest
    • Water Contest

      Water Contest