Watermeter lezen met raspberry en Inductieve NPN sensor Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
pvangorp
Posts: 116
Joined: Tuesday 28 March 2017 10:18
Target OS: Raspberry Pi
Domoticz version: Latest B
Location: The Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by pvangorp » Saturday 18 November 2017 16:38

My diode gives 3,3v :o 1,7v might be to low. Did you get the correct diode?

Draakje
Posts: 113
Joined: Thursday 22 October 2015 21:14
Target OS: Linux
Domoticz version: 3.5468
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Draakje » Saturday 18 November 2017 17:38

pvangorp wrote:
Saturday 18 November 2017 16:38
My diode gives 3,3v :o 1,7v might be to low. Did you get the correct diode?
Well I checked the number on the diode (1n746a) and according to the specs this should be a 3,3v zener..

But it does give the readings but like a thousand to high.. (as in 0,001 reports as 1)
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch

Draakje
Posts: 113
Joined: Thursday 22 October 2015 21:14
Target OS: Linux
Domoticz version: 3.5468
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Draakje » Saturday 18 November 2017 17:53

Could someone explain the bouncetime option ?

As my meter increases way to hard I must do some fine tuning.. And before I go and alter all kinds of options and break the whole thing....

I might have stumbled onto something. Maybe somebody can confirm..
When I enter my watermeter reading I only enter the liters not the numbers behind the comma..
As I read the first post again.. I notice that I shoul enter the whole number..
As in 592,123 meterstand = 592123 (and not what I did 592)


edit2 :
So I just did it :)
and with a small test it all worked just fine..
Will have to see in a few weeks if the meter is still accurate

For all the fans.. A pic :)
I just drilled a hole in the correct spot and bolted the sensor :)
Regards,
Attachments
IMG_0058.jpg
IMG_0058.jpg (391.04 KiB) Viewed 2584 times
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch

Draakje
Posts: 113
Joined: Thursday 22 October 2015 21:14
Target OS: Linux
Domoticz version: 3.5468
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Draakje » Saturday 18 November 2017 18:13

O still one question,

Over time the meter will turn offline (red) this is just because no water has been used in a time period.
Is there some setting to set to not have the meter turn offline? (the meter will come online when water is used)
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch

pvangorp
Posts: 116
Joined: Tuesday 28 March 2017 10:18
Target OS: Raspberry Pi
Domoticz version: Latest B
Location: The Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by pvangorp » Saturday 18 November 2017 21:28

Draakje wrote:
Saturday 18 November 2017 17:38
pvangorp wrote:
Saturday 18 November 2017 16:38
My diode gives 3,3v :o 1,7v might be to low. Did you get the correct diode?
Well I checked the number on the diode (1n746a) and according to the specs this should be a 3,3v zener..

But it does give the readings but like a thousand to high.. (as in 0,001 reports as 1)
Go to settings, meters and set the RFXMeter for water to 1000. Thats all

Draakje
Posts: 113
Joined: Thursday 22 October 2015 21:14
Target OS: Linux
Domoticz version: 3.5468
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Draakje » Monday 20 November 2017 8:45

Well the meter is working and Have to see if the measurement is correct..( as said before I will check it after a week )

Bit different question and this may just be something cosmetic..

As seen in the picture it says I have consumed 134 Liters.. This is of course not correct (or at least I think so) I believe it should be 0,134
I say this because the total consumption seems about right..

Is this something which can be changed?

(RFXMeter is set to 1000 )
Attachments
Screen Shot 2017-11-20 at 07.42.34.png
Screen Shot 2017-11-20 at 07.42.34.png (25.69 KiB) Viewed 2547 times
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch

User avatar
philchillbill
Posts: 239
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by philchillbill » Monday 20 November 2017 16:20

Your meter produces 1 pulse per liter so measuring 0,134 liters is impossible. The average water consumption per day in the Netherlands is 119 liters per person so 134 sounds dead right to me !
NUC/Ubuntu, Evohome Heating + HGI80, Evohome Security, 4x HikVision IP cams, Aeotec, Neo & Fibaro Z-Wave, Logitech Media Server (on Synology DS916+), 10x SqueezeBox, Kodi, Harmony Hub, 5x Amazon Echo, HA-Bridge, Hue.

Draakje
Posts: 113
Joined: Thursday 22 October 2015 21:14
Target OS: Linux
Domoticz version: 3.5468
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Draakje » Monday 20 November 2017 16:49

philchillbill wrote:
Monday 20 November 2017 16:20
Your meter produces 1 pulse per liter so measuring 0,134 liters is impossible. The average water consumption per day in the Netherlands is 119 liters per person so 134 sounds dead right to me !
Ok Now I see what I am doing wrong..
I compare 1m3 with 1 liter .. and that is not correct..
1m3 = 1000 liters.. (thanks philchillbill)

:oops: me feeling stupid :)

Well anyway thanks for the answer :)
Last edited by Draakje on Tuesday 21 November 2017 17:01, edited 1 time in total.
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch

User avatar
philchillbill
Posts: 239
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by philchillbill » Tuesday 21 November 2017 16:39

No worries. but just to be correct: 1m3 is 1000 liters, not .001 liter. It's a cubic-meter of water. You have it the wrong way round (still).
NUC/Ubuntu, Evohome Heating + HGI80, Evohome Security, 4x HikVision IP cams, Aeotec, Neo & Fibaro Z-Wave, Logitech Media Server (on Synology DS916+), 10x SqueezeBox, Kodi, Harmony Hub, 5x Amazon Echo, HA-Bridge, Hue.

sammyke007
Posts: 33
Joined: Monday 08 May 2017 20:48
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Belgium
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by sammyke007 » Thursday 30 November 2017 15:16

Hallo allemaal

Ik ben volop bezig mijn watermeter (België) uit te lezen.
Het betreft dit type meter:
Image. Je kan deze uitlezen met een hallsensor gezien er een uitsparing is, waarin deze past (links op de foto, zwart plastic kapje verwijderen en de op kabel gesoldeerde hall sensor inschuiven).
Ik gebruik een RPI 3. Op GPIO 21 (pin 40) steekt een KY024 (met hall sensor) dewelke een puls geeft elke keer als het meest rechtse getal (nr 2 op de foto, deciliter dus als ik het juist voor heb) 1x volledig rond gaat. Dus per liter krijg ik een puls door op mijn hall sensor. Dat werkt ook momenteel.

Ik gebruik een licht gewijzigd script;

Code: Select all

import RPi.GPIO as GPIO
import time
import urllib
import os


idx = 90
#Reset TimerKeepAlive
TimerKeepAlive = 0

#Board is pin nr, BMC is GPIO nr
#Read output from water meter op pin 40
GPIO.setmode(GPIO.BOARD)
# Set GPIO 21 (Pin 40) als Input aditional as Pullup activated
GPIO.setup(40, GPIO.IN, pull_up_down = GPIO.PUD_UP)

#Functie  callback
#Funtion used by interruptcall
def Interrupt(channel):
  
  #Send counter to domoticz JSON
  global Counter
  Counter = 1
  httpresponse = urllib.urlopen("http://192.168.1.190:8084/json.htm?type=command&param=udevice&idx="+str(idx)+"&svalue="+str(Counter))
  #For debug => print example of JSON-call
  #print "JSON call = "+ str(url1)
  print "Watermeter Counter = " + str(Counter)

#Interrupt-Event, NPN off a sensor is 1 and detection is 0
#Detection is 0,falling interupt
GPIO.add_event_detect(40, GPIO.FALLING, callback = Interrupt, bouncetime = 350)

try:
  while True:

        #Send every 50 minutes [300sec] an update to keep sensor alive in Domoticz
        TimerKeepAlive = TimerKeepAlive + 1
        print "Counting time " + str(TimerKeepAlive)
        if TimerKeepAlive > 1800:

                httpresponse = urllib.urlopen("http://192.168.1.190:8084/json.htm?type=command&param=udevice&idx=90&svalue=0")
                #For debug => print JSON-call
                #print "JSON call = "+ str(url1)

                TimerKeepAlive = 0
        else:
                time.sleep(1)
except KeyboardInterrupt:
  GPIO.cleanup()
  print "\nBye"
Dit lijkt vrij goed te werken. Alleen als ik mijn kraan dichtdraai op het moment dat de magneet bij de hall sensor staat (en het ledje dus oplicht op de KY024), dan blijft de counter optellen.

Iemand enig idee aub?
Alvast bedankt!

raymonvdm
Posts: 10
Joined: Tuesday 29 March 2016 10:17
Target OS: Linux
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by raymonvdm » Friday 01 December 2017 10:59

I build a watermeter based on a NodeMCU and LJ12A3-4-Z/BX and this is working fine. However the Arduino Sketch i used boots with the counter on 0 and starts couting until the next reboot (which is fine for now)

I`m sending the data to Domoticz every 5 minutes but Domoticz is adding the values to the counter. So for example if the count is 16 Liter the value of 16.00 is send every 5 minutes. The value for Domoticz is 16.00 after 5 minutes, 32.00 after 10 minutes, 48.00 after 15 minutes.

This is wrong and i need to change the IDX to be a Delta Counter (is this possible in domoticz?)

Code: Select all


/json.htm?type=command&param=udevice&idx=258&svalue=16.00

Device Type = Counter Incremental (Water 1000/m3)

Code: Select all


/json.htm?type=devices&rid=258

{
   "ActTime" : 1512119268,
   "ServerTime" : "2017-12-01 10:07:48",
   "Sunrise" : "08:26",
   "Sunset" : "16:24",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 939827.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "Counter" : "590.002 m3",
         "CounterToday" : "282.293 m3",
         "CustomImage" : 0,
         "Data" : "590.002 m3",
         "Description" : "",
         "Favorite" : 1,
         "HardwareID" : 5,
         "HardwareName" : "Dummy",
         "HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
         "HardwareTypeVal" : 15,
         "HaveTimeout" : false,
         "ID" : "82258",
         "LastUpdate" : "2017-12-01 10:06:48",
         "Name" : "Water Meter",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "SubType" : "Counter Incremental",
         "SwitchTypeVal" : 2,
         "Timers" : "false",
         "Type" : "General",
         "TypeImg" : "counter",
         "Unit" : 1,
         "Used" : 1,
         "ValueQuantity" : "",
         "ValueUnits" : "",
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "258"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}






Note: In the end i need to modify the arduino sketch to just send the total usage and keep the value during reboots. But for now i want to change the domoticz IDX

sammyke007
Posts: 33
Joined: Monday 08 May 2017 20:48
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Belgium
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by sammyke007 » Friday 01 December 2017 17:48

Micha123 wrote:
Wednesday 06 September 2017 0:13
Im set LUA to DEVICE

Im checking the names again and again. I became that error message.

Maybe i test it with an other browser to start the lua script but i dont think what the problem is....


tested again, script startet, readed the Value from virtual Counter, so i restart the pi and after a simply restart i got the error again.
Micha, after failing with the Python script, I got the LUA script working and it works great!
Your error is shown, because you didn't make the Uservariable WaterMeter in Domoticz!

So in Domoticz > Setup > more > user variables
Name WaterMeter
type integer
value "current stand of your real meter"
Add !

sammyke007
Posts: 33
Joined: Monday 08 May 2017 20:48
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Belgium
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by sammyke007 » Friday 01 December 2017 18:37

LouiS22 wrote:
Monday 23 October 2017 10:19
Trigun wrote:
Friday 13 October 2017 21:33
pvangorp wrote:
Friday 13 October 2017 21:27
What happens when you swap the commandarray and weet line order. The print above the commandarray is in the log?
something happend.

Code: Select all

2017-10-13 21:29:06.049 LUA: Water usage is still 173.005m3
2017-10-13 21:29:06.050 LUA: wget http://192.168.1.94:8080/json.htm?type=command¶m=udevice&idx=157&svalue=173005 -O /dev/null
2017-10-13 21:29:06.067 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Watermeter.lua
but unfortunately nothing happens on the other device.

i just found out that I never see the following print:

Code: Select all

print("Water usage is set to " .. sWaterUsageTot / 1000 .. "m3 ");
is this correct or should it only set once, in the beginning?
Have you found the bug yet?
Louis22, the correct command is:

Code: Select all

os.execute('curl "http://192.168.1.190:8084/json.htm?param=udevice&type=command&idx=91&svalue='..sWaterUsageTot..'"')
the HTTP link needs to be in between " " so when I seperate it for readability:

Code: Select all

os.execute('curl "http://192.168.1.190:8084/json.htm?param=udevice&type=command&idx=91&svalue='..sWaterUsageTot..' " ')

User avatar
LouiS22
Posts: 502
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by LouiS22 » Saturday 02 December 2017 10:41

sammyke007 wrote:
Friday 01 December 2017 18:37
LouiS22 wrote:
Monday 23 October 2017 10:19
Trigun wrote:
Friday 13 October 2017 21:33


something happend.

Code: Select all

2017-10-13 21:29:06.049 LUA: Water usage is still 173.005m3
2017-10-13 21:29:06.050 LUA: wget http://192.168.1.94:8080/json.htm?type=command¶m=udevice&idx=157&svalue=173005 -O /dev/null
2017-10-13 21:29:06.067 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_Watermeter.lua
but unfortunately nothing happens on the other device.

i just found out that I never see the following print:

Code: Select all

print("Water usage is set to " .. sWaterUsageTot / 1000 .. "m3 ");
is this correct or should it only set once, in the beginning?
Have you found the bug yet?
Louis22, the correct command is:

Code: Select all

os.execute('curl "http://192.168.1.190:8084/json.htm?param=udevice&type=command&idx=91&svalue='..sWaterUsageTot..'"')
the HTTP link needs to be in between " " so when I seperate it for readability:

Code: Select all

os.execute('curl "http://192.168.1.190:8084/json.htm?param=udevice&type=command&idx=91&svalue='..sWaterUsageTot..' " ')
Mate, THANK YOU! Indeed that was my problem, now it's okay and I'm happy :) Thanks again!

User avatar
LouiS22
Posts: 502
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by LouiS22 » Saturday 02 December 2017 19:48

And the last question: which virtual sensor should I use on my Master? Counter or Counter incremental?

sammyke007
Posts: 33
Joined: Monday 08 May 2017 20:48
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Belgium
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by sammyke007 » Saturday 02 December 2017 19:52

Just create it with the JSON command from the first page of this post. Don't forget to change the IP!

I'll write a full guide tomorrow if OK for the authors because everything is spread now...

User avatar
philchillbill
Posts: 239
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by philchillbill » Tuesday 05 December 2017 10:32

Draakje wrote:
Saturday 18 November 2017 18:13
Over time the meter will turn offline (red) this is just because no water has been used in a time period.
Is there some setting to set to not have the meter turn offline? (the meter will come online when water is used)
Go to Setup -> Settings -> Other -> Sensor Timeout and set a value that's long enough for you. I have 4320 which is 72 hours = 3 days.
NUC/Ubuntu, Evohome Heating + HGI80, Evohome Security, 4x HikVision IP cams, Aeotec, Neo & Fibaro Z-Wave, Logitech Media Server (on Synology DS916+), 10x SqueezeBox, Kodi, Harmony Hub, 5x Amazon Echo, HA-Bridge, Hue.

Draakje
Posts: 113
Joined: Thursday 22 October 2015 21:14
Target OS: Linux
Domoticz version: 3.5468
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Draakje » Tuesday 05 December 2017 10:39

philchillbill wrote:
Tuesday 05 December 2017 10:32

Go to Setup -> Settings -> Other -> Sensor Timeout and set a value that's long enough for you. I have 4320 which is 72 hours = 3 days.
Thanks!
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch

Trigun
Posts: 187
Joined: Wednesday 30 November 2016 12:58
Target OS: Raspberry Pi
Domoticz version: 4.9700
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Trigun » Tuesday 05 December 2017 10:39

sammyke007 wrote:Just create it with the JSON command from the first page of this post. Don't forget to change the IP!

I'll write a full guide tomorrow if OK for the authors because everything is spread now...
Hi Sammyke007,

I followed your feedback for a while and just wanted to say thanks! It’s been a great help!!
I am looking forward to your guide!

Grtz


Sent from my iPhone using Tapatalk

sammyke007
Posts: 33
Joined: Monday 08 May 2017 20:48
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Belgium
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by sammyke007 » Tuesday 05 December 2017 23:52

viewtopic.php?f=32&t=20751

Here is a quick write up!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests