A friend of mine had this little hydroponic nursery that was being run by mechanical timers. For temperature monitoring he had a thermometer taped inside. One of his main problems was that the timers have only a 15 minute resolution. He wanted to run some things for shorter times. I figured it was a job for Arduino which I had no experience with but I had heard of because I'm an open source supporter.
So I did my research and ordered up a bunch of stuff from seeed studios. An Uno and a bunch of the Grove stuff including the Grove base shield. So this Uno is loaded up with; two switches, two DHT22 sensors, one analogue temp sensor, four relays, a serial LCD (16x2) display, an SD card shield and a real time clock with battery.
Like everyone else I had to walk before I could try running so I made the LED on pin 13 blink. Then I poked at each of my devices to get them working.
Inside the unit is the analogue temp and a DHT22. The other DHT22 sits outside for ambient air readings. The LCD displays the time and real time temps and humidity as well as the highest and lowest values recorded. Which are scrolled through with a button. The LCD backlight can be turned on and off with the other button and it also times out and auto shuts off. The LCD backlight blinks if an alarm condition is met.
The relays can have four different scheduled events to run during a day. They can only be programmed to a minute, which is fine for this purpose. Any relay can be overridden if needed such as for thermostatic control of the vent fan. I wanted to be able to program the relays via the LCD screen and switches but basically have no program space left. So the relay programming is uploaded with the sketch. As part of the function is to properly time relays it is possible to set the clock via the switches and this routine will time out and quit if their is no user input. That keeps it from being left part way through setting the clock and not being able to do anything waiting for user input. Hopefully the battery backed RTC means never having to do this.
The big advantage of this system is that it logs data so that he can get a good idea of what is really happening in there. Then we can fine tune the cooling and alarm system.
I did do battle with running out of RAM and it currently uses about 31k of program space. So it's pretty much full. I see a couple of places that need some tweaking like bounds checking in the function that programs the relays. When the hardware is all installed into its new home I'll get some pics.
I've attached the code for this as well as a utility that I wrote up that can turn relays on and off and dump the datafile via serial.
Hopefully someone can find something useful in there. I'd also be happy to hear some criticisms of my code. Bear in mind that I code as a fun hobby, not a living, so go easy on me.
sketchbook-2012-08-28.zip (12.9 KB)