Greenhouse controller - is arduino the right choice?

Hi all.

I just finished building a greenhouse, and I would like to figure out the best way to control it.

I would like to controller the following things.

1: Timer for 4x 24V pumps. Every 4th hour run the pump for 15 min) My initial idea was to run these from a timer, controlling a 24V power supply, which again powered the pumps. “Great” concept - if all the pumps needed to or could run at the same time. To get the most out of the greenhouse, it would be better not to run all pumps simultaneously. Since the timer I have bought is 230V, it would properly end up on a shelf. The pumps pull 1,4A

Not included in today’s solution, it would be neat if I got an alarm if the pumps were supposed to run and there wasn’t water on the grow table (flotation switch?)

2: No gear brought yet - We are thinking about putting up a misting system in the roof - both for watering, but water will also cool the air on the hottest days. I need a more powerful pump and have been looking at one 24V 9A, but I could use a 230V pump. A timer and a temperature controller could run the pump for the misting system.

3: I’m building a solar thermal collector for water, this need to run a pump and open the water flow if the temperature in the collector is higher than the water in temperature out of the reservoir, and turn the pump and water flow off if the temperature in the collector is lower than the water going out of the reservoir. I also need to pump water through the floor tubes if the temperature outsides drop below xx. This system will be turned off in the summertime but used in late autumn, winter, and early spring.

4: lights, if there are less than xx lumens, turn the lights on, but the lights should always be off between 23:00 and 07:00 (Or something like that)

I played with plcs at school 25 years ago, but didn’t work in the subfield later. And I have never used Arduino, and there are quite a few models to choose from, so instead of buying the wrong main piece and shield(s), I thought it would best to start here.

And another thing to consider, I would like to add a few solar panels next to the solar collector and a few batteries for storing power for lights and pumps when there isn’t enough sun. I will be able to charge the batteries and heat the water if needed from the house if needed, but that doesn’t need to be automated. An alarm would be excellent, though.

So, is this an Arduino project, or should I find a plc to use? Or maybe there is a more or less finished Arduino project I could buy?

As I understand, most of what I want is just a few “if” “then”, and maybe some “and”, “or”, “not”. At least until I get to the alarm part of the system.

If you Google “Arduino greenhouse” you can see what others have done.

1 Like

You can control a greenhouse with an Arduino. You will need some optoisolated relay modules to switch power to your pumps and any solenoid operated valves - Arduinos can’t provide much power.

You will need a clock module I expect. Also perhaps a means of talking to wifi if it reaches the greenhouse so you can monitor/record/command.

Many people have done similar projects - sometimes they’re called Garduino.

Pin count is an important consideration to figuring out which particular Arduino you need. How many sensors, relays, etc will you have. A Mega is an easy choice because of its large number of pins. It might be worth getting a Nano or similar to start with though, just to learn how to use the hardware.

Your project will probably evolve. Given that, whatever hardware you choose now will be wrong, so get something in the low end to help you figure out what you really need. Hopefully it will find its way into another project later.

1 Like

What electronic builds and software experience do you have ?

What have you built in the past along this line ?

Search the site for past similar requests.

I always start with a proposed schematic (changes as progress is made as needed).

To start with you will need an RTC, relays, display . . .

Builds before - None.

Electronics builds - few - i do some soldering of wires when needed. Software experience - I presume you are asking about programming experience - Not so much. I have tweaked both PHP and javascript to change them to what I wanted, and we did have some fun with the plc at school.

I think all your requirements can be satisfied by the Arduino Board with atmega 328p microcontroller. But this microcontroller is not really having the good frequency. I you want the things to be performed faster you need to go with different microcontroller with greater frequency.

Arduino is a great choice you get a long-running community and help from all other resources if you need any help you can post here.
Arduino will satisfy all your needs.

I wan to to suggest another microcontroller that can be programmed with the Arduino-IDE just the same way as an “original” Arduino but offers some more functionality than an “original” arduino. The ESP32.

All your tasks are not timecritical that switching something on / off has to be spot on time in the scale of milliseconds. So the speed of an Arduino is sure suffificient.

The ESP32 offers:
WiFi Onboard. If your greenhouse is in the area where your local WiFi is receivable you could even transfer commands and measured values over WiFi to any Browser on PC or Smartphone

Bluetooth on board.

RTC Real Time Clock on board. Switching on a Pump for a 2,57 seconds or one hour is a peace of cake for any microcontroller. Keeping time over weeks in sync with general time at a precision of seconds requieres a Real Time clock.
An ESP32 has this RTC onboard. With an Arduino you have to add a RTC-module to have this functionality.

WiFi offers synchronising time as a side-effect.The RTC-Time will be synchronised automatically as soon as you connected over Wifi to a router.
If your local Wifi is not reachable you coud use your smartphone to act as a hotspot using mobile data then connect your ESP32 to this hotspot and time will be synced again and then can run for weeks and months with a small deviation.

There is a difference:
an ESP32 works on 3.3V. an classical Arduino on 5V.
Some sensors need 5V and using this sensor would require using a voltage-levelshifter.
But for almost anything there are sensors than can work on 3.3V up to 5V.
So if you know you are on 3.3V you can choose the sensors for example for measuring temperature and relative humidity in a single module that works on 3.3V

after initially building the basic functions you described above
You can advance to more functions like:
An ESP32 has quite a lot of memory where you could store measured values and “download” those values from time to time. Using a laptop with serial interface over USB-cable bluetooth or WiFi

The common modules look like this

Do you have permanent 230V AC at hand in your greenhouse?
Using a ESP32 with WiFi switched on needs 5V 0,3 A which means permant 1,5W.
And Arduino needs lesser than that. So if you use a battery to power it a low-power-microcontroller might be a better choice.

best regards Stefan

You think 16 million instructions per second is not enough to run a greenhouse? Perhaps you should wait until you have gained more knowledge and experience before offering help to others on the forum, otherwise you will only cause confusion.


A clock module or a WiFI microcontroller, as once you have an Internet connection, you have a clock available.

And using Wifi automatically transfers you from an Arduino to an ESP system - the WeMOS D1 Mini is an excellent start.

For multiple inputs and outputs you use I2C port expanders.

Ready to buy systems offer a limited functionality or if they are very configurable they will cost a lot. A microcontroller offers a versatility even a $2000 PLC can NOT offer.

The “price” of the microcontroller is time to learn programming and time programming it. If you think this is a hobby you enjoy that’s the way to go.

This DIY-control-system can grow over time.
For example
Timer for 4x 24V pumps. Every 4th hour run the pump for 15 min)
Is indeed just something like 30 lines of code.

So what is your attitude to programming:

a) Don’t really like but have to do it. I hope I can find lots of “function-modules” I just put together and then its working

b) Interesting to learn to program. Let’s se how far I can get in my programming-skills over time

This forum offers great help up to an almost professional level of software-development.
best regards Stefan

@cral I would recommend starting with a simple, basic Arduino such as the classic Nano v3. This will be more than capable enough for 90%+ of the ideas you mentioned. You can think about more sophisticated boards with wi-fi or whatever later, but for now, keep things simple so your learning curve is not too steep.

I would also recommend steering clear of 230V circuits for now. They are dangerous enough in normal circumstances, and much more so in humid environments with water raining down from above!

For controlling pumps at 24V, even at 9A, relays could be used, but I would recommend using logic level mosfets. They are small, easy to use, silent, don’t wear out, energy efficient, etc. Relays are not technology from the last century, they are from the century before that!

But that’s irrelevant for the moment. Start building simple circuits on breadboards and writing simple code. Use LEDs to represent your pumps switching on. Sounds like you might need quite a few temperature sensors, and if you use analog ones, you will quickly run out of analog pins. Fortunately, there are digital temperature sensors which are easy to use and can all share a single pin. They are called ds18b20 and come in various sealed probe designs. Just get some plain ones to use in your breadboard prototyping work.


I disagree with that
The only additional thing with an ESP32 is installing the ESP32-board-support
Which is a four step-process inside the Arduino-IDE. If you don’t use WiFi
it is the same as with a classic Arduino.

Which is well explained with step by step screenshots here

Building a webinterface with using ESP-Dash is much easier than setting it up from scratch.

include some libs

  #include <WiFi.h>
  #include <AsyncTCP.h>
  #include <ESPAsyncWebServer.h>
  #include <ESPDash.h>

create objects

AsyncWebServer MyServer(80);
ESPDash MyDashboard(&MyServer); 

create website with interactive elements is as easy as this

//  Button Card Format - (Dashboard Instance, Card Type, descriptive Text)
Card MyButton(&MyDashboard, BUTTON_CARD, "Blink On / Off");

//  Slider Card Format - (Dashboard Instance, Card Type, descriptive Text, Card Symbol(optional), int min, int max)
Card MySlider1(&MyDashboard, SLIDER_CARD, "Blink-Period in Milliseconds", "", 50, 1000);

and attaching call back-functions

  // Attach Button Callback this function gets executed every time the Button is clicked 
  MyButton.attachCallback([&](bool MyButtonState){
    DoBlink = MyButtonState;
    Serial.println("Button Triggered: " + String((MyButtonState)?"true":"false"));
    MyButton.update(MyButtonState); //Make sure we update our button's value and send update to dashboard */

  // Attach Slider Callback this function gets executed every time the slider is adjusted to a new value
  MySlider1.attachCallback([&](int MySliderValue){
    BlinkFreq = MySliderValue;
    Serial.println("MySlider1 Triggered: " + String(MySliderValue));
    MySlider1.update(MySliderValue); // Make sure we update our slider's value and send update to dashboard */

compile, upload, type in IP-adress click on slider to adjust a value
No messing with the html, defining arrays of chars or whatever

best regards Stefan

I would offer that you break down your list of devices into single sentences and not explanations.

4 ground watering pumps, 1 at a time, 15 minute intervals.

don’t run pumps in day, after 7 AM before 7 PM

1 pressure pump for spray or mist

light sensor

as you look at these in simpler terms, the outputs become more obvious.

a MEGA has more pins both digital and analog
any micro can use port expanders or shift registers to control more things.

the ESP devices offer WiFi, but a MEGA [ or ESP] can also offer an RF or BluTooth module.

in other words, pin count is the least of your worries.

As a general start, would offer that a simple NANO and a 4 channel relay module and some form, ( ANY form ) of light sensor.
These would be very low cost to get started and you would be able to have a proof of concept project and it may be all you need, just more expansion.

There are some VERY complex greenhouse control projects, soil moisture, humidity, multiple zones of water, fan off/on, roll up sides of plastic, open vents, and more.

Without getting into the possible interfaces, you can do a lot of work with one Arduino.

My personal recommendation is to get a NANO, relays, light sensor, a capacitive soil sensor, port expander and and start learning the code. [ also a BME-280 temperature humidity module]
Your PIC experience will soon be replaced with how simple the Arduino world is and how the multitude of sensor and modules has made it so much easier to add things.

If you wanted to start with an ESP, the EXP32 on a larger board will have more of the pins brought out. The smaller ones work the same, just some of the channels are not connected to pins. [ the way the ESP8266-01 does not bring out all channels to the pins ]

Also, you would need to get 2 long breadboards and remove one of the power strips. the small aircraft carrier ESP boards are much too large for use on a single breadboard.

[ I agree with Stepan that the ESP32 offers a gateway to external devices such as the internet or a phone, PC, etc but that is getting pretty far from the initial request. One can go into overload with just how much a simple micro can do. ]


one of the desired points is watering in daytime.
as we know the length of day, dawn and sunset change daily.

there are a few options to ‘know the time’

one is to get the actual time from a device. eitehr an RTC or the internet.
and then have a day of year list with listed times of dawn and sunset
or calcuate from summer Solstic to know the times.

another way is to use a light sensor, know the difference in the last 10 sunrise times in seconds or minutes and just figure that today will be about the same.
if the last 10 where 66 seconds earlier that each before…
ditto for nightfall.
you could calculate and store it in minutes and as any farmer knows, being off by an hour is not going to make much difference.

I pick 10 and would ignore any that were longer than some set window. that would eliminate overcast or rainy days.

using minutes would mean you could fit each in a byte.

The school where I worked with the PLC? I ended up as a certificated powerline technician, so yeah, I should leave those tiny 230V for the electricians :wink:

However, I do agree. Water and electricy doesn’t mix very well.

Mosfets and ds18b20! Noted.

It looks like the other posters have provide some useable device. I would like to add some other considerations.

Noise :frowning:

In the real world there is a lot of electrical noise that can cause error in sensor readings, reset the Arduino etc.

Even thought the Arduino is a full board, it lacks any protection on its inputs and outputs. To make a successful project one must consider electrical noise and electrical isolation at the beginning.
Physical wiring is important, electrical noise is a slippery character and can easily jump from one wire to another.

The other consideration is the addition of a watchdog timer. My understanding you have to reprogram the board boot loader as there is a timing issue with the standard bootloader and the WDT.

Sorry for that, I really respect your response. But I believe in the real time green house with multiple components and equipments to be controlled might not be sustainable with that frequency. Let me know if I am really wrong. Actually one of my team has faced this issue and moved to the ARM microcontroller. Hope to hear from you.

it might be that they faced problems and then switched to an arm-based microcontroller. My estimation from far away is that their programming was very ineffective.
can you tell me a single example of something that in a greenhouse is so timecritical that some signal has to be spot-on in the millisecond-range?

Yes of course if you would like to use a DIY-electronic-ignition-system for the ermergency-fuel-to-electric-power-generator but what else?

best regards Stefan


My 2 cents…
The Atmel chip is nothing special and certainly not worse than a hundred other choices.

I would venture a guess that is about as rock solid as any chip in its class.

Also, in the greehouse use.
One could add 100 aditional devices.
30 soil sensors, 30 relays, temperature, humidity, light, rain sensors, flow sensors…
And be able to make everything is time enough.

Memory is about the biggest limit.