Water usage meter using esp8266 and proximity sensor

Everything about esp8266 and more.

Moderator: leecollings

Post Reply
azonneveld
Posts: 157
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Water usage meter using esp8266 and proximity sensor

Post by azonneveld »

Perhaps this post is useful for those measuring waterconsumption, or those who want to measure their waterconsumption

To measure the waterusage, I have implemented the watermeter as described here

Initially I used the 'puls counter' in ESPEASY as described by the obove example, but this generated false readings.
The false reading, are caused by the debounce timer. This timer is not restarted when a puls is received during the debounce time.

Therefor I changed the counting to normal switches, using rules.

Code: Select all

On System#Boot do
	timerset,6,30 // Data send Timer
Endon
On Rules#Timer=6 do //send data to domoticz
        timerset,6,10 // reset data send timer
	SendToHTTP <domoticz-ip,port>,/json.htm?type=command&param=udevice&idx=<meterIDX>&svalue=[Waterteller#Count]  //send update to domoticz
	TaskValueSet,2,1,0  //reset waterpuls counter
Endon

On Waterpuls#State do
	timerset,7,1
endon

On Rules#Timer=7 do
   	TaskValueSet,2,1,[Waterteller#Count]+1
endon
full description on how to make the watermeter, is available here as PDF

PS how to configure domoticz is not included yet
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Water usage meter using esp8266 and proximity sensor

Post by jeroenkl »

thxs!
THBR
Posts: 37
Joined: Saturday 02 November 2019 21:05
Target OS: -
Domoticz version:
Contact:

Re: Water usage meter using esp8266 and proximity sensor

Post by THBR »

Hello,

I also use the 'puls counter' in ESPEASY as described by the above example, and also many false readings (high value peaks). Tried many settings without positive results.

So I disabled the counter in ESPEASY and made the two new devices as described in the attached PDF. However In Domoticz I get no readings of waterusage.

What's going wrong?

Thanks.
Attachments
Rules Set 1.jpg
Rules Set 1.jpg (24.08 KiB) Viewed 2346 times
Image 3.jpg
Image 3.jpg (27.33 KiB) Viewed 2346 times
Image 1.jpg
Image 1.jpg (65.93 KiB) Viewed 2346 times
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Water usage meter using esp8266 and proximity sensor

Post by Gravityz »

i think this design is not the best one.
also when you copy espeasy scripts you can not use them 1:1 if the setup is different.

i am using the pulsecounter without any problems but you need to know what is causing the false or spike pulses.
most of the time this is hardware related.

to help you out
i see 2 things which definately are not right.

TaskValueSet,2,1,0 writes value 0 into task 2, first entry(in your case DHT22 Temperatrure)
so this needs to be
TaskValueSet,4,1,0 (set the state back to zero.

the other
TaskValueSet,2,1,[Waterteller#Count]+1
needs to be
TaskValueSet,5,1,[Waterteller#Count]+1 (the counter is incremented.


personaly i do not think you need al those timers

if you get a pulse
go increment the counter
send that counter to domoticz

i think the Waterpulse state follows the state of the switch so if the switch is on it is 1, if not it is 0

so the trigger should be
On Waterpuls#State=1 do
increment counter
send it to domoticz
reset the state to zero so it does not get triggered multiple times

also on the switch you created you ned to specify a debounce time otherwise if keeps on bouncing
start with 100ms
hope this helps
THBR
Posts: 37
Joined: Saturday 02 November 2019 21:05
Target OS: -
Domoticz version:
Contact:

Re: Water usage meter using esp8266 and proximity sensor

Post by THBR »

Hi Gravityz,

Thanks for the info and sorry for the late response.

I am a rookie in this field...

I have implemented your tips and changes and in esp easy both devices seem to work fine now. Used liters are now displayed in esp easy under "count:".

However, the data (used liters) is not visible in Domoticz. There the counter remains at zero/is not updated?

But if I in the browser e.g. input
192.***.*.***:8080/json.htm?type=command&param=udevice&idx=141&svalue=15 results a status/title "ok"/"updated" and then the water counter in Domoticz is updated fine!

Furthermore, no errors in the logs of ESP easy and Domoticz. I am using version ESP_Easy_mega_20220328_normal_ESP8266_4M1M Mar 28 2022.

The other devices in esp easy (P1 en DHT22 work fine).

Any idea what could be the cause of this?

Regards, Theo.
Gravityz
Posts: 583
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Water usage meter using esp8266 and proximity sensor

Post by Gravityz »

and if you try this

SendToHTTP 192.168.1.xx,8080,/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=[Waterteller#Count]
THBR
Posts: 37
Joined: Saturday 02 November 2019 21:05
Target OS: -
Domoticz version:
Contact:

Re: Water usage meter using esp8266 and proximity sensor

Post by THBR »

Yes, that worked!

But, pff... now the actual value of the count in esp asy, e.g. 852, keeps increasing the waterteller in domoticz with 852 every 7? seconds without consuming water (a kind of loop). So in Domoticz its continues to increase by 852 liters every 7? second


My updated rules (devices unchanged):

On System#Boot do
timerset,6,30 // Data send Timer
Endon
On Rules#Timer=6 do //send data to domoticz
timerset,6,10 // reset data send timer
SendToHTTP 192.168.0.144,8080,/json.htm?type=command&param=udevice&idx=141&nvalue=0&svalue=[Waterteller#Count]
TaskValueSet,4,1,0 //reset waterpuls counter
Endon

On Waterpuls#State do
timerset,7,1
endon

On Rules#Timer=7 do
TaskValueSet,5,1,[Waterteller#Count]+1
endon


A part of the esp easy log (debug), see attachment.

Thanks again!
Attachments
log.txt
(15.35 KiB) Downloaded 51 times
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests