Instructables

The Arduino Weather Station / Thermostat

Featured

Step 5: Current code with wiring instructions

Picture of 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)

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

//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 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.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);
}



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

 
Remove these adsRemove these ads by Signing Up
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!