Hello everyone,
I have a little garden with a sprinkler system based on Hunter hardware (3 valves, several nozzles and a 9V battery control unit).
Last year I replaced the control unit with an OpenSprinkler Bee, but unfortunately a couple of weeks ago I broke it while tinkering with the firmware (to flash it I had to disconnect it a couple of times and maybe I wasn’t enough gentle).
So I decided to build a new one by myself!
Disclaimer: I am not an electronics expert at all. I am a web developer and got into electronics just recently thanks to ESPHome and Home Assistant. So my projects are primitive and probably stuffed with errors and not safe. But my house didn’t burn yet, so I am happy.
Here are the details of my project: I didn’t replace valves and nozzles, so the important detail here is that the valves are solenoids. They need a strong brief current to open and a similar current (with inverted polarity) to close. I searched a lot and came up with using a motor drivers (L298) to drive valves. That was the big unknown part of the project. The rest is just an ESP8266 (NodeMCU), a 12V PSU and cables
The motor drivers I found are very handy, because they also output a 5V current that I used to supply power to the ESP8266. So I connected them to a 12V PSU. I found out that 12V are enough to drive my valves, so instead of using a capacitor like OpenSprinkler and Hunter control unit did, I just supplied the 12V current from the PSU to valves through the drivers. (Hunter and OpenSprinkler did a different job: they used a capacitor because their power supply is very constrained, I just went with bazooka)
I thank a lot Ray Wang of OpenSprinkler for building such a wonderful piece of engineering. I learned a lot reading the source code and the hardware implementation details.
Here’s a video of the system in action: https://twitter.com/ermannob/status/1256227720167645186
This is the scheme (I recently learned using Fritzing a bit… what a wonderful piece of software!)
Here’s a picture of the system:
And this is the relevant code of ESPHome:
switch:
- platform: gpio
pin: 16
id: valve1_enable
internal: true
restore_mode: ALWAYS_OFF
- platform: gpio
pin: 5
id: valve1_one
internal: true
- platform: gpio
pin: 4
id: valve1_two
internal: true
- platform: gpio
pin: 0
id: valve2_two
internal: true
- platform: gpio
pin: 2
id: valve2_one
internal: true
- platform: gpio
pin: 14
id: valve2_enable
internal: true
restore_mode: ALWAYS_OFF
- platform: gpio
pin: 15
id: valve3_enable
internal: true
restore_mode: ALWAYS_OFF
- platform: gpio
pin: 13
id: valve3_one
internal: true
- platform: gpio
pin: 12
id: valve3_two
internal: true
- platform: template
name: "Zona 1"
icon: "mdi:sprinkler"
id: zona1
turn_on_action:
- switch.turn_off: valve1_one
- switch.turn_on: valve1_two
- delay: 100ms
- switch.turn_on: valve1_enable
- delay: 500ms
- switch.turn_off: valve1_enable
- switch.template.publish:
id: zona1
state: ON
turn_off_action:
- switch.turn_on: valve1_one
- switch.turn_off: valve1_two
- delay: 100ms
- switch.turn_on: valve1_enable
- delay: 500ms
- switch.turn_off: valve1_enable
- switch.template.publish:
id: zona1
state: OFF
- platform: template
name: "Zona 2"
icon: "mdi:sprinkler"
id: zona2
turn_on_action:
- switch.turn_off: valve2_one
- switch.turn_on: valve2_two
- delay: 100ms
- switch.turn_on: valve2_enable
- delay: 500ms
- switch.turn_off: valve2_enable
- switch.template.publish:
id: zona2
state: ON
turn_off_action:
- switch.turn_on: valve2_one
- switch.turn_off: valve2_two
- delay: 100ms
- switch.turn_on: valve2_enable
- delay: 500ms
- switch.turn_off: valve2_enable
- switch.template.publish:
id: zona2
state: OFF
- platform: template
name: "Zona 3"
icon: "mdi:sprinkler"
id: zona3
turn_on_action:
- switch.turn_off: valve3_one
- switch.turn_on: valve3_two
- delay: 100ms
- switch.turn_on: valve3_enable
- delay: 500ms
- switch.turn_off: valve3_enable
- switch.template.publish:
id: zona3
state: ON
turn_off_action:
- switch.turn_on: valve3_one
- switch.turn_off: valve3_two
- delay: 100ms
- switch.turn_on: valve3_enable
- delay: 500ms
- switch.turn_off: valve3_enable
- switch.template.publish:
id: zona3
state: OFF
You can see that the 3 template switches, when turning on and off, they set the correct polarity and enable the output current from the driver.
I didn’t set up automations in Home Assistant yet, those will come soon.
Any hints or suggestions are welcome!