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.
Melissen
Posts: 47
Joined: Wednesday 16 November 2016 10:39
Target OS: -
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Melissen » Sunday 26 August 2018 12:01

Also made a script for a waterflowmeter !!!

You first need to make-activate 2 uservariables.
-begin INTEGER value=0
-begintijd INTEGER value=0
Then you need to make a virtual device Waterflow
- go to HARDWARE and make another virtualsensor "Waterflow" at Watermeter and use this as 'waterflow'


After this, you can use this script
jIDX is number of Waterflow device.

BE CAREFUL... AFTER 5 minutes of inactive watermeter, the flow resets to zero. When you use water again and the switch (on the watermeter) is almost directly ON, you can read a high flow-result, after the second liter the reading will be correct. When you turn off the water the flow will give the last value, but resets after 5 minutes. Will you turn on the water after about 4 minutes, you will get a low flow-value, because you only used that liter in the last 4 minutes. So the flow is 0,25liter/min ( 1 liter in 4 minutes)
Hope you will understand the start and end values of the flowmeter. When you use water for a longer time, the readings will be spot on.

EDITED 26-8 18:42
Edited line56 (putted - 300 in it), so the flowvalue isn't very high when you turn on water and metal plate is right in front of sensor. So no high values like 120liters/min anymore

Code: Select all

commandArray = {}

-- IDX Waterflow
jIDX = 404

-- Begintijd in uservariables zetten
if  (uservariables['begin'] == 0)
    then
        -- print ("begin instellen")
        commandArray['Variable:begin'] = tostring(1)
        commandArray['Variable:begintijd']= tostring(os.time())
end        

-- Decimalen
function round(num, numDecimalPlaces)
   local mult = 10^(numDecimalPlaces or 0)
   return math.floor(num * mult + 0.5) / mult
end

-- timedifference
functiontimedifference(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


-- Script
if (devicechanged['GPIO Watermeter'] == 'Off')
   then 
       -- print ("Watermeter gaat naar Off")
       btijd = uservariables['begintijd']
       duur = os.time() - btijd
       lpm = 60 /duur
       -- print (lpm)
       lpm = round(lpm, 2)
       -- print (btijd)
       -- print (os.time() - btijd)
       -- print (os.time())
       -- print (duur)
       -- print (lpm)
       commandArray['Variable:begintijd']= tostring(os.time())
       commandArray['UpdateDevice'] = ''..jIDX..'|0|'..lpm..''
   else
        -- Keep a live device and set flow to zero
        if (timedifference(otherdevices_lastupdate["GPIO Watermeter"]) > 300)
           then
               -- print("tijd langer dan 300")
               flow = 0
               -- commandArray['Variable:begintijd']= tostring(os.time() - 300)
               commandArray['UpdateDevice'] = ''..jIDX..'|0|'..flow..''
        end
end       

return commandArray
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches

jonathan12
Posts: 6
Joined: Sunday 31 December 2017 18:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by jonathan12 » Tuesday 28 August 2018 11:31

jonathan12 wrote:
Wednesday 15 August 2018 21:27
How big does the voltage drop has to be of the NPN sensor?

Mine is 2.8V with metal detecting and 3.5V without metal.
Input is 5V and i use a zener diode 3.3V

When i test the sensor it is always level=1
The led is on when metal is detected

pi@raspberrypi:~ $ sudo raspi-gpio get 21
GPIO 21: level=1 fsel=0 func=INPUT
Can someone tell me how big the voltage drop has to be?
My sensor is always level 1. With or without metal.

freijn
Posts: 396
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by freijn » Tuesday 28 August 2018 13:30

It must go from VCC to zero

I have found, the higher the voltage the more sensitive it becomes. +5 could work but is too low..

CAREFULL **WARNING** !!

If you make VCC +12 then the output will be +12 as well. Feeding that into a Rapsberry or Arduino will be destructive !

I have made voltage reducer with 2 resistors and 1 led... Nice bonus is the led shows the puls :-)

webrazor
Posts: 29
Joined: Monday 09 November 2015 10:33
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by webrazor » Wednesday 05 September 2018 15:55

I got the original script in this post running but only when i start it manual with

Code: Select all

python watermeter.py
For some reason the script wont execute in the crontab. This is the log:

Code: Select all

Sep  5 15:22:57 raspberrypi cron[390]: (CRON) INFO (Running @reboot jobs)
Sep  5 15:22:57 raspberrypi CRON[435]: (webrazor) CMD (sudo /usr/bin/python /home/pi/domoticz/scripts/watermeter.py >/var/log/cronlog.log 2>&1)
And this is the code in the crontab using: crontab -e

Code: Select all

@reboot sudo /usr/bin/python /home/pi/domoticz/scripts/watermeter.py >/var/log/cronlog.log 2>&1
How can i check the script is really running?

bolderbast
Posts: 4
Joined: Thursday 06 September 2018 17:39
Target OS: Linux
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by bolderbast » Thursday 06 September 2018 17:51

Hi all,

I got this working, however with every 1 liter the Domoticz sensor increases with 10 liters. I can reproduce it as follows:

curl "https://<server>:<port>/json.htm?type=command&param=udevice&idx=966&svalue=600
Sensor reports 6 m3

curl "https://<server>:<port>/json.htm?type=command&param=udevice&idx=966&svalue=601
Sensor reports 6.01 m3

But 1 liter should be 0,001 m3 instead of 0,01 m3.

Any suggestions?
Thanks in advance!

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

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Hobbybob » Thursday 06 September 2018 18:00

bolderbast wrote:
Thursday 06 September 2018 17:51
Hi all,

I got this working, however with every 1 liter the Domoticz sensor increases with 10 liters. I can reproduce it as follows:

curl "https://<server>:<port>/json.htm?type=command&param=udevice&idx=966&svalue=600
Sensor reports 6 m3

curl "https://<server>:<port>/json.htm?type=command&param=udevice&idx=966&svalue=601
Sensor reports 6.01 m3

But 1 liter should be 0,001 m3 instead of 0,01 m3.

Any suggestions?
Thanks in advance!
Make sure you have the correct settings in Domoticz.

Go to "Settings" -< "Meters/counters" and make sure you have 1000 filled in the option water meter divider. You probably have 100 there.

bolderbast
Posts: 4
Joined: Thursday 06 September 2018 17:39
Target OS: Linux
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by bolderbast » Thursday 06 September 2018 18:12

Hobbybob wrote:
Thursday 06 September 2018 18:00
bolderbast wrote:
Thursday 06 September 2018 17:51
Hi all,

I got this working, however with every 1 liter the Domoticz sensor increases with 10 liters. I can reproduce it as follows:

curl "https://<server>:<port>/json.htm?type=command&param=udevice&idx=966&svalue=600
Sensor reports 6 m3

curl "https://<server>:<port>/json.htm?type=command&param=udevice&idx=966&svalue=601
Sensor reports 6.01 m3

But 1 liter should be 0,001 m3 instead of 0,01 m3.

Any suggestions?
Thanks in advance!
Make sure you have the correct settings in Domoticz.

Go to "Settings" -< "Meters/counters" and make sure you have 1000 filled in the option water meter divider. You probably have 100 there.
Spot on! Thanks for this quick help! :-)

rubberduck84
Posts: 5
Joined: Monday 15 February 2016 10:09
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by rubberduck84 » Friday 05 October 2018 20:39

Ik have problems with the python script.
I got this error on domoticz

2018-10-05 20:37:32.288 Error: EventSystem: Failed to execute python event script "watermeter"
2018-10-05 20:37:32.289 Error: EventSystem: File "<string>", line 61
2018-10-05 20:37:32.289 Error: EventSystem: print "JSON call = "+ str(url1)
2018-10-05 20:37:32.289 Error: EventSystem: ^
2018-10-05 20:37:32.289 Error: EventSystem: SyntaxError: invalid syntax

Have anyone the fix for this problem?

Joep123
Posts: 34
Joined: Monday 26 March 2018 18:44
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Joep123 » Monday 08 October 2018 18:42

Melissen wrote:
Sunday 26 August 2018 12:01
Also made a script for a waterflowmeter !!!

You first need to make-activate 2 uservariables.
-begin INTEGER value=0
-begintijd INTEGER value=0
Then you need to make a virtual device Waterflow
- go to HARDWARE and make another virtualsensor "Waterflow" at Watermeter and use this as 'waterflow'

After this, you can use this script. jIDX is number of Waterflow device.
Thanks for sharing this script, works fine (just a small typo: functiontimedifference(s) should be function timedifference(s), with a space after function).

I saved the script as script_device_waterflow.lua but I see the script will be triggered mutiple times in a second. How can I solve this? The average load of my Pi increased from 2% to 11-12%.

2018-10-08 18:28:37.117 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:39.288 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:39.585 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:39.851 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:39.918 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:39.958 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:39.993 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.027 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.061 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.095 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.129 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.163 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.402 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.638 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:40.929 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:41.168 Status: EventSystem: Script event triggered: Waterflow
2018-10-08 18:28:41.203 Status: EventSystem: Script event triggered: Waterflow

leonkoster
Posts: 2
Joined: Sunday 12 August 2018 20:52
Target OS: -
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by leonkoster » Tuesday 16 October 2018 22:17

I tried making it work but i keep getting the following error:

Traceback (most recent call last):
File "/home/pi/downloads/domoticz/scripts/watermeter.py", line 21, in <module>
f = file(fn, "r+")
NameError: name `file` is not defined

remko2000
Posts: 47
Joined: Thursday 28 December 2017 15:38
Target OS: Raspberry Pi
Domoticz version:
Location: Broek op Langedijk
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by remko2000 » Friday 19 October 2018 18:07

I've a problem to read good values from my NPN-sensor (https://nl.aliexpress.com/item/Free-Shi ... 4c4dzOHtIO.
I connect it like this:
Schermafbeelding 2018-10-19 om 17.58.53.png
Schermafbeelding 2018-10-19 om 17.58.53.png (16.78 KiB) Viewed 403 times
I use this script:

Code: Select all

#!/usr/bin/env python

#imports
import time
import RPi.GPIO as GPIO
import json
import urllib2
import threading

#vars
GET_URL = 'http://localhost:8080/json.htm?type=devices&rid=%d'
SET_URL = 'http://localhost:8080/json.htm?type=command&param=udevice&idx=%d&svalue=%d'
WATER_DELTA = 0
WATER_IDX = 184
WATER_GPIO = 23
WATER_COUNTER_LOCK = threading.Lock()

def gpio_intr(pin):
    if pin == WATER_GPIO:
        global WATER_DELTA
        with WATER_COUNTER_LOCK:
            WATER_DELTA += 1
        print 'Water counter tick: %d' % WATER_DELTA

def main():
    global WATER_DELTA

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(WATER_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.add_event_detect(WATER_GPIO, GPIO.FALLING, callback=gpio_intr)

    while True:
        time.sleep(5)

        WATER_DELTA_POST = WATER_DELTA
        if WATER_DELTA_POST != 0:
            try:
                res = json.load(urllib2.urlopen(SET_URL % (WATER_IDX, WATER_DELTA_POST)))
                if res['status'] != 'OK':
                    raise Exception('Domoticz json error')
                with WATER_COUNTER_LOCK:
                    WATER_DELTA -= WATER_DELTA_POST
            except Exception as e:
                print e

        print 'Water delta %d ' % (WATER_DELTA_POST)

if __name__=="__main__":
    main() 
If I start my script and when I go past the sensor with my screwdriver I get this back:

Code: Select all

Callback function called!
quitting event handler because this was probably a false positive
Callback function called!
JSON call = http://10.0.1.88:8080/json.htm?type=command&param=udevice&idx=17&svalue=14
Watermeter Counter = 14
Callback function called!
quitting event handler because this was probably a false positive
Callback function called!
JSON call = http://10.0.1.88:8080/json.htm?type=command&param=udevice&idx=17&svalue=15
Watermeter Counter = 15
Callback function called!
quitting event handler because this was probably a false positive
Callback function called!
JSON call = http://10.0.1.88:8080/json.htm?type=command&param=udevice&idx=17&svalue=16
Watermeter Counter = 16
Callback function called!
quitting event handler because this was probably a false positive
Callback function called!
JSON call = http://10.0.1.88:8080/json.htm?type=command&param=udevice&idx=17&svalue=17
Watermeter Counter = 17
Callback function called!
quitting event handler because this was probably a false positive
Callback function called!
JSON call = http://10.0.1.88:8080/json.htm?type=command&param=udevice&idx=17&svalue=18
Watermeter Counter = 18
I get some input in my RFXMeter sensor in Domoticz (V4.10007) but this is very irregular and goes up but also down. These are not reliable values.
In the file: meterstand_water.txt I only see: ' meterstand = 21'.

What can be the problem?
Attachments
Schermafbeelding 2018-10-19 om 18.53.17.png
Schermafbeelding 2018-10-19 om 18.53.17.png (26.65 KiB) Viewed 399 times
Schermafbeelding 2018-10-19 om 18.06.52.png
Schermafbeelding 2018-10-19 om 18.06.52.png (27.02 KiB) Viewed 400 times

remko2000
Posts: 47
Joined: Thursday 28 December 2017 15:38
Target OS: Raspberry Pi
Domoticz version:
Location: Broek op Langedijk
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by remko2000 » Sunday 21 October 2018 15:55

Problem solved. I think a problem with the hardware/100nF condensator. It's now working like a charm with the pythonscript from @pvangorp. Now I try to add the waterflowmeter from @pvangorp https://ehoco.nl/waterflowmeter-in-domo ... omment-257
but get the following error:
2018-10-21 15:57:18.216 Error: EventSystem: in Waterflow: [string "commandArray = {}..."]:22: bad argument #1 to 'sub' (string expected, got nil)
Maybe some errors in the LUA script?

jonathan12
Posts: 6
Joined: Sunday 31 December 2017 18:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by jonathan12 » Sunday 28 October 2018 13:11

I tried to make the watermeter working in Domoticz by following the manual of: https://ehoco.nl/watermeter-uitlezen-in ... ua-script/

I and many others are still getting this error: EventSystem: in Watermeter: [string “commandArray = {}…”]:18: attempt to perform arithmetic on global ‘sWaterUsage’ (a nil value)

Does someone know how to fix it?

The on off switch is detecting the sensor.

User avatar
philchillbill
Posts: 230
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Watermeter lezen met raspberry en Inductieve NPN sensor

Post by philchillbill » Saturday 03 November 2018 16:33

webrazor wrote:
Wednesday 05 September 2018 15:55
For some reason the script wont execute in the crontab...
It's better to run this python script as a systemd service than as a cronjob. Cron is more intended for something that runs for a while and comes to a natural finish, like a backup. Services are for things that keep running indefinitely, which is definitely what this is intended to do. After all, Domoticz runs as a service and not as a cronjob...

Create the watermeter.service unit file

Code: Select all

 cd /etc/systemd/system
 sudo nano watermeter.service
Copy/paste the text below into the editor (if you placed your python script in a different directory than /home/pi then adjust WorkingDirectory and ExecStart accordingly):

Code: Select all

 [Unit] 
  Description=WaterUsageMonitor 
  Wants=network.target
  After=network.target
 [Service]
  Type=simple 
  WorkingDirectory=/home/pi
  ExecStart=/usr/bin/python /home/pi/watermeter.py
 [Install]
  WantedBy=multi-user.target
Save the file in the editor by hitting CTRL-X and then saying Y to update and save.
Reload the system control config, start the service now, and enable it to always automatically start at system boot:

Code: Select all

 sudo systemctl daemon-reload
 sudo systemctl start watermeter.service
 sudo systemctl enable watermeter.service
If you want to see the status of the service to check for errors, at any time you can type

Code: Select all

 sudo systemctl status watermeter.service
Don’t forget to remove any cronjob that also starts the script (if you had one) as otherwise it will run twice on your system simultaneously.
Last edited by philchillbill on Saturday 03 November 2018 16:33, edited 5 times in total.
NUC/Ubuntu, Evohome Heating + HGI80, Evohome Security, 4x HikVision IP cams, Aeotec, Neo & Fibaro Z-Wave, Logitech Media Server (on Synology DS916+), 10x SqueezeBox, Kodi, Harmony Hub, 5x Amazon Echo, HA-Bridge, Hue.

User avatar
philchillbill
Posts: 230
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by philchillbill » Saturday 03 November 2018 16:39

remko2000 wrote:
Friday 19 October 2018 18:07
I connect it like this:

Schermafbeelding 2018-10-19 om 17.58.53.png

What can be the problem?
The problem with this circuit is that your 3k3 resistor will be in parallel with the input resistance of the GPIO pin when you connect it up. This means that your voltage divider will not be very stable, nor will it divide by the ratio you expect. It's much safer to use either a FET as a level-shifter, or use a zener diode. Both approaches are explained in earlier posts in this thread.
NUC/Ubuntu, Evohome Heating + HGI80, Evohome Security, 4x HikVision IP cams, Aeotec, Neo & Fibaro Z-Wave, Logitech Media Server (on Synology DS916+), 10x SqueezeBox, Kodi, Harmony Hub, 5x Amazon Echo, HA-Bridge, Hue.

mickmack82
Posts: 4
Joined: Wednesday 31 January 2018 16:04
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by mickmack82 » Thursday 15 November 2018 17:53

jonathan12 wrote:
Sunday 28 October 2018 13:11
I tried to make the watermeter working in Domoticz by following the manual of: https://ehoco.nl/watermeter-uitlezen-in ... ua-script/

I and many others are still getting this error: EventSystem: in Watermeter: [string “commandArray = {}…”]:18: attempt to perform arithmetic on global ‘sWaterUsage’ (a nil value)

Does someone know how to fix it?

The on off switch is detecting the sensor.
The problem is the initial value 0 when a new sensor is created and the fact that the sensor never has been updated, since it is new.
The current LUA script cant deal with that. This problem occurs every single day, because at midnight the counter is reset to 0 for the new day.
I came up with the following script that seems to be working. The only disadvantage is that a new day doesn't start with 0 litres, but with 1. This could be adjusted to 0.0001 for example, as long it is not 0.

Code: Select all

commandArray = {}

-- Set IDX of Watermeter
iIDX = 360

-- 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

if ( uservariables["WaterMeter"] == -1 ) then
    commandArray['UpdateDevice'] = ''..iIDX..'|0|0'
    commandArray['Variable:WaterMeter'] = tostring(0)
    return commandArray
end

-- Water usage
-- Retrieve value from water meter device:
sWaterUsage = tonumber(otherdevices_svalues['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 (sWaterUsage == 0 or sWaterUsage == nil) then
        print("Nil or 0")
        sWaterUsage = 1
        commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..'' 
        return commandArray
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("> 300")
        print("Water usage is still " .. sWaterUsage / 1000 .. "m3 ")
        commandArray['UpdateDevice'] = ''..iIDX..'|0|'..sWaterUsage..''   
    end
end

return commandArray

Joep123
Posts: 34
Joined: Monday 26 March 2018 18:44
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Joep123 » Thursday 15 November 2018 21:10

Thanks for sharing the modified script @mickmack82.

But when I reboot the Pi the counter and daily usage will be resetted to value 0.

Joep123
Posts: 34
Joined: Monday 26 March 2018 18:44
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Joep123 » Thursday 15 November 2018 21:11

mickmack82 wrote:
Thursday 15 November 2018 17:53
The problem is the initial value 0 when a new sensor is created and the fact that the sensor never has been updated, since it is new.
The current LUA script cant deal with that. This problem occurs every single day, because at midnight the counter is reset to 0 for the new day.
I came up with the following script that seems to be working. The only disadvantage is that a new day doesn't start with 0 litres, but with 1. This could be adjusted to 0.0001 for example, as long it is not 0.
Thanks for sharing the modified script @mickmack82.

But when I reboot the Pi the counter and daily usage will be resetted to value 0.

mickmack82
Posts: 4
Joined: Wednesday 31 January 2018 16:04
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by mickmack82 » Thursday 15 November 2018 21:29

Ok. I must admit that I havn't tested that scenario.
I'll do some more tests in the weekend.

Evertjob89
Posts: 3
Joined: Sunday 18 November 2018 10:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Watermeter lezen met raspberry en Inductieve NPN sensor

Post by Evertjob89 » Sunday 18 November 2018 10:22

Goodmorging,

Friday i've received the NPN sensor and got it finally working after some issues.
The only problem i have is that the script (most likely) is pushing random liters to Domoticz, for example on 04:00 i've used 0 liters but Domoticz got 11 liters counted.

Does any one has the same issues or any idea how i can solve this problem?

Kinds regards,
Evert-Job

Post Reply

Who is online

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