moisture sensor

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

moisture sensor

#1 Post by manjh » 23 Aug 2018, 21:42

I am looking for a cheap solution to measure moisture level on some of my precious plants, and also in the garde (so I can turn on the sprinklers).
The Wiki mentions one supported device, but at $13 it is not cheap.

On the website of one of our Chinese shops, I find this one:
https://www.banggood.com/Capacitive-Soi ... rehouse=CN.
Only 2,75 Euro, so about a quarter of the price.
I understand the difference: I2C versus analog. But it is worth a try.
Is there a way to use this sensor? Electrically not really a problem, I think, but how about SW support?

Alternative is the Xiaomi Flowermate. More expensive, but you don't need an ESP to drive it, and since it runs OK on a single cell battery for a year, no power supply. May be worth the extra $$$, but the Domoticz plugin is not 100% shockproof. In my house the Flowermate does not connect (possibly due to distance), and then the plugin starts crashing. I've even had Domoticz crash. So for now, I would rather go with an ESP driven sensor.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#2 Post by grovkillen » 23 Aug 2018, 22:17

You could add that as feature request to our GitHub. I find the price plus communication protocol quite nice and see that more people would find it a good piece of hardware.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: moisture sensor

#3 Post by manjh » 23 Aug 2018, 23:38

grovkillen wrote: 23 Aug 2018, 22:17 You could add that as feature request to our GitHub. I find the price plus communication protocol quite nice and see that more people would find it a good piece of hardware.
There are even cheaper sensors available, but this one uses "capacitive measurement", which causes less corrosion. At least that is what the seller claims.... :(

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#4 Post by dynamicdave » 24 Aug 2018, 12:59

Hi,
Here's a link to a PDF for a simple exercise I did with my IoT students.

http://resources-area.co.uk/node-red-fl ... _meter.pdf

We used the very inexpensive resistive sensor and then used a transistor to power the sensor for 15 seconds every 15 minutes.
The unit has been in used for nearly 3-months and does not show any sign of corrosion

Hope you find this useful.

Regards, David

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: moisture sensor

#5 Post by Shardan » 24 Aug 2018, 13:34

manjh wrote: 23 Aug 2018, 21:42 I am looking for a cheap solution to measure moisture level on some of my precious plants, and also in the garde (so I can turn on the sprinklers).
The Wiki mentions one supported device, but at $13 it is not cheap.

On the website of one of our Chinese shops, I find this one:
https://www.banggood.com/Capacitive-Soi ... rehouse=CN.
Only 2,75 Euro, so about a quarter of the price.
I understand the difference: I2C versus analog. But it is worth a try.
Is there a way to use this sensor? Electrically not really a problem, I think, but how about SW support?

Alternative is the Xiaomi Flowermate. More expensive, but you don't need an ESP to drive it, and since it runs OK on a single cell battery for a year, no power supply. May be worth the extra $$$, but the Domoticz plugin is not 100% shockproof. In my house the Flowermate does not connect (possibly due to distance), and then the plugin starts crashing. I've even had Domoticz crash. So for now, I would rather go with an ESP driven sensor.
Hello manjh,

the sensor you selected from banggood has an analog output, as far as I can see from thebanggood site.

It should be possible to use this sensor directly with ESPEasy with the ADC input and the analog plugin.
Due to website the sensor has an output of 0...3 V so a voltage divider will be necessary if you use a bare ESP chip.
NodeMCU and WeMOS usually have the voltage divider already built in.

Alternatively a separate ADC with higher resolution can be used, a ADS1115 for example.
Regards
Shardan

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#6 Post by dynamicdave » 30 Aug 2018, 09:15

In case anyone is interested I've made use of ESP Easy rules, timers and a generic dummy device (i.e. variables) to control one of the inexpensive resistive moisture sensors.

I'm using a Wemos D1 Mini which is triggered by sending an event (via MQTT) called "activate" from my Raspberry Pi (running Node-RED).
This action turns ON a BC547 transistor (its base is connected to D6 via a 1K resistor) to supply 3V3 to the moisture sensor.
It also kicks-off a 6-second timer.
The analog input (from the moisture sensor) is set to sample at 5-second intervals.
The samples will only be "live" if the transistor is turned on, and will only be sent to my Raspberry Pi (running Node-RED) if the timer is active.
To ensure the system only sends a single sample I set a variable called "sent" once the first sample has been published.
This action effectively shuts the door after the first sample.

The Wemos is triggered once every 15-minutes for 6-seconds, so hopefully corrosion should not occur on the metal fingers of the moisture sensor.

Hope someone might find this useful.
Cheers from David.

on System#boot do
timerSet,1,0
TaskValueSet,12,1,0 //Set var#activation = 0
TaskValueSet,12,2,0 //Set var#sent = 0
endon

on activate do
gpio,12,1 //Set GPIO(D6)=1 (Turn on the transistor)
publish node26/status, "activated"
TaskValueSet,12,1,1 //Set var#activation = 1
TaskValueSet,12,2,0 //Set var#sent = 0
timerSet,1,6
endon

on paw#value do
if [var#activation]>0 and [var#sent]=0
publish node26/reading, {"paw": [paw#value]}
TaskValueSet,12,2,1 //Set var#sent = 1
endif
endon

on Rules#timer=1 do
gpio,12,0 //Set GPIO(D6)=0 (Turn off the transistor)
publish node26/status, "deactivated"
TaskValueSet,12,1,0 //Set var#activation = 0
endon

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#7 Post by grovkillen » 30 Aug 2018, 10:11

Thank you for this Dave!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: moisture sensor

#8 Post by manjh » 30 Aug 2018, 11:03

Great work Dave, this is useful. Even when using the non-corrosive version of the sensor, it makes sense.

To make the solution complete, I suggest two things:
1. add an electrical diagram
2. create a Wiki page with the full solution

Keep up the good work! :)

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#9 Post by dynamicdave » 30 Aug 2018, 12:31

Thanks for your inputs.

Hope to have some free-time this weekend to produce a schematic and a step-by-step instruction guide.

Cheers from David
Last edited by dynamicdave on 30 Aug 2018, 21:08, edited 1 time in total.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#10 Post by dynamicdave » 30 Aug 2018, 20:56

Here's my first attempt at documenting the Soil Moisture monitor.

Here's a link to the PDF tutorial guide and the Node-RED flow.
Although there is a link in the PDF document to the Node-RED flow - I've shown the direct link here in case your PDF viewer doesn't render the link correctly.

http://resources-area.co.uk/node-red-fl ... sensor.pdf

http://resources-area.co.uk/node-red-fl ... onitor.txt

I hope you enjoy reading the above document as much as I enjoyed creating it for my IoT students at Bohunt School here in the UK.

Cheers from David
Last edited by dynamicdave on 30 Aug 2018, 21:13, edited 2 times in total.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#11 Post by grovkillen » 30 Aug 2018, 21:00

dynamicdave wrote: 30 Aug 2018, 20:56 Here's my first attempt at documenting the Soil Moisture monitor.

Here's a link to the PDF tutorial guide and the Node-RED flow.

http://resources-area.co.uk/node-red-fl ... sensor.pdf

http://resources-area.co.uk/node-red-fl ... onitor.txt

I hope you enjoy reading the above document as much as I enjoyed creating it for my IoT students at Bohunt School here in the UK.

Cheers from david
Great!! Love it, thanks . :o
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#12 Post by dynamicdave » 30 Aug 2018, 21:17

Thanks

Just one question...

What is the correct syntax for TaskValueSet ????

I've seen it written as TaskValueSet,12,1,0 and TaskValueSet 12,1,0
i.e. with a comma after the keyword or a "space"

Cheers from David

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: moisture sensor

#13 Post by TD-er » 30 Aug 2018, 21:19

Very nice to see that it is actually being used to teach and to make students curious for automating things.
I am very curious to see what new and refreshing ideas they will come up with.

Edit:
About the space. That's currently being read as a comma.
But I suggest to actually write the comma, since treating the space as parameter separator is confusing.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#14 Post by dynamicdave » 30 Aug 2018, 21:54

Thanks - that makes sense to use the 'comma' and also matches the syntax of other commands that exist in the "rules".

Cheers from David.

User avatar
realrope
Normal user
Posts: 14
Joined: 04 Sep 2018, 09:20

Re: moisture sensor

#15 Post by realrope » 04 Sep 2018, 10:42

Hi David,
Hey, you have IoT students? What platform are you using? Raspi?
best yours rob


dynamicdave wrote: 24 Aug 2018, 12:59 Hi,
Here's a link to a PDF for a simple exercise I did with my IoT students.

http://resources-area.co.uk/node-red-fl ... _meter.pdf

We used the very inexpensive resistive sensor and then used a transistor to power the sensor for 15 seconds every 15 minutes.
The unit has been in used for nearly 3-months and does not show any sign of corrosion

Hope you find this useful.

Regards, David

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#16 Post by dynamicdave » 04 Sep 2018, 13:14

Hi Rob,
I use a set of Raspberry Pi(es) running Node-RED and MQTT on a self-contained private network in the school.
The students each have one or two Wemos D1 Minis mounted on breadboards that they use to create various types of nodes (that communicate with a certain RPi to increase performance).
The above is just one example of an application using Wemos devices and RPi the students have tackled.

Cheers from David.

kenkoknz
Normal user
Posts: 64
Joined: 03 Jul 2018, 23:46
Location: New Zealand

Re: moisture sensor

#17 Post by kenkoknz » 04 Sep 2018, 23:59

Hi,
Good write up. I noticed that the system is powered by a power bank, as a matter of interest how long does it last. Another thought as stage 2, is to add in "sleep" function this could extend battery life considerably and also your students could learn about the sleep function.
Cheers,
Ken

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#18 Post by dynamicdave » 05 Sep 2018, 09:38

Hi Ken,
Thanks for your inputs.
The reason it is battery powered at the moment is I didn't have a mains outlet socket near the herb plants, so I used a power-block.
The power-block lasts about 3-days at the moment.
I haven't had time to find out if anything else is using the WiFi (which I think is the main power-hungry culprit).

I like your idea of putting the Wemos (ESP8266) to sleep.
I know how to do it, but haven't tried it - have you ????

Since posting the PDF instruction sheet, I've extended the Node-RED flow so it sends a message to Telegram when the plant needs water.
I've also written some code to send an in-line keyboard to Telegram that display some buttons on the phone/tablet.
e.g. [ Parsley ] [ Basil ] [Thyme ] [ Rosemary ]
If you click the appropriate button the system responds with the PAW (Potentially Available Water) value for the specific herb.

I've also ordered an ADS1115 which is a 4 channel analog to digital multiplexer with an I2C interface.
I'm hoping I'll be able to monitor four herb plants with just one Wemos D1 Mini.
My wife has expressed an interest in having a similar system to monitor her precious house plants !!!!

Cheers from David.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#19 Post by grovkillen » 05 Sep 2018, 10:23

I would love for use to have an official ESP Easy school kit based on this Dave. Awesome job incorporating our FW into the teaching of students. Stuff like this really makes our journey more fun!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#20 Post by dynamicdave » 05 Sep 2018, 12:02

Hi to Grovkillen,
Here's a link to the website I set-up last year to document the students' work.

http://youtrain.me.uk/iotclub/

This year I've been given a Google Classroom account which makes posting documents and keeping in contact with the students much easier.
The downside is... everything is now private.

I've been using ESP-Easy with various ESP8266-based devices for a couple of years.
My favourite platform/set-up is the Wemos D1 Mini talking to Node-RED (running on a Raspberry Pi) via MQTT.
Everything seems to fit together so well, and it means I can "knock-up" an experimental system is next to no time.

A friend I met on Node-RED Discourse wrote a neat routine to check the firmware version in each Wemos (against the latest release) on a network and report the ones that are out-of-date.
Here's a link if you are intersted...

https://discourse.nodered.org/t/et-disp ... ces/1893/5

Cheers from David.

dampa
Normal user
Posts: 87
Joined: 19 Jul 2018, 01:48

Re: moisture sensor

#21 Post by dampa » 06 Sep 2018, 11:45

@manjh - I've been using that capacitive sensor for a week now with no problem.
I use it with a WeMos and have it connected to 5V, GND and A0.
Under 'Devices' I added an 'Analog Input - Internal' and enabled the device and send the data to the controller. Then I watched the log to get the 'dry' reading (804) and then stuck it in a glass of water to get the 'wet' reading (440).

With the two readings, I set the calibration points
Point 1 ('dry'): 805 => 0.000
Point 2 ('wet'): 440 => 100.000

And I was off and running.

Hope this helps.

manjh
Normal user
Posts: 516
Joined: 08 Feb 2016, 11:22

Re: moisture sensor

#22 Post by manjh » 06 Sep 2018, 12:58

looks good. I will order a few and try this.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#23 Post by alabama » 20 Sep 2018, 12:11

@dynamicdave
Not only that this helps me, because I have the plan to use some of such moisture sensores, too. But even more your tutorial helps me very much to understand to use ESPEasy and write some rules by myself! I found it yccidentally because I'm searching for some "dummie-specific" description of the use of TaskValueSet.
Thank you!

Perhaps one stupid question is allowed: Where is the 9V block connected on your breadboard? Perhaps one additional photo top of your real breadboard will be helpfull?

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#24 Post by dynamicdave » 20 Sep 2018, 14:08

Hi,
I don't really understand this question, as I'm not using 9v in this project

"Where is the 9V block connected on your breadboard?"

http://resources-area.co.uk/node-red-fl ... sensor.pdf

I used a Power-Block that gives out 5v that connects to the WeMos D1 Mini board via a normal micro-usb connector.
The WeMos board has an on-board regulator that steps-down the 5v to 3v3 to power the ESP8266 IC.

The moisture sensor interface board runs off of 3v3 that comes from a pin on the WeMos.

Hope that helps.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#25 Post by alabama » 20 Sep 2018, 14:45

You are right, of cause - my failure. I read "9V" instead of "5V".

So forget this question. Everything is clear.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#26 Post by alabama » 05 Oct 2018, 17:33

Perhaps someone can help me with my current problem.
I try to start my watering with something like (using FHEM)

Code: Select all

http://192.168.178.87/control?cmd=event,Standardberegnung=240
So far, this works. The number "240" and the event "Standardberegnung" comes to my NodeMCU. This shall start the watering for all in all four lines one after the other by use of magnetic valves with variable duration (in this example all lines 240 s, later the duration of the single lines shall be modified inside the rule by a factor) and with a fixed pause between each line (in my case I choose 300 s, see the following rules set).

Now my problem is that I need the value (240 in this example) all in all four times. But I saw, that after the first time I use the variable %eventvalue% it seems to be set to 0. So my next idea is to set the %eventvalue% to the variable by use of TaskValueSet and name it "Dauer#Dauer" like the example of @dynamicdave shows. This also works, I see in the logging that Dauer#Dauer is set to 240.

But it seems there is also some failure in my idea. My timer1 is not set. I hope this is only some syntax failure, or s my idea in general impossible?

Code: Select all

On Standardberegnung do
  TaskValueSet,12,1,%eventvalue% //sets ‘Dauer#Dauer’ to a number
  notify 1, "Standardberegnung 1 startet"
  Pulse,15,1,200  
  timerSet,1,[Dauer#Dauer]
endOn

On Rules#Timer=1 do  //When Timer1 expires, do
  notify 1, "Standardberegnung 1 stoppt"
  Pulse,13,1,200
  timerSet,2,300
endOn

On Rules#Timer=2 do  //When Timer2 expires, do
  notify 1, "Standardberegnung 2 startet"
  Pulse,14,1,200
  timerSet,3,[Dauer#Dauer]
endOn

.... [same for the next lines]

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#27 Post by grovkillen » 05 Oct 2018, 17:39

Can you try this:

Code: Select all

On Standardberegnung do
  TaskValueSet,12,1,%eventvalue% //sets ‘Dauer#Dauer’ to a number
  notify,1, "Standardberegnung 1 startet"
  Pulse,15,1,200  
  Event,timerSetUp=1,[Dauer#Dauer]
endOn

On Rules#Timer=1 do  //When Timer1 expires, do
  notify,1, "Standardberegnung 1 stoppt"
  Pulse,13,1,200
  Event,timerSetUp=2,300
endOn

On Rules#Timer=2 do  //When Timer2 expires, do
  notify,1, "Standardberegnung 2 startet"
  Pulse,14,1,200
  Event,timerSetUp=3,[Dauer#Dauer]
endOn

On timerSetUp Do
 timerSet,%eventvalue1%,%eventvalue2%
EndOn
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#28 Post by alabama » 05 Oct 2018, 18:11

I tried, but it don't work. Enclosed you can see the first part of the log and after 240 s nothing happens. Unfortunately I don't understand your code. Especially what about the last part? Perhaps it's better that I write my complete rules (after the log). And at all: Perhaps it was a stupid idea from me to add this question in this thread - it would be better in its own thread.

Code: Select all

83126: Dummy: value 1: 0.00
83126: Dummy: value 2: 0.00
83126: Dummy: value 3: 0.00
83126: Dummy: value 4: 0.00
83128: EVENT: Dauer#Dauer=0.00
83197: EVENT: Dauer#=0.00
83266: EVENT: Dauer#=0.00
83333: EVENT: Dauer#=0.00
92206: WD : Uptime 2 ConnectFailures 0 FreeMem 22008
92648: EVENT: Clock#Time=Fri,17:58
122206: WD : Uptime 2 ConnectFailures 0 FreeMem 21984
128106: EVENT: Standardberegnung=240
128149: ACT : TaskValueSet,12,1,240
128159: ACT : notify 1, 'Standardberegnung 1 startet'
128169: ACT : Pulse,15,1,200
128372: SW : GPIO 15 Pulsed for 200 mS
128378: ACT : Event,timerSetUp,1,0.00
128426: Command: taskvalueset
128428: Command: notify
128429: Command: event
128429: EVENT: timerSetUp,1,0.00
129779: EMAIL: Connection Closed Successfully
143126: Dummy: value 1: 240.00
143126: Dummy: value 2: 0.00
143126: Dummy: value 3: 0.00
143126: Dummy: value 4: 0.00
143128: EVENT: Dauer#Dauer=240.00
143199: EVENT: Dauer#=0.00
143266: EVENT: Dauer#=0.00
143333: EVENT: Dauer#=0.00
152207: WD : Uptime 3 ConnectFailures 0 FreeMem 21992
152648: EVENT: Clock#Time=Fri,17:59
182205: WD : Uptime 3 ConnectFailures 0 FreeMem 21856
203126: Dummy: value 1: 240.00
203126: Dummy: value 2: 0.00
203126: Dummy: value 3: 0.00
203126: Dummy: value 4: 0.00
203128: EVENT: Dauer#Dauer=240.00
203199: EVENT: Dauer#=0.00
203267: EVENT: Dauer#=0.00
203336: EVENT: Dauer#=0.00
212203: WD : Uptime 4 ConnectFailures 0 FreeMem 21992
212648: EVENT: Clock#Time=Fri,18:00
Rule Set 1: This shall be used for initialisation and for the single watering of each line.

Code: Select all

On System#Boot do
  GPIO,4,0
  GPIO,5,0
  timerSet,8,60      //Set Timer 8 for the next event in 60 seconds
endOn

On Rules#Timer=8 do
  Pulse,13,1,200
  Pulse,12,1,200
  Pulse,0,1,200
  Pulse,4,1,200
  notify 1, "System gestartet oder alle Ventile nach einer Stunde sicherheitshalber geschlossen"
endOn

On Beregnungsstart_1 do
  notify 1, "Beregnung 1 startet"
  Pulse,15,1,200  
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_1 do
  notify 1, "Beregnung 1 stoppt"
  Pulse,13,1,200
endOn

On Beregnungsstart_2 do
  notify 1, "Beregnung 2 startet"
  Pulse,14,1,200
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_2 do
  notify 1, "Beregnung 2 stoppt"
  Pulse,12,1,200
endOn

On Beregnungsstart_3 do
  notify 1, "Beregnung 3 startet"
  Pulse,2,1,200
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_3 do
  notify 1, "Beregnung 3 stoppt"
  Pulse,0,1,200
endOn

On Beregnungsstart_4 do
  notify 1, "Beregnung 4 startet"
  Pulse,5,1,200
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_4 do
  notify 1, "Beregnung 4 stoppt"
  Pulse,4,1,200
endOn
Rule Set 2: Used for standard watering

Code: Select all

On Standardberegnung do
  TaskValueSet,12,1,%eventvalue% //sets ‘Dauer#Dauer’ to a number
  notify 1, "Standardberegnung 1 startet"
  Pulse,15,1,200  
  Event,timerSetUp,1,[Dauer#Dauer]
endOn

On Rules#Timer=1 do  //When Timer1 expires, do
  notify 1, "Standardberegnung 1 stoppt"
  Pulse,13,1,200
  Event,timerSetUp,2,300
endOn

On Rules#Timer=2 do  //When Timer2 expires, do
  notify 1, "Standardberegnung 2 startet"
  Pulse,14,1,200
  Event,timerSetUp,3,[Dauer#Dauer]
endOn

On Rules#Timer=3 do  //When Timer3 expires, do
  notify 1, "Standardberegnung 2 stoppt"
  Pulse,12,1,200
  Event,timerSetUp,4,300
endOn

On Rules#Timer=4 do  //When Timer4 expires, do
  notify 1, "Standardberegnung 3 startet"
  Pulse,2,1,200
  Event,timerSetUp,5,[Dauer#Dauer]
endOn

On Rules#Timer=5 do  //When Timer5 expires, do
  notify 1, "Standardberegnung 3 stoppt"
  Pulse,0,1,200
  Event,timerSetUp,6,300
endOn

On Rules#Timer=6 do  //When Timer6 expires, do
  notify 1, "Standardberegnung 4 startet"
  Pulse,5,1,200
  Event,timerSetUp,7,[Dauer#Dauer]
endOn

On Rules#Timer=7 do  //When Timer7 expires, do
  notify 1, "Standardberegnung 4 stoppt"
  Pulse,4,1,200
  Event,timerSetUp,8,300
endOn

On timerSetUp Do
 timerSet,%eventvalue1%,%eventvalue2%
EndOn

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#29 Post by grovkillen » 05 Oct 2018, 19:08

It seems that your rule for setting the dummy happens after the timer is triggered.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#30 Post by alabama » 05 Oct 2018, 19:25

Okay, seems to be possible. So it's not sure that the sequence is made like it's written inside the rules? I'll try to add another timer that ensures that the sequence is right. I'll report, but now I can't continue direct.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#31 Post by grovkillen » 05 Oct 2018, 20:00

No it's event based meaning that events are what is triggering the "on" parts of the rules.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#32 Post by alabama » 06 Oct 2018, 01:44

now it seems to work. I have used already all 8 timers, so I used the dummy variable as trigger. Here are my rule sets:

Set 1, individual watering each line

Code: Select all

On System#Boot do
  GPIO,4,0
  GPIO,5,0
  timerSet,8,60      //Set Timer 8 for the next event in 60 seconds
endOn

On Rules#Timer=8 do
  Pulse,13,1,200
  Pulse,12,1,200
  Pulse,0,1,200
  Pulse,4,1,200
  TaskValueSet,12,1,0 //sets ‘Dauer#Dauer’ to 0
  notify 1, "System gestartet oder alle Ventile nach einer Stunde sicherheitshalber geschlossen"
endOn

On Beregnungsstart_1 do
  notify 1, "Beregnung 1 startet"
  Pulse,15,1,200  
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_1 do
  notify 1, "Beregnung 1 stoppt"
  Pulse,13,1,200
endOn

On Beregnungsstart_2 do
  notify 1, "Beregnung 2 startet"
  Pulse,14,1,200
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_2 do
  notify 1, "Beregnung 2 stoppt"
  Pulse,12,1,200
endOn

On Beregnungsstart_3 do
  notify 1, "Beregnung 3 startet"
  Pulse,2,1,200
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_3 do
  notify 1, "Beregnung 3 stoppt"
  Pulse,0,1,200
endOn

On Beregnungsstart_4 do
  notify 1, "Beregnung 4 startet"
  Pulse,5,1,200
  timerSet,8,3600      //Set Timer 8 for the next event in 3600 seconds
endOn

On Beregnungsstop_4 do
  notify 1, "Beregnung 4 stoppt"
  Pulse,4,1,200
endOn
Set 2, complete watering all 4 lines

Code: Select all

On Standardberegnung do
  TaskValueSet,12,1,%eventvalue% //sets ‘Dauer#Dauer’ to a number
  TaskValueSet,12,2,1            //sets ‘Dauer#aktiv’ to 1
endOn

On Dauer#Dauer do
  if [Dauer#aktiv]=1
    notify 1, "Standardberegnung 1 startet"
    Pulse,15,1,200  
  TaskValueSet,12,2,0            //sets ‘Dauer#aktiv’ to 0
  timerSet,1,[Dauer#Dauer]
  endif
endOn

On Rules#Timer=1 do  //When Timer1 expires, do
  notify 1, "Standardberegnung 1 stoppt"
  Pulse,13,1,200
  timerSet,2,300
endOn

On Rules#Timer=2 do  //When Timer2 expires, do
  notify 1, "Standardberegnung 2 startet"
  Pulse,14,1,200
  timerSet,3,[Dauer#Dauer]
endOn

On Rules#Timer=3 do  //When Timer3 expires, do
  notify 1, "Standardberegnung 2 stoppt"
  Pulse,12,1,200
  timerSet,4,300
endOn

On Rules#Timer=4 do  //When Timer4 expires, do
  notify 1, "Standardberegnung 3 startet"
  Pulse,2,1,200
  timerSet,5,[Dauer#Dauer]
endOn

On Rules#Timer=5 do  //When Timer5 expires, do
  notify 1, "Standardberegnung 3 stoppt"
  Pulse,0,1,200
  timerSet,6,300
endOn

On Rules#Timer=6 do  //When Timer6 expires, do
  notify 1, "Standardberegnung 4 startet"
  Pulse,5,1,200
  timerSet,7,[Dauer#Dauer]
endOn

On Rules#Timer=7 do  //When Timer7 expires, do
  notify 1, "Standardberegnung 4 stoppt"
  Pulse,4,1,200
  timerSet,8,300
endOn

acaonweb
New user
Posts: 7
Joined: 13 Sep 2018, 19:37

Re: moisture sensor

#33 Post by acaonweb » 09 Oct 2018, 13:39

I hope this 3d isn't dead :)
I've my Weemos D1 with a moisture sensor connected(YL-69) correctly sends values to Domoticz through MQTT and idx.
The sensor is obvusly connected to 5V, GND (power) and A0 (analog signal)
ALL WORKS FINE.
But I want power that through a battery pack. I've set sleep mode throught Easyesp web interface, connected D0 (GPIO16) to RESET... all works with 3AAA alkaline battery.
BUT (here is the real problem) the sensor drain the battery in a couple of hours, because sleep mode do the job (on the weemos), but 5A is still available.

So how can i resolve it? How can put in sleep mode and turn off 3.3/5V pin? there any other way (ie: other electronic parts to connect between sensor and Weemos D1)?
Can someone help me with a kind of schematic?



Thanx in advance

Fabrizio

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#34 Post by alabama » 21 Oct 2018, 17:47

Have you seen the pdf's of @dynamicdave? I think that shall work: Switch on and of the 5V by a transistor.

acaonweb
New user
Posts: 7
Joined: 13 Sep 2018, 19:37

Re: moisture sensor

#35 Post by acaonweb » 28 Oct 2018, 09:54

oh, yes... i missed it... now i can check it 😊


Thanx

Fabrizio

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#36 Post by alabama » 09 Nov 2018, 10:39

So, since this morning my moisture sensor according to @dynamicdave is running. Yesterday ther was a unknown problem, the transistor wouldn't work, but after reconnect the voltage of the wemos it works fine.

I use the configuration nearly 1:1, but I don't use MQTT but FHEM on the controller. So I delete the publish-commands and add in the third rule the line

Code: Select all

TaskValueSet,11,1,[paw#value]
This uses one more dummy device wich is connected to my controler. Fist I tried to use paw#value direct. But very soon I saw that this is a stupid idea: At the end of every sequence, when the transistor switches off, paw#value is set to 10, like shown in @dynamicdaves plot of this device.

Now my next idea is to add more sensores to one wemos. But I think that I will use more transistores and not the ADS1115 like @dynamicdave wrote. Then I will use some more rules to let the procedure run on the wemos and the controler only get the data, for example all 30 minutes and the 4 or 5 seonsores with distance perhaps one minute. I thik this can work.

acaonweb
New user
Posts: 7
Joined: 13 Sep 2018, 19:37

Re: moisture sensor

#37 Post by acaonweb » 11 Nov 2018, 10:15

ok, I've checked the pdf, but i've seen that Wemos D1 provide 3.3 V out from gpio's
i've connected my sensors's VCC to GPIO 14 (.ie) and it works so good.

using

Code: Select all

http://IP/control?cmd=GPIO,12,1
and

Code: Select all

http://IP/control?cmd=GPIO,12,0
and i can see the sensor led turn on and off correctly.
the sensor send analog value through mqtt( i can read it in DOmotcz)

I've wrote a rule to have GPIO14 high output on boot

I put Wemos D1 in sleep mode (60 seconds sleep and 60 second , connecting gpio16 to reset, and it goes to sleep, and the GPIO14 goes low (and power off the sensors that is what i want)
the problem is at wake up, because GPIO14 stays off, and there is no way to put it hight when wake up.
Honeslly i don't know if memos wakes up...


any ideas?

Fabrizio

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#38 Post by grovkillen » 11 Nov 2018, 10:27

You should use the serial log and see how it's waking up. Once it's behaving as wanted you can trust it wakes up.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

acaonweb
New user
Posts: 7
Joined: 13 Sep 2018, 19:37

Re: moisture sensor

#39 Post by acaonweb » 11 Nov 2018, 11:32

i'm a real newbie... what is serial log and how i can check it?

thanx 😊

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#40 Post by grovkillen » 11 Nov 2018, 12:07

You can use my flasher and just use the "serial monitor" of you have the unit connected through USB
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

acaonweb
New user
Posts: 7
Joined: 13 Sep 2018, 19:37

Re: moisture sensor

#41 Post by acaonweb » 11 Nov 2018, 12:38

grovkillen wrote: 11 Nov 2018, 12:07 You can use my flasher and just use the "serial monitor" of you have the unit connected through USB
Can you provide me a link for my flasher?

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#42 Post by alabama » 11 Nov 2018, 12:43

One stupid qustion: Is'nt "your flasher" that one comes with the FW?

@dynamicdave: Is it possible that in your sketch the Transistor is wrong sided? I made everthing same like you show and the flat side lookes to me, bit the System wouldn't work . Next day I searched the datasheet and see that the collector is (looking on the flat side) left. I turned it and it worked (I forgott to write this above).

acaonweb
New user
Posts: 7
Joined: 13 Sep 2018, 19:37

Re: moisture sensor

#43 Post by acaonweb » 11 Nov 2018, 12:54

alabama wrote: 11 Nov 2018, 12:43 One stupid qustion: Is'nt "your flasher" that one comes with the FW?

@dynamicdave: Is it possible that in your sketch the Transistor is wrong sided? I made everthing same like you show and the flat side lookes to me, bit the System wouldn't work . Next day I searched the datasheet and see that the collector is (looking on the flat side) left. I turned it and it worked (I forgott to write this above).
Well,for install easyesp I use the app that let me choose the bin file and the com port.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: moisture sensor

#44 Post by grovkillen » 11 Nov 2018, 13:15

Yep my flasher is the one inside the release zip file. That one also let you monitor the serial ports.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#45 Post by alabama » 12 Nov 2018, 12:05

Hmmm, I have to see again next time I connect a device via USB to my computer, I don't remember to see something like the editor.

But anyway, thanks.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#46 Post by alabama » 12 Nov 2018, 12:17

Now I have changed my rules to include 4 moisture sensors with one WeMos. Further I have added three more sensors, resistants and transistors to the GPIO 13, 14 and 15 of the WeMos. At last my dummy-device Task 11 uses 4 values and dummy-device Task 12 has one more value like shown in the figure.
The analog autput of alle sensors are connected together to the analog input of the WeMos.
Devices.jpg
Devices.jpg (214.36 KiB) Viewed 44610 times
Of cause the two digits don' make much sence. But for the first test I must see the different values for all sensors places one beside the other. This moment I have some problem with the resolution of mey test sensor for my coffee plant: It shos alway values between 5.2 (very dry) and 6.3 (really wet) - not very helpfull. Perhaps it will be better to place some other material (fine sand?) around the sensor?

Here is my rules set (perhaps devide in two sets because the maximum number of characters are reached)

Code: Select all

On System#Boot do
 notify 1, "System gestartet"
 timerSet,1,0
 TaskValueSet,12,1,0 //Set var#activation = 0
 TaskValueSet,12,2,0 //Set var#sent = 0
 TaskValueSet,12,3,1 //Set var#sensor = 1
 timerSet,2,30 //Start after 30 seconds first cycle
 timerSet,3,0
 timerSet,4,0
 timerSet,5,0
endOn

On activate do // Manual request per browser or FHEM
 GPIO,12,1 //Set GPIO(D6)=1 (Turn on the transistor)
 TaskValueSet,12,1,1 //Set var#activation = 1
 TaskValueSet,12,2,0 //Set var#sent = 0
 TaskValueSet,12,3,1 // Sensor 1 is first measured
 timerSet,1,6 // 6 sec active to get at least one value
 timerSet,2,1800 //Start timer for one measure every 1/2 hour
 timerSet,3,60 //  1 minute later senor 2
 timerSet,4,120 // 2 minutes later senor 3
 timerSet,5,120 // 3 minutes later senor 4
endOn

On Rules#timer=2 do //Automatic cycle verey 1/2 hour
 GPIO,12,1 //Set GPIO(D6)=1 (Turn on the transistor)
 TaskValueSet,12,1,1 //Set var#activation = 1
 TaskValueSet,12,2,0 //Set var#sent = 0
 TaskValueSet,12,3,1 // Sensor 1 is measured
 timerSet,1,6 // 6 sec active to get at least one value
 timerSet,2,1800 //Start timer for one measure every 1/2 hour
 timerSet,3,60 //  1 minute later senor 2
 timerSet,4,120 // 2 minutes later senor 3
 timerSet,5,120 // 3 minutes later senor 4
endOn

On Rules#timer=3 do //Second sensor
 GPIO,13,1 //Set GPIO(D7)=1 (Turn on the transistor)
 TaskValueSet,12,1,1 //Set var#activation = 1
 TaskValueSet,12,2,0 //Set var#sent = 0
 TaskValueSet,12,3,2 // Sensor 2 is measured
 timerSet,1,6 // 6 sec active to get at least one value
endOn

On Rules#timer=4 do //Third sensor
 GPIO,14,1 //Set GPIO(D5)=1 (Turn on the transistor)
 TaskValueSet,12,1,1 //Set var#activation = 1
 TaskValueSet,12,2,0 //Set var#sent = 0
 TaskValueSet,12,3,2 // Sensor 3 is measured
 timerSet,1,6 // 6 sec active to get at least one value
endOn

On Rules#timer=5 do //Fourth sensor
 GPIO,15,1 //Set GPIO(D8)=1 (Turn on the transistor)
 TaskValueSet,12,1,1 //Set var#activation = 1
 TaskValueSet,12,2,0 //Set var#sent = 0
 TaskValueSet,12,3,2 // Sensor 4 is measured
 timerSet,1,6 // 6 sec active to get at least one value
endOn

On paw#value do
 If [var#activation]>0 and [var#sent]=0
 If [var#sensor}=1
 TaskValueSet,11,1,[paw#value] //Dummy for saving sensor 1.
 endIf
 If [var#sensor}=2
 TaskValueSet,11,2,[paw#value] //Dummy for saving sensor 2.
 endIf
 If [var#sensor}=3
 TaskValueSet,11,3,[paw#value] //Dummy for saving sensor 3.
 endIf
 If [var#sensor}=4
 TaskValueSet,11,4,[paw#value] //Dummy for saving sensor 4.
 endIf
 TaskValueSet,12,2,1 //Set var#sent = 1
 endIf
 endOn

On Rules#timer=1 do
 GPIO,12,0 //Set GPIO(D6)=0 (Turn off the transistor of sensor 1)
 GPIO,13,0 //Set GPIO(D7)=0 (Turn off the transistor of sensor 2)
 GPIO,14,0 //Set GPIO(D5)=0 (Turn off the transistor of sensor 3)
 GPIO,15,0 //Set GPIO(D8)=0 (Turn off the transistor of sensor 4)
 TaskValueSet,12,1,0 //Set var#activation = 0
 endOn


User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: moisture sensor

#47 Post by dynamicdave » 13 Nov 2018, 10:25

Oops sorry - as someone pointed out (above) the transistor's body outline is round the wrong way.
The instructions in my document are correct, so if you follow them the circuit should work.

Note: I've corrected and uploaded the new breadboard layout.

Cheers from David.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#48 Post by alabama » 13 Nov 2018, 10:50

@dynamicdave
Do you have some experience meanwhile about the resolution of these sensors? In my case I fear it is not so good. From the range between 0 and 10 it seem only about 5 to 7 is realistic, ant that only in optimistic viewing. But perhaps my sensors just the cheapest ones.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#49 Post by alabama » 15 Nov 2018, 00:20

My idea with the 4 transistors, 4 sonsors and 1 WeMos seems not to work. Last two days I run a test and get the following results in the attached figure. The red line "Topf 1" is the first sensor strictly according @dynamicdave. The others are the test with 4 sensors in different plants with different watering. First I wonder that all 4 values nearly alwaya same and then I wondering the amount of about 9 against 6-7 on the single sensor (the scale reaches from 2 to 10 - unfortunately I cut it).

After some tests with different voltage sources and places I measure the resistance of the sensors - they seem to be ok. Then I measure the voltage of the moisture device at the two pins for the resistor. The single version has a voltage of about 2.9 V, the 4 ones on the combined system have only about 0.6 V. If I remove 3 of the four transistors from the voltage the last one has also 2.9 V.

So my impression is that the four sensors are not the solution for this idea. Too bad, as a layman I do not have the working idea now. Perhaps it's enough to use other transistors?

EDIT: I think I got the solution: The transister shall not be in the Vcc-line but in the grnd line. I changed it and now all sensors get about 2.9 V if its GPIO is high. Now I have to see what about the absolut values in camparison to each other.

EDIT 2: Nope, seems not really work as good as I want. Now tha values all are not the same and not al around 9 but all of them are only about half of the value as if the sensors are single used. If I remove 3 sensors and transistors complete from voltage one shows about 5.4, if I connect the others this one value goes down to about 2.2. So next test ist to use an ADS1115.
Attachments
successless.jpg
successless.jpg (19.5 KiB) Viewed 44460 times
successless.jpg
successless.jpg (9.13 KiB) Viewed 44513 times

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: moisture sensor

#50 Post by alabama » 16 Nov 2018, 21:25

Okay, this series of tests are over, this simple way is not working. There is an influence from the other, not actice sensors to the active one by the data line. My idea to avoid this by a simple diode (1N4001) in each data line also don't work.

But now I have another question: Why do we need the transistor and don't simply connect the power of the sensors with the GPIO? I measured the current of the sensor an see it is somthing between 1.7 and 3.5 mA. The data sheet of the esp gives max. 12 mA. So I think that the transistor is not needed. Is this right?

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests