Watermeter lezen met raspberry en Inductieve NPN sensor Topic is solved
Moderators: leecollings, remb0
-
- Posts: 140
- Joined: Thursday 22 October 2015 21:14
- Target OS: Linux
- Domoticz version: 4.11539
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi All,
I have a problem.. I kinda broke my python... and now this script is not working any more..
I have tried many things but my knowledge of pyhton is not that high.
when I run the script I get this error:
/usr/bin/python /home/domoticz/domoticz/scripts/watermeter.py
Traceback (most recent call last):
File "/home/domoticz/domoticz/scripts/watermeter.py", line 20, in <module>
f = file(fn, "r+")
NameError: name 'file' is not defined
Currently python v3.7 is installed
Other python scripts (like DeConz ) are running fine..
Any help is appreciated
I have a problem.. I kinda broke my python... and now this script is not working any more..
I have tried many things but my knowledge of pyhton is not that high.
when I run the script I get this error:
/usr/bin/python /home/domoticz/domoticz/scripts/watermeter.py
Traceback (most recent call last):
File "/home/domoticz/domoticz/scripts/watermeter.py", line 20, in <module>
f = file(fn, "r+")
NameError: name 'file' is not defined
Currently python v3.7 is installed
Other python scripts (like DeConz ) are running fine..
Any help is appreciated
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
-
- Posts: 140
- Joined: Thursday 22 October 2015 21:14
- Target OS: Linux
- Domoticz version: 4.11539
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Ok, I fixed it myself (and google:) )Draakje wrote: ↑Thursday 02 April 2020 21:19 Hi All,
I have a problem.. I kinda broke my python... and now this script is not working any more..
I have tried many things but my knowledge of pyhton is not that high.
when I run the script I get this error:
/usr/bin/python /home/domoticz/domoticz/scripts/watermeter.py
Traceback (most recent call last):
File "/home/domoticz/domoticz/scripts/watermeter.py", line 20, in <module>
f = file(fn, "r+")
NameError: name 'file' is not defined
Currently python v3.7 is installed
Other python scripts (like DeConz ) are running fine..
Any help is appreciated
turns out the command file is not supported anymore and has been replaced by open.
So after changing file to open the script worked again!
(Lines 20 & 40. f = file(fn, "r+") )
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
-
- Posts: 15
- Joined: Wednesday 25 December 2019 16:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2020.2
- Location: Limburg
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi everyone,
Like many of us I try to setup a watermeter with inductive NPN sensor. The led lights on and off when the wheel is spinning. I have setup all the devices in Domoticz but still the data on my dashboard is unchanged. The GPIO is connected on 21
pi@domoticz:~ $ sudo raspi-gpio get 21
GPIO 21: level=1 fsel=0 func=INPUT
In the cronlog.log I found this.
Best regards,
Johan
Like many of us I try to setup a watermeter with inductive NPN sensor. The led lights on and off when the wheel is spinning. I have setup all the devices in Domoticz but still the data on my dashboard is unchanged. The GPIO is connected on 21
pi@domoticz:~ $ sudo raspi-gpio get 21
GPIO 21: level=1 fsel=0 func=INPUT
In the cronlog.log I found this.
- Spoiler: show
Best regards,
Johan
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Why use many different and complex scripts? I have an esp8266( with esp easy)with a proximity sensor. I’ve sanded 2mm of the orange tip for better detection and all the data is send to domoticz. I’ve been running it for three months now without any liters being lost.jvrietveld wrote: Like many of us I try to setup a watermeter with inductive NPN sensor. The led lights on and off when the wheel is spinning. I have setup all the devices in Domoticz but still the data on my dashboard is unchanged. The GPIO is connected on 21
-
- Posts: 15
- Joined: Wednesday 25 December 2019 16:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2020.2
- Location: Limburg
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi Trigun,Trigun wrote: ↑Tuesday 07 July 2020 10:01 Why use many different and complex scripts? I have an esp8266( with esp easy)with a proximity sensor. I’ve sanded 2mm of the orange tip for better detection and all the data is send to domoticz. I’ve been running it for three months now without any liters being lost.
Your comment prompted me to look at this solution. I have worked with esp8266 before in a NodeMCu and Wemos D1. The ESP Easy software is also very easy to configure. I think I'll try this url https://robothuis.nl/2020/05/01/waterme ... -domoticz/ as a new way to solve this.
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Good idea! Although I don’t even use the voltage regulator. I soldered the sensor on to my wemos. Used a stable raspberry pi power supply and configured espeasy. As easy as that.jvrietveld wrote:Hi Trigun,Trigun wrote: ↑Tuesday 07 July 2020 10:01 Why use many different and complex scripts? I have an esp8266( with esp easy)with a proximity sensor. I’ve sanded 2mm of the orange tip for better detection and all the data is send to domoticz. I’ve been running it for three months now without any liters being lost.
Your comment prompted me to look at this solution. I have worked with esp8266 before in a NodeMCu and Wemos D1. The ESP Easy software is also very easy to configure. I think I'll try this url https://robothuis.nl/2020/05/01/waterme ... -domoticz/ as a new way to solve this.
Goog luck!
Oh yeah, if you, by accident, sanded to much of the sensor tip, use some painting tape to add an extra layer or two the tape is thin enough for a good detection.
Sent from my iPhone using Tapatalk
-
- Posts: 18
- Joined: Sunday 12 February 2017 15:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi all,
Got my sensor working using the LUA scripting. Still got a problem with the counter increasing, although the led is not on activated. This causes the meter to read appr 50-70 an hour without any usage..
Read something about shielding the cable, but could it also be a error in the script?
Someone able to give me a clue how to solve this?
thanks!
----
the Script:
commandArray = {}
-- IDX van de virtuele Watermeter
iIDX = 311
-- Stand van fysieke watermeter overnemen naar de virtuele watermeter (user variable "WaterMeter")
if ( uservariables["WaterMeter"] > 0 ) then
print("Water usage is set to " .. uservariables["WaterMeter"] / 1000 .. "m3 by user")
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..uservariables["WaterMeter"]..''
commandArray['Variable:WaterVerbruik'] = tostring(uservariables["WaterMeter"])
commandArray['Variable:WaterMeter'] = tostring(0)
end
if ( uservariables["WaterMeter"] == -1 ) then
commandArray['UpdateDevice'] = ''..iIDX..'|0|0'
commandArray['Variable:WaterMeter'] = tostring(0)
return commandArray
end
-- Waterverbruik
-- Waterverbruik ophalen uit de variabele WaterVerbruik:
sWaterUsage = uservariables["WaterVerbruik"]
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
if (devicechanged['GPIO Watermeter'] == 'Off') then
sWaterUsageTot = (sWaterUsage + 1)
print("Waterverbruik is gewijzigd naar " .. sWaterUsageTot / 1000 .. "m3 ")
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsageTot..''
commandArray['Variable:WaterVerbruik'] = tostring(sWaterUsageTot)
else
-- Iedere 5 minuten het waterverbruik registreren (t.b.v. grafieken/statistieken), ook al is er niets verbruikt.
if otherdevices_lastupdate["Waterverbruik"] == nil then
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..''
elseif (timedifference(otherdevices_lastupdate["Waterverbruik"]) > 300) then
print("Laatste waterverbruik is meer dan 5 minuten geleden")
print("Waterverbruik is nog steeds " .. sWaterUsage / 1000 .. "m3 ")
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..''
end
end
return commandArray
Got my sensor working using the LUA scripting. Still got a problem with the counter increasing, although the led is not on activated. This causes the meter to read appr 50-70 an hour without any usage..
Read something about shielding the cable, but could it also be a error in the script?
Someone able to give me a clue how to solve this?
thanks!
----
the Script:
commandArray = {}
-- IDX van de virtuele Watermeter
iIDX = 311
-- Stand van fysieke watermeter overnemen naar de virtuele watermeter (user variable "WaterMeter")
if ( uservariables["WaterMeter"] > 0 ) then
print("Water usage is set to " .. uservariables["WaterMeter"] / 1000 .. "m3 by user")
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..uservariables["WaterMeter"]..''
commandArray['Variable:WaterVerbruik'] = tostring(uservariables["WaterMeter"])
commandArray['Variable:WaterMeter'] = tostring(0)
end
if ( uservariables["WaterMeter"] == -1 ) then
commandArray['UpdateDevice'] = ''..iIDX..'|0|0'
commandArray['Variable:WaterMeter'] = tostring(0)
return commandArray
end
-- Waterverbruik
-- Waterverbruik ophalen uit de variabele WaterVerbruik:
sWaterUsage = uservariables["WaterVerbruik"]
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
if (devicechanged['GPIO Watermeter'] == 'Off') then
sWaterUsageTot = (sWaterUsage + 1)
print("Waterverbruik is gewijzigd naar " .. sWaterUsageTot / 1000 .. "m3 ")
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsageTot..''
commandArray['Variable:WaterVerbruik'] = tostring(sWaterUsageTot)
else
-- Iedere 5 minuten het waterverbruik registreren (t.b.v. grafieken/statistieken), ook al is er niets verbruikt.
if otherdevices_lastupdate["Waterverbruik"] == nil then
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..''
elseif (timedifference(otherdevices_lastupdate["Waterverbruik"]) > 300) then
print("Laatste waterverbruik is meer dan 5 minuten geleden")
print("Waterverbruik is nog steeds " .. sWaterUsage / 1000 .. "m3 ")
commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..''
end
end
return commandArray
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Joost,
The issue is that you only detect a status from the sensor you need to detect the change only. The so called flank.
if (devicechanged['GPIO Watermeter'] == 'Off') then
when the meter stops just under the sensor your led is always activated or vise vera, not activated.
The Lua script would get compilcated and might miss stuff. Hence I would advise you to eighter use Python or goto an
arduino with easpEASY where flank detection is already build in.
Cheers,
Frank
The issue is that you only detect a status from the sensor you need to detect the change only. The so called flank.
if (devicechanged['GPIO Watermeter'] == 'Off') then
when the meter stops just under the sensor your led is always activated or vise vera, not activated.
The Lua script would get compilcated and might miss stuff. Hence I would advise you to eighter use Python or goto an
arduino with easpEASY where flank detection is already build in.
Cheers,
Frank
-
- Posts: 18
- Joined: Sunday 12 February 2017 15:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Thansk Frank. Ill try to use a python script!
Cheers
Cheers
-
- Posts: 10
- Joined: Monday 11 September 2017 10:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Friesland
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
First off all, awesome post, have been working on it for several days and now it works! Day 2 succesfullypvangorp wrote: ↑Wednesday 06 September 2017 20:45 I've upgraded my script by adding a "uservariable" this makes it possible to set the initial value and to make a correction when your PI is off for a while. Create a user variable called "WaterMeter" and enter the meter value eg "999999" (Where "999999" = 999.999m3). When the value is "0" it ignores the user variable.
I also added a variable for IDX, to make it easier to change the script.
So you don't need the lineany moreTo set the initial meter values http://<<YOUR DOMOTICZ IP>>/json.htm?type=command¶m=udevice&idx=34&svalue=999999
My updated scriptCode: Select all
commandArray = {} -- Set IDX of Watermeter iIDX = 34 -- Set Watermeter based on user variable "WaterMeter" if ( uservariables["WaterMeter"] > 0 ) then print("Water usage is set to " .. uservariables["WaterMeter"] / 1000 .. "m3 by user") commandArray['UpdateDevice'] = ''..iIDX..'|0|'..uservariables["WaterMeter"]..'' commandArray['Variable:WaterMeter'] = tostring(0) end -- Water usage -- Retrieve value from water meter device: sWaterUsage = otherdevices_svalues['Waterverbruik'] -- To have a better readable format, divide number by 1000: sWaterUsagePrint = tonumber(sWaterUsage / 1000); -- calculation is done with the unmodified water value sWaterUsage = tonumber(sWaterUsage); -- For Debuging -- print("Water usage until now is " .. sWaterUsagePrint .. "m3 ") -- print('GPIO Watermeter = '..otherdevices['GPIO Watermeter']) function timedifference(s) year = string.sub(s, 1, 4) month = string.sub(s, 6, 7) day = string.sub(s, 9, 10) hour = string.sub(s, 12, 13) minutes = string.sub(s, 15, 16) seconds = string.sub(s, 18, 19) t1 = os.time() t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds} difference = os.difftime (t1, t2) return difference end if (devicechanged['GPIO Watermeter'] == 'Off') then sWaterUsageTot = (sWaterUsage + 1) print("Water usage is set to " .. sWaterUsageTot / 1000 .. "m3 ") commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsageTot..'' else -- Keep a live device if (timedifference(otherdevices_lastupdate["Waterverbruik"]) > 300) then print("Water usage is still " .. sWaterUsage / 1000 .. "m3 ") commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..'' end end return commandArray
Started with de python but very happy with the lua script inside Domoticz.
To share my experience to get this working, some off the bumps i got into, that it may help others:
- had some issue with libary (I think), so updated the GPIO driver to 2.52, see http://wiringpi.com/wiringpi-updated-to ... rry-pi-4b/ Issue was; I wasn't able to select the port when setting up a virtual switch to the GPIO port.
- set the port in init.d solved my issue my port (GPIO15) changed eached time I booted
- didnt understand the jason inital meter setup but found out (yes, noob) I could just put it in the adress bar in a browser. Thanks to this update of pvangorp happy to use a variable, again inside Domoticz = I like!
- in above script of pvangorp changed the status trigger to Closed (instead of Off) and it worked! And the names of the devices off course + ID as mentioned.
Hardwarde; I used the BS170 MOSFET with two 10k resistors, 5V power supply to the sensor works well, the MOSFET switches the 3V3 from Raspberry so nice protection to prevent 5V on the GPIO input. Herewith also a very clear switching, no flanking issues.
OS: RPi4B, GH
ELECTRICITY: P1 Smart Meter USB
WATER: NPN inductive sensor
SOLAR: Omnik Inverter, PVOutput
LIGHTS: Philips HUE + GLEDOPTO + Yeelight
SENSORS: Xiaomi Temp + Humidity + Baro + Motion + HUE
ELECTRICITY: P1 Smart Meter USB
WATER: NPN inductive sensor
SOLAR: Omnik Inverter, PVOutput
LIGHTS: Philips HUE + GLEDOPTO + Yeelight
SENSORS: Xiaomi Temp + Humidity + Baro + Motion + HUE
-
- Posts: 10
- Joined: Monday 11 September 2017 10:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Friesland
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
if the led is not activated it sounds like the sensor isn't working.. I would check power supply, distance to meter (metal)Joost996me wrote: ↑Friday 22 January 2021 13:51 Hi all,
Got my sensor working using the LUA scripting. Still got a problem with the counter increasing, although the led is not on activated. This causes the meter to read appr 50-70 an hour without any usage..
Read something about shielding the cable, but could it also be a error in the script?
OS: RPi4B, GH
ELECTRICITY: P1 Smart Meter USB
WATER: NPN inductive sensor
SOLAR: Omnik Inverter, PVOutput
LIGHTS: Philips HUE + GLEDOPTO + Yeelight
SENSORS: Xiaomi Temp + Humidity + Baro + Motion + HUE
ELECTRICITY: P1 Smart Meter USB
WATER: NPN inductive sensor
SOLAR: Omnik Inverter, PVOutput
LIGHTS: Philips HUE + GLEDOPTO + Yeelight
SENSORS: Xiaomi Temp + Humidity + Baro + Motion + HUE
-
- Posts: 1
- Joined: Friday 19 March 2021 15:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
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.
-
- Posts: 140
- Joined: Thursday 22 October 2015 21:14
- Target OS: Linux
- Domoticz version: 4.11539
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
did somebody tried to use Tasmota software to read the watermeter with the NPN sensor?
I did found this article using other software https://robothuis.nl/2020/05/01/waterme ... -domoticz/ (dutch)
This is using a wemos D1 mini (have lots of those) running ESP EASY
Was wondering if anyone figured this out with a standard tasmota firmware.. (would save me the hassle )
regards
I did found this article using other software https://robothuis.nl/2020/05/01/waterme ... -domoticz/ (dutch)
This is using a wemos D1 mini (have lots of those) running ESP EASY
Was wondering if anyone figured this out with a standard tasmota firmware.. (would save me the hassle )
regards
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
-
- Posts: 140
- Joined: Thursday 22 October 2015 21:14
- Target OS: Linux
- Domoticz version: 4.11539
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
To all it may concern.
I have successfully connected the NPN sensor to a Sonoff Basic (R2).
Red wire is connected to 5v.
Blue wire is connected to GND
Yellow wire is connected to IO2
In the Tasmota software you have to select GPIO2 to counter.
I needed to compile Tasmota because I needed the condition function to have the updates sent immediately to domoticz.
This is done by a rule.
"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":120,"Free":391,"Rules":"on Counter#C1 DO if (%var1% < %value%) publish domoticz/in {\\\"idx\\\":12,\\\"svalue\\\":\\\"%value%\\\"}; var1 %value% endif ENDON"}}
with this setup I reuse my existing Sonoff Basic (so it has 2 functions now) and have a neater solution.
I have successfully connected the NPN sensor to a Sonoff Basic (R2).
Red wire is connected to 5v.
Blue wire is connected to GND
Yellow wire is connected to IO2
In the Tasmota software you have to select GPIO2 to counter.
I needed to compile Tasmota because I needed the condition function to have the updates sent immediately to domoticz.
This is done by a rule.
"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":120,"Free":391,"Rules":"on Counter#C1 DO if (%var1% < %value%) publish domoticz/in {\\\"idx\\\":12,\\\"svalue\\\":\\\"%value%\\\"}; var1 %value% endif ENDON"}}
with this setup I reuse my existing Sonoff Basic (so it has 2 functions now) and have a neater solution.
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
-
- Posts: 1
- Joined: Saturday 15 May 2021 19:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Can anyone share which 5V Inductive Proximity Sensor works with a raspberry pi?
I tried the LJ12A3–4-Z/BX one and stumbled upon the same issue where the sensor's LED indicated a metal detection but the output can't actually be detected on a GPIO pin.
-
- Posts: 3
- Joined: Friday 21 June 2019 21:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
I have added a very small 5V to 12V up converter to power the sensor from the Pi and a resistor voltage step down network to bring the output back to 3.3v
-
- Posts: 12
- Joined: Friday 18 September 2020 11:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi, I now also installed a Zenner NPN and did run with ESP8266 (espeasy) without problems. I sent the count to a virtual sensor and did not encounter any issues.JeeGee wrote: ↑Friday 24 January 2020 19:35 My PNP with the plugin was running fine, but this week I had 3 times the issue that the measuring went crazy.
Examples: in one hour it said I used 400 liters, out of the blue and even one time 15.000 liters.
Tried to place the PNP a it different, but so far it didn't help.
Anyone else seeing this? And could be the cause?
I then thought lets hook up the sensor directly to PI running the plugin. I also get once or twice a day peak values of over 100 litres consumption although no water was used. I set-up the Telegram notification on "above" 100 litres consumption and that one even keeps on sending messages with the disabled plug-in (and disconnected sensor). I moved back to ESP8266 HTTP to Domoticz. In my opinion, this got nothing to do with sensor position since it works just fine on Espeasy, but same setup with plugin, twice a day peak values of over 100 litres. If somebody guides me to better logging I am happy to re-set up with plugin....maybe akamming is able to help.
-
- Posts: 69
- Joined: Friday 14 November 2014 9:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Last week i did a fresh install of Domoticz and updated to (build 138172). Now the watermeter-plugin gives an error
I have read in this post that this probably has something to do with the new Python framework.
https://domoticz.com/forum/viewtopic.p ... 81#p279981
Or could this be the problem?
https://www.domoticz.com/wiki/Developi ... hon_plugin
Code: Select all
Error: (FindModule) Domoticz/DomoticzEx modules not found in interpreter.
https://domoticz.com/forum/viewtopic.p ... 81#p279981
Or could this be the problem?
https://www.domoticz.com/wiki/Developi ... hon_plugin
Troubleshooting
Importing Modules Fails
...........
Broadly these are: the plugin directory, the existing Python path as picked up when Domoticz started and the 'site' directories for system level modules installed with pip3. Local 'site' directories are not searched by defaul although plugin developers can add any directory the like to the path inside the plugin. Pip3 installs packages in system directories when sudo is used on linux platforms.
-
- Posts: 12
- Joined: Friday 18 September 2020 11:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi, need to withdraw my post. I have now added 1K resistors to my sensors (water pull-down / gas pull-up) and seems working fine. I will need to check on a longer period to confirm that no fake counts occur. I also added some pictures from my Zenner water and Actaris gas counter...thanks again to akamming for the plug-in.GeyerA wrote: ↑Thursday 25 November 2021 18:19Hi, I now also installed a Zenner NPN and did run with ESP8266 (espeasy) without problems. I sent the count to a virtual sensor and did not encounter any issues.JeeGee wrote: ↑Friday 24 January 2020 19:35 My PNP with the plugin was running fine, but this week I had 3 times the issue that the measuring went crazy.
Examples: in one hour it said I used 400 liters, out of the blue and even one time 15.000 liters.
Tried to place the PNP a it different, but so far it didn't help.
Anyone else seeing this? And could be the cause?
I then thought lets hook up the sensor directly to PI running the plugin. I also get once or twice a day peak values of over 100 litres consumption although no water was used. I set-up the Telegram notification on "above" 100 litres consumption and that one even keeps on sending messages with the disabled plug-in (and disconnected sensor). I moved back to ESP8266 HTTP to Domoticz. In my opinion, this got nothing to do with sensor position since it works just fine on Espeasy, but same setup with plugin, twice a day peak values of over 100 litres. If somebody guides me to better logging I am happy to re-set up with plugin....maybe akamming is able to help.
BTW, using this reed sensor on the gas counter https://www.pic-gmbh.com/produkte/ms-332-3
UPDATE: Just got again a fake read of 250 liters water consumption; could it be that the pull up resistor is too small with 1K?
UPDATE2: Now changed to 10K resistor...
UPDATE3: Still had a fake reading on water sensor so displaced the raspberry away from any disturbances like NAS, power and network cables as well as network gigaswitches and managed to have one day without fake reading. I will keep you posted.
UPDATE4: Since the fake readings on water sensor did come back, I decided to move back to ESP8266 with ESPeasy. (pulse high on water and gas meter as well as 500ms debounce time).
UPDATE5: Fake readings still occurred also on ESP8266, seems the water sensor reading is the culprit. I have now connected the gas sensor on raspberry using the nice domoticz plugin and water on WeimosMini with espeasy. I also have to say that the external 1KOhm pull ups did not change anything so I am also using the internal pullups.
UPDATE6: It has now been working for nearly a week without fake reading. Seems, if I hook up both sensors on one device (regardless external 1kOhm pull-up or not), interferences will occur. Having it split, works fine.
- Attachments
-
- PXL_20211207_111742281s.jpg (220.86 KiB) Viewed 1921 times
-
- PXL_20211207_111733166s.jpg (212.36 KiB) Viewed 1921 times
-
- Posts: 111
- Joined: Thursday 08 December 2016 9:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Hi
Anyone updated the Python script to work with Python 3?
Needed to replace my PI, so took the opportunity to upgrade to PI 4 and latest version software.
When rebuilding config and installing the watermeter.py script again I got an error message:
Traceback (most recent call last):
File "/home/bernard/domoticz/scripts/watermeter.py", line 4, in <module>
import urllib2
ModuleNotFoundError: No module named 'urllib2'
Looked it up and Python 3 does not support urllib2
This is replaced by urllib.request, urllib.parse with different syntax to use. As I have no programming skills I tried this:
replace:
import urllib2
with:
import urllib.parse
import urllib.request
and replace:
req1 = urllib2.Request(url1)
response1 = urllib2.urlopen(req1)
with:
req1 = urllib.request(url1)
reponse1 = urlopen(req1)
would this be correct? it appears to work as I do not get an error on this, now I have:
Traceback (most recent call last):
File "/home/bernard/domoticz/scripts/watermeter.py", line 20, in <module>
f = file(fn, "r+")
NameError: name 'file' is not defined
Is that something that has changed when moving to Python 3?
When someone has updated the Python script when you share it will be much appreciated.
I have the feeling the debugging is above my programming knowledge
Thank you very much,
Bernard
Anyone updated the Python script to work with Python 3?
Needed to replace my PI, so took the opportunity to upgrade to PI 4 and latest version software.
When rebuilding config and installing the watermeter.py script again I got an error message:
Traceback (most recent call last):
File "/home/bernard/domoticz/scripts/watermeter.py", line 4, in <module>
import urllib2
ModuleNotFoundError: No module named 'urllib2'
Looked it up and Python 3 does not support urllib2
This is replaced by urllib.request, urllib.parse with different syntax to use. As I have no programming skills I tried this:
replace:
import urllib2
with:
import urllib.parse
import urllib.request
and replace:
req1 = urllib2.Request(url1)
response1 = urllib2.urlopen(req1)
with:
req1 = urllib.request(url1)
reponse1 = urlopen(req1)
would this be correct? it appears to work as I do not get an error on this, now I have:
Traceback (most recent call last):
File "/home/bernard/domoticz/scripts/watermeter.py", line 20, in <module>
f = file(fn, "r+")
NameError: name 'file' is not defined
Is that something that has changed when moving to Python 3?
When someone has updated the Python script when you share it will be much appreciated.
I have the feeling the debugging is above my programming knowledge
Thank you very much,
Bernard
Who is online
Users browsing this forum: No registered users and 1 guest