Irrigation control


I’ve built an ESP8266 based device which I am going to use to auto-water my greenhouse plants based upon data from it’s ‘soil humidity’ & ‘Temperature’ sensors.

The device regularly sends data via MQTT to node-red, and node-red then determines if, when & how much water to administer. Node-red then sends a MQTT message to the device, telling it how long to switch on the irrigation pump.
For example; greenhouse/control 65
…would activate the pump on for 65 seconds.

All good, installed & working so far as a POC…

However I need to work some more on the calculation used by node-red to determine the pump timing as there are 3 influencing factors;

  1. Time of Day - I want watering to be reduced during the night
  2. Soil Humidity - more water to be available if soil humidity is low
  3. Temperature - as the temperature rises, I can be more generous with water

I realise that the actual timings will need to be tweaked by trial & error, but has anyone any ideas what would be the best way to perform a three way calculation such as this?


Hi, I have a working irrigation, 4 station system, with 5 solonoids, one for borehole pump, connected to an esp8266, RPi tuen determines watering, sends mqtt msg, which switches on and off. I also have a Dashboard interface to do manual on off, and override auto timers.

I do not yet have temp and hum, but all ready for that now.

On your qyestion, you should not water at night time, my knowledge of plants tells me, thus you should rather move starting times with morning times, that is easy, their are nodes for that. Re the other 2, next post I will share my thoughts…


Could you share your project, please? (just in case it is not commercial)
Many people are interested these days in automated watering and many projects rise.
I think it’s better to re-use ready solution rather than make the same mistakes in person.


I will gladly share both my ESP sketch and my node-red flow, but need to finish it first, and iron out a few minor glitches.



Since you have asked... I am putting my designs on Github for you. Only starting now, but enough eye-candy to look at already. Will give you some ideas on what I am doing. Will also publish flows when done.

IoTPlay sprinkler System


Hi Paul,
I'm new to Node-Red and am trying to do something similar to what you've done in your greenhouse. Mine will be in a Root Pouch garden. Would you mind sharing your flow?


The problem is that my flow is deeply embedded into the ESP code and would only serve to confuse you.

Briefly, the ESP is programmed to update node-RED at regular intervals with the soil humidity and temperature. Node-RED then uses the node-red-contrib-pid node to calculate how much water to administer (or should I say 'how long to run the irrigation pump) and sends this command back to the ESP, again by MQTT.
The ESP carries out that task, and then without further contact from node-RED shuts off the irrigation pump.
The process then repeats at set intervals.

I've built it that way so that if node-RED crashes (which it never does), or the network/MQTT fails (which it does!), then the ESP will work autonomously, and shut the pump off.

I have built other functions into the ESP, such as, if communications with node-RED fail, then the ESP will resort to a independent mode, to provide sufficient water for the plants to at least survive.

So as you can see, a lot of the functionality is split between node-RED and the ESP, and just posting the flow would not help. Sorry.


@Paul-Reed - Hey Paul,
Actually I think a lot of us would like to see it...well I would. I have a number of ESP's already reporting temperature and soil humidity. I'd love to take a peek at your ESP code too - which one are you using?

From another Paul :blush:


In case it is of interest I have ported the pid algorithm across to the Tasmotta ESP S/W so the whole control loop can now be run in the ESP if necessary. This makes the system even more resilient as it doesn't need the network to keep the loop running. As it is the same algorithm as node-red-contrib-pid it can be initially setup running the algorithm in node-red, which makes it easier to tune, then moved into the ESP device when it is all running ok. I have a couple of loops running using the Sonoff TH10 which can have a temperature sensor plugged in and has a relay ouput, which gives a complete temperature control system for under £10 if prepared to wait for delivery from China.


The easiest to use! - Wemos D1 mini.

As for sharing... the flow would need a bit of work, as it's part of a bigger flow, and would need detaching. However.... the ESP code is