Update March 2017
The RTC and DHT libraries are notorious for creating problems as there are so many of those libraries around carrying the same name. Therefore, In Step 17 I have linked to codebender where you can find the code with the proper libraries.
However, codebender is closing down, so I also added a zip file with the code and libraries, but I kept the libraries local, with the INO file, as not to overwrite your existing libraries.

I have been using Attiny chips for irrigation tasks in my garden, but having plans to build a greenhouse, an Arduino seemed to be the way to go as it has more ports. I know, there are many 'Garduino' type projects already, including ones that twitter the state of your plants, but I just wanted something more basic, so, what does an anal retentive Asperger do in such a case: build something myself.

No use of course to spend 23-25 euro's for an Arduino Uno and then still have to add a shield for peripherals: seemed a bit overdone and as I have built various 'arduino's' already, I decided to just get the chip, a crystal, and 2 capacitors + some more stuff and build the entire thing on an Archer experiment board that I bought 20 years ago but has been idle all that time (radioshack partno 276-168). The Archer experiment board has islands with 3 holes and 2 seperate tracks (Vcc and Gnd) snaking in between. Of course it can also be done on regular strip board, perfboard or one can make a PCB for it.

Note At the time I wrote this, it was economical to build an 'Arduino' yourself with a bare chip. However, as prices of Arduino clones have dropped considerably, it now in fact is much smarter to get an Arduino Pro Mini clone and add the required hardware to that

In the end I decided I needed to have the following functions

  1. measure temperature
  2. measure humidity of the air
  3. measure humidity of the soil
  4. measure water level in a container
  5. measure light, basically to determine if it is light or day
  6. measure CO2
  7. choose between measuring soil humidity or a pure hydroponics irrigation
  8. switch a fan
  9. switch a pump
  10. switch a heater
  11. switch a lamp
  12. log daily temperature

List of materials
Atmega 328 here to burn bootloader yourself or buy one preprogrammed
1x 28 pins IC foot narrow (or 2x 14 pins ic foot)
16MHz Crystal
2x 22 nF (often carries '223' imprint)
1x 10 k (brown-black-orange)
1x 100nF (often carries '104' imprint)
1x PCB
1x momentary make switch
perfboard This is what I used because I had that laying around idle for years already
NOTE:an attractive alternative is a cheap arduino clone such as the Pro mini or Pro Micro that can be had for a few dollars at e.g. Dealextreme.com or at AliExpress (currently 1.50 Euro)

16x2LCD CG046-3007 A00, but any other will do.
1602 I2C module

1x 7805, isolated
1x 1N4001
2x 100uF (16 V en 25 Volt)
1x 1 k resistor (brown-black-red)
1x LED
1x psu connector
Note: Consider getting a plug in USB charger with a cord and forget about making your own PSU

1x LDR
1x DHT11 moisture sensor (e.g. from dealextreme)
1x make push button
1x throw switch
1x buzzer (I use the CMB-06, a triggerable buzzer) ($2.99) but use any other buzzer you have or are comfortable with e.g. this one. Aliexpress has some buzzers that literally cost dimes
1x NPN transistor (e.g.BC547)
1x 330 Ohm (orange-orange-brown)
2x 10k (Brown-black-red)

Solidstate relays
4x330 Ohm (orange-orange-brown)
4x8pin dil foot
4x39MF22 SSR
4x2pin screw connector (mains voltage)
1x 5pin female printheader
1x 5pin male header 90degrees angle
ALTERNATIVELY: buy a ready made 4 channel mechanical relay for just about the same price as loose parts for the SSR, such as this one, or an even cheaper one.

bits and bolts
a couple of different colour wires, some print headers, four 3mm bolts and nuts, some 2.5 mm bolts and nuts, 4 spacers
solder tin, solder iron.
I have used Cinch plugs for connection... but actually these are hard to solder.

I use two casings:
one for the processor and most of the peripherals (I use a plastic box that contained screws: 9x12x4.5 cm)
one for the SSR's (I used a Tic-Tac peppermint dispenser The bigger one for 100 mints: 8.5x2x5 cm)

Step 1: Arduino for Garden, Greenhouse or Growbox: Inputs and Outputs

Before I describe the construction I will discuss the individual items:

An Atmel 328 with an Arduino bootloader is used. That makes for easy adaptation and uploading of the program. It will be a "bare bones" setup with no USB entrance, but simply with the TTL Rx and Tx signals on a header. Consider using a cheap Arduino pro mini, pro micro or Arduino nano

Simply a 7805 circuit fed from a wallwart. No 3.3 Volts will be necessary Consider buying a ready to use cheap 5 Volt USB charger

Humidity and temperature sensor
A DHT11 sensor will provide that. It is a 3 pin sensor of which the data can easily be read by the Arduino. There is a library available.

Simply read as an input to set various functions in the software

An LDR read by an analogue port. It basically is there to determine if it is day or night. This allows for extra light when the days are too short or to perform certain functions different at day or might(such as different day and night temperature, no irrigation at night etc)

Soil Moisture sensor
This sensor, read by an analogue port will give information about the humidity of the soil and signal the processor it is time to irrigate. There is an entire science on DIY soil moisture sensors. I will just be using the classic '2 nails' approach. The software and hardware will allow for the current through the sensor to be switched off, thus delaying corrosion.

Level sensor
This sensor checks if the water reservoir is still full. A simple float switch will suffice

used to give signals, e.g. if the water reservoir is empty. I use an old CMB-06 that has a trigger, meaning it can be triggered with a small current while it can get its main current directly from the power supply lines.

Solid state relays
I use 4 solid state relays to switch a fan, a pump, a heater and the lights. The solid state relays are separated from the processor print out of safety precautions. Consider using a cheap 5Volt 4 relay board

<p>Hi, great tutorial, I'm trying to reproduce it but I still get these errors:</p><p>Arduino: 1.8.1 (Windows 8.1), Board: &quot;Arduino/Genuino Uno&quot;</p><p>WARNING: library DHTlib claims to run on [atmelavr] architecture(s) and may be incompatible with your current board which runs on [avr] architecture(s).</p><p>D:\Documents\Arduino\Sketch\greenhouse26instructables\greenhouse26instructables.ino: In function 'void loop()':</p><p>greenhouse26instructables:513: error: 'class DateTime' has no member named 'dayOfWeek'</p><p> dag = now.dayOfWeek();// contains day of week (0-6)</p><p> ^</p><p>greenhouse26instructables:514: error: 'class DateTime' has no member named 'dayOfYear'</p><p> doy = now.dayOfYear();</p><p> ^</p><p>exit status 1</p><p>'class DateTime' has no member named 'dayOfWeek'</p><p>Please help</p>
<p>these errors point at the compiler linking in the wrong libraries. there are many libraries called RTC or DHT and judging from you.<br>The DHT lib just gives a warning, but should not cause too much problems.<br>To make sure you get the right libraries, in Step 17 I added a link to codebender that links in the proper libraries, but as codebender is closing down in the (near) future, I also attached the file, including the right dht and RTC libraries. I kept those as local files with the ino file to avoid them overwriting your existing libraries</p>
<p>Can I use a DHT11 with 2 meter cable without losing accuracy on the readings? </p>
<p>you should be able to. The datasheet <a href="http://www.micropik.com/PDF/dht11.pdf"> http://www.micropik.com/PDF/dht11.pdf</a></p><p>states:</p><p>When the connecting cable is shorter than 20 metres, a 5K pull-up resistor is recommended; </p><p>when the connecting cable is longer than 20 metres, choose a appropriate pull-up resistor as needed.</p>
<p>Thank you, I have completely missed this and probably would have continued to do so if you hadn't mentioned it.<br><br>Since you're a fast responder, I'll dare to ask another one. How moisture sensitive are these sensors and the accompanying electronics? Have you tried it over a period of time? I would imagine they wouldn't handle 99% RH very well and with the morning sun coming that would be a reoccuring situation. Also I was thinking of making a mushroom fruiting chamber to use the system in over the winter when there's nothing in the greenhouse. There you would work with &gt;90% RH constantly. I certainly hope the DHT11 being able to handle it since it's a humidity sensor, but I'm worrid about the far more expensive CO2-sensor. Know anything about it?</p>
<p>also there the datasheet gives a reply as the dht11 can handle 20-90%RH and indeed it is not really great at 99%RH</p><p>With regard to CO2, i was lucky enough to get a free Winsen....if i hadnt iI might not have put one in, but it works OK. However, if you start to play with CO2 levels, you need to make sure you adapt your feed as well asit affects your growth rate. Currently I only use it as indicator.</p><p>Now mushrooms.... good idea, I havent been too succesful with that yet, but i may in future)</p>
<p>I won't feed anything when it comes to CO2, in a greenhouse low levels would mean I would start a circulation fan or exchange the air in the greenhouse, in the case of mushrooms I would do the same but with high concentrations.<br><br>Thank you for the guide and your response! This has been very helpful.</p>
<p>my pleasure. good luck</p>
<p>Also do anyone have a good idea on individual drip irrigation for up to 10 pots? Individual lines to each pot with a valve is a neccessity unless you do the water cannon thing I saw with a stepper motor the other day, but I don't want to go there. Is there any good solution to this problem?</p>
<p>if you want individual drip irrigation (if that really would be necessary) there are several ways: 10 pumps, or take one main line and attach 10 drip lines. at the end of each drip line set a drip regulator. These are small drippers that you can turn or twist so they pass more or less water. </p>
<p>The adjustable dripper sounds like the most convenient solution. Not as good if you want to go on vacation and be able to monitor and water over Internet though. I'll think of it :)</p>
<p>google for 'adjustable dripper'</p>
what are the software and hardware requirements for this project???<br>can any one suggest me???<br>i would like do this project as my college project.<br>please anyone suggest me the hardware and software requirments<br>
<p>they are described in the instructable, what is not clear in it?</p>
<p>this looks awesome and too complicated for me. Do you know an easier way to dispense water to the plant like giving the plant 30 mL of water every 12 hours. I'm new with the programming so i need something kind of simple, if you or anyone else could help me that would be awesome.</p>
<p>yes that is not that hard. there are various ways to do that. e.g. take an arduino pro mini, run a timer on that and every 12 hrs switch a pin high that has a small pump attached to it that pumps long enough to dispense 30 ml<br><br>or<br>Take a timer and an attiny85. Switch a pin high in the setup routine and keep that high with 'delay()' for a specified time to drive a pump. Set the timer for every 12 hrs and feed the attiny off the timer. It will restart every 12 hrs, run the setup and dispense the water</p>
<p>Very nice project and thank you for sharing the code..</p><p>Did you have a special reason for using a analog input ( A1 ) for the ' irrigation ' level ?</p>
<p>thank yuo for your kind words.<br>the raeson I use an anaolog input for irrigation level is because I need to read a variable resistor for that. Tha analog input is the way to do that</p>
<p>Thank you for your reply.. It's indeed a easy way to adjust your moisture level..</p>
<p>Thanks for sharing! This really motivated me to make my own Growbox! Quick question: You mentioned a heater, what would use as a heater? A heat lamp? Or what? A link to what you had in mind would be really appreciated! <br>Keep up the awesome work!</p>
<p>Thanks, I actually have used several, a lamp was one of them but that could disturb plants who will interpret the intermittent switching of a lamp at 'dark time' as a 'short day. some herbs and i think tomatoe dont like that. currently i use a 12 volt car heater.</p><p>That may not work in every space but mine is relatively small (130x60x60cm) and well insulated as it is completly build from alufoil covered foam</p><p>I must admitt i also have heated with a small burner. though that was ofcourse harder to regulate, the benefit was CO2 production that benefitted the plants. </p>
<p>Thanks for the reply! Going off of what you said i found this<br><a href="http://www.amazon.com/Lasko-100-MyHeat-Personal-Ceramic/dp/B003XDTWN2/ref=sr_1_4?ie=UTF8&qid=1447873183&sr=8-4&keywords=car+heater" rel="nofollow">http://www.amazon.com/Lasko-100-MyHeat-Personal-Ce...</a><br>Looks perfect</p>
<p>indeed looks good for a not too big space. Ceramic, like my carheater</p>
<p>the carheater i mentioned is a 12 volt heater thais used to keep windscreen from freezing in the winter</p>
<p>Thanks for sharing! I'm using your project as a base for mine (will post soon). I'm trying to use (almost) the same approach you have on step 5 to start a 3-6V water pump like this one <a href="http://www.aliexpress.com/item/DC3v-6v-5v-Small-Submersible-Waterproof-Water-Pump-Fish-Tank-Circulate-Aquarium/32361105440.html?spm=2114.01020208.3.20.098q5s&ws_ab_test=searchweb201556_3_79_78_77_92_91_80,searchweb201644_5,searchweb201560_9" rel="nofollow">http://www.aliexpress.com/item/DC3v-6v-5v-Small-Su...</a> connected to Arduino Uno's Vin (9v external)</p><p>But I'm not sure I'm getting it right, since it's not working...lol</p><p>Any help would be appreciated! </p>
<p>Alex, tnx for yr comment.Our approaches are a bit different as I use a transistor to put voltage on a sensor while you try to switch a pump with an altogether different voltage.<br>I understand what you are trying to do but I see some problems with your circuit:<br>When you switch on yr transistor 9 volt will fall over your 5 Volt pump. In order to regulate that you added the zener diode. However your zenerdiode will have trouble dealing with the almost 4 volt excess voltage as it has no resistor to lose the 4 volts in. Therefore chances are your zener will just burn out.<br>Although still a bit unorthodox you could put the aener in series with the pump. That way some 4 volt will fall over your relay and the zener will not be in trouble. (provided it can take the current the pump needs). </p><p>Still you need to put a reverse diode over your pump to suppress EMF feedback</p><p>I am wondering though why you are using 9 Volts to switch your pump if you have 5 volts available<br><br></p>
<p>hi there love the project </p><p>but I suck at the code part can any one help me I want to use this project with a uno but the code dosnt want to load can sumone please E-mail me the code for a uno <a href="mailto:Techead101@gmail.com" rel="nofollow">Techead101@gmail.com</a> thanks</p>
<p>it should load on a UNO so there must be another problem. What error message do you get?</p>
<p>Can I use an Arduino Uno?</p>
<p>yes of course you can, just need to add the RTC and LCD and other peripherals.<br>I just wanted to have it all on one perfboard and had still an atmega laying around. could even get a pro mini for say 2 dollars in china and use that on a perfboard</p>
Oh ok thanks! using this for my final project in robotics
<p>good luck</p>
<p>this is just perfect, wow.!! thank you for sharing.</p>
<p>my pleasure Akin</p>
you read my mind and thank god you made it right. you just showed 85% of my automation grade last project. the only thing diferent from what i need is the data readings, full control, and even especies choice from an android app. based on fancy pepper cultivars such &quot;ghost pepper&quot; &quot;Carolina Reaper&quot; an so on... once im done ill share!
<p>looking forward to that.<br>I currently am testing a wifi module on this project</p>
<p>One of the more comprehensive garden monitor/controllers.</p><p>Thanks</p>
<p>thanks Acheide. Sorry for my late reply, but i discovered i seem to have to click 'Make Comment' twice, otherwise it won't store</p>
That's a nice project! I would use your project to create my own watering system :D thanks for sharing
<p>thanks Timofte. As a matter of fact I quite enjoyed your clock project and have 'stolen' some of your symbol definitions that I am now using rather than text for temperature and humidity :-)</p>
very well done..nicely explained..cheers
<p>Thanks BLR_Ravi :-)</p>

About This Instructable




Bio: I am a physician by trade. After a career in the pharmeceutical world I decided to take it a bit slower and do things I ... More »
More by diy_bloke:Adding an MCP23017 I/O Extender to Arduino or ESP8266 Calculating Sunset and Sunrise for a Microcontroller A Simple MQTT Pub/Sub Node With Arduino UNO and ENC28J60 Ethernetshield 
Add instructable to: