Arduino Nano - SI7006-A20 Humidity & Temperature Sensor Tutorial
by Dcube Tech Ventures in Circuits > Electronics
13 Views, 0 Favorites, 0 Comments
Arduino Nano - SI7006-A20 Humidity & Temperature Sensor Tutorial
SI7006-A20 is a humidity and temperature sensor which can operate on I2C communication protocol. It has a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital converter etc. Incorporated with highly advanced signal processing elements and callibration data feature this sensor forms one of the most efficient device to measure humidity and temperature. Here is its demonstration with Arduino Nano.
What You Need..!!
Connection:
Take an I2C shield for Arduino Nano and gently push it over the pins of Nano.
Then connect the one end of I2C cable to SI7006-A20 sensor and the other end to the I2C shield.
Connections are shown in the picture above.
Code:
The arduino code for SI7006-A20 can be downloaded from our github repository-DCUBE Store Community
Here is the link for the same :
https://github.com/DcubeTechVentures/SI7006-A20/blob/master/arduino/SI7006_A20.ino
We include library Wire.h to facilitate the I2c communication of the sensor with the Arduino board.
You can also copy the code from here, it is given as follows:
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// SI7006-A20
// This code is designed to work with the SI7006-A20_I2CS I2C Mini Module
#include
// SI7006-A20 I2C address is 0x40(64)
#define Addr 0x40
void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(9600);
// Start I2C transmission
Wire.beginTransmission(Addr);
// Stop I2C transmission
Wire.endTransmission();
delay(300);
}
void loop()
{
unsigned int data[2];
// Start I2C transmission
Wire.beginTransmission(Addr);
// Send humidity measurement command, NO HOLD MASTER
Wire.write(0xF5);
// Stop I2C transmission
Wire.endTransmission();
delay(500);
// Request 2 bytes of data
Wire.requestFrom(Addr, 2);
// Read 2 bytes of data
// humidity msb, humidity lsb
if(Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
}
// Convert the data
float humidity = ((data[0] * 256.0) + data[3]);
humidity = ((125 * humidity) / 65536.0) - 6;
// Start I2C transmission
Wire.beginTransmission(Addr);
// Send temperature measurement command, NO HOLD MASTER
Wire.write(0xF3);
// Stop I2C transmission
Wire.endTransmission();
delay(500);
// Request 2 bytes of data
Wire.requestFrom(Addr, 2);
// Read 2 bytes of data
// temp msb, temp lsb
if(Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
}
// Convert the data
float temp = ((data[0] * 256.0) + data[1]);
float ctemp = ((175.72 * temp) / 65536.0) - 46.85;
float ftemp = ctemp * 1.8 + 32;
// Output data to serial monitor
Serial.print("Relative humidity : ");
Serial.print(humidity);
Serial.println(" % RH");
Serial.print("Temperature in Celsius : ");
Serial.print(ctemp);
Serial.println(" C");
Serial.print("Temperature in Fahrenheit : ");
Serial.print(ftemp);
Serial.println(" F");
delay(500);
}
Applications:
SI7006-A20 is a highly efficient and reliable sensor that can be incorporated in indoor weather stations that can maintain the optimum indoor environment in terms of humidity and temperature suited for human body.It forms an integral part in automotive climate control and defogging systems. It can also be employed in mobile phones and tablets.