Water meter ESPeasy Wemos TCRT5000 WIFI
Moderator: leecollings
- JHO01
- Posts: 24
- Joined: Wednesday 02 November 2016 13:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Water meter ESPeasy Wemos TCRT5000 WIFI
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) -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
In this post I want to share my build.
Hardware:
-water meter (see picture) -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
RPI-3, Z-stick Gen5, RFlink, Zigbee2mqtt, 1-wire DS18B20, Fibaro switches, various RF-433 sockets, BMP018, Somfy, Wemos, Tradfri.
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI

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?
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- JHO01
- Posts: 24
- Joined: Wednesday 02 November 2016 13:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Why not , do you mind sharing the code for the rules?
RPI-3, Z-stick Gen5, RFlink, Zigbee2mqtt, 1-wire DS18B20, Fibaro switches, various RF-433 sockets, BMP018, Somfy, Wemos, Tradfri.
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
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
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- heggink
- Posts: 972
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
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.
Docker in Truenas scale, close to latest beta
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
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
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
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
I guess you are right.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- JHO01
- Posts: 24
- Joined: Wednesday 02 November 2016 13:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
-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.
-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.
RPI-3, Z-stick Gen5, RFlink, Zigbee2mqtt, 1-wire DS18B20, Fibaro switches, various RF-433 sockets, BMP018, Somfy, Wemos, Tradfri.
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Dear....sincze wrote: βWednesday 11 July 2018 20:30Sure.
Remember that you need an additional device to do the counting!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
Wemos_Domoticz.JPG
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?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- heggink
- Posts: 972
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Just an el cheapo AliExpress inductive sensor like everyone else uses on the forum.
Docker in Truenas scale, close to latest beta
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
DASHTICZ π
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 112
- Joined: Sunday 20 May 2018 12:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Hi,
Is this code for the water meter Lua, Python or dzVents?
Is this code for the water meter Lua, Python or dzVents?
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
I think you mean the code is for the rules in espeasy
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 3
- Joined: Sunday 07 October 2018 20:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Can you explane how the script works? I don't understand the part of teh dummy device 

- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
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
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

Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 228
- Joined: Thursday 21 May 2015 9:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
sincze wrote: βSunday 03 March 2019 13:58Values are temporarily stored in a virtual device on the ESP, You probably don't want to have updates all the time.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
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.
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Store the amount of pulses (liters) in a dummy sensor.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.
Send the amount of pulses every minute to Domoticz using a timer.
Reset the dummy counter
Hence.. l/min

Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 228
- Joined: Thursday 21 May 2015 9:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
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.sincze wrote: βThursday 30 May 2019 15:28Store the amount of pulses (liters) in a dummy sensor.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.
Send the amount of pulses every minute to Domoticz using a timer.
Reset the dummy counter
Hence.. l/minFlow meter.
Flowmeter.png
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
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Water meter ESPeasy Wemos TCRT5000 WIFI
Image of your devices in espeasy would come in handy now
if typo then no calculation

if typo then no calculation

Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Who is online
Users browsing this forum: No registered users and 0 guests