MINI Si7021 Temperature and Humidity Sensor

by gr8yt in Circuits > Arduino

9602 Views, 14 Favorites, 0 Comments

MINI Si7021 Temperature and Humidity Sensor

MiniTemp.jpeg
MiniTempPins.jpeg

Synopsis: At ± 0.3% accuracy (temp and humidity) the Mini Si7021 is a very precise sensor for accumulating temperature and humidity data. The I2C bus architecture provides fast data acquisition, error detection and support for monitoring multiple sensors. Remote (off chip) temperature data collection is possible via the ground plane of the sensor which is directly connected to the temperature sensor on the chip. Temperature and humidity readings are adjustable for precise readings in specific environments.

If you are serious about collecting accurate temperature and humidity readings then sensors utilizing the Si70xx family of chips would be a good recommendation to evaluate for your project. However, for the novice user wanting quick and easy temperature and/or humidity data other options are probably better suited for those needs.

______________________________________________________________________

This is the SMD MINI Si7021 Temp and Humidity Sensor with I2C Interface for Arduino from ICStation. One thing's for sure, it is small! I couldn't wait to get the header pins (came with) soldered on so I could stick it on a breadboard before I lost it!

The interface with this sensor is new to me, it uses the I2C serial bus. I have included some information on the I2C serial bus in the specifications section of this Instructable. As well, there is a ton of good reading material on the I2C serial bus on the internet if you are interested.

The attached .pdf file (Si70XX HUMIDITY AND TEMPERATURE SENSOR DESIGNER’S GUIDE) will tell you everything you could ever wanted to know about the Si70xx family of chips, and a whole bunch more! If you are a serious backyard meteorologist I highly recommend you peak at that file.

So to get started I first had to learn how to wire things up correctly for the I2C serial bus to work. The major point here involves the two (2) pull-up resistors you need. Those resistors are used to bring the SCL and SDA lines (more on those later) HIGH as the device(s) can only drive the line(s) LOW. So without the pull-up resistors nothing is going to work on the I2C bus.

We're going to take a look at what you'll need to have around to play with this in Step 1 and we'll get to the wiring in Step 2. So, let move on... (hit that Next Step button over there for me)

Items You Will Need and Items You Don't "need" But Should Probably Get

Items you will need;

1. one (1) Arduino Uno (or similar)

2. one (1) breadboard and jumper wires (if you don't have a breadboard, GET ONE. They're cheap and make things a whole lot easier)

3. two (2) 21k resistors (color bands Red,Brown,Orange)

4. one (1) .01uF capacitor (ceramic if you have it, faster and no polarity to worry about)

4. one (1) Temperature / Humidity module (part # 7046 at ICStation.com)

5. one (1) understanding spouse while you play with this

Items you don't "need" but should probably get;

1. The I2C scanner sketch for Arduino

1a. The .ino file for this sketch is attached to this Instructable (double clicking the file will open the Arduino interface and load the file for you - don't forget to open the Arduino interface serial monitor to view the output from the sketch)

1b. This is a great tool for locating devices on the I2C serial bus. This sketch makes a call to every usable address on the I2C bus. Each device on the I2C bus will in-turn respond to that call to their address. The address of each responding device is displayed for you on the serial monitor.

1c. By running this sketch first, after things are setup, you will know if your setup is correct or not. If the sketch returns the address of your device perfect, all is well! If the sketch does not find your device you know somethings amiss in your setup.

2. Patience, I found this - my first experience with I2C communications - could be a little frustrating at times.

3. Arduino code - well da - that's coming later in another step.

Wiring for I2C Serial Bus Communications

TempHumWiring.jpg
56662c804fbade26f4001230.jpeg

The important thing about wiring this are those two pull-up resistors. Both the SCL and SDA lines are "open drain" drivers. Meaning that the chip can drive the output LOW on those lines, but it cannot drive those lines HIGH. For the line to be able to go HIGH you must provide the pull-up resistors.

Other than that, the wiring is pretty straight forward;

(Remember to disconnect any power supply to your Arduino or breadboard before beginning)

1. Connect the 3.3v power out from your Arduino to the positive rail on your breadboard

2. Connect the GND (ground) from your Arduino to the ground (negative) rail on your breadboard.

3. add the .01uF capacitor to your breadboard (I used a ceramic cap, watch polarity otherwise)

3a. connect 3.3v to one leg of the capacitor

3b. connect the other leg of the capacitor to ground (GND)

4. now make another connection from the leg of the capacitor with 3.3v on it (3a. above) to VCC on the sensor

Note: The capacitor is used to smooth the power flowing in to the sensor. Think of it this way, the capacitor just sits there and does nothing. That is until there is a drop in the power level, at which point the capacitor will discharge into the power line to compensate for that drop, thereby "smoothing" out the power coming into the sensor. And that's important because the sensor uses that same power as output for data measurements - smooth power in, smooth data out. You can play with the value of the capacitor, the attached developer guide provides more information on that.

5. Connect ground to GND on sensor

6. Install the resistors on your breadboard

7. Connect one leg of each resistor into the 3.3v power being supplied to the sensor

8. Connect SCL from the sensor to the opposite leg of one resistor (not the leg you just connected in #7.)

9. and continue that connection from the resistor to Pin 5 (A5) on the Arduino

10. Connect SDA to the other resistor, same as we did for SCL

11. and continue that connection from the resistor to Analog Pin 4 (A4) on the Arduino

Note: The resistors are used to keep the SCL and SDA lines HIGH until they are pulled LOW by the sensor.

We should be wired up and ready to go. Now would be a good time to load the I2C scanner sketch onto your Arduino and (cross your fingers) see if it finds the sensor.

If it doesn't find the sensor here are a couple of troubleshooting tips:

1. ensure all connections are correct (I know that's a given, but I worked in IT for 26 years and the number of people that start troubleshooting in the wrong place is unbelievable, always start with the basics and work your way up from there)

2. really check the wiring around those resistors, wired wrong - no worky

3. verify that A4 and A5 on your Arduino board are putting out around 5v. I know we are using the 3.3v side of things from the Arduino but in the process of creating the I2C bus those pins get some special treatment. During one of my more "patient" moments with this project I finally checked those pins and found A4 was dead (I then remembered a short on that pin from another project). A quick board swap and I could stop making up new swear words.

Arduino Code for SI70xx Temp/Hum Sensor

OK, we're all wired up, you ran the I2C Scanner sketch, it found your device, so I guess we're ready for some code.

I DID NOT write the following sketch and of course I don't remember where I found it so I can not credit the correct entity for it. If you recognize it and know where it's from please let me know so I can update this appropriately.

#include
const int ADDR =0x40;

int X0,X1,Y0,Y1,Y2,Y3;

double X,Y,X_out,Y_out1,Y_out2;

void setup() {

Serial.begin(19200);

Wire.begin();

delay(100);

Wire.beginTransmission(ADDR);

Wire.endTransmission();

pinMode(13,OUTPUT);

}

void loop() {

/**Send command of initiating temperature measurement**/

Wire.beginTransmission(ADDR);

Wire.write(0xE3);

Wire.endTransmission();

Serial.print("Temp");

Serial.print("\t");

Serial.println("RH");

/**Read data of temperature**/

digitalWrite(13,HIGH);

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("%");

digitalWrite(13,LOW);

delay(300);

// below are items added by Brad White 12/7/2015

Serial.println(); // adds a blank line between readings on the serial monitor

delay(1000); // slowing things down a bit for readability

// end of Brad's messing around with this sketch

}

The .ino file for this sketch is attached. Double click on it to automatically load it into your Arduino interface.

Downloads

Specifications

Mini.jpg

The following information pertains to the SMD MINI Si7021 Temp and Humidity Sensor (available from ICStation for $6.15, well it was $6.15 when I started writing this)

This sensor uses the I2C bus. The wheels on the bus go round and round, round and round, round and round, the wheels on the bus go... Ops sorry, not sure where my head went that time.

This I2C bus is a two wire bus, using one wire each for SCL (Serial Clock Line) and SDA (Serial Data Line). SCL is used to synchronize all data transfers over the I2C bus and SDA is the data line, guess what it's for. There will only be one "master" device on any I2C bus at any one time. The master communicates with one or more "slave" devices on the same bus. I2C was developed primarily for close proximity communications between ICs (integrated circuits) and other devices on the same circuit board.

The package includes;

(1) Mini Temp/Humidity sensor

(1) 4 pin header

The specifications are;

1. Operating voltage: 1.9 - 3.6V (recommended 3.3V)

2. Standby current: 60nA (nA = One thousand millionth ( 10-9 ) of an ampere)

3. Temperature range: -40 to 85 ℃ (-40' to 185' F) (Recommended -10 to 60 ℃ (14' to 140' F)

Note: For us non-metric speaking American's -40'c to 185'c equals really really cold, to absolutely freak'n hot

4. Temperature accuracy: ± 0.3 ℃

5. Humidity range: 0-100% RH (recommended 20% - 80% RH)

6. Humidity Accuracy: ± 3% RH (0-80% RH)

7. Temperature conversion time: 7ms

8. Humidity conversion time: 17ms (temperature conversions occur automatically with humidity conversion)

9. Interface Type: I2C

10. Module size: 8.5*10mm (21/64th x 25/64th)

I2C Command Table for Temp/Humidity Sensor

Measure Relative Humidity, Hold Master Mode 0xE5

Measure Relative Humidity, No Hold Master Mode 0xF5

Measure Temperature, Hold Master Mode 0xE3

Measure Temperature, No Hold Master Mode 0xF3

Read Temperature Value from Previous RH Measurement 0xE0

Reset 0xFE

Write RH/T User Register 1 0xE6

Read RH/T User Register 1 0xE7

Write Heater Control Register 0x51

Read Heater Control Register 0x11

Read Electronic ID 1st Byte 0xFA 0x0F

Read Electronic ID 2nd Byte 0xFC 0xC9

Read Firmware Revision 0x84 0xB8

Attached you will find a 33 page specifications document for the sI7021 chip used in this sensor. The "packaging" pictured in the document is different then how this sensor looks, however the sI7021 chip inside is the same.

Thanks for reading and as always if you noticed any errors or omissions in this Instructable please do not be shy about pointing them out to me. I'd much rather correct something than let it mess up someone else.

Happy Holidays!

Downloads