Step 5: Current Code With Wiring Instructions

The following is the code as it exists today. I am adding a second SHT21 for indoor/outdoor measuring (means hacking a second I2C channel, as the SHT21's all have the same address, and can't exist on one channel), and I'm still waiting for my real time clock chip and barometric pressure sensor to arrive from Sparkfun.com (they arrived yesterday, and I will work on this on the weekend - 9-29-10). I migrated the project over to my new Arduino Mega 2560 (58 I/O lines), and installed the new 0021 IDE. I will edit this instructable as the project evolves.

// 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 Arduino 3v (not 5v)

//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 #include

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.

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 16x2 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.setCursor(0,1); // set cursor to column 0, row 1
lcd.print("Temp in C: ");
lcd.setCursor(0,2); // set cursor to column 0, row 2
lcd.print("Temp in F: ");
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
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);

See http://arduinotronics.blogspot.com/2010/09/our-temperature-humidity-monitor-is.html for actual code as instructables breaks our include statements.

<p>Good instructable, but, his is an old clock check out the newer more accurate DS3231 clock Easier to implement with the new 1604 4 line LCD module with the I2C backpack module it only requires 2 serial data wires as opposed to 7</p>
gr8 keep it up
I was thinking about doing something like this, but with wind speed and rainfall as well. Thanks for the instructable! It'll probably help a lot when I finally get around to building mine.
I'll eventually get those functions in there, probably by sniffing the wireless feed from a lacrosse weather station. easier than making a anemometer and rain gauge.
I thought about making a anemometer and rain gauge, and I've even planned them out, but I don't want to take the time to actually make them. So instead, I just bought them from sparkfun: http://www.sparkfun.com/commerce/product_info.php?products_id=8942<br><br>I'll post an instructable once they arrive at my house and I've programed my arduino!
<p>I know this was quite a while ago. But did you get that SparkFun weather kit? If so, what do you think of it?</p>
<p>We did. It's up and flying. I didn't think it would hold up, as it appears fragile, but after a year or so, it's still going strong. Need to publish the code for that.</p>
<p>Cool, nice to know. The &quot;arms&quot; that hold the anemometer and vane look kind of delicate to me. </p>
<p style="margin-left: 20.0px;">Couple of quick questions, is it impossible to use the Arduino to keep time.... (I was thinking of using pulseIn function at the start/end of the loop to keep time...) <br><br>So if the RTC is essential can you just plug it into 5 consecutive Arduino pins instead of dealing with so much wiring?</p>
<p>There exists an Arduino Time library <a href="http://playground.arduino.cc/Code/Time" rel="nofollow">http://playground.arduino.cc/Code/Time<br></a>But this will not work if running on external power and not connected to the computer of course.</p><p>When I just started with Arduino, I attempted to write a clock code <a href="https://docs.google.com/document/d/1nSeXLC3vC2sNe9FH0mwJZSAChyE0TAnjdgfyfuhzQFs/edit" rel="nofollow">https://docs.google.com/document/d/1nSeXLC3vC2sNe9...</a><br>There was a decent amount of drift over a few hours, but it was still pretty cool. Again, I did this when I just started with Arduino/programming so it's definitely not the best thing around. You could probably find some better stuff if you just Googled, &quot;Arduino clock&quot; or something like that.This is something I found <a href="https://www.instructables.com/id/Make-an-accurate-Arduino-clock-using-only-one-wire/" rel="nofollow">https://www.instructables.com/id/Make-an-accurate-A...</a> Haven't looked at it much though.</p><p>Secondly, in my code, I kept time using the millis() function. You would probably have better luck using interrupts.</p><p>Good luck</p>
If you look at my other instructables, and projects at <a href="http://arduinotronics.blogspot.com" rel="nofollow">http://arduinotronics.blogspot.com</a> you will find network based time clients, gps based, and pc set ds1307 (no need to stay connected) projects.
<p>Thanks pal!</p><p>I will definitely look at those links!!, Personally I am all about doing more with less, and this is up my alley! </p>
<p>Cool. I'm interested to see how your project turns out. Good luck.</p>
the rtc uses two datalines (a4 and a5) in addition to power and ground. you can't just plug the rtc into the arduino, as the pin connections will not line up.
<p>Hmm... I think you can, instead of GND you just digiWrite(pin LOW) and instead of 5V you digiWrite(Pin HIGH)... I know its not best practice but it does seem to work seamlessly<br><br>Have a look at an example with an Ultrasonic sensor: </p><p>https://www.youtube.com/watch?v=pdIUNHps-5s</p>
<p>sda and scl are reversed on this module, so you can't. you'll need to find another module. do you really want to waste your analnog ports defining them as power and ground?</p>
<p>Good point, I guess that depends on what the circuit needs, I really like what you built... especially that its self powered. I just bought some 1W panels + lipo batteries to see if I can build similar circuits. </p>
Hi! We launched a new project of weather map layer for OpenStreetMap <a href="http://openweathermap.org" rel="nofollow">http://openweathermap.org/</a>. It public project that collects data from more than 20,000 meteorological and weather stations around the world. The more weather stations connect the more precise weather data we provide to people. All collected weather data are provided under CC-BY-SA 2.0.You can connect your weather station to the service <a href="http://openweathermap.org/connect" rel="nofollow">http://openweathermap.org/connect</a>
I'm wondering if you ever added the relays and the outdoor temp and humidity.
I added the SSR's, directly addresses by an output pin. This allows control of ac devices, up to 660v and 150 amps, depending on the SSR, with an optically isolated 5v input.<br><br>I also added the outdoor temp and humidity.
Does/Can this setup also log data for an extended period of time (say three months)? I'd love to be able to drop this in an off-grid spot and have it continuously working for me; just check on it every few weeks and dump data to a laptop. Or even better, find a way to dump the data to a server so I can visit it and dl it from anywhere. Would this work?
You can use Gobetwino (http://www.mikmo.dk/gobetwino.html) to log the serial output to a file on a computer connected to the Arduino. If you have a machine that is always on, this is a pretty good way to go, as it doesn't require any additional hardware.<br><br>If not, one of the listed options is pretty nice, especially the storage shields.
Yes, there is a sd card data logging shield that would do this. There's even a wifi shield and ethernet shield for real time communications.<br> <br> <a href="http://www.seeedstudio.com/depot/sd-card-shield-for-arduino-v21-p-492.html">http://www.seeedstudio.com/depot/sd-card-shield-for-arduino-v21-p-492.html<br> <br> http://www.asynclabs.com/store?page=shop.product_details&amp;flypage=flypage.tpl&amp;product_id=26&amp;category_id=6<br> <br> http://www.ladyada.net/make/eshield/</a><br>
This is very cool. When you are ready to integrate forecasted weather for your location to make your HVAC controls predictive, let me know, as we can provide and even integrate your sensor data if we can get at the output.
What OS are you using? I am using Xubuntu 11.04
Ubuntu 11.04 and Windows Vista.
I said to myself 6 months ago how i should do this project, good job getting to it first!
Wait till I get the relays installed and it turns on my a/c and furnace when necessary :-) Should have barometric pressure and time / date functions (for setback thermostat capability) working next weekend. Running out of IO lines, will need a expander. <a href="http://www.embedds.com/arduino-i2c-expansion-io/">http://www.embedds.com/arduino-i2c-expansion-io/</a>
Yea, I have a heat pump, and one of the efficiency tweaks is to not turn on the auxiliary heating when the outside weather is above 0 degF<br><br>I might reuse some of this to add that feature to my &quot;dumb&quot; digital thermostat, which will do a call for &quot;aux heat&quot; if it kicks on and the room temp is 2 degF below the set point.
nice job! how much did it cost you about?
About $70 or so.
That is awesom. Now if i can figure out how to make it send signals back over morse code or something without RF i'll be set.
We both remember the modulated lightbeam kits of the late 70's.
I think one of your wires on your lcd is loose in that first picture. Mine does the funny wierd symbols if a wire temporarily becomes disconnected.
naw, it was a errant carriage return (println instead of print), carried over from the serial output of the original code snippet.

About This Instructable




Bio: Professionally, I'm an IT Engineer (Executive Level) and Electronics Tech. I'm a Amateur Radio Operator (KK4HFJ). I lived off grid, with Solar (PV ... More »
More by sspence:DIY I2C LCD Display with Inputs Raspberry Pi & the Neo 6M GPS Earthquake / Vibration Sensor 
Add instructable to: