What's new

DIY Grow room controller (Arduino) – Tutorial/Log

kkmmbb

Member
A while ago I started making my own grow room controller. Mainly with cheap Arduino components purchased on Ebay. My knowledge was very limited, but I managed to put together a (somewhat) working controller. This controller is far from finished, I see it as version V. 1.0. Plenty of room for improvements and upgrades. That is the reason I wanted to publish this to Icmag. For the purpose of helping/receiving help/inspiring others to make the same project and to document my progress. I wanted to give back to the people of the internet, since I have used a ton of tutorials to make this work.

My requirements for the controller started like this:

  • Auto-control light. 18/6 and 12/12 schedule
  • Thermostat controlled in/out-take fans
  • Auto-controlled dehumidifier
  • Auto-controlled room circulation fan
Note: I come from Europe, so all measurements and so forth are written in Celsius and AC power is based on 220V.



Intro:
This is the main layout of the controller. It can be mounted on the wall or placed on a table. The project box is quite big, but there is a lot of empty space inside so a smaller box can be used.
Information is displayed onto an LCD screen (20x4). The controller is powered by 1x 220V AC plug on the left side, with ON/OFF option. Underneath the controller, there is a RESET button.
A USB cable is also sticking out of the box, but this is just for testing/upgrading phase, so it is easier for me to upload new code onto the Arduino.



AC power-outputs:
The controller has 6x AC outlets. #1 for light. #2 for fan-out. #3 for fan-in. #4 for circulation fan. #5 for humidifier. #6 is not used (yet).
These outlets are controlled by the 8-channel relay board, which is controlled by the Arduino. All power used by the grow-room is supplied by the controller (for a maximum of 10A). The power entering the controller is connected to a muffer, which spreads the power in a parallel-series to all the outlets. I am not schooled in AC power, but in DC power so I am not sure this is the best/safest way to do it. Let me know if there are better ways.



Vegetation and flowering phase:
In a future version of the controller, a rotary encoder switch will be used to choose light intervals, as well as desired temp/hum values for triggering fans and dehumidifier. But for now, there are two separate codes. One for veg phase and one for flower phase. Intervals and temp/hum values are written in the code, on the IDE.

Time tracking:
The controller is not connected to the internet, nor does it have a real-time clock. So basically it only knows when it was turned on, and starts counting milliseconds at that moment. This means if Flowering phase is used, and the controller is turned on at 12pm, it will do so forever. There is on the third line of the LCD display a “Days NR#” since it was turned on. So if veg time should be 4 weeks, user will know 4 weeks have passed when days counter hits Day Nr #28.
Note: The 1 0 0 (or 0 0 0/ 1 1 1) at the bottom of the LCD screen indicates whether or not circulation fan is on/off, if in/out-take fans are on/off and if dehumidifier is on/off.

Controlling intake/outtake fans & dehumidifier:

[FONT=&quot]The intake/outtake fans are controlled by the DHT22 sensor. The Arduino compares these readings to the desired/set values in the code, and triggers the relay ON or OFF if values are met.
As for the dehumidifier, the humidity readings from the DHT22 sensor is sent to the Arduino, which compares them to the set value of when the dehumidifier should be turned on.
A thermostat principle is used to achieve this. FX when temp hits 29 degrees Celsius, in/out-take fans are turned ON. They stay ON, until temp hits 22 degrees Celsius.
[/FONT]


Components list:

  • Arduino Uno
  • 8 channel 5V optocoupler Relay (Too big since i only use 5 channels)
  • DHT22 Sensor
  • 20x4 I2C LCD display
  • Power supply for Arduino (9V, 1A)
  • Power supply for Relay (5V, 2A)
  • Assorted wires + other small installation stuff
  • Project box

Hardware setup:
First we have the Arduino Uno powered by its own power supply.
The DHT22 sensor is connected to pin(5), 5V and ground on the Arduino.
The 8-channel relay is also powered by its own power supply. This power supply is connected to pin(JD-VCC) and ground on the far right side of the relay. The relay is also connected to 5V from Arduino. The relay data-pins are connected to Arduino pin(7,8,9,10,11,12).
The LCD(20x4) screen is connected to Arduino SCL and SDA pins, 5V and ground.
Reset-button is connected to 5V and ground. The button is a momentary switch, so when triggered 5V and ground are connected, in which the Arduino is reset (Same as turning it off and on again).



Software setup:
I am using the official Arduino.cc IDE for writing code. I will not explain the basic fundamentals of Arduino coding, since there are many great tutorials on this subject. So if this is totally alien to you, I would recommend looking into some beginners guides on Arduino programming. I will try to shortly explain the changeable parts of the code, without making this tutorial any longer than needed. Questions are very welcome on workings of the code, or on things that I did not explain properly. I will try to explain as best as I can. (Note: This code will not work if all pins are not connected exactly like in my setup!)
The only difference in Vegetation phase and Flower phase code, is light schedule, the chosen temp/humidity values for when the in/out-take fans should be triggered, and also when the dehumidifier is turned on/off. All these values can be modified in the code.
[FONT=&quot]The code is organized in different parts. Fx. “Light timer”, “Temperature control”, ” Humidity control” and so on, for easily overview and modifying of the code.[/FONT]

Code that should be modified for desired thermostat values is this part (Line 30+31 in code):
int tempset=26, tempreset=19; // For vegfase: 20-30C // For flowerfase: 18-26C
int humset=55, humreset=40; // For vegfase: 40-70% // For flowerfase: 40-50%
In this part, tempest=26 is when the out/in-take fan should be turned ON. 26 meaning 26 degrees Celsius. Tempreset=19, is when the out/in-take fans should be turned OFF again. So when temp hits 26C fans turn ON, and then temp hits 19C, they turn OFF.
Humset=55 is when the dehumidifier should be turned ON. 55 meaning 55%. And like before, humreset=40, means it will turn OFF when humidity hits 40%.
Next part of the code which can be modified is light timer (Line 110-123):
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;

if (lightState) {
lightState = LOW;
interval = 43200000; // 64800000 = 18 hours ON // 1 hour = 3600000
myDisplay.backlight();
} else {
lightState = HIGH;
interval = 43200000; // 21600000 = 6 hours OFF
myDisplay.noBacklight(); }

[FONT=&quot]digitalWrite(lightPin, lightState); } [/FONT]
In this light timer part, interval can be modified to the desired amount of hours ON/OFF. In this part, it is set to 43200000 ms. Which equals 12 hours. So when Arduino turns on to start with light is OFF, it then turns ON. When light has been ON for 12 hours, it goes to next interval which is also 12 hours. So continually 12 hours OFF and 12 hours ON. So this part is different from Vegetation phase, in which first interval is set at=64800000ms which is 18 hours ON, and second interval is at=21600000ms which is 6 hours OFF.
The last part of the code which can be modified to your desired value is circulation timer. This controls the fan inside grow room. It is initially set at 5mins ON and 5mins OFF interval (Line 127-135):
if (currentMillis - previousMillis2 >= interval2) {
previousMillis2 = currentMillis;

if (fanroomState) {
fanroomState = LOW;
interval2 = 300000; // 300000 = 5 mins ON // 1 min = 60000
} else {
fanroomState = HIGH;
[FONT=&quot] interval2 = 300000; } // 300000 = 5 mins OFF [/FONT]
So here we can see first interval2 is set to 300000ms, which equals to 5 mins. This can be modified to whatever interval2 is desired. 1 min = 6000ms.
This was the 3 parts of the code which can be modified to fit the desired thermostat temp/hum value, and timer intervals. Everything else can be modified in the code, but these 3 parts are the key components, as changing a lot of the other code stuff will give errors in running the controller. For questions on code, feel free to ask away and I will try to answer as best as I can. I myself, is quite new to Arduino, so I might not be able to answer everything.

[FONT=&quot]One last thing I would like to note. The LCD screens light turns OFF when light timer goes to OFF mode, so LCD light does not spread confusing unnecessary light into the room in dark period.[/FONT]

Download links to Vegetation and Flowering phase code:
http://www.mediafire.com/download/r3sdx3l4u84uxx3/Veg_and_Flower_phase_sketch.zip

Libraries used in Arduino IDE for creating Flowering and vegetation Phase code:
http://www.mediafire.com/download/40qstnapg48qubb/Grow_controller_arduino_libraries.zip

Contains following libraries:

  • DHT library
  • Liquid crystal I2C library
  • Time-master library
I would recommend all who is totally new to this whole Arduino thing to check out the many very well-made tutorials on how to get started with the basics. There is a ton of these on youtube, as well a lot of written (non-video) tutorials which can be found on google.

For those who are familiar with Arduino or other microcontrollers, I think this guide will be somewhat understandable, although I think some of the points in this tutorial could have been written differently or in a more teachable-friendly way. I hope this whole thing is understandable and not just a long confusing mess. Let me know! And if there are any questions what so ever, I will try to answer it as best as I can. I hope this helps someone in need, or sparks new curiosity amongst the human internet-population. Thanks for a great forum! Goodbye for now, until next time.
 
This is excellent. I am going towards an arduino controller system for light controls and some fan controls, as well. I am considering a typhon controller, already programmed, with the same basic functions, and I am using two single relays for separate light controls. thanks for sharing. I plan on building two receptacles with the switch and regulator and logic connections from controller via 22 gauge wire with 5v. the receptacle will have it's own 5v power supply to the relay for energizing. This will give me control of my lights on/off thru dimming function, pwm 5v, to the LED Drivers and the receptacle. peace.
 
those relays should only be used to control other power relays that have higher ratings for lights, it shouldn't be controling straight lights.

Anyway Nice job kk keep up the great work.
 
Opto-Isolated 2 Channel Relay Board (We have sold thousands, now get a good price!)

Please note: Large Quantities may have a longer lead time. Please email for details: [email protected].

See more details, applications on our WIKI here:

With high-current relays, AC250V 10A ; DC30V 10A NOTE: Each relay draws about .08A (80ma) so about 4 relays are the maximum you should run from the Arduino +5V supply. (Running from USB it may be less). More than 2 relays: we recommend you use a separate 5V supply for the relays.

Dimensions here: http://arduino-info.wikispaces.com/RelayDimensions

NOTES: If you want complete optical isolation, connect "Vcc" to Arduino +5 volts but do NOT connect Arduino Ground. Remove the Vcc to JD-Vcc jumper. Connect a separate +5 supply to "JD-Vcc" and board Gnd. This will supply power to the transistor drivers and relay coils.

If relay isolation is enough for your application, connect Arduino +5 and Gnd, and leave Vcc to JD-Vcc jumper in place.

NOTE: It is sometimes possible to use these relay boards with 3.3V signals, IF the JD-VCC(RelayPower) is provided from a +5V supply and the VCC to JD-VCC jumper is removed. . That 5V relay supply could be totally isolated from the 3.3V device, or have a common ground IF opto-isolation is not needed. If used with isolated 3.3V signals, VCC (To the input of the opto-isolator, next to the IN pins) should be connected to the 3.3V device's +3.3V supply. NOTE: Some RaspberryPi users have found that some relays are reliable and others do not actuate sometimes. It may be necessary to change the value of R1 from 1000 ohms to something like 220 ohms, or supply +5V to the VCC connection.

NOTE: The digital inputs from Arduino are Active LOW: The relay actuates and an LED lights whe the input pin is LOW, and turns off on HIGH. See the Wiki article for how-to assure relays do not activate at power-on time.

This is an excellent relay for what we use in lighting. I am using a similar relay to initiate and shut down circuits for lighting without a timer any longer.
peace
 

Attachments

  • OptoRelayChannelData-575.jpg
    OptoRelayChannelData-575.jpg
    15 KB · Views: 54
Those little blue relays are great for arduino use. They are rated at 10 amp resistive load. I believe most high intensity discharge lights are an inductive load. I could be wrong or I could be using the wrong terminology but I would rather over build than under build. Some say using an inductive load with a resistive relay will shorten the life of the relay. Others say to use 50% of the rated capacity. The general rule of thumb is to not load a component to more than 80% of its rated value. So 10 amps x 50% = 5 amp inductive load x 80% = 4 amp max for an inductive load (hid's). That works out to about a 400 watt lamp at 110 volts.

I have 10 of the little blue relays working off 1 arduino with a separate 5v supply. Three of the little blue relays trip larger, 30 amp contactor for my lamps. The other little blue relays control fans and pumps. Temperature sensors add to the complexity but allow the system to turn fans (and lights if too hot) on/off automatically based on temperature.

You can buy a system that does the same as my arduino setup but the arduino setup costs a small fraction of the cost and is infinitely more flexible.
 
OP,
Have you looked into the TimeAlarms library?

If you roll your own with an arduino or pi or whatever, instead of buying a pre-made item, you'll have enough $$$ left over to afford a thermal camera. Here's a pic of an 8 relay board.
8relays.jpg


As you can see, the relays generate heat when energized. The arduino also generates heat. Be careful combining them in an enclosure.
 
Last edited:
Those little blue relays are great for arduino use. They are rated at 10 amp resistive load. I believe most high intensity discharge lights are an inductive load. I could be wrong or I could be using the wrong terminology but I would rather over build than under build. Some say using an inductive load with a resistive relay will shorten the life of the relay. Others say to use 50% of the rated capacity. The general rule of thumb is to not load a component to more than 80% of its rated value. So 10 amps x 50% = 5 amp inductive load x 80% = 4 amp max for an inductive load (hid's). That works out to about a 400 watt lamp at 110 volts.

I have 10 of the little blue relays working off 1 arduino with a separate 5v supply. Three of the little blue relays trip larger, 30 amp contactor for my lamps. The other little blue relays control fans and pumps. Temperature sensors add to the complexity but allow the system to turn fans (and lights if too hot) on/off automatically based on temperature.

You can buy a system that does the same as my arduino setup but the arduino setup costs a small fraction of the cost and is infinitely more flexible.

Don't know about you, but I use LED lights not HID, HPS, or MH now. Modern LED lights use less than 2 amps and 400w at 120v. Perhaps for HPS or MH you need an inductive relay, but for low wattage and amperage these do quite well for everyday appliances controlled by arduino's.
peace
 

kkmmbb

Member
Hey guys thanks for stopping by! and thanks for the imput. I have been a little busy working on a Golden Grower v.1.2 lite version. To control a micro grow-room. With 2x cree 3050 cob, in/out fans and circ fan. So a little more simple than version 1.0. Version 1.2 also has a micro-sd module to record temp/humidity, so at the end of veg/flower cycle i can see some data!

AvidLerner: This is excellent. I am going towards an arduino controller system for light controls and some fan controls, as well....
Sounds great avid, i havent heard of this typhon controller and cant find it. Can you post a link maybe? sounds interesting.

Skinny Leaf: What is the contact rating of the relays on that relay controller board?
Yes, just at Avid has pointet out, these relays should be perfect for small/medium grows. They are rated at 10amps, so they can handle a bit. For more info on these relays, here is the datasheet: https://www.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf

plutosmoke: [FONT=Arial, Helvetica, sans-serif]those relays should only be used to control other power relays that have higher ratings for lights, it shouldn't be controling straight lights
Anyway Nice job kk keep up the great work.
[/FONT]
Thanks for stopping by and posting imput! yes i must admit i do not know the full specs of these relays. I will have to do some homework on these, and thanks for the kind words!

The Meadows: OP,
Have you looked into the TimeAlarms library?
Hey Meadows! thanks for your imput, on both relay info and a new library. I was not familiar with this library before you mentioned it. I have spent the last couple of days looking into it. I think i will use it, combined with some of the existing code from version 1.0. It seems like a perfect library for this project, since i am trying to avoid using RTC. Even though i have a couple lying around. Maybe they will be used another time.
And thank you for mentioning that the relays get hot! I had not even concidered this fact. And it is really important!

AvidLerner: Don't know about you, but I use LED lights not HID, HPS, or MH now. Modern LED lights use less than 2 amps and 400w at 120v. Perhaps for HPS or MH you need an inductive relay, but for low wattage and amperage these do quite well for everyday appliances controlled by arduino's.
peace
Yes this is a very good point! These relays will not be useful for 1-5kwatt operations, but for small growrooms they are perfect. I will be using the controller with 2x cree 3050 cobs as mentioned above. I am really exited to get the little cabinet up and running.
I have had one previous grow in the cab, but temp was a big problem for me, and the in/outtake was controlled by a timer, and not a thermometer.

Here is the thread i started with the cabinet, if anyone is interested: https://www.icmag.com/ic/showthread.php?t=312829

So i am really excited to get this up and running. I am currently finishing up the cabinet with new modifications and also looking for a perfect indica strain that can be scrogged! I would love to hear what strains you guys prefer! Until next time, my loving internet friends!
 

kkmmbb

Member
And there was a question on the contact rating on these relays. It is also in the datasheet but here is also a small picture of it (Note: it seems the manufacture of the relay has only made one datasheet, for both 5v and 12v relay):

picture.php

album.php
 

jikko77

Active member
Typhon is a reef controller.
it manage 4 pwm channel.
it has a lcd diplay

here a couple of link.
the first one is a typhon like controller, using an arduino and some common hw:
http://www.nano-reef.com/topic/321511-typhon-based-led-controller-on-the-cheap-seriously/

the second link a youtube video of the typhon itself:
https://www.youtube.com/watch?v=d3V_qRzNWdw

official manual:
http://stevesleds.com/uploads/Typhon_LED_Controller_2214.pdf

the typhon is became obsolete, now it is replaced from the HurricaneX LED Controller.

@kkmmbb: nice work.
 

Latest posts

Latest posts

Top