Page 2 of 20

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 12 August 2017 22:35
by ratjenl
gielie wrote: Saturday 12 August 2017 22:04 Your sensor is not working, do you see the led blinking when the water is running, and did connect it to the right pin.
Thank you for your quick reply, everything is well connected but the led isn't blinking at all. I will order a new one

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 12 August 2017 22:44
by gielie
ratjenl wrote: Saturday 12 August 2017 22:35
gielie wrote: Saturday 12 August 2017 22:04 Your sensor is not working, do you see the led blinking when the water is running, and did connect it to the right pin.
Thank you for your quick reply, everything is well connected but the led isn't blinking at all. I will order a new one
Try hold it near something iron, see if the led goes on, it should. Check if there is enough power from the pi otherwise try another power source

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 12 August 2017 22:47
by ratjenl
gielie wrote: Saturday 12 August 2017 22:44 Try hold it near something iron, see if the led goes on, it should. Check if there is enough power from the pi otherwise try another power source
Already tried it. Plugged it into an 12v adapter and nothing changes.... I think i really got an doa one.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 12 August 2017 22:48
by gielie
Hobbybob wrote: 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?
No resistor needed, just the 3 wires connected to the pi. I ordered this from Ali http://s.aliexpress.com/yUFbiQBZ, makes the connection much easier.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Saturday 12 August 2017 23:06
by D'rMorris
ratjenl wrote: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
Did you setup your GPIO pin correctly? You have to export it first in sysfs. Is GPIO21 listed in /sys/class/gpio? And if it's listed, is the direction set to in?

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 8:11
by ratjenl
D'rMorris wrote: Saturday 12 August 2017 23:06
Did you setup your GPIO pin correctly? You have to export it first in sysfs. Is GPIO21 listed in /sys/class/gpio? And if it's listed, is the direction set to in?
It is listed but the file is empty....

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 9:02
by oohlaf

gielie wrote:
Hobbybob wrote: Saturday 12 August 2017 22:33 Do you know if there are any resistors or other components involved in this setup?
No resistor needed, just the 3 wires connected to the pi. I ordered this from Ali http://s.aliexpress.com/yUFbiQBZ, makes the connection much easier.
Really? Aren't the gpio input pins specified as 3.3v max, not 5v.

Verstuurd vanaf mijn XT1562 met Tapatalk


Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 9:32
by ratjenl
oohlaf wrote: Sunday 13 August 2017 9:02

Really? Aren't the gpio input pins specified as 3.3v max, not 5v.

Verstuurd vanaf mijn XT1562 met Tapatalk
Measured with an multimeter it says 5.12 v.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 14:10
by oohlaf
ratjenl wrote: Sunday 13 August 2017 9:32
oohlaf wrote: Sunday 13 August 2017 9:02 Really? Aren't the gpio input pins specified as 3.3v max, not 5v.
Measured with an multimeter it says 5.12 v.
That's the output pin, you have 5v output.
I was talking about the input pin, the wire you connect on PIN 19 as input, is max 3.3volt.
How much does the NPN output on that pin when it detects metal?

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 14:54
by ratjenl
mine does 5 volt all the time, got it connected on pin40 (GPIO21)

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 15:09
by oohlaf
ratjenl wrote: Sunday 13 August 2017 14:54 mine does 5 volt all the time, got it connected on pin40 (GPIO21)
so by putting 5v on a pin that is meant to receive 3.3v you potentially break your pi.

https://learn.sparkfun.com/tutorials/vo ... ll?print=1

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 15:55
by ratjenl
oohlaf wrote: Sunday 13 August 2017 15:09
so by putting 5v on a pin that is meant to receive 3.3v you potentially break your pi.

https://learn.sparkfun.com/tutorials/vo ... ll?print=1
Hmmz, well it has been on for 24 hours now. I pulled it off and i am happy my pi is still working. Thank you for the link. I hope everything is still working and i can still use the pins.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 17:25
by Hobbybob
oohlaf wrote: Sunday 13 August 2017 15:09
ratjenl wrote: Sunday 13 August 2017 14:54 mine does 5 volt all the time, got it connected on pin40 (GPIO21)
so by putting 5v on a pin that is meant to receive 3.3v you potentially break your pi.

https://learn.sparkfun.com/tutorials/vo ... ll?print=1
Is there also any good solution for this? I followed the link, but when it starts to give me diagrams I get a bit confused as I'm not into those at all...

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Sunday 13 August 2017 20:36
by Hobbybob
Okay, I've tried to read up on the information about this, and I came up with the following wiring-scheme. As said, I am not very good at reading diagrams with symbols, so I made something a litte more visual for myself.

Can anybody with a little more knowledge than me check if this would be a good way? I calculated the 1kOhm and 2kOhm on the site oohlaf mentioned, and fiddled with the Ohms to get two values that I can actually buy, and produces as close to 3.3V as possible.
Schakeling watermeter.jpg
Schakeling watermeter.jpg (299.74 KiB) Viewed 5216 times

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 15 August 2017 22:22
by oohlaf
Hi,

Yes, you got it right, you can also have a look at this topic:
viewtopic.php?f=17&t=1103&start=40

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 15 August 2017 22:58
by Hesmink
Never realised it would put 5v on the gpio pin.
On the bright side, the rpi still works fine after doing this a few months.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 15 August 2017 23:34
by Hobbybob
oohlaf wrote: Tuesday 15 August 2017 22:22 Hi,

Yes, you got it right, you can also have a look at this topic:
viewtopic.php?f=17&t=1103&start=40
Great, thank you!

The sensor should be on a boat between China and the Netherlands by now :)

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Tuesday 15 August 2017 23:59
by Milifax
Hobbybob wrote: Tuesday 15 August 2017 23:34
Great, thank you!

The sensor should be on a boat between China and the Netherlands by now :)
Or you could use a cleaner option like a level converter:
https://m.nl.aliexpress.com/s/item/32 ... #autostay

Whatever your choice might be, check the voltage of the signal at the end of your 10m cable. Maybe the voltage drop in the cable gets you to the 3v3. Not plausible, but that way you have your real voltage at the Rpi-end.
And with that measurement, calculate what you need.

Edit: just read a bit more of your thread. Using a separate powersuply for the sensor and only wire the signal is not to be adviced. The GND could have potential difference, or better GND WILL have potential difference. Currents flow and bad readings could occur. Just use the power from the GPIO pins.

Next, why use an extra Pi if all others fail. An Arduino Nano would be a far cheaper and cleaner option. A Rpi for just 1 signal is overkill.
The arduino could be used for some pre calculation if you want as well.

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Wednesday 16 August 2017 10:24
by Hobbybob
Milifax wrote: Tuesday 15 August 2017 23:59 Or you could use a cleaner option like a level converter:
https://m.nl.aliexpress.com/s/item/32 ... #autostay

Whatever your choice might be, check the voltage of the signal at the end of your 10m cable. Maybe the voltage drop in the cable gets you to the 3v3. Not plausible, but that way you have your real voltage at the Rpi-end.
And with that measurement, calculate what you need.

Edit: just read a bit more of your thread. Using a separate powersuply for the sensor and only wire the signal is not to be adviced. The GND could have potential difference, or better GND WILL have potential difference. Currents flow and bad readings could occur. Just use the power from the GPIO pins.

Next, why use an extra Pi if all others fail. An Arduino Nano would be a far cheaper and cleaner option. A Rpi for just 1 signal is overkill.
The arduino could be used for some pre calculation if you want as well.
Thanks for the pointers! Will take them into account!

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Posted: Friday 25 August 2017 10:45
by pvangorp
Instead you can connect a 3.3v zener diode on the black wire and your GPIO's are safe. They are verry cheap and perfect for low power. https://www.kiwi-electronics.nl/zenerdiode-3v3-500ma.

For accurate measurement use a 9 or 12 volt adapter instead of 5v from the PI.