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.

Moderators: leecollings, remb0

akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

Hi,

If you installed the plugin in the plugins directory, after a reboot you should be able to select the plugin on the hardware page, just like any other hardware, see screenshot:
watermeter.png
watermeter.png (98.08 KiB) Viewed 1878 times
if you scroll down on this page, you can configure the plugin…

if you have trouble installing the plugin, please check the wiki on plugins (https://www.domoticz.com/wiki/Using_Python_plugins)
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Seems I had to install de python DEV part......
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Ok, hardware can be found now in the list. But after the add and the message, device added, there is NO new device!

Any idea?
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

JeeGee wrote: Wednesday 18 December 2019 22:16 Ok, hardware can be found now in the list. But after the add and the message, device added, there is NO new device!

Any idea?
is "Accept New Hardware Devices" enabled in the settings of Domoticz?
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Yes. Earlier I added my smart meter, so that should work.

I see the hardware is added to the list, but no new device
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

2019-12-18 22:23:10.717 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:23:24.720 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:23:29.986 Error: (WMPS) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-watermeter/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-12-18 22:23:29.986 Error: (Watermeter) Module Import failed, exception: 'ImportError'
2019-12-18 22:23:29.986 Error: (Watermeter) Module Import failed: ' Name: RPi'
2019-12-18 22:23:29.986 Error: (Watermeter) Error Line details not available.
2019-12-18 22:24:34.732 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:24:48.735 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:25:02.863 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:25:16.866 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:25:30.869 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:25:44.872 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:25:58.874 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:26:12.877 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:26:26.880 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:26:40.883 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:26:54.885 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:27:08.888 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:27:22.891 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:27:36.894 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:27:50.897 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:28:04.900 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:28:18.903 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:28:32.905 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:28:46.908 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:29:00.911 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:29:14.914 Error: Watermeter hardware (6) thread seems to have ended unexpectedly
2019-12-18 22:29:28.975 Error: (WMPS) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-watermeter/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-12-18 22:29:28.975 Error: (Watermeter) Module Import failed, exception: 'ImportError'
2019-12-18 22:29:28.975 Error: (Watermeter) Module Import failed: ' Name: RPi'
2019-12-18 22:29:28.975 Error: (Watermeter) Error Line details not available.
2019-12-18 22:29:51.367 Error: (WMPS) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-watermeter/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-12-18 22:29:51.367 Error: (Watermeter) Module Import failed, exception: 'ImportError'
2019-12-18 22:29:51.367 Error: (Watermeter) Module Import failed: ' Name: RPi'



Hmmmmmm And now?
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

hmmmm… this error is not generated by the plugin itself.

I just tested by adding the plugin to another domoticz instance, works perfectly on my system.

What are your system details (hardware, os version, python version, etc...)?
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Pi 3
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=raspbian

Python 3.5
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

What 's your domoticz version?
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Version: 4.10717
Build Hash: b38b49e5
Compile Date: 2019-05-09 13:04:08
dzVents Version: 2.4.19
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

JeeGee wrote: Thursday 19 December 2019 8:28 Version: 4.10717
Build Hash: b38b49e5
Compile Date: 2019-05-09 13:04:08
dzVents Version: 2.4.19
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
I am also on raspbian stretch, and tried to reproduce your issue by installing the latest stable, so I now have exactly the same software as you:

Code: Select all

Version: 4.10717
Build Hash: b38b49e5
Compile Date: 2019-05-09 13:04:08
dzVents Version: 2.4.19
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
And did not encounter the issue, so i suspect it's a library issue on your system


few things i can think of:
1. Can you try to install other plugins (e.g. you could try the buienradar plugin) to find out this issue is specific for the watermeter plugin?
2. Did you already try to make the plugin.py exeutable (chmod +x plugin.py)
3. Did you check if you have this issue? https://www.domoticz.com/wiki/Linux#Pro ... ing_Python
4. Did you check the troubleshooting section in the domoticz wiki for plugins ? (https://www.domoticz.com/wiki/Using_Python_plugins)

PS In the test above i found another small issue which i fixed, so i suggest you reinstall the plugin. This this will not fix this problem, but another one after you fixed the library issue.
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Thanks, reinstalled the plugin.


few things i can think of:
1. Can you try to install other plugins (e.g. you could try the buienradar plugin) to find out this issue is specific for the watermeter plugin?
Installed buienrader, works 100%.

2. Did you already try to make the plugin.py exeutable (chmod +x plugin.py)
Yes, did that the very first time.

3. Did you check if you have this issue? https://www.domoticz.com/wiki/Linux#Pro ... ing_Python
Well not page, but via wiki, I found the issue about installing the dev stuff.

4. Did you check the troubleshooting section in the domoticz wiki for plugins ? (https://www.domoticz.com/wiki/Using_Python_plugins)
Yes, that where the dev is mentioned.

Looking at the logs:
2019-12-19 19:58:48.456 Error: (WMPS) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-watermeter/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-12-19 19:58:48.456 Error: (Watermeter) Module Import failed, exception: 'ImportError'
2019-12-19 19:58:48.456 Error: (Watermeter) Module Import failed: ' Name: RPi'
2019-12-19 19:58:48.457 Error: (Watermeter) Error Line details not available.
2019-12-19 19:59:54.925 Error: Watermeter hardware (5) thread seems to have ended unexpectedly

To me it looks like in import error with RPi, but why?
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

SOLVED!

If you are using Raspbian Stretch, RPi.GPIO is NOT included in Python 3.5 by default.

sudo apt-get install python3-rpi.gpio

After that.... I have a new device Watermeter.

TESTPULSE option seems to work. So now the real work, get the NPN connected and working.

EDIT1: did you use the script by WillyWong1?

EDIT2: it seems the file meterstand.txt is ignored. Doesn't pick up the value I set in it. A service restart, also did'nt create it.
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

JeeGee wrote: Thursday 19 December 2019 20:54 SOLVED!

If you are using Raspbian Stretch, RPi.GPIO is NOT included in Python 3.5 by default.

sudo apt-get install python3-rpi.gpio

After that.... I have a new device Watermeter.
Good to know, i will add that to the readme
JeeGee wrote: Thursday 19 December 2019 20:54 EDIT1: did you use the script by WillyWong1?
I used the script on this site as a base https://ehoco.nl/watermeter-uitlezen-in ... on-script/
JeeGee wrote: Thursday 19 December 2019 20:54 EDIT2: it seems the file meterstand.txt is ignored. Doesn't pick up the value I set in it. A service restart, also did'nt create it.
few thoughts:
- I fixed a bug yesterday, which might which might cause this. Did you reinstall the plugin after yesterday? if not, this might fix
- are looking at the right spot? If you use the default settings, the meterstand.txt should be placed in the domoticz directory
- The meterstand.txt is only used when there is a pulse. so if you did not connect the NPN sensor, don't expect updates to the virutal sensor in domoticz. (You can test the working of the script with an undocumented feature . If you create a file named "TESTPULSE in the directory of the waterpmeter plugin directory and restart, it will simulate a pulse every 10 seconds for testing purposes.)
- if this all does not help, please turn on debug logging by creating a file named "DEBUG" (contents don't matter) in the directory of the plugin, restart and send me the output..
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Started from scratch. Removed all and used your latest version 1.01

Placed an empty TESTPULSE and didn't connect a PNP yet. Set it to GPIO21 with resistor NULL

But then I get this error and NO device is created:
2019-12-20 21:35:53.458 Error: (Watermeter) 'onStart' failed 'AttributeError':'module 'RPi.GPIO' has no attribute 'PUD_NONE''.
2019-12-20 21:35:53.458 Error: (Watermeter) ----> Line 235 in '/home/pi/domoticz/plugins/domoticz-watermeter/plugin.py', function onStart
2019-12-20 21:35:53.458 Error: (Watermeter) ----> Line 159 in '/home/pi/domoticz/plugins/domoticz-watermeter/plugin.py', function onStart

I did the same yesterday, and I guess that was with the other version and then I didn't had the error with resistor Null.

If I change it to pullup, the device is created. And every 10 seconds it counts 1 liter. Total is higer in number, is there something in the database from yesterday?

BTW found the meterstand.txt file. looked at the wrong location indeed.
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

JeeGee wrote: Friday 20 December 2019 21:50 But then I get this error and NO device is created:
2019-12-20 21:35:53.458 Error: (Watermeter) 'onStart' failed 'AttributeError':'module 'RPi.GPIO' has no attribute 'PUD_NONE''.
2019-12-20 21:35:53.458 Error: (Watermeter) ----> Line 235 in '/home/pi/domoticz/plugins/domoticz-watermeter/plugin.py', function onStart
2019-12-20 21:35:53.458 Error: (Watermeter) ----> Line 159 in '/home/pi/domoticz/plugins/domoticz-watermeter/plugin.py', function onStart
aha.. i never tested without configuring pullup or pulldown… this was a bug and is fixed now, tx for spotting this. You could get the new one from github, but looking at you config you need to configure a pull up resistor anyway (see below)
JeeGee wrote: Friday 20 December 2019 21:50 If I change it to pullup, the device is created. And every 10 seconds it counts 1 liter. Total is higer in number, is there something in the database from yesterday?
Yes this can very well be the case. If you want to change the number, just change the meterstand file

I also saw your direct messages, please reply in the forum (you can quote me and i will get a notification as well) in which you ask wheter or not to connect directly to the pi.

I am not an electronics expert, but of a lot of this has already been said in this forum. I understand if you connect directly it is not 100% compliant with the specs (you get a bit more than 3.3V on the pins) . So it is not recommended by several members on the forum. On the other hand there are a lot of users connecting it directly (you have to configure a pull up resistor btw, otherwise this will not work!) like myself without problems.

Mine works also fine directly connected. Not at once however. I had to try several NPN sensors, because not all sensors worked fine.

This is the one which fixed my problems https://nl.aliexpress.com/item/32826250 ... 4c4dmnYJqX
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Ok, will stick to the forum then.

Welcome, happy to make your plugin working 100%.

I think I need a bit more explanation about the pull-up resistor.... sorry.

So, long story short, this has to be used to make it work?
watermeter.JPG
watermeter.JPG (101.68 KiB) Viewed 1762 times
You said: "Mine works also fine directly connected. Not at once however. I had to try several NPN sensors, because not all sensors worked fine."

So you don't use any resistors at all?
JeeGee
Posts: 22
Joined: Sunday 25 August 2019 13:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by JeeGee »

Hmmm I connected my NPN as the scheme above. Took 3 resistors (1k), as you need 2k, I soldered them after each other to make it 2k.

Connected it to my Pi 3 model b at the pins shown above. But it doesn't count. If I use metal in front of the NPN I see the led turing on.

I ordered one from Ali: LJ12A3-4-Z/BX

Could it be because og the way connected at the moment or do I need an other NPN?

Are there commandline options to see if there is data on GPIO21?

Thanks
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

JeeGee wrote: Monday 23 December 2019 9:28 So you don't use any resistors at all?
Correct. I only configured the internal pull up resistor
akamming
Posts: 337
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by akamming »

JeeGee wrote: Monday 23 December 2019 11:13
Are there commandline options to see if there is data on GPIO21?

Thanks
You can do "cat /sys/class/gpio/gpio21/value"
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest