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.
Post Reply
markiemark
Posts: 1
Joined: Thursday 13 April 2017 21:24
Target OS: Raspberry Pi
Domoticz version:
Contact:

Watermeter lezen met raspberry en Inductieve NPN sensor

Post by markiemark » Thursday 13 April 2017 23:45

Water meter uitlezen alleen met een Inductieve naderingsschakelaar en domoticz op een raspberry pi. Ik hoop dat het blogje duidelijk en volledig is. Zelf ben ik namelijk niet zo handig met python en had af en toe een uurtje over om het in elkaar te knutselen. Omdat ik deze oplossing nog nergens voorbij heb zien komen toch maar even een blog berichtje gemaak.

meter.jpg
meter.jpg (66.66 KiB) Viewed 4826 times
Je heb alleen een sensor van b.v. Aliexpress of eBay nodig van rond de $2,00 een beugeltje en een paar avonden om het werkend te krijgen :lol: . En natuurlijk een watermeter met een klein draaiend metertje met een ijzeren plaatje.
zelf heb ik deze sensor van alie gebruikt
KSOL DC6-36V 300mA NPN GEEN 3-wire 4mm Tubular Inductieve Proximity Sensor Switch LJ12A3-4-Z-BX
Inductieve-Sensor.jpg
Inductieve-Sensor.jpg (9.56 KiB) Viewed 4826 times
===================================
Sensor aansluiten
===================================
Sensor met een beugeltje aan de watermeter bevestigen en aansluiten op de raspberry pi:
Blauw = GND (b.v. pin 39)
Bruin = 5V (b.v. pin 2 of 4)
Zwart = GPIO (b.v. GPIO 21 / Pin 40)
Het is een 6-36 volt sensor maar werkt bij mij perfect op 5v van de raspberry.


=================================
Domoticz Teller aanmaken
=================================
Ik heb niet kunnen vinden hoe je dit via Domoticz web kan doen. Het lukte mij alleen om via json de RFXmeter aan te maken.
1 = maak sensor
2 = lees IDX
3 = maak RFXMeter aan met juiste IDX
Gebruik je eigen IP en poort nummer.
Let op dat je in domoticz settings, de deler van water op 1000 zet => RFXMeter/Meter delers water: 1000
385762.png
385762.png (25.14 KiB) Viewed 4826 times
1

Code: Select all

192.168.1.123:8080/json.htm?type=createvirtualsensor&idx=29&sensorname=Water&sensortype=113
{
"status" : "OK",
"title" : "CreateVirtualSensor"
}

2

Code: Select all

192.168.1.123:8080/json.htm?type=devices&filter=all&used=true&order=Name
{
"AddjMulti" : 1.0,
.....
"idx" : "321"
}

3
De IDX invullen in de JSON call

Code: Select all

      
192.168.1.123:8080/json.htm?type=setused&idx=321&name=RFXMeter&switchtype=2&used=true
{
"status" : "OK",
"title" : "SetUsed"
}
[/code]

====================================
Script watermeter.py
====================================
Met dit python script lees je de GPIO uit en schrijf je elke liter waterverbruik via JSON naar domoticz.
Plaats script in /home/pi/domoticz/scripts/
Vul watermeterstand in bij "Counter"
Ook de GPIO en de IDX met juiste waarde vullen.

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import urllib2
import os

#Watermeter stand (wordt alleen initeel gebruikt als er geen bestand meterstand.txt is)
global Counter
Counter = 1154651

#Domoticz URL
domoticz_url = "http://192.168.1.123:8080"
#Domoticz IDX van de water sensor (RFXMeter)
idx = 321

#Open meterstand.txt file en lees meterstand
#Als meterstand.txt niet aanwezig is maakt script bestand aan en vult de meterstand
fn = "/home/pi/domoticz/scripts/meterstand.txt"
if os.path.exists(fn):
    f = file(fn, "r+")
    f = open(fn)
    inhoud = f.readline()
    a,b,c = inhoud.split()
    Counter = int(c)
else:
    f = open(fn, "w")
    f.write( 'meterstand = ' + repr(Counter))
    f.close()

#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 aditioneel als Pullup-Weerstand aktiveren
GPIO.setup(40, GPIO.IN, pull_up_down = GPIO.PUD_UP)

#Functie  callback
#Dit is de functie die aangeroepen wordt in de interrupt
def Interrupt(channel):
  #Teller elke interupt uitlezen en met 1 liter verhogen 
  f = file(fn, "r+")
  f = open(fn)
  inhoud = f.readline()
  a,b,c = inhoud.split()
  Counter = int(c)
  Counter = Counter + 1
  f.close()
  #Schrijf meterstand naar bestand
  f = open( fn, 'w')
  f.write( 'meterstand = ' + repr(Counter))
  f.close()
  #Send counter to domoticz JSON
  url1 = domoticz_url+'/json.htm?type=command&param=udevice&idx='+str(idx)+'&svalue='+str(Counter)
  req1 = urllib2.Request(url1)
  response1 = urllib2.urlopen(req1)
  #Voor debug => print voorbeeld van de JSON aanroep en/of de counter
  #print "JSON call = "+ str(url1)
  #print "Watermeter Counter = " + str(Counter)

#Interrupt-Event toevoegen, bij een NPN off geeft sensor een 1 en en bij detectie een 0
#Bij detectie (LED on) een 0 daarom check dalende interrupt.
GPIO.add_event_detect(40, GPIO.FALLING, callback = Interrupt, bouncetime = 350)

try:
  while True:
      time.sleep(1)
except KeyboardInterrupt:
  GPIO.cleanup()
  print "\nBye"
(aanpassing script aangegeven door Hesmink 30 april 2017 verwerkt)

=======================================
Meterstand.txt
=======================================
De meterstand wordt bijgehouden in dit bestand. Anders zou bij elke herstart van de raspberry de meter weer op nul starten. Als de meterstand in domoticz niet meer klopt kan het bestand meterstand.txt aangepast worden met de juiste meterstand. Bij de eerst volgende interrupt van de sensor zal de juiste meterstand aan domoticz doorgegeven worden.

=======================================
Crontab
=======================================
Crontab job aanmaken op raspberry (in de sudo crontab anders werkt het niet)
om bij het starten van de raspberry het Python script automatische te starten.

Code: Select all

sudo crontab -e
Voeg de volgende regel toe.

Code: Select all

@reboot /usr/bin/python /home/pi/domoticz/scripts/watermeter.py >/var/log/cronlog.log 2>&1
Je kan het script natuurlijk ook zelf starten of via screen draaien.

Code: Select all

sudo python /home/pi/domoticz/scripts/watermeter.py
=======================================
Check of de cron het python script gestart heeft
=======================================

Code: Select all

grep cron /var/log/syslog
=======================================
update na 1 maand
=======================================
Per dag registreer ik ongeveer 3 tot 7 liter te veel waterverbruik. Mijn meterstand in Domoticz is rond de 130 liter hoger dan mijn watermeter. Heb nog geen tijd gehad om te kijken hoe dit kan of hoe ik dit kan voorkomen.
Last edited by markiemark on Friday 05 May 2017 11:12, edited 3 times in total.

User avatar
EdwinK
Posts: 858
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by EdwinK » Saturday 15 April 2017 10:41

Thanks for your info. Not something I can make my self, but good to read someone has the knowhow on how to do this.
Running latest BETA on a Pi-3 | Toon Thermostat | RFxcom | Dashticz V2 |

Hesmink
Posts: 153
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Hesmink » Sunday 16 April 2017 23:28

This seems a lot like:

viewtopic.php?f=28&t=14071

I have the sensor from that topic, but that one didn't detect enough with 5V (same specs though).
I ordered the one you are using to see if that one works for me.

ScottBeijen
Posts: 2
Joined: Thursday 27 April 2017 21:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by ScottBeijen » Friday 28 April 2017 0:00

Thanks for the workflow, it works like a charm. Took me some hours to get it up and running including soldering the wires hard to the GPIO.

Tricky thing is to check if the meterstand.txt is available for editing by the Pi user. the files was created by root. When I logged onto my Pi trough VNC iIcould not edit the meterstand.txt. I ended up creating the file myself and giving the file full access for everyone.

Running the script trough Terminal for the first time gave me the following error.
"valueerror need more than 0 value to unpack"
After this it did work though :lol:

Now the script is in the autostart via crontab and after a reboot of the Pi it still works 8-)

After recreating the meterstand.txt as I wrote, the error changed to
"valueerror need more than 1 value to unpack"

Here is a link to the part I bought:
DC6-36V 300mA NPN NO 3-wire 4mm Tubular Proximity Sensor Switch LJ12A3-4-Z-BX CP
http://www.ebay.com/itm/331957782214?_t ... EBIDX%3AIT
$2.27 :D

Again thanks for taking the effort to post this solution.

If somebody needs some little help, Just post below.

Jeff
Posts: 36
Joined: Tuesday 16 December 2014 0:39
Target OS: Windows
Domoticz version: 2.3674
Location: Weert, Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Jeff » Friday 28 April 2017 0:17

Why don't you take it the easy way?
Since the pictured meter is a itron Aquadis+ you can achieve the same with less editing in files etc. by buying a so called Cyble sensor.
This sensor just snaps in place on top of the meter and can be connected to a piface input for monitoring the water consumption. The only downside of this is the price.

NietGiftig
Posts: 140
Joined: Sunday 11 October 2015 8:50
Target OS: Raspberry Pi
Domoticz version: V3.6224
Location: Holland
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by NietGiftig » Friday 28 April 2017 10:45

Jeff wrote:The only downside of this is the price.
But an heavy downside :D
5 Eur vs 82,50 Eur
RPI-2 + SSD / ESPEasy Sensors & Switches / Sonoff / RFLink / Action Switches / TP-Link switch / Node-Red / Reacticz

ScottBeijen
Posts: 2
Joined: Thursday 27 April 2017 21:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by ScottBeijen » Friday 28 April 2017 11:27

NietGiftig wrote:
Jeff wrote:The only downside of this is the price.
But an heavy downside :D
5 Eur vs 82,50 Eur
Jep, I ended up spending only $2.27 and didn't have to buy a Piface.

Hesmink
Posts: 153
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Hesmink » Sunday 30 April 2017 22:45

Got it to work too.
This sensor does work for my watermeter with 5v input. 8-)

Had to slightly modify the python script because it fails when the datafile does not exist:

Code: Select all

if os.path.exists(fn):
    f = file(fn, "r+")
    f = open(fn)
    inhoud = f.readline()
    a,b,c = inhoud.split()
    Counter = int(c)
else:
    f = open(fn, "w")
    f.write( 'meterstand = ' + repr(Counter))
    f.close()
I have to check how reliable the interrupts are, but technically, it works fine.
I used dupont connectors to prevent soldering.

benbammens
Posts: 30
Joined: Tuesday 30 May 2017 19:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by benbammens » Tuesday 06 June 2017 11:25

After about a week of experimenting I finally have my water meter in Domoticz. I used your code as base but adapted it a little bit.

I use the custom pulse sensor for my water meter (belgium) with 1 pulse every 0,5 liter.

In the beginning I had a lot of false signals. It was unusable. In the end I found the problem. The outer sleeve of the sensor cable had been removed for about 0,5m so the inner cables were dangling. This gave a lot of interference from other stuff. Opening our electric gade made the counter go nuts.
Twisting the two signal cable together made it better but not perfect.

Now i shortened the cable even further but I still have about 4liter (8 pulses) too much in 24hours.

Anyone knows a solution?

benbammens
Posts: 30
Joined: Tuesday 30 May 2017 19:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by benbammens » Friday 16 June 2017 9:09

Well, the problem seemed to be in the script. I adjusted the bounce and delay, and now I have an error of about 0,3%. I can live with that.

Here is the final code:

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import urllib2
import os

#Watermeter stand (wordt alleen initeel gebruikt als er geen bestand meterstand_water.txt is)
global Counter
Counter = 0

#Domoticz URL
domoticz_url = "http://xxx.xxx.x.xxx:8080"
#Domoticz IDX van de water sensor (RFXMeter)
idx = 54

#Open meterstand.txt file en lees meterstand
#Als meterstand.txt niet aanwezig is maakt script bestand aan en vult de meterstand
fn = "/home/pi/domoticz/scripts/meterstand_water.txt"
if os.path.exists(fn):
    f = file(fn, "r+")
    f = open(fn)
    inhoud = f.readline()
    a,b,c = inhoud.split()
    Counter = int(c)
else:
    f = open(fn, "w")
    f.write( 'meterstand = ' + repr(Counter))
    f.close()

#Board is pin nr, BMC is GPIO nr
#Read output from water meter op pin 19
GPIO.setmode(GPIO.BOARD)
# Set GPIO 10 (Pin 19) als Input aditioneel als Pullup-Weerstand aktiveren
GPIO.setup(19, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

#Functie  callback
#Dit is de functie die aangeroepen wordt in de interrupt
def Interrupt(channel):
    print('Callback function called!')
    time.sleep(0.05)         # need to filter out the false positive of some power fluctuation
    if GPIO.input(19) == 0:
       print('quitting event handler because this was probably a false positive')
       return
    #Teller elke interrupt uitlezen en met 0.5 liter verhogen (deler watermeter op 10 zetten)
    file(fn, "r+")
    f = open(fn)
    inhoud = f.readline()
    a,b,c = inhoud.split()
    Counter = int(c)
    Counter = Counter + 5
    f.close()
    #Schrijf meterstand naar bestand
    f = open( fn, 'w')
    f.write( 'meterstand = ' + repr(Counter))
    f.close()
    #Send counter to domoticz JSON
    url1 = domoticz_url+'/json.htm?type=command&param=udevice&idx='+str(idx)+'&svalue='+str(Counter)
    req1 = urllib2.Request(url1)
    response1 = urllib2.urlopen(req1)
    #Voor debug => print voorbeeld van de JSON aanroep en/of de counter
    print "JSON call = "+ str(url1)
    print "Watermeter Counter = " + str(Counter)

    #Interrupt-Event toevoegen, sensor geeft een 0 en en bij detectie een 1
#Bij detectie een 1 daarom check stijgende interrupt.
GPIO.add_event_detect(19, GPIO.RISING, callback = Interrupt, bouncetime = 200)

try:
    while True:
      time.sleep(0.2)        
except KeyboardInterrupt:
  GPIO.cleanup()
  print "\nBye"

Longlegg1983
Posts: 1
Joined: Thursday 29 June 2017 22:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Longlegg1983 » Thursday 29 June 2017 22:48

Thank you for this post! I'm only experiencing a problem: I have the NPN sensor and the script working, but when I connect it to my water meter, it can not detect the movement of the metal plate wheel. If I then hold the NPN against another metal item, it counts immediately. Do I need a stronger NPN? Or what is a possible solution? There is an Elkster water meter from 2012 in my house.

Hesmink
Posts: 153
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Hesmink » Saturday 01 July 2017 13:04

Longlegg1983 wrote:Thank you for this post! I'm only experiencing a problem: I have the NPN sensor and the script working, but when I connect it to my water meter, it can not detect the movement of the metal plate wheel. If I then hold the NPN against another metal item, it counts immediately. Do I need a stronger NPN? Or what is a possible solution? There is an Elkster water meter from 2012 in my house.
Which NPN sensor do you have? I have 2, one is to week at 5v to sense my water meter, the other one (from this topic) works fine.

D'rMorris
Posts: 296
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by D'rMorris » Friday 28 July 2017 21:11

benbammens wrote:Well, the problem seemed to be in the script. I adjusted the bounce and delay, and now I have an error of about 0,3%. I can live with that.

Here is the final code:

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import urllib2
import os

#Watermeter stand (wordt alleen initeel gebruikt als er geen bestand meterstand_water.txt is)
global Counter
Counter = 0

#Domoticz URL
domoticz_url = "http://xxx.xxx.x.xxx:8080"
#Domoticz IDX van de water sensor (RFXMeter)
idx = 54

#Open meterstand.txt file en lees meterstand
#Als meterstand.txt niet aanwezig is maakt script bestand aan en vult de meterstand
fn = "/home/pi/domoticz/scripts/meterstand_water.txt"
if os.path.exists(fn):
    f = file(fn, "r+")
    f = open(fn)
    inhoud = f.readline()
    a,b,c = inhoud.split()
    Counter = int(c)
else:
    f = open(fn, "w")
    f.write( 'meterstand = ' + repr(Counter))
    f.close()

#Board is pin nr, BMC is GPIO nr
#Read output from water meter op pin 19
GPIO.setmode(GPIO.BOARD)
# Set GPIO 10 (Pin 19) als Input aditioneel als Pullup-Weerstand aktiveren
GPIO.setup(19, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

#Functie  callback
#Dit is de functie die aangeroepen wordt in de interrupt
def Interrupt(channel):
    print('Callback function called!')
    time.sleep(0.05)         # need to filter out the false positive of some power fluctuation
    if GPIO.input(19) == 0:
       print('quitting event handler because this was probably a false positive')
       return
    #Teller elke interrupt uitlezen en met 0.5 liter verhogen (deler watermeter op 10 zetten)
    file(fn, "r+")
    f = open(fn)
    inhoud = f.readline()
    a,b,c = inhoud.split()
    Counter = int(c)
    Counter = Counter + 5
    f.close()
    #Schrijf meterstand naar bestand
    f = open( fn, 'w')
    f.write( 'meterstand = ' + repr(Counter))
    f.close()
    #Send counter to domoticz JSON
    url1 = domoticz_url+'/json.htm?type=command&param=udevice&idx='+str(idx)+'&svalue='+str(Counter)
    req1 = urllib2.Request(url1)
    response1 = urllib2.urlopen(req1)
    #Voor debug => print voorbeeld van de JSON aanroep en/of de counter
    print "JSON call = "+ str(url1)
    print "Watermeter Counter = " + str(Counter)

    #Interrupt-Event toevoegen, sensor geeft een 0 en en bij detectie een 1
#Bij detectie een 1 daarom check stijgende interrupt.
GPIO.add_event_detect(19, GPIO.RISING, callback = Interrupt, bouncetime = 200)

try:
    while True:
      time.sleep(0.2)        
except KeyboardInterrupt:
  GPIO.cleanup()
  print "\nBye"
I'm also using this code and I also have a little too much after some time. At how much volt are you powering your NPN? And do you have a resistor installed? And if so, which value?

Thanks!

benbammens
Posts: 30
Joined: Tuesday 30 May 2017 19:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by benbammens » Friday 28 July 2017 21:58

I didn't use an NPN. The water meter in our new house had a standard pulse contact so I used that one.

To counteract the error I just adjust the offset of the watermeter once in a while in Domoticz.

But hey, we're talking about a few liters every month so it really doesn't matter :)

I have seen that fiddling with the raspberry gives a lot of false readings (from the contacts wiggling I guess), so if you're experimenting a lot with it you can expect a fair bit of errors.

User avatar
gielie
Posts: 172
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by gielie » Monday 07 August 2017 17:21

After a lot of trial and error i tot iT working. Thanks for the script.
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

Hobbybob
Posts: 63
Joined: Monday 01 May 2017 19:03
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Hobbybob » Saturday 12 August 2017 13:55

Hello, I want to include water-usage in my Domoticz as well, and although it will be dificult to get a wire running between the metercabinet in the hallway where the water-meter is and my livingroom where I have my Raspberry Pi, I am guessing it is going to be the only way...

So: 2 questions:
First off: the device in Domoticz you have a screenshot of is a counter that is modified to display water. I can reproduce that, but I also see a type "Counter incremental". What is the difference between these two, and following that: what is the correct one to use?
Aside from that: Can I connect the blue and brown wires to another power supply, and just the black one to the Pi or does that not work? That would save me 2 wires that I have to move through the rooms... Also: is it a problem if the signal-wire is relatively long? Say, 10 meters?

Oh, and do you need to use any resistor or anything before the signal-wire goes ino the GPIO, or can the Pi handle the output from the sensor as-is?

ratjenl
Posts: 17
Joined: Saturday 12 August 2017 9:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by ratjenl » Saturday 12 August 2017 19:53

Well i am trying hard but cannot get it to work. I followed al the steps as described but still this error keeps popping up :

Callback function called!
Traceback (most recent call last):
File "/home/pi/domoticz/scripts/watermeter.py", line 41, in Interrupt
if GPIO.input(21) == 0:
RuntimeError: You must setup() the GPIO channel first

Can someone push me in the good direction ?

Thnx

User avatar
gielie
Posts: 172
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by gielie » Saturday 12 August 2017 22:02

Hobbybob wrote:
Saturday 12 August 2017 13:55
Hello, I want to include water-usage in my Domoticz as well, and although it will be dificult to get a wire running between the metercabinet in the hallway where the water-meter is and my livingroom where I have my Raspberry Pi, I am guessing it is going to be the only way...

So: 2 questions:
First off: the device in Domoticz you have a screenshot of is a counter that is modified to display water. I can reproduce that, but I also see a type "Counter incremental". What is the difference between these two, and following that: what is the correct one to use?
Aside from that: Can I connect the blue and brown wires to another power supply, and just the black one to the Pi or does that not work? That would save me 2 wires that I have to move through the rooms... Also: is it a problem if the signal-wire is relatively long? Say, 10 meters?

Oh, and do you need to use any resistor or anything before the signal-wire goes ino the GPIO, or can the Pi handle the output from the sensor as-is?
Maybe you can use a second pi for your water meter.
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

User avatar
gielie
Posts: 172
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by gielie » Saturday 12 August 2017 22:04

ratjenl wrote:
Saturday 12 August 2017 19:53
Well i am trying hard but cannot get it to work. I followed al the steps as described but still this error keeps popping up :

Callback function called!
Traceback (most recent call last):
File "/home/pi/domoticz/scripts/watermeter.py", line 41, in Interrupt
if GPIO.input(21) == 0:
RuntimeError: You must setup() the GPIO channel first

Can someone push me in the good direction ?

Thnx
Your sensor is not working, do you see the led blinking when the water is running, and did connect it to the right pin.
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

Hobbybob
Posts: 63
Joined: Monday 01 May 2017 19:03
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Hobbybob » Saturday 12 August 2017 22:33

gielie wrote:
Saturday 12 August 2017 22:02
Hobbybob wrote:
Saturday 12 August 2017 13:55
Hello, I want to include water-usage in my Domoticz as well, and although it will be dificult to get a wire running between the metercabinet in the hallway where the water-meter is and my livingroom where I have my Raspberry Pi, I am guessing it is going to be the only way...

So: 2 questions:
First off: the device in Domoticz you have a screenshot of is a counter that is modified to display water. I can reproduce that, but I also see a type "Counter incremental". What is the difference between these two, and following that: what is the correct one to use?
Aside from that: Can I connect the blue and brown wires to another power supply, and just the black one to the Pi or does that not work? That would save me 2 wires that I have to move through the rooms... Also: is it a problem if the signal-wire is relatively long? Say, 10 meters?

Oh, and do you need to use any resistor or anything before the signal-wire goes ino the GPIO, or can the Pi handle the output from the sensor as-is?
Maybe you can use a second pi for your water meter.
That is also an option. I already ordered the sensor on Ali, so I guess I'll wait for that to come in first, and test with a longer wire before I buy a second Pi (I only have one).

Do you know if there are any resistors or other components involved in this setup?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests