Greenhouse irrigation

Every year, I return back from my hols to find plants in my greenhouse dead or on life support due to lack of water (despite promises by family to look after them!!!), so this year I thought I'd get node-red to sort it for me.

I purchased a Wemos D1 Mini esp board, relay board, a capacitive humidity sensor, DS18B20 temperature sensor and a Mains powered water pump. All courtesy of AliExpress and costing less than £10 for the lot.
Wired the lot together, and used Nick @knolleary 's MQTT PubSubClient library to communicate with node-red which I have running on a Pi about 15 metres away.

Basically, every 10 minutes via MQTT, the device tells node-red what the soil humidity & soil temperature is, and in turn node-red tells the device how much water to pump to the plants.
The amount of water is automatically determined via node-red-contrib-pid (thanks @Colin Law), to ensure that the watering does not overshoot the target humidity and drown the plants.

I've just returned back home after a week away, and everything worked well!!! Tomatoes still have green leaves, and the soil humidity was within 1% of the target humidity level of 62%.

As I would be accessing the dashboard whilst away from home, I built a phone friendly dashboard so I can keep an eye on things.
The space to the right of the 5ml/100/ml/start/stop buttons accommodates information icons which are visible when a certain condition applies.

Click on the image to see it all!!
moisture1

11 Likes

I can sleep soundly in my bed now knowing that my efforts are helping to feed the world. Or at least keep you in tomatoes through the summer :slight_smile:

I imagine that might not have been the easiest of loops to tune.

1 Like

Proportional band, integral time, derivative time, initial integral, derivative smoothing factor....
I still don't know if I've got it setup as it should be, but it works, and I suppose that is what counts.

The blog post that you have made really helped, but still a steep learning curve (for me!!).

1 Like

Great project! A good reason to invest in a greenhouse, having fresh tomatoes and other vegetables, flowers etc

Maybe good to know is that the nutrition content in purchased vegetables has been dramatically reduced the last 20-30 years due to several reasons so it really make sense to grow your own (I will see if I find the table showing this)

Regarding your project, I have not started with Wemos yet, does it not require you to have a special programmer and add firmware also? Or did it work straight out of the box?

No programmer needed, you only need a micro usb lead to connect it to a PC. I had a number of these leads laying about, so didn't have to buy one.
Once programmed, you can use the same micro usb lead to power it, by plugging it into any usb socket - I used an old phone charger.

To program the Wemos, I used the Arduino IDE which was fairly easy to use, and has a number of pre-installed libraries to cut down the programming needed.

This was my first attempt at programming an ESP, and it's opened a lot of doors for me to build other iot gadgets, such as MQTT controlled dimmers and relay boards, security lighting controller, etc, etc.

Paul

As an alternative you could just flash a firmware like ESPEasy or tasmota. No programming needed. ESPEasy provides a tool FlashESP8266 to flash the firmware.

2 Likes

Hi Paul,

Looks interesting. I have a greenhouse, tomatoes, peppers, and a lack of time to water them ‘properly’.

Is there any reason why you use such a Wemo device. I have never used Arduino, so I was wondering if you could accomplish the same thing like this:

  • Raspberry zero in the greenhouse reading sensors and controlling valves, by running a Node-Red flow on it.
  • Communicate to a normal Raspberry (like in your example) via MQTT, by running a second Node-Red flow on this device.

Or is such a Wemo device better suitable ? Since I’m in a Node-Red mood this year, I prefer to use Node-Red all over the place if possible :wink:

Bart

I’m not that familiar with the pi zero, but does it have an analogue input pin?
If it doesn’t, then you would need additional circuitry to read the capacitive sensor.
The Wemos D1 does have such a pin, so it’s ready to hook the sensor up.

You could use a resistive sensor, as they have a digital output, but I found that they were not accurate, and influenced by plant feed.

Yep, seems you are right that the Raspberry (zero) has no analogue input… Found this tutorial, which uses this cheap soil moisture sensor (with a digital output) that can easily be wired to a Raspberry.

Is this the kind of inaccurate sensors that you are talking about? And could you please share some more details about the inaccuracy. Are they so bad that they cannot be used ?

The other advantage of the wemos is that you can put it into deep sleep, and can get months of operation from a battery, (which could also be topped up from solar). While of course we would like it to run Node-RED, the fact that it can easily run MQTT means there will still be some @knolleary goodness inside :slight_smile:

2 Likes

I tried those sensors first, and they work by measuring the resistance of the soil, or should I say the moisture in the soil.
Problem is that they are heavily influenced by temperature, and can vary by 20-30% as the greenhouse heats up (Google ‘soil conductivity temperature’). I even found a formula to try and compensate for this, which helped, but not good enough.

The other influence is soil composition, especially the minerals and salts which it contains - higher salt = lower resistance.
So when you add liquid feed, you will change the soil resistance.

Maybe you will have more luck, but with the capacitive sensor I get good consistent results, especially as I’ve programmed it to take 10 successive readings 10 milliseconds apart, and then average the results.

The resistive sensors went in the bin!!

@Paul-Reed - which capacitive sensor are you using?

https://m.aliexpress.com/item/32882371718.html?pid=808_0000_0101&spm=a2g0n.search-amp.list.32882371718&

1 Like

Seems to work OK! I’ve just returned from 8 days away from home, and everything is looking as good as the day I left.

Only slight glitch was that I underestimated the amount of water needed in the reservoir, as I had based it upon previous week’s consumption plus 50%, but didn’t account for a prolonged heatwave. :open_mouth:
The result was that I ran out of water one day early, but because the plants were so well hydrated, it didn’t make much difference.
The PID soon re-hydrated the plants once the reservoir was topped up.

You should think about getting two float valves to put in the reservoir - one at the top and one at the half way mark. then get a electronic valve attached to a hose ending in the reservoir. if the middle switch stays down, the tank is low and needs water, it the top is up, shut off the valve. I use a wemos to control the valve and MQTT to send it messages. I make sure to ignore the valves during watering times and average the readings to let the water settle since I’m running hydroponics and most of the water that goes to the plants is returned to the tanks. But it is amazing when the weather gets hot, how much water they will use and how big the tomato plants will grow!

1 Like

Unfortunately that wouldn’t have helped, as I was 200 miles away and couldn’t top it up!
I’ve already got the float sensors, but are not fitting them until I get a bigger ‘permanent’ reservoir.

EDIT - Aah yours is automatically topped up via mains water.
I’m not going to be that advanced, I just intend to get a msg when it’s low, prompting a top up, and prepare better before I go on holiday.

A very cool project and beautiful dashboard.

I am bit curious about what kind of mains power pump you are using and how you assured that the water is (equally) dispersed to the plants in need of it.

The pump is a mains powered submersible pump, similar to https://www.ebay.co.uk/itm/Submersible-Water-Pump-Fish-Pond-Aquarium-Tank-Waterfall-Fountain-Sump-Feature/122905418684?var=&hash=item1c9dbbdbbc

Water is pumped through 13mm pipe which runs around the circumference of the greenhouse. 4mm pipe then taps into the hose at regular intervals, feeding water to the plants through dribblers (8 litres/hour each).

I'm not measuring the soil humidity of every plant, but measuring just one which is used as an typical example, which seems to work out just fine.

I get reassurance that the ESP is doing what it's told because it's been programmed to update node-red with it's status via MQTT giving me the time that the pump was energised, and the time when it was de-energised, see charts below - the top chart shows what node-red is telling the ESP to do, whilst the bottom chart tells me exactly what the ESP has done!

Problems could occur if the tank ran out of water or the dribbles got blocked, but these can be mitigated. Also I have an emergency mode, that automatically kicks in if the network/internet goes down, so it loses contact with node-red. It will then works independently until the network is restored.

1 Like

Hi I am trying to do the same thing with you but I found that the moisture sensors are not accurate so I decided to just water my plants some hours per week. I used a sonoff plug and raspberry pi with mqtt. It worked well but the problem was that if for some reason the wifi went down, my esp never recieve a message to on/off the water. So I am thinking to send from the mqtt some kind of rules for when to be on/off. Now I am using ESPeasy to flash my device. what do you think?Is anyone trying to do that?

What sort of sensor did you try, resistive or capacitive?
The resistive type are notoriously inaccurate!