💬 Water Meter Pulse Sensor
-
Hi
I am trying to use the subject code with pulse water meters and hope someone can help to figure out what needs to be adjusted to get more accurate data.My setup:
Gateway ESP8266 (NodeMCU) + NRF24 -> Connected to Domoticz
Sensor node: Arduino Uno + NRF24
Default codes from Build. Test sensors so far work great.Task:
Need to connect Siemens WFK2 water meters (four of them actually) with pulse outputs (2 line). According to data sheet (link text) there are two types: reed output or NAMUR.To start with, I connected the reed output of the water meter via 10k resistor to +5V, GND and D3. Again, according to data sheet, for every 10l the water meter should give an impulse (e.g. connect the switch). Taking this into account I have adjusted pulse factor to 100 and based on Nominal Flow Rate (Max Flow Rate impossible in my case) limited Max Flow to 25 l/min. This setup works, but I definitely get wrong flow values (e.g. with constant flow of 6l/min serial monitor and domoticz report anything between 12-15l/min) and also wrong water usage m3 and litre usage in Domoticz.
When trying to debug, found out following behaviour (must be connected to Pulse length an Qn from data sheet IMHO):
with each turn it indeed switches on, e.g. shortens the contacts which generates pulse for the sensor, however it takes up to 2-4 litres until switch is in the off state.As a result you might have a situation when meter switches on, one closes the tap, and the signal is on for minutes/hours until tap is again opened and 2-4 litres have been used, after which signal will switch off.
Do I understand correctly that the debouncer which should take care of similar situations is not ready for this?
thanks in advance for support
-
Hi Aram
The original code from the mysensors site does not handle your situation very well (indeed because the switch staying on or off for a long time). You can use my code (see my post further up this discussion). In my case I have a pulse every 1 liter.
In your case you only have 1 pulse every 10 liters, which means you have to take a much longer period to calculate the flow correctly. Basically you have to set MIN_SEND_FREQ to a higher value. The flow is calculated based on the number of pulses in a given time period. Example: with 6 l/min you have to calculate this value only once every 5 minutes (=30 liter = 3 pulses from your Siemens meter) instead of every 30 seconds as I do. So if MIN_SEND_FREQ = 600 (every 5 minutes) your flow is calculated as:
flow = ((double) (pulseCount-oldPulseCount)) * (60000.0 / ((double) intervalcnt*(double) CHECK_FREQUENCY)) / ppl;
In the example above (pulseCount-oldPulseCount) = 3 pulses
ppl = 0.1
intervalcnt = MIN_SEND_FREQ = 600
CHECK_FREQUENCY = 500
==> flow is 6 l/minregards
Bart
-
bart59,
thanks for quick reply. I will try to adjust MIN_SEND_FREQ and use your code.
however, if I understand correctly, with the current logic used its impossible to avoid misinterpretations of pulses in case of very very long on or off state. It will approximate the flow rate to more correct value during usage of water (this is good enough) and should report total usage somehow correctly (this one I would better get as precise as possible). I wonder if the code will capture the correct number of pulses in the case of very long on state.BTW, I was not able to find a readily available sketch to connect NAMUR output, which is basically 5kOhm off state and 1.5795 kOhm on state. I believe, I will have to calculate required pull up resistance to get a proper voltage divider for 5\3.3v, right?
-
My code basically measures the time between two upward pulses. You can modify the code to also count the downward pulses. The net effect is that you will get a count every 5 liter (on average), but if there is no flow, the first pulse will always be off by 1-4 liter because you do not know how far the rotation is completed.
On NAMUR: you can actually use my code here too: I use analog input A1 to measure the voltage on the infra red sensor (which varies between 0 and 1.1 Volt). During the learn mode (set with a seaprate DIP switch) the code measures the input voltage for a period of 30 seconds while you turn open the water tap (you may want to increase the timing in your case) and then calculates the average between the lowest and highest voltage as the currect point there is a 1 or 0 coming from the pump (in my case it is an IR LED that is reflecting from a mirror into a photo sensor and the position of the mirror may change - resulting in different voltages).
regards
Bart -
Would anyone be able to help me get the hall sensor to work to work directly connected to an ESP8266 MQTT gateway? I was able to created the MQTT gateway, appended this sketch to the MQTT gateway sketch and connect the hall sensor DO to D12 (D3 is occupied), but when I subscribe to my mosquitto server no values are published. I am able to see the prefixes and they get published every 20 seconds as expected, but there are no sensor values. I plan on using this with home assistant, incase that helps with the final setup. If anyone has any recommendations it would be greatly appreciated.
-
Can you please roughly say
- what is the current consumption overall
- what is the current consumption when measuring a pulse
- what is the current consumed when the data is transmitted
-
Can you please roughly say
- what is the current consumption overall
- what is the current consumption when measuring a pulse
- what is the current consumed when the data is transmitted
@jagadesh-waran welcome to the MySensors community.
The current consumption depends on which Arduino you are using and which radio you are using.
Could you describe what your goal is?
Maybe the page on battery power can be useful.
-
@jagadesh-waran welcome to the MySensors community.
The current consumption depends on which Arduino you are using and which radio you are using.
Could you describe what your goal is?
Maybe the page on battery power can be useful.
@mfalkvidd im using mini at 8mhz with a 3V battery, No LDO and an ESP8266
I want to calculate the battery life say im using 3V 19000mah battery and if im consuming 100 gallons per day
Could you please update me the life of the battery?
Could you please update me the current consumptions at various intervals?
-
@mfalkvidd im using mini at 8mhz with a 3V battery, No LDO and an ESP8266
I want to calculate the battery life say im using 3V 19000mah battery and if im consuming 100 gallons per day
Could you please update me the life of the battery?
Could you please update me the current consumptions at various intervals?
-
I am trying this node. I have it set up. but I am having the same problem as Dirtbag. I am not getting any values. I debugged and I am getting 1 and 0 for my sensor output, so my sensor is working when I trigger it with a magnet.
Does this work with MQTT gateway?? am I missing something. Communication is fine between by ESP gateway and my node.?
Thanks ahead of time for any help with this. -
Hi. i'm having a strange problem using a arduino nano connecting a hall sensor to read my water meter. My water meter is dated from 1996 and i can't use the TCRT5000 sensor so i'm trying my luck with the hall sensor. My problem is that my arduino is always sending data.... even if i have the water turned off the most strange thing is that even when the arduino is not connected to the hall sensor it send's data. How can i fix this problem ?
-
Hi. i'm having a strange problem using a arduino nano connecting a hall sensor to read my water meter. My water meter is dated from 1996 and i can't use the TCRT5000 sensor so i'm trying my luck with the hall sensor. My problem is that my arduino is always sending data.... even if i have the water turned off the most strange thing is that even when the arduino is not connected to the hall sensor it send's data. How can i fix this problem ?
-
@mrc-core did you read this part of the instructions?
You can also set the frequency that the sensor will report the water consumption by updating the SEND_FREQUENCY. The default frequency 3 times per minute (every 20 seconds).
@mfalkvidd Yes i did but has you can see even when the hall sensor is not connected the arduino sends data and the water increases in the the gateway. I can work on the SEND_FREQUENCY and see if it fix this problem.
Thnaks for the replay
-
Have been working with the code and have found one strange thing. When my sensor sends data to the gateway "domoticz" the gateway sends a value to the sensor. The strange thing is that my arduino does not have any sensor connected and sow the data send is zero but my gateway sends akways a positive value and increases this value every time it sends data to the arduino.
Even if i go to the arduino code and set the volume and pulseCount to 0 flash it to the arduino, load the value of zero to the gateway and then e flash the same code but this time i remove the volume and pulseCount to 0 the first time the arduino sends data to the gateway it always receive a value insted of zero since i dont have the hall sensor connected to the arduino.
I'm using a arduino mini pro 3.3v on a easy pcb by soundberg81 and i have setup the digital pin2 to connect the hall sensor.
Here's some log from my arduino:
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=1
14 TSM:FPAR
51 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
1032 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
1037 TSF:MSG:FPAR OK,ID=0,D=1
2058 TSM:FPAR:OK
2059 TSM:ID
2060 TSM:ID:OK
2062 TSM:UPL
2065 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2172 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2178 TSF:MSG:PONG RECV,HP=1
2181 TSM:UPL:OK
2182 TSM:READY:ID=1,PAR=0,DIS=1
2187 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2320 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2327 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
2335 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
3517 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
3526 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=OK:Water Meter
3535 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=5,sg=0,ft=0,st=OK:2.4.B
3544 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=21,pt=0,l=11,sg=0,ft=0,st=OK:Hall Sensor
3551 MCO:REG:REQ
3589 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
5596 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
5665 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
5670 MCO:PIM:NODE REG=1
5673 MCO:BGN:STP
5677 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=25,pt=0,l=0,sg=0,ft=0,st=OK:
5683 MCO:BGN:INIT OK,TSP=1
6484 TSF:MSG:READ,0-0-1,s=1,c=2,t=25,pt=0,l=1,sg=0:0
Received last pulse count from gw:2
pulsecount:2
35686 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:2
volume:0.003
35694 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.003
l/min:2.05
65687 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.05
pulsecount:4
65695 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:4
volume:0.004
65704 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.004
l/min:0.00
95688 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:5
95696 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:5
volume:0.005
95706 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.005
pulsecount:5
125689 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:5
volume:0.006
125698 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.006
l/min:2.00
155691 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:7
155699 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:7
volume:0.007
155708 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.007
l/min:0.00
185691 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:8
185699 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:8
volume:0.008
185708 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.008
pulsecount:8
215696 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:8
volume:0.009
215707 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.009
l/min:2.00
245693 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:10
245701 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:10
volume:0.010
245710 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.010
l/min:0.00
275694 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:11
275702 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:11
volume:0.011
275714 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.011
pulsecount:11
305695 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:11
volume:0.012
305703 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.012
l/min:2.00
335698 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:13
335707 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:13
volume:0.013
335718 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.013
l/min:0.00
365732 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:14
365776 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=NACK:14
volume:0.014
365788 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=1,st=OK:0.014
376929 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
376934 TSF:MSG:BC
377041 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
l/min:5.36
395735 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=NACK:5.36
pulsecount:16Again since i'm geting this problem i don't have my sensor connected to the arduino.
-
Have been working with the code and have found one strange thing. When my sensor sends data to the gateway "domoticz" the gateway sends a value to the sensor. The strange thing is that my arduino does not have any sensor connected and sow the data send is zero but my gateway sends akways a positive value and increases this value every time it sends data to the arduino.
Even if i go to the arduino code and set the volume and pulseCount to 0 flash it to the arduino, load the value of zero to the gateway and then e flash the same code but this time i remove the volume and pulseCount to 0 the first time the arduino sends data to the gateway it always receive a value insted of zero since i dont have the hall sensor connected to the arduino.
I'm using a arduino mini pro 3.3v on a easy pcb by soundberg81 and i have setup the digital pin2 to connect the hall sensor.
Here's some log from my arduino:
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=1
14 TSM:FPAR
51 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
1032 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
1037 TSF:MSG:FPAR OK,ID=0,D=1
2058 TSM:FPAR:OK
2059 TSM:ID
2060 TSM:ID:OK
2062 TSM:UPL
2065 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2172 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2178 TSF:MSG:PONG RECV,HP=1
2181 TSM:UPL:OK
2182 TSM:READY:ID=1,PAR=0,DIS=1
2187 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2320 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2327 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
2335 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
3517 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
3526 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=OK:Water Meter
3535 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=5,sg=0,ft=0,st=OK:2.4.B
3544 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=21,pt=0,l=11,sg=0,ft=0,st=OK:Hall Sensor
3551 MCO:REG:REQ
3589 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
5596 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
5665 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
5670 MCO:PIM:NODE REG=1
5673 MCO:BGN:STP
5677 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=25,pt=0,l=0,sg=0,ft=0,st=OK:
5683 MCO:BGN:INIT OK,TSP=1
6484 TSF:MSG:READ,0-0-1,s=1,c=2,t=25,pt=0,l=1,sg=0:0
Received last pulse count from gw:2
pulsecount:2
35686 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:2
volume:0.003
35694 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.003
l/min:2.05
65687 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.05
pulsecount:4
65695 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:4
volume:0.004
65704 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.004
l/min:0.00
95688 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:5
95696 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:5
volume:0.005
95706 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.005
pulsecount:5
125689 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:5
volume:0.006
125698 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.006
l/min:2.00
155691 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:7
155699 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:7
volume:0.007
155708 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.007
l/min:0.00
185691 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:8
185699 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:8
volume:0.008
185708 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.008
pulsecount:8
215696 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:8
volume:0.009
215707 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.009
l/min:2.00
245693 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:10
245701 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:10
volume:0.010
245710 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.010
l/min:0.00
275694 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:11
275702 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:11
volume:0.011
275714 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.011
pulsecount:11
305695 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:11
volume:0.012
305703 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.012
l/min:2.00
335698 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:13
335707 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:13
volume:0.013
335718 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.013
l/min:0.00
365732 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:14
365776 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=NACK:14
volume:0.014
365788 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=1,st=OK:0.014
376929 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
376934 TSF:MSG:BC
377041 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
l/min:5.36
395735 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=NACK:5.36
pulsecount:16Again since i'm geting this problem i don't have my sensor connected to the arduino.
-
@mrc-core if nothing is connected to the sensor pin, the pin will float and might create spurious interrupts. Connect the pin to gnd to make sure it doesn't get any false triggers.
@mfalkvidd Thanks. Have now connected the digital pin2 to gnd and in the last 1h the values are always 0.000 going to leave it this way until night since now i'm at work. I would like to find out what was creating the spurious interrupts??
Other thing that ill find out tonight is when i connect the sensor to the arduino will it create rong data or will it only send real data only when the water meter starts running water...One more thing today at 8:00 when i did the pin2 to gnd the first "boot" over domoticz i got this value as you can see on the image below. Is this normal? Have been trying to deleted but it wont go away.
Once again thanks for your help.

-
@mfalkvidd Thanks. Have now connected the digital pin2 to gnd and in the last 1h the values are always 0.000 going to leave it this way until night since now i'm at work. I would like to find out what was creating the spurious interrupts??
Other thing that ill find out tonight is when i connect the sensor to the arduino will it create rong data or will it only send real data only when the water meter starts running water...One more thing today at 8:00 when i did the pin2 to gnd the first "boot" over domoticz i got this value as you can see on the image below. Is this normal? Have been trying to deleted but it wont go away.
Once again thanks for your help.

@mrc-core
The spurious interrups are caused by the open line. The Arduino has high impedance inputs and anything from a WiFi signal or the signal from a close by circuit can cause the value to swing between 0 and 3 Volt, triggering your input. See https://www.arduino.cc/en/Tutorial/DigitalPinsOn your high value in the graph: Domoticz water sensors require the sensor to post the total water volume. This means that the sensor needs to "know" the total of volumes from all the past measurements. In fact all the (wrong) past pulses you generated with the open input are stored by the sensor. There are 2 ways this storage mechanism can be realized in Arduino code:
(1) keep the value in the Arduino EEPROM and
(2) use a build in feature of Domoticz to store values on behalf of sensors.Mysesnsors uses method 2 as method (1) has 2 disadvantages: The code needs to continuously write to the EEPROM, because you never know when the Arduino will be rebooted. The EEPROM on the Arduino chip does not allow you to write to it that often (max 100,000 times or so) and the EEPROM is cleared when you update the software. The sketch used by MySensors uses method (2) by sending the pulsecount to the gateway using send(lastCounterMsg.set(pulseCount)) statement at the same time the volume is sent to Domoticz with send(volumeMsg.set(volume, 3)); At each reboot the sensor requests the value of VAR1 from the gateway using request(CHILD_ID, V_VAR1); The sensor does not send any data to the gateway until the gateway has received the counter past value. The receive() function is called by the Mysensor library when data comes back from the gateway. There the pulseCount += gwPulseCount statement adds the value to the pulseCount.
This means the sensor will not be able to "forget" the pulses that came from the period your digital input was not connected.
There are 3 ways to fix this problem:
- you can delete your sensor at the Domoticz side (throwing away all history): First power down your Arduino sensor, the go into Domoticz screen and remove the sensor from the Utility screen and then remove the sensor from the Setup->Hardware->MysensorsGW->Setup->Click on your water meter-> delete all Children-> delete the water meter sensor itself. Then power up your Arduino and you will see the sensor show up again.
- as above: remove your sensor from the Utilities tab and change the code to give your sensor another new ID. At the top of your code you can put a statement like
#define MY_NODE_ID 10This will be the ID number that shows in the hardware setup screen in Domoticz for your sensor. If you omit this code MySensors will create a new (unique) code for you. However in my system I prefer to allocate the numbers myself to each sensor. So a quick way to create a brand new sensor history in Domoticz is to simply change the MY_NODE_ID number (change from 10 to 11).
- change yuor Arduino code to force a 0 in the VAR1 holding variable for your sensor. You can do that by adding a statement send(lastCounterMsg.set(0)); inside your loop() function (best place is here):
// Only send values at a maximum frequency or woken up from sleep if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY)) { lastSend=currentTime; send(lastCounterMsg.set(0)); // <--- keep here shortly and remove later if (!pcReceived) { //Last Pulsecount not yet received from controller, request it again request(CHILD_ID, V_VAR1); return; }You will compile and upload this code to your Arduino and let it run for a minute or so, then remove the line and upload the orginal code. You should now be able to remove the data point in Domoticz (by using ctrl-mouseclick on the graphic item)
Hope this helps
Bart
-
@mrc-core
The spurious interrups are caused by the open line. The Arduino has high impedance inputs and anything from a WiFi signal or the signal from a close by circuit can cause the value to swing between 0 and 3 Volt, triggering your input. See https://www.arduino.cc/en/Tutorial/DigitalPinsOn your high value in the graph: Domoticz water sensors require the sensor to post the total water volume. This means that the sensor needs to "know" the total of volumes from all the past measurements. In fact all the (wrong) past pulses you generated with the open input are stored by the sensor. There are 2 ways this storage mechanism can be realized in Arduino code:
(1) keep the value in the Arduino EEPROM and
(2) use a build in feature of Domoticz to store values on behalf of sensors.Mysesnsors uses method 2 as method (1) has 2 disadvantages: The code needs to continuously write to the EEPROM, because you never know when the Arduino will be rebooted. The EEPROM on the Arduino chip does not allow you to write to it that often (max 100,000 times or so) and the EEPROM is cleared when you update the software. The sketch used by MySensors uses method (2) by sending the pulsecount to the gateway using send(lastCounterMsg.set(pulseCount)) statement at the same time the volume is sent to Domoticz with send(volumeMsg.set(volume, 3)); At each reboot the sensor requests the value of VAR1 from the gateway using request(CHILD_ID, V_VAR1); The sensor does not send any data to the gateway until the gateway has received the counter past value. The receive() function is called by the Mysensor library when data comes back from the gateway. There the pulseCount += gwPulseCount statement adds the value to the pulseCount.
This means the sensor will not be able to "forget" the pulses that came from the period your digital input was not connected.
There are 3 ways to fix this problem:
- you can delete your sensor at the Domoticz side (throwing away all history): First power down your Arduino sensor, the go into Domoticz screen and remove the sensor from the Utility screen and then remove the sensor from the Setup->Hardware->MysensorsGW->Setup->Click on your water meter-> delete all Children-> delete the water meter sensor itself. Then power up your Arduino and you will see the sensor show up again.
- as above: remove your sensor from the Utilities tab and change the code to give your sensor another new ID. At the top of your code you can put a statement like
#define MY_NODE_ID 10This will be the ID number that shows in the hardware setup screen in Domoticz for your sensor. If you omit this code MySensors will create a new (unique) code for you. However in my system I prefer to allocate the numbers myself to each sensor. So a quick way to create a brand new sensor history in Domoticz is to simply change the MY_NODE_ID number (change from 10 to 11).
- change yuor Arduino code to force a 0 in the VAR1 holding variable for your sensor. You can do that by adding a statement send(lastCounterMsg.set(0)); inside your loop() function (best place is here):
// Only send values at a maximum frequency or woken up from sleep if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY)) { lastSend=currentTime; send(lastCounterMsg.set(0)); // <--- keep here shortly and remove later if (!pcReceived) { //Last Pulsecount not yet received from controller, request it again request(CHILD_ID, V_VAR1); return; }You will compile and upload this code to your Arduino and let it run for a minute or so, then remove the line and upload the orginal code. You should now be able to remove the data point in Domoticz (by using ctrl-mouseclick on the graphic item)
Hope this helps
Bart
@bart59 Thanks have done like you said and did clean the data from the gateway.
All day until 1h ago i had left my arduino connected on my pc and i did like mfalkvidd said connecting the digital pin 2 to gnd and my arduino did not send any strange value to the gateway always seend volume 0.00 this was perfect.
Now that i'm at home i had connect my arduino to the sensor 3.3v gnd and digital pin2 and in the first log there it was value increase on volume when my sensor was in front off me...I have a arduino nano pro 3.3v on easy pcb board and i'm using the hall sensor i dont see why i'm getting this problem...
I have a WiFi AP inside home and my sensor is outside.Even the water flow says i have a 2.00 L/min when the sensor is not near the water meter.
-
@bart59 Thanks have done like you said and did clean the data from the gateway.
All day until 1h ago i had left my arduino connected on my pc and i did like mfalkvidd said connecting the digital pin 2 to gnd and my arduino did not send any strange value to the gateway always seend volume 0.00 this was perfect.
Now that i'm at home i had connect my arduino to the sensor 3.3v gnd and digital pin2 and in the first log there it was value increase on volume when my sensor was in front off me...I have a arduino nano pro 3.3v on easy pcb board and i'm using the hall sensor i dont see why i'm getting this problem...
I have a WiFi AP inside home and my sensor is outside.Even the water flow says i have a 2.00 L/min when the sensor is not near the water meter.
-
New update.... have change the arduino mini pro for another one flash a new code a new sensor and again i'm getting volume data when the sensor is not near the water meter. I dont understand what's happening.
@mrc-core Just to make sure: are you connecting/disconnecting the data pin to your sensor when the Arduino is powered off and are you sure the connection is solid? If you connect things with power on you may accidently trigger a pulse a 100 times.... which will be sent to the gateway 20 secs later. Always power off stuff first and use a solid connection (soldering is always better) when making modifications. How did you power the hall sensor? Should be from the 3.3V VCC connector of the Arduino and not from the higher voltage or something separate. Can you upload a photo of your setup to allow us to see how you connect things?
Bart