Subscribe to Arduino Academy and start learning today for FREE!

Our Temperature / Humidity Monitor is working!

We received our SHT21 Temperature / Humidity Sensor today from Misenso. No documentation came with it, so a bit of googling found parts of the necessary info on 3 different sites (spliced a few bits of code, installed the I2C library, and crossed my fingers on the wiring). If you want to duplicate this email me, and I’ll send you the pde file, the library, and schematic. It’s specific to this implementation of the SHT21 module and most 4 line LCD displays.

Become the Maker you were born to be. Try Arduino Academy for FREE!

 

 

// Connections:
// LCD pin 1 to Arduino GND
// LCD pin 2 to Arduino 5v
// LCD pin 3 (Contrast) to GND
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pin 16 to Arduino GND
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2

//Tested with SHT21 Breakout from Misenso
//SHT21 pin SDA to Arduino Analog pin 4
//SHT21 pin SCL to Arduino Analog pin 5
//SHT21 pin GND to Arduino GND
//SHT21 pin VCC to Arduion 3v (not 5v)

//RGB LED
//Red Cathode to Arduino pin 9
//Blue Cathode to Arduino pin 8
//Green Cathode to Arduino pin 7
//Anode to 270 ohm resistor to 5V

#include <LiquidCrystal.h>
#include <Wire.h>
#include <LibHumidity.h>

LibHumidity humidity = LibHumidity(0);

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13; // pin 13 will control the backlight
int RedLEDPin = 9; // LED connected to digital pin 9
int BlueLEDPin = 8; // LED connected to digital pin 8
int GreenLEDPin = 7; // LED connected to digital pin 7

void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.

//I2C
pinMode(16, OUTPUT);
digitalWrite(16, LOW); //GND pin
pinMode(17, OUTPUT);
digitalWrite(17, HIGH); //VCC pin

//Furnace / AC Indicator
pinMode(RedLEDPin, OUTPUT); // sets the digital pin as output
pinMode(BlueLEDPin, OUTPUT); // sets the digital pin as output
pinMode(GreenLEDPin, OUTPUT); // sets the digital pin as output

}

void loop()
{
lcd.begin(20,4); // columns, rows. use 16,2 for a 16×2 LCD, etc.
lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print(“Humidity: “); // change this text to whatever you like. keep it clean.
lcd.print(humidity.GetHumidity());
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print(“Temp in C: “);
lcd.print(humidity.GetTemperatureC());
lcd.setCursor(0,2); // set cursor to column 0, row 2
lcd.print(“Temp in F: “);
lcd.print(humidity.GetTemperatureF());
{
if (humidity.GetTemperatureF() < 60) { digitalWrite(RedLEDPin, LOW); // sets the Red LED on digitalWrite(BlueLEDPin, HIGH); // sets the Blue LED off digitalWrite(GreenLEDPin, LOW); // sets the Green LED off } else if (humidity.GetTemperatureF() >= 75)
{
digitalWrite(BlueLEDPin, LOW); // sets the Blue LED on
digitalWrite(RedLEDPin, HIGH); // sets the Red LED off
digitalWrite(GreenLEDPin, HIGH); // sets the Green LED off
}
else
{
digitalWrite(GreenLEDPin, LOW); // sets the Green LED on
digitalWrite(BlueLEDPin, HIGH); // sets the Blue LED off
digitalWrite(RedLEDPin, HIGH); // sets the Red LED off

}
}

delay (20000);
}

 

Unsure what is causing the two strange characters at the end of the Temp in F line, but will work on that. (Michael Grant pointed out the unnecessary carriage return we had in our code. All fixed now.)

Become the Maker you were born to be. Try Arduino Academy for FREE!

Subscribe
Notify of
guest
19 Comments
Inline Feedbacks
View all comments
yoby1954
12 years ago

I would like to build this temperature sensor can you send me the detailed information, and where to get the parts. I am a beginer in electronics however, very good with the soldering iron……
jrs

Steve Spence
12 years ago

It's just the Arduino, lcd display (both from Hacktronics.com), and the temp / humidity sensor from misenso.com. The details are in the code.

SkyKid90
12 years ago

Can u e-mail me the detailed info please at andrescm90@hotmail.com, Thanks Regards
Andrew

Steve Spence
12 years ago

The code, library, and schematic downloads are now included in the tutorial.

Anonymous
Anonymous
12 years ago

what is the point of the 3 rgb leds?

Steve Spence
12 years ago

It's not 3 RGB's. There are two RGB's. One for each tank. Blue for cold, green for good, red for too hot.

Ch... @ Florida
11 years ago

Hi,
Thanks for this great tutorial.
However, I am having issues when verifying the code on Arduino software.
I have installed the LibHumidity.

Am I missing a file ?

Thanks,
Charles.

Error :

/Volumes/Home HD/Charles/Downloads/Arduino.app/Contents/Resources/Java/libraries/LibHumidity/LibHumidity.cpp:27:20: error: wiring.h: No such file or directory
/Volumes/Home HD/Charles/Downloads/Arduino.app/Contents/Resources/Java/libraries/LibHumidity/LibHumidity.cpp: In member function 'uint16_t LibHumidity::readSensor(uint8_t)':
/Volumes/Home HD/Charles/Downloads/Arduino.app/Contents/Resources/Java/libraries/LibHumidity/LibHumidity.cpp:123: error: 'class TwoWire' has no member named 'send'
/Volumes/Home HD/Charles/Downloads/Arduino.app/Contents/Resources/Java/libraries/LibHumidity/LibHumidity.cpp:124: error: 'delay' was not declared in this scope
/Volumes/Home HD/Charles/Downloads/Arduino.app/Contents/Resources/Java/libraries/LibHumidity/LibHumidity.cpp:133: error: 'class TwoWire' has no member named 'receive'
/Volumes/Home HD/Charles/Downloads/Arduino.app/Contents/Resources/Java/libraries/LibHumidity/LibHumidity.cpp:134: error: 'class TwoWire' has no member named 'receive'

Steve Spence
11 years ago

Are you using IDE 1.0?

Did you install the library, close the IDE, then restart, and import the library?

Ch... @ Florida
11 years ago

Thanks for your fast answer…

I have Arduino IDE1.0 installed, with the LibHumidity in it. Still having this error. When you say "import the library", what do you mean? isn't it already in the code?

(I am using IDE on MacOSX, i don't believe it's the issue but maybe i should try on windows?)

Thanks again

Steve Spence
11 years ago

The library has to be "installed" (copied into your libraries folder), then "included" in your sketch. This library has not been tested, nor has this sketch, under IDE 1.0. IDE 1.0 makes a lot of changes.

Ch... @ Florida
11 years ago

Alright, I've figured it out. Apparently, even when using an ISO from Sept 2010, I had an error. The compilation worked on my Virtual Machine with Win7.

Anyway, thank you for the tips. I am building the exact one, however i am attempting to add an Ethernet shield so the data (temp/humidity) would also be live stream (there is a twitter app for this if i remember).

I might come back if I have more questions!
Thanks =]

Nicht Nur Ein Traum
11 years ago

Hello,

I want to add two sht2x to the board. You posted that you had to "hack another I2C Channel". How did you do that? Did you write it somewhere?

thx and br
Stefan

Steve Spence
11 years ago

Contact http://www.misenso.com for that. They developed the hack for the second channel.

pippo
11 years ago

Hello,
a question: can you explain me the follow code?

//I2C
pinMode(16, OUTPUT);
digitalWrite(16, LOW); //GND pin
pinMode(17, OUTPUT);
digitalWrite(17, HIGH); //VCC pin

what does it mean?

Steve Spence
11 years ago

pinMode(16, OUTPUT); // means pin 16 is an output, not an input.

digitalWrite(16, LOW); // means pin 16 is at ground potential, not 5 volts

pinMode(17, OUTPUT); // means pin 17 is an output

digitalWrite(17, HIGH); // means pin 17 is at 5v

pippo
11 years ago

…but these pins are not used in this project, why you wrote this code?
Thank you.

Steve Spence
11 years ago

Actually they are. Analog 4 and 5 is Digital 16 and 17.

Macros
10 years ago

Thanks for the tutorial and library.

Just a note, to get this library working under Arduino 1.0 you need to add #include <Arduino.h> to LibHumidity.cpp. This will rectify the 'delay' was not declared in this scope.
Change all Wire.receive to Wire.read.
Change all Wire.send to Wire.write.

The library should also be installed to DocumentsArduinolibraries

Crystal OS
10 years ago

Can u e-mail me the detailed info please at crystilis@gmail.com, Thanks Regards dave.

Archives

19
0
Would love your thoughts, please comment.x
()
x