Using Tasmota on Sonoff 4CH Pro for home irrigation system

1,100 views
Skip to first unread message

Neill Adamson

unread,
Apr 1, 2019, 2:33:06 PM4/1/19
to SonoffUsers
I've managed to connect 2 Sonoff 4CH Pros to control a 6 zone outdoor irrigation system.
I've implemented basic Timers to alternate the watering of zones 1-3 and 4-6 on alternate days.

The next step is to geek out with some rules and make the solution totally kick-ass.

The various rules I have in mind would be:
  1. store the length of time each zone runs in the Rule rather than using a Timer. 
  2. adjust the length of time each zone runs, based on the seasons Summer/Winter. Using:
    • Mem<x> as a boolean variable to hold W/S indicator or length of time and/or
    • some threshold of the local <sunrise>/<sunset> time as a proxy for Summer/Winter. e.g. if <sunrise> later than 6am, then Winter = 10 mins watering.
  3. start a timer whenever a physical button switches on. Each zone then runs for a max watering period before switching to the next zone (so the Gardner can physically activate the water cycle.
Also, because the 6-zones are spread over 2 4CH Sonoffs, (Z1-Z4, Z5-Z6), I would like the end of Z4 watering to automatically activate Z5 on the 2nd Sonoff. The only way to achieve this seems to be to use some MQTT message and trigger the power on the 2nd Sonoff. (I know I could put Z4-Z6 on the 2nd Sonoff and alternate watering based on the Sonoff 1 or Sonoff 2, but because of other wiring and CH available I'm maxing out Sonoff 1 first).

Has anyone done anything similar? Do you have rules that achieve any of the above that you would be willing to share with me?

I'll post back here with the rules I get to work.

TIA

Piotr Antczak

unread,
Apr 2, 2019, 1:53:46 AM4/2/19
to SonoffUsers
Hi Neill!

I have irrigation system based on Tasmota. I've created my own hardware solution based on Wemos D1 Mini and MCP23017. I'm able to control 16 zones (right now I have 10) from one solution.
IMG_20180822_210317.jpg
IMG_20180822_203840.jpg

IMG_20180723_213152.jpg

I do believe that rules are too simple to make a "kick-ass" solution (that's my opinion), that's why I'm using Node-Red to implement all the logic. But... the solution HAS TO BE resistant for situation when there is something wrong with MQTT or Node-Red itself. That's why my rules are using timers to SWITCH OFF particular zone, to not allow to change my garden into a lake ;)

From Node-Red (I'm using Peter Scargills Bigtimer to schedule the moment of start) I send backlog command to device via MQTT:
1. set variable (each variable is responsible for it's own zone) with the value how long this zone should be ON
2. call event which open the valve and set the timer

Rules on Wemos D1 Mini:
on event#R>0 do 
backlog ruletimer%value% %var%value%%;sensor29 %value%,on 
endon 
on event#R=0 do 
backlog ruletimer16 %var16%;sensor29 0,on 
endon 
on rules#timer<16 do 
sensor29 %value%,off 
endon 
on rules#timer=16 do 
backlog sensor29 0,off;event stopall 
endon 

on event#stopall do
backlog sensor29 1,off;ruletimer1 0;sensor29 2,off;ruletimer2 0;sensor29 3,off;ruletimer3 0;sensor29 4,off;ruletimer4 0;sensor29 5,off;ruletimer5 0;sensor29 6,off;ruletimer6 0;sensor29 7,off;ruletimer7 0;sensor29 8,off;ruletimer8 0;sensor29 9,off;ruletimer9 0;sensor29 10,off;ruletimer10 0;sensor29 11,off;ruletimer11 0;sensor29 12,off;ruletimer12 0;sensor29 13,off;ruletimer13 0;sensor29 14,off;ruletimer14 0;sensor29 15,off;ruletimer15 0 
endon

My situation is specific because I have a well from which the water is pumped to the sprinkler system:
1. well is refilled by rain or by me/system (the seven level sensor based on the same hardware inform me what is a water level in the well - pins of MCP23017 are configured as inputs and are connected to floating switches in the well)
2. well can become empty, so I have to stop watering (stopall event)
3. well can become full, so I have to start the process of emptying
4. one of the relay is responsible for powering all the solenoid valves (that's the "safety fuse") - before I start sprinklers I have to switch on power to valves

10 relays:
1. Power for valves
2. Valve to refill well
3-10 Eight sprinkler zones

Here is the seven level sensor I've made:

IMG_20180516_183332.jpg


--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Piotr Antczak

Piotr Antczak

unread,
Apr 2, 2019, 2:06:08 AM4/2/19
to SonoffUsers
... and before I start the sprinklers I have to calculate how much water do I need in the well (each zone, and each sprinkler in the zone has it own "water consumption" in the time unit), and start refilling the well before the cycle.
--
Piotr Antczak

Raghu N

unread,
Apr 2, 2019, 2:10:27 AM4/2/19
to SonoffUsers
Hi Piotr,
I have a Water level controller for which I have used a ultrasound sensor but have not been happy with the result.
I earlier have multiple contact based sensors  but had corrosion issue because of DC voltages.

I would appreciate if you could detail the sensors that you have connected to the well .
My system requirements are similar, the actuator / motor should start at the lowest level and stop at the top most level.
I have nodemcu and node red on a Pi.

Thanks in advance
To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Piotr Antczak

Ing. Umberto Ballestrazzi

unread,
Apr 2, 2019, 2:14:02 AM4/2/19
to Neill Adamson, SonoffUsers
Some time ago I started to think that tasmota is not best solution for irrigation systems. I've found at least other 2 applications specific for irrigation (they are both on github).
My favorite requires esp32 because of the flash (it uses file system implementation for store garden images). One of the solutions handles display, keys and up to 32 zones using a shift register and runs on esp8266 as far as on pi. They sell also an appliance based on the software.
I did not like this solution because it requires hardware and in my case the 4 channels could be enough.
I'm still waiting for the solution similar to a commercial irrigation system...

 


--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Piotr Antczak

unread,
Apr 2, 2019, 2:14:36 AM4/2/19
to SonoffUsers

Piotr Antczak

unread,
Apr 2, 2019, 2:26:39 AM4/2/19
to SonoffUsers
Hi Umberto!

I'm using Tasmota for 2 reasons:
1. With rules and some Home Automation software (in my case Node-Red) it is able to do almost everything (my Node-Red flow is pretty complicated because I have to take care of information from my well level controller)
2. Tasmota is on every device in my house - so I have consistent environment

My hardware cost me couple of dolars:
3$ for Wemos
4$ for 8 channel relay
1$ for 2 channel relay
0.5$ for MCP23017
0.1$ for logic level converter

PCB was made by JLCPCB for 15$ (with shipping) - 10 pieces)

I have made an web application to let me control irrigation system by browser/mobile (start stop particular zone):

image.png

--
Piotr Antczak

Piotr Antczak

unread,
Apr 2, 2019, 2:30:53 AM4/2/19
to SonoffUsers
... the hardware I have made is able to control relays and keys/buttons (there is 16 pins available - or even 19 if you use some "spare" pins on wemos) at the same time. I have to define particular pin of MCP23017 as input or output.
Display can also be connected (i2c) because the i2c bus is "chainable" and Tasmota has support for some displays.
--
Piotr Antczak

Ing. Umberto Ballestrazzi

unread,
Apr 2, 2019, 2:45:24 AM4/2/19
to Piotr Antczak, SonoffUsers
Hi Piotr,
the system I'm speaking about is this
Is similar to your solution (it uses an hc595 as a shift register to control as many zones as you need otherwise is the same as your) but probably is more similar to a commercial sprinkler.
It lacks of mqtt (and openhab/nodered/alexa integration).

The other solution  I evaluated is opensprinkler. They have a web site where they sell hardware but there is also the firmware on github.

Speaking about of the box solutions, I think that tasmota is actually the best solution for home control but I have some doubts about sprinklers.

Piotr Antczak

unread,
Apr 2, 2019, 2:57:13 AM4/2/19
to SonoffUsers
Umberto,

The first one is similar to my solution (but I have made dedicated PCB for that). It has its own scheduler so it does not need Node-Red-Like solution.
The second one is ... "off the shelf" product with opensource software - it looks VERY "profi".

From my experience I can tell that Tasmota (and Node-Red) is enough for my sprinkler system, but I realize that this is not as easy to configure and maintain as those two solution you provided. 


wt., 2 kwi 2019 o 08:44 Umberto Ballestrazzi - 4 Planning <u.balle...@4planning.it> napisał(a):
Hi Piotr,
the system I'm speaking about is this
Is similar to your solution (it uses an hc595 as a shift register to control as many zones as you need otherwise is the same as your) but probably is more similar to a commercial sprinkler.
It lacks of mqtt (and openhab/nodered/alexa integration).

The other solution  I evaluated is opensprinkler. They have a web site where they sell hardware but there is also the firmware on github.

Speaking about of the box solutions, I think that tasmota is actually the best solution for home control but I have some doubts about sprinklers.





Il giorno mar 2 apr 2019 alle ore 08:30 Piotr Antczak <antcza...@gmail.com> ha scritto:


--

Umberto Ballestrazzi

Mob: +39 335 301364

 

4 Planning s.r.l.

Viale Medaglie d'Oro, 33

41124 Modena (MO)

P.Iva: 02413280369

Tel: +39 059 8677792

Fax: +39 059 8671527



--
Piotr Antczak

Raghu N

unread,
Apr 3, 2019, 3:59:45 AM4/3/19
to SonoffUsers
Hi Piotr,
Thanks. I have ordered these.
Do you connect to directly to the GND and a GPIO pin on a nodemcu or do I need to it any differently. 

Regards
Raghu

Piotr Antczak

unread,
Apr 3, 2019, 4:17:43 AM4/3/19
to SonoffUsers
I connect it directly to MCP23017 (with external pullup). If you want to connect it to nodemcu directly remember that:
GPIO0 (D3) has the pullup resistor, but it is special pin - if it is LOW during boot the MCU get into flash mode (program via UART)
GPIO2 (D4) has the pullup resistor, but it is special pin - if it is LOW during boot the MCU get into "strange" mode  
GPIO15 (D8) has the pulldown resistor, but is is a special pin - if it is HIGH during boot, the MCU get into "Boot from SD card" mode

Generally: you can use pins on nodemcu but use pullup resistors, and rather don't use those three pins.


To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Piotr Antczak

Phil

unread,
Apr 3, 2019, 9:55:14 AM4/3/19
to SonoffUsers
You may also find this useful for feedback from the garden.
GitHub - ThomDietrich/miflora-mqtt-daemon: Linux service to send Xiaomi Mi Flora plant sensor data to an MQTT broker 🌱🌼🥀🏡🌳
if using node red load the contrib-xiaomi-ble-node from the pallet for even easier access.. 
Reply all
Reply to author
Forward
0 new messages