Water meter ESPeasy Wemos TCRT5000 WIFI

Everything about esp8266 and more.

Moderator: leecollings

User avatar
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

Post 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
wm.jpg (144.05 KiB) Viewed 13676 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
RPI-3, Z-stick Gen5, RFlink, Zigbee2mqtt, 1-wire DS18B20, Fibaro switches, various RF-433 sockets, BMP018, Somfy, Wemos, Tradfri.
User avatar
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

Post by sincze »

:D 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
Waterflow.JPG (39.71 KiB) Viewed 13642 times
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.
User avatar
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

Post by JHO01 »

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.
User avatar
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

Post 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&param=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
Wemos_Domoticz.JPG (63.74 KiB) Viewed 13596 times
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.
freijn
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

Post 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
User avatar
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

Post 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.
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 :-)
freijn
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

Post 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
User avatar
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

Post 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
Meters.JPG (14.27 KiB) Viewed 13550 times
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.
User avatar
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

Post 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
WhatsApp Image 2018-07-12 at 19.35.24.jpeg (197.2 KiB) Viewed 13530 times
RPI-3, Z-stick Gen5, RFlink, Zigbee2mqtt, 1-wire DS18B20, Fibaro switches, various RF-433 sockets, BMP018, Somfy, Wemos, Tradfri.
Derik
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

Post 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&param=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?
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
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Water meter ESPeasy Wemos TCRT5000 WIFI

Post 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.
User avatar
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

Post by heggink »

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 :-)
Knibor
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

Post by Knibor »

Hi,

Is this code for the water meter Lua, Python or dzVents?
User avatar
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

Post by sincze »

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.
lodie
Posts: 3
Joined: Sunday 07 October 2018 20:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Water meter ESPeasy Wemos TCRT5000 WIFI

Post by lodie »

Can you explane how the script works? I don't understand the part of teh dummy device :shock:
User avatar
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

Post 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 :shock:

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&param=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 :lol:
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.
Justintime
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

Post 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 :shock:

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&param=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 :lol:

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.
User avatar
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

Post 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
Flowmeter.png (59.1 KiB) Viewed 10403 times
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.
Justintime
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

Post 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
User avatar
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

Post by sincze »

Image of your devices in espeasy would come in handy now :)

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests