I volunteered to develop a little greenhouse automation for a family friend, so I spent some time getting the required hardware and writing the code for the project. I am at the alpha stage where i have built my prototype about 80% there and wrote 90% of the code. I suspect I will need to add some electrical components to improve my design and maybe my code can be optimized a bit.
So, here's the high level project overview:
I am monitoring the temperature and humidity of the greenhouse to make sure they don't go too high. If they rise above a threshold then I trigger a relay to turn on an exhaust fan to get the warm humid air out. Additionally, I have a pair of soil moisture sensors (I average the 2 sensors for my threshold reference), which when the threshold is passed, they trigger another relay which is connected to a pool/fountain water pump to get water over to the plants in the greenhouse.
The LCD flips between displaying the current sensor readings and the fan/water pump status during general run time.
Additionally, based on the input to the keypad the user can see the thresholds, or enter a configuration mode or shortcut to a specific configuration setting. I am storing the thresholds in the EEPROM and loading from the EEPROM when the Arduino is powered.
Components are:
- Arduino Nano v3
- 2 Relay Module with Songle SRD-05VDC-SL-C relays (Based on this post I "may" be ok?)
- 2 Soil Moisture Sensors eBay reference
- 4x4 Matrix Keypad eBay reference
- 16x2 LCD Display
- DHT11 Sensor
Since I started with the Arduino and pieced it all together, I am certain my electronics connections can be much improved as the modules and sensors are tied to the pins (Where the tutorials called for potentiometers/resistors those were added but I am not sure if having everything together requires additional design). Unfortunately I could not get a hang of using Eagle to draw my schematic.
The code behind the project is attached. Note that I am aware that there is technically a "logic error" with the soil threshold and it is reversed right now, this will be adjusted closer to release time.
My next "to do" steps are:
- Get 2 extension cords (3 prong variety) and to splice the relays into the extension cords.
- Build/integrate an enclosure of some kind, preferrably so that it only has a few plugs for sensors and fan/pump
GreenHouseBeta.ino (21.6 KB)



