Page 1 of 2
Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Monday 09 July 2018 16:44
by JHO01
With the help of this forum and many other sources I build a water meter.
In this post I want to share my build.
Hardware:
-water meter (see picture)

- wm.jpg (144.05 KiB) Viewed 14097 times
-infrared sensor to pick up the rotation of the small red/silver wheel : TCRT5000 Infrared Sensor (Aliexpress)
-Wemos D1 Mini
-connect TCRT5000 VCC=>5V (Wemos), TCRT5000 GND=>G (Wemos), TCRT5000 D0=>D5 (Wemos)
-align the sensor on the rotating wheel and adjust the TCRT5000 sensitivity; make sure the led turns on/off when the wheel rotates
Software steps:
Domoticz:
-Create Virtual Sensor, General Counter Incremental,; note IDX
-Settings, Meters/Counters, RFXMeter/Counter Dividers: Water 100000 (each Rotation/pulse is 1 Liter)
-Utility, select the just created water meter and Edit: set the Meter Offset to the already consumed M3 according to the original meter.
Wemos:
-Flash Wemos with ESPeasy
ESPEasy:
-Config: Connect to your wifi network
-Controllers: Connect to your Domoticz HTTP or Domoticz MQTT
-Devices: Generic - Pulse counter, !st GPIO-14 (D5), Debounce Time 100, Counter type Delta, Mode type CHANGE, send to Controller use IDX from above created counter; make sure that both Device and send to controller is enabled.
Done
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Tuesday 10 July 2018 21:05
by sincze

nice one.
I hope it will be stable. As I've seen a faire share of false interrupts generated by the TCRT-5000. (especially when the reflecting part is on the 'edge' .
I can confirm it works as I've had to build my own application for it to get my sensor stable since 2014.
Recently I switched to an NPN watermeter and ESP, just to give it a try.
Why not add a flow meter as well in your ESP settings (rules), so you can see the actual usage per minute?

- Waterflow.JPG (39.71 KiB) Viewed 14063 times
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Tuesday 10 July 2018 23:14
by JHO01
Why not , do you mind sharing the code for the rules?
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Wednesday 11 July 2018 20:30
by sincze
JHO01 wrote: ↑Tuesday 10 July 2018 23:14
Why not , do you mind sharing the code for the rules?
Sure.
Code: Select all
On System#Boot do // When the ESP boots, do
TaskValueSet 4,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset the Liters counter to 0
TaskValueSet 4,2,0 // Previous Counter used for memory
TimerSet,1,60 // Set Timer 1 for the next event in 60 seconds
EndOn
On Watermeter#Count do // When Pulse is detected
if [Watermeter#Count] > 0
TaskValueSet 4,1,[Watermeter#Count] // Set the Pulse to the Liters dummy sensor
endif
EndOn
on Rules#Timer=1 do // When Timer 1 expires, do
if [Liters#Liters] > 0 or [Liters#Previous] > 0 // Only send value if amount of Liters > 0 else 'keep the change ;-)'
SendToHTTP 192.168.***.***,8080,/json.htm?type=command¶m=udevice&idx=****&nvalue=0&svalue=[Liters#Liters]
TaskValueSet 4,2,[Liters#Liters]
TaskValueSet 4,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset submitted Liters counter to 0
endif
TimerSet,1,60 // Set Timer 1 for the next event in 60 seconds
endon
Remember that you need an additional device to do the counting!

- Wemos_Domoticz.JPG (63.74 KiB) Viewed 14017 times
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Wednesday 11 July 2018 22:10
by freijn
JHO01 wrote: ↑Monday 09 July 2018 16:44
-Settings, Meters/Counters, RFXMeter/Counter Dividers: Water 100000 (each Rotation/pulse is 1 Liter)
Are you sure it must be 100000 ? I believe it must be 1000
Cheers,
Frank
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 12 July 2018 9:25
by heggink
I tried for ages to get the tcrt to work but dropped it for the inductive sensor because of the false positives when it gets stuck on an edge. Never happens with the inductive sensor.
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 12 July 2018 9:44
by freijn
Heggink
I noticed , during my experiments, that the position of the sensor is EXTREEM sensitive.
I ended printing a cap around the meter, with a larger hole in it for the sensor. The printed a circle around the sensor and glue the sensor on the
correct place experimenting the best posistion and best response. Till now, works fine.
My "biggest" worrie.. if the water company comes to read the meter visible output. My sensor needs to be removed and I have to start the
process again
Cheers,
Frank
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 12 July 2018 11:21
by sincze
freijn wrote: ↑Wednesday 11 July 2018 22:10
JHO01 wrote: ↑Monday 09 July 2018 16:44
-Settings, Meters/Counters, RFXMeter/Counter Dividers: Water 100000 (each Rotation/pulse is 1 Liter)
Are you sure it must be 100000 ? I believe it must be 1000
Cheers,
Frank
I guess you are right.

- Meters.JPG (14.27 KiB) Viewed 13971 times
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 12 July 2018 19:45
by JHO01
-Settings, Meters/Counters, RFXMeter/Counter Dividers: Water
10000 (each Rotation/pulse is 1 Liter ,typo sorry
-No false positives so far, perhaps because a used a piece of wood to attach the TCRT. this is then placed on top of the water meter without glue. This minimises the optical IR errors.

- WhatsApp Image 2018-07-12 at 19.35.24.jpeg (197.2 KiB) Viewed 13951 times
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Tuesday 09 October 2018 16:13
by Derik
sincze wrote: ↑Wednesday 11 July 2018 20:30
JHO01 wrote: ↑Tuesday 10 July 2018 23:14
Why not , do you mind sharing the code for the rules?
Sure.
Code: Select all
On System#Boot do // When the ESP boots, do
TaskValueSet 4,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset the Liters counter to 0
TaskValueSet 4,2,0 // Previous Counter used for memory
TimerSet,1,60 // Set Timer 1 for the next event in 60 seconds
EndOn
On Watermeter#Count do // When Pulse is detected
if [Watermeter#Count] > 0
TaskValueSet 4,1,[Watermeter#Count] // Set the Pulse to the Liters dummy sensor
endif
EndOn
on Rules#Timer=1 do // When Timer 1 expires, do
if [Liters#Liters] > 0 or [Liters#Previous] > 0 // Only send value if amount of Liters > 0 else 'keep the change ;-)'
SendToHTTP 192.168.***.***,8080,/json.htm?type=command¶m=udevice&idx=****&nvalue=0&svalue=[Liters#Liters]
TaskValueSet 4,2,[Liters#Liters]
TaskValueSet 4,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset submitted Liters counter to 0
endif
TimerSet,1,60 // Set Timer 1 for the next event in 60 seconds
endon
Remember that you need an additional device to do the counting!
Wemos_Domoticz.JPG
Dear....
Will you please explane what i can do with this script.
Is this script working with the watermeter so i can see if the meter is working?
Or what is the extra option?
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Tuesday 09 October 2018 21:46
by joostnl
Can you tell me which sensor your using?
heggink wrote: ↑Thursday 12 July 2018 9:25
I tried for ages to get the tcrt to work but dropped it for the inductive sensor because of the false positives when it gets stuck on an edge. Never happens with the inductive sensor.
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Tuesday 09 October 2018 22:44
by heggink
Just an el cheapo AliExpress inductive sensor like everyone else uses on the forum.
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Monday 26 November 2018 20:06
by Knibor
Hi,
Is this code for the water meter Lua, Python or dzVents?
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Monday 26 November 2018 20:44
by sincze
I think you mean the code is for the rules in espeasy
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Saturday 02 March 2019 20:42
by lodie
Can you explane how the script works? I don't understand the part of teh dummy device

Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Sunday 03 March 2019 13:58
by sincze
lodie wrote: ↑Saturday 02 March 2019 20:42
Can you explane how the script works? I don't understand the part of teh dummy device
Code: Select all
on Rules#Timer=1 do // When Timer 1 expires, do
if [Liters#Liters] > 0 or [Liters#Previous] > 0 // Only send value if amount of Liters > 0 else 'keep the change ;-)'
SendToHTTP 192.168.***.***,8080,/json.htm?type=command¶m=udevice&idx=****&nvalue=0&svalue=[Liters#Liters]
TaskValueSet 4,2,[Liters#Liters]
TaskValueSet 4,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset submitted Liters counter to 0
endif
TimerSet,1,60 // Set Timer 1 for the next event in 60 seconds
endon
Values are temporarily stored in a virtual device on the ESP, You probably don't want to have updates all the time.
When the timer expires (every 60 sec or so) it sends the data to a domoticz device. This also can create a flow meter l/min automatically

Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 30 May 2019 13:02
by Justintime
sincze wrote: ↑Sunday 03 March 2019 13:58
lodie wrote: ↑Saturday 02 March 2019 20:42
Can you explane how the script works? I don't understand the part of teh dummy device
Code: Select all
on Rules#Timer=1 do // When Timer 1 expires, do
if [Liters#Liters] > 0 or [Liters#Previous] > 0 // Only send value if amount of Liters > 0 else 'keep the change ;-)'
SendToHTTP 192.168.***.***,8080,/json.htm?type=command¶m=udevice&idx=****&nvalue=0&svalue=[Liters#Liters]
TaskValueSet 4,2,[Liters#Liters]
TaskValueSet 4,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset submitted Liters counter to 0
endif
TimerSet,1,60 // Set Timer 1 for the next event in 60 seconds
endon
Values are temporarily stored in a virtual device on the ESP, You probably don't want to have updates all the time.
When the timer expires (every 60 sec or so) it sends the data to a domoticz device. This also can create a flow meter l/min automatically
I am moving out of the Mysensors enviroment and going all with easpeasy. Also with tcrt5000 sensor which works great in my setup.
The incrmental sensor works but now i am trying to get the Flow to work. I have setup Easpeasy with the Generic Pule counter. Also i have tried t oupload the script and set a dummy sensor for the waterflow and corresponding IDX in the script. But whatever i try no waterflow.
I dont have the Generic Dummy device setup in the easpeasy is that maybe the culprit?? I have tried it also but dont know which parameters to set in the generic dummy device like idx?
Maybe you can help me out a bit.
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 30 May 2019 15:28
by sincze
Justintime wrote: ↑Thursday 30 May 2019 13:02
I am moving out of the Mysensors enviroment and going all with easpeasy. Also with tcrt5000 sensor which works great in my setup.
The incrmental sensor works but now i am trying to get the Flow to work. I have setup Easpeasy with the Generic Pule counter. Also i have tried t oupload the script and set a dummy sensor for the waterflow and corresponding IDX in the script. But whatever i try no waterflow.
I dont have the Generic Dummy device setup in the easpeasy is that maybe the culprit?? I have tried it also but dont know which parameters to set in the generic dummy device like idx?
Maybe you can help me out a bit.
Store the amount of pulses (liters) in a dummy sensor.
Send the amount of pulses every minute to Domoticz using a timer.
Reset the dummy counter
Hence.. l/min

Flow meter.

- Flowmeter.png (59.1 KiB) Viewed 10824 times
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 30 May 2019 18:55
by Justintime
sincze wrote: ↑Thursday 30 May 2019 15:28
Justintime wrote: ↑Thursday 30 May 2019 13:02
I am moving out of the Mysensors enviroment and going all with easpeasy. Also with tcrt5000 sensor which works great in my setup.
The incrmental sensor works but now i am trying to get the Flow to work. I have setup Easpeasy with the Generic Pule counter. Also i have tried t oupload the script and set a dummy sensor for the waterflow and corresponding IDX in the script. But whatever i try no waterflow.
I dont have the Generic Dummy device setup in the easpeasy is that maybe the culprit?? I have tried it also but dont know which parameters to set in the generic dummy device like idx?
Maybe you can help me out a bit.
Store the amount of pulses (liters) in a dummy sensor.
Send the amount of pulses every minute to Domoticz using a timer.
Reset the dummy counter
Hence.. l/min

Flow meter.
Flowmeter.png
Yes i have created the dummy switch in espeasy (Watermeter, Previous and Liters) in the dummy switch i have set the idx of the domoticz waterflow device.
I have loaded the script in espeasy with the Domoticz IP and i guess the IDX of the waterflow dummy switch....
It just doesnt calculate the differences....
Code: Select all
32099: WD : Uptime 1 ConnectFailures 0 FreeMem 17696 WiFiStatus 3
60697: EVENT: Watermeter#Count=87.00
60751: ACT : TaskValueSet 4,1,87.00
60759: Command: taskvalueset
60777: EVENT: Watermeter#Total=87.00
60802: EVENT: Watermeter#Time=1076.00
60827: Domoticz: Sensortype: 1 idx: 502 values: 87.00
60838: Dummy: value 1: 0.00
60842: EVENT: Liters#Liters=0.00
60895: EVENT: Liters#Previous=0.00
60920: EVENT: Liters#Watermeter=0.00
60945: EVENT: Liters#=0.00
60969: Domoticz: Sensortype: 1 idx: 501 values: 0.00
61545: EVENT: Rules#Timer=1
61667: ACT : TimerSet,1,60
61675: Command: timerset
62100: WD : Uptime 1 ConnectFailures 0 FreeMem 17680 WiFiStatus 3
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Posted: Thursday 30 May 2019 18:59
by sincze
Image of your devices in espeasy would come in handy now
if typo then no calculation
