logo elektroda
logo elektroda
X
logo elektroda

Garden irrigation controller integrated into the HomeAutomation network via the mySensors protocol.

jroger 
Welcome,

I wanted to show you my irrigation controller that I built based on ESP8266 has a clone of the WemosD1 board. It is interfaced with the home automation using the MySensors library [ref 3].

In a nutshell, the idea is to have all devices managed from one application (doesn't matter if it's air conditioning, ventilation, heat pump, blinds, curtains, light, water, cameras, ...) and I'm sticking to it. The controller was intended to be, and is, a replacement for the Hunter controller, which had no integration with home automation (a WiFi module needs to be purchased and then the question of integration with my current system and requirements remained).

The irrigation controller can be packaged in two Kradex enclosure models, Z101 and ZD1006 - pre-drilled plates for both enclosures.

This controller is such a slightly poorer clone of user @tmf's controller (https://www.elektroda.pl/rtvforum/topic3667909.html), nevertheless its "poorness" in my case its a super advantage.

.
Irrigation controller based on ESP8266 with three illuminated buttons.



.
I've added reference links to the entries at the end of the post. I have used them myself, if anyone is interested in the topic it will save time.

Features.
Functions.
Functions the device has:

1. powering the entire device via 24V AC (with the LM2675 inverter to 3.3V DC, which is required for the ESP8266 WiFi module)
2. control of 3 24V AC valves (with optoMOS, which gives galvanic separation)
3. shutting off watering via rain sensor (cutting off one pole of the valves' power supply via a reed switch in the rain sensor)
4. detection of whether current is actually flowing through the valves (via ACS711)
5. user interface in the form of (3 illuminated buttons and 2 indicator lights).
6. MySensors interface for the exchange of information and commands with the controller via WiFi.

Details of the solution and individual functions.
.
.
Electrical schematic for an irrigation controller with ESP8266. Wiring diagrams of an irrigation controller on two colorful PCBs.
.

Power supply. .

I based the power supply module on the LM2675M-3.3 chip, which is popularly used. I had picked it up on the forum for several projects.
The purpose of the module was to convert 24V AC to 3.3V DC, which is needed to power the ESP8266. The device is powered by 24V AC because this is the rated current to be supplied to the solenoid valves.

I made the module as a cross between information from DS and archived threads where user @-RoMan- and advice given to me by user @ArturAVS.

The power module has two protections. The first protection is a 1A polymer fuse on the path that goes to the rectifier bridge, the idea is to not let too much current into the inverter.
The second protection is a 1A fusible (cylindrical) fuse that protects the solenoid valves. I don't expect to use more than one valve at a time, so this protection is more than OK (the coil current of my solenoid valve at start-up should not exceed 0.5A, and 0.2A during operation). Possible additional protection is software prohibiting the actuation of more than one valve.

. Control of 3 24V AC valves
Controlled by optoMOS relays (Panasonic AQY212).
The control is done with SSR optoMOS relays (Panasonic AQY212). I used them because the technology in which they are made guarantees galvanic separation between the board circuit and the valve circuit.
They are controlled from three pins of the ESP8266 chip. These pins are also used to illuminate the buttons, so a high state of a pin illuminates the diode in the relay (and closes it, consequently activating the valve) and illuminates the diode in the button on the case. Cool effect.

Disabling watering by rainfall sensor.
.
This is a function I copied from the Hunter controller. The rainfall sensor contains a reed switch (NC) that disconnects the circuit when it rains. Without going into detail why, but I have left this function as it is. One 24V AC pole of the valve supply flows through the wire with the reed switch in the rainfall sensor. If the washers are on and there is rainfall at the same time, the circuit is disconnected by the reed switch and the washers switch off. Generally the function works, but I wouldn't do it today - my integration with the weather takes care of that (if rainfall is predicted, watering on a particular day won't happen).

Detecting if current is actually flowing through the valves (using ACS711)
.
As stated above, there may be a situation where there is an order to splash water and at the same time there is a disconnection of the solenoid valve circuit by the rainfall sensor. I detect this situation with a Hall sensor (ACS711 chip). It is plugged into the solenoid valve circuit and it measures the current in this circuit, the analogue measurement from this sensor is passed to the ESP8266, and this pin it with the ADC (pin A0). .

With this function I detect a "RAIN STOP" situation, i.e. stopping watering due to rainfall (logically: IF the solenoid valve is open AND no current is flowing through it THEN signal RAIN STOP).

VERY IMPORTANT NOTE : when using the WiFi libraries on the ESP8266 you need to know that the A0 pin (or more precisely the ADC) is used by the ESP in the WiFi signal quality monitoring process. Reading the current value from the ACS should be done in intervals - I use 50ms and it is OK. A non-stop reading with no interval will result in signal loss (and the module will no longer recover the connection). For the inquisitive, I refer to the references (ref 4., ref 5.).

Below I paste the short code for the Arduino Framework for inspiration.
Code: C / C++
Log in, to see the code
.

User interface. .
The interface is implemented by 3 illuminated buttons and 2 indicator lights.

The 3 illuminated buttons are used to manually activate/deactivate the valves, and the fact that they are illuminated indicates that the electro-valve in question is open (i.e.: the section is irrigated). A section can be switched off with a button if it is currently working. Generally, I have left the buttons in case, for some reason, there is no connection with the automatic control panel (the controller itself is not very "intelligent", it does not know the schedules).

From a device point of view, The buttons are shorted to the input pins of the ESP8266, each input pin is pulled up to 3V3 with a 10k resistor (PULL UP). Pressing the button short circuits the input pin to ground and this signal is interpreted by the ESP.

As the buttons are connected to the board via wires, there is a risk of them generating interference (they can act as antennas). For this reason, I additionally used 100nF capacitors on the input pins of the ESP8266.

It takes the controller as many minutes to start watering a section as it is told to by the controller. Information about the section watering time is stored in the ESP8266's EEPROM, so this information is not lost when there is no connection to the controller. The idea is to protect against the situation where the controller orders the watering, the connection to the controller is lost and the water pours endlessly - and this is part of the fine intelligence of the device itself.

There are 2 indicator lights. One (RX CMD) indicates that a command has been received from the button or from the automation management device, and the other indicates that watering has stopped due to information from the rain sensor ('RAIN STOP', I wrote about this above).

MySensors interface
The device communicates with the outside world over the TCP/IP protocol on a programmed port (e.g. 5003). The communication interface is based on the mySensors library.
At the moment, the device 'exposes' the interface for 8 logical devices (section switch, watering length of each section - x3 sections equals 6 devices), the 'RAIN STOP' flag and the current flowing through the ACS711 chip. Communication is, of course, two-way.

Thanks to very efficient and reliable communication, the entire watering logic resides in the home automation system controller. The integration part itself is very interesting, but also quite extensive and deviates from the design of the device itself.
As an illustrative example, I am uploading below a screen shot of how irrigation looks from my controller (domoticz). Thanks to the fact that everything is in one place, interesting effects can be achieved quickly (e.g. preventing watering in the event of rainfall forecast for the day, etc.).

.
Screenshot of a terminal interface displaying irrigation controller data. .



.

References:
1. LM2675 power supply: https://www.elektroda.pl/rtvforum/topic2311352.html
2. user irrigation controller @tmf: https://www.elektroda.pl/rtvforum/topic3667909.html
3. mySensors: https://www.mysensors.org/
4. analogRead() problem in WiFi library for ESP8266 ("analogRead forces WiFi to disconnect #1634") https://github.com/esp8266/Arduino/issues/1634
5. a thorough investment of the analog read() problem, great stuff
https://github.com/krzychb/EspScopeA0/tree/master/Bravo#results

About Author
jroger wrote 19 posts with rating 12 . Been with us since 2011 year.

Comments

gulson 25 Oct 2024 20:21

Thank you for sharing the solution! I see that it would also be possible to integrate with Home Assistant, since you have a connection to MySensors. I'm getting the combination right? https://www.home-assistant.io/integrations/mysensors/ Because... [Read more]

jroger 25 Oct 2024 20:31

Hey @gulson, Yes, mySensors integrates with HomeAssistant without a problem, although I have not used Home Assistant, so I am not in a position to discuss the details (I only use Domoticz). J ... [Read more]

Oddawajsanki 27 Oct 2024 18:45

interesting project :D [Read more]

Anonymous 28 Oct 2024 09:16

With this . I would be wary of seeing this https://obrazki.elektroda.pl/4349665700_1730103281_thumb.jpg Apparently there is a break but in practice it is practically non-existent. No... [Read more]

Kuniarz 31 Oct 2024 19:24

Great design and execution ! . It would be useful to have descriptions next to these buttons and LEDs. You know what they are for, maybe someone in the family does too, but if a complete stranger... [Read more]

jroger 01 Nov 2024 11:25

Hey @Kuniarz, Thanks. I have several sticker designs, also with descriptions, etc. I chose one because it suited me best - a matter of taste. The family knows what to press to pour. I know from... [Read more]