Page 10 of 20

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 18 November 2017 15:38
by pvangorp
My diode gives 3,3v :o 1,7v might be to low. Did you get the correct diode?

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 18 November 2017 16:38
by Draakje
pvangorp wrote: Saturday 18 November 2017 15: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)

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 18 November 2017 16:53
by Draakje
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,

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 18 November 2017 17:13
by Draakje
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)

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 18 November 2017 20:28
by pvangorp
Draakje wrote: Saturday 18 November 2017 16:38
pvangorp wrote: Saturday 18 November 2017 15: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

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Monday 20 November 2017 7:45
by Draakje
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 )

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Monday 20 November 2017 15:20
by philchillbill
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 !

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Monday 20 November 2017 15:49
by Draakje
philchillbill wrote: Monday 20 November 2017 15: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 :)

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 21 November 2017 15:39
by philchillbill
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).

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Thursday 30 November 2017 14:16
by sammyke007
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!

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Friday 01 December 2017 9:59
by raymonvdm
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

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Friday 01 December 2017 16:48
by sammyke007
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 !

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Friday 01 December 2017 17:37
by sammyke007
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..' " ')

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 02 December 2017 9:41
by LouiS22
sammyke007 wrote: Friday 01 December 2017 17: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!

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 02 December 2017 18:48
by LouiS22
And the last question: which virtual sensor should I use on my Master? Counter or Counter incremental?

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 02 December 2017 18:52
by sammyke007
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...

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 05 December 2017 9:32
by philchillbill
Draakje wrote: Saturday 18 November 2017 17: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.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 05 December 2017 9:39
by Draakje
philchillbill wrote: Tuesday 05 December 2017 9: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!

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 05 December 2017 9:39
by Trigun
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

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 05 December 2017 22:52
by sammyke007
viewtopic.php?f=32&t=20751

Here is a quick write up!