Why don't you connect the sensor to an esp8266? with esp easy installed on it, I find it is the best solution to get data wireless to your pi. I bought https://www.aliexpress.com/item/new-Wir ... 0.0.RhBndZHobbybob 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?
Watermeter lezen met raspberry en Inductieve NPN sensor Topic is solved
Moderators: leecollings, remb0
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
-
- Posts: 70
- Joined: Tuesday 28 March 2017 10:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Latest B
- Location: The Netherlands
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Thats also a way of fixing it
-
- Posts: 70
- Joined: Tuesday 28 March 2017 10:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Latest B
- Location: The Netherlands
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
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 line
My updated script
I also added a variable for IDX, to make it easier to change the script.
So you don't need the line
any moreTo set the initial meter values http://<<YOUR DOMOTICZ IP>>/json.htm?type=command¶m=udevice&idx=34&svalue=999999
My updated script
Code: 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
Last edited by pvangorp on Wednesday 06 September 2017 21:01, edited 1 time in total.
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
I have somthing setup now with a wire, but perhaps for future sensors (I don't think this will be the last one I connect). Is there a wiki or tutorial or anything on how to connect and configure one of these for usage in Domoticz? I'm very interested.u01pei wrote: ↑Wednesday 06 September 2017 20:33Why don't you connect the sensor to an esp8266? with esp easy installed on it, I find it is the best solution to get data wireless to your pi. I bought https://www.aliexpress.com/item/new-Wir ... 0.0.RhBndZHobbybob 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?
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Yes there is:I have somthing setup now with a wire, but perhaps for future sensors (I don't think this will be the last one I connect). Is there a wiki or tutorial or anything on how to connect and configure one of these for usage in Domoticz? I'm very interested.
https://www.letscontrolit.com/wiki/index.php/ESPEasy
-
- Posts: 16
- Joined: Saturday 12 August 2017 9:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
I received another 2 sensors. Both are working fine except one wont read through the plastic on my watermeter. As far as i can see i have the same meter posted here in this topic.
Can anybody explain why i don't get the liters but the total amount as stated in the attachment ?
Can anybody explain why i don't get the liters but the total amount as stated in the attachment ?
- Attachments
-
- water.png (12.16 KiB) Viewed 2951 times
-
- Posts: 70
- Joined: Tuesday 28 March 2017 10:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Latest B
- Location: The Netherlands
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Disconnect it from your pi and test it with a 9v battery. The higher the voltage, the bettter the detection. When it works oke you'll need a 9v or 12v adapter and a step-down converter otherwise you'll fry your pi.
The litres is only the first day. The counter is set initially today.
The litres is only the first day. The counter is set initially today.
-
- Posts: 16
- Joined: Saturday 12 August 2017 9:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
One is working from within the pi, the other one just isn't strong enough even with an 12v or 24v adapter is just doenst read through the plastic. I guess there is a slight difference in both npn's.
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
I had the same problem. The sensor worked when I tested it by holding it against something metal, but the plastic top on the watermeter was too thick or something. Also with a 12v adapter. I now have a working setup with a tcrt5000 with the help of heggink. That uses an infared detector, maybe you could look at that.
-
- Posts: 138
- Joined: Thursday 01 May 2014 9:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands - Sittard
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
If you share your script we can have a look. Perhaps you are mixing up nvalues and svalues?ratjenl wrote: ↑Wednesday 06 September 2017 21:31 I received another 2 sensors. Both are working fine except one wont read through the plastic on my watermeter. As far as i can see i have the same meter posted here in this topic.
Can anybody explain why i don't get the liters but the total amount as stated in the attachment ?
- LouiS22
- Posts: 433
- Joined: Friday 27 February 2015 13:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Budapest, Hungary
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
1 m3 is 1000 liter. So your screenshot seems correct. 914 m3 is 914000 liter.ratjenl wrote: ↑Wednesday 06 September 2017 21:31 I received another 2 sensors. Both are working fine except one wont read through the plastic on my watermeter. As far as i can see i have the same meter posted here in this topic.
Can anybody explain why i don't get the liters but the total amount as stated in the attachment ?
One more thing: have you set the divider at domoticz's settings page (Settings/Meters-Counters/) (as stated on the first post)? Maybe that'S the step you missed.
- gielie
- Posts: 290
- Joined: Tuesday 12 January 2016 11:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest β
- Location: The Netherlands (Alkmaar)
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
OK i tried this script but i can't get to work, i don't understand any of it, the python script works great but id like this one to work either and there must be something im missing.pvangorp 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
Can you change the script with some additions of the variables in the beginning like IDX=? GP0=?
What kind of switch do i have to add? and how does the script know what gpo pin i use.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
-
- Posts: 16
- Joined: Saturday 12 August 2017 9:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Everything is working now ok for me. Domoticz is showing a lot more then the actual usage ( domoticz says 915.333 while the meter says 915.261. I am trying to figure out how to fix this, maybe it is because i placed the npn not good enough. Sometimes the red led keeps burning. Anybody else got this issue aswell ?
-
- Posts: 62
- Joined: Monday 28 August 2017 16:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
Check hownyour sensor works.
If you sensor short/unshort VCC then you need to pulldown gpio
If your sensor is short/unshort GND then you need to pullup gpio
Then you need to know when your sensor is shorting unshorting pin (vcc of gnd)
If it unshort pin by bounce so you need in your script
if (devicechanged['GPIO Watermeter'] == 'Off')
If it shorts the pin by bounce you need
if (devicechanged['GPIO Watermeter'] == 'on')
If you have that wrong, so you became wrong measure.
If you sensor short/unshort VCC then you need to pulldown gpio
If your sensor is short/unshort GND then you need to pullup gpio
Then you need to know when your sensor is shorting unshorting pin (vcc of gnd)
If it unshort pin by bounce so you need in your script
if (devicechanged['GPIO Watermeter'] == 'Off')
If it shorts the pin by bounce you need
if (devicechanged['GPIO Watermeter'] == 'on')
If you have that wrong, so you became wrong measure.
-
- Posts: 16
- Joined: Saturday 12 August 2017 9:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
I don't get anything of what you are saying my friend. I got exactly the same sensor as the topicstarterMicha123 wrote: ↑Friday 08 September 2017 9:26 Check hownyour sensor works.
If you sensor short/unshort VCC then you need to pulldown gpio
If your sensor is short/unshort GND then you need to pullup gpio
Then you need to know when your sensor is shorting unshorting pin (vcc of gnd)
If it unshort pin by bounce so you need in your script
if (devicechanged['GPIO Watermeter'] == 'Off')
If it shorts the pin by bounce you need
if (devicechanged['GPIO Watermeter'] == 'on')
If you have that wrong, so you became wrong measure.
-
- 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
hi pvangorp,
I recently received a new NPN sensor.
I tested t with a 9v battery and it works!
when I put in on my meter, it doesn't work. I believe th glass is too thick for the sensor to measure anything.
is there a solution for this problem?
all tests work so I am close to the final step.
Thnx in advance!
I recently received a new NPN sensor.
I tested t with a 9v battery and it works!
when I put in on my meter, it doesn't work. I believe th glass is too thick for the sensor to measure anything.
is there a solution for this problem?
all tests work so I am close to the final step.
Thnx in advance!
- gielie
- Posts: 290
- Joined: Tuesday 12 January 2016 11:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest β
- Location: The Netherlands (Alkmaar)
- Contact:
Re: Watermeter lezen met raspberry en Inductieve NPN sensor
I had the same with one of my sensors (one worked out of the box one didnt).Trigun wrote: ↑Friday 15 September 2017 11:33 hi pvangorp,
I recently received a new NPN sensor.
I tested t with a 9v battery and it works!
when I put in on my meter, it doesn't work. I believe th glass is too thick for the sensor to measure anything.
is there a solution for this problem?
all tests work so I am close to the final step.
Thnx in advance!
What i did i took some of the plastic tip of the sensor with sandpaper, just a small bit and tested it and it worked, probably the plastic tip is too thick.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
-
- 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
Sounds like an idea! Will test it, thnx for Your reply!gielie wrote:I had the same with one of my sensors (one worked out of the box one didnt).Trigun wrote: ↑Friday 15 September 2017 11:33 hi pvangorp,
I recently received a new NPN sensor.
I tested t with a 9v battery and it works!
when I put in on my meter, it doesn't work. I believe th glass is too thick for the sensor to measure anything.
is there a solution for this problem?
all tests work so I am close to the final step.
Thnx in advance!
What i did i took some of the plastic tip of the sensor with sandpaper, just a small bit and tested it and it worked, probably the plastic tip is too thick.
Sent from my iPhone using Tapatalk
-
- 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
It Worked! thanks for the great tip!Trigun wrote: ↑Friday 15 September 2017 11:49Sounds like an idea! Will test it, thnx for Your reply!gielie wrote:I had the same with one of my sensors (one worked out of the box one didnt).Trigun wrote: ↑Friday 15 September 2017 11:33 hi pvangorp,
I recently received a new NPN sensor.
I tested t with a 9v battery and it works!
when I put in on my meter, it doesn't work. I believe th glass is too thick for the sensor to measure anything.
is there a solution for this problem?
all tests work so I am close to the final step.
Thnx in advance!
What i did i took some of the plastic tip of the sensor with sandpaper, just a small bit and tested it and it worked, probably the plastic tip is too thick.
Sent from my iPhone using Tapatalk
-
- 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
Hi pvangorp,pvangorp wrote: ↑Sunday 03 September 2017 7:56 The problem with my previous script is that when no water used, the devices shows offline.
I fixed this with a keep a live part. When no water detected update with keep a live every 5 minutes, just like the other smart meters in Domoticz.
Code: Select all
commandArray = {} -- 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'] = '34|0|'..sWaterUsageTot..'' else -- Keep a live device if (timedifference(otherdevices_lastupdate["Waterverbruik"]) > 300) then print("Water usage is still " .. sWaterUsage / 1000 .. "m3 "); commandArray['UpdateDevice'] = '34|0|'..sWaterUsage..'' end end return commandArray
where did you put this script and how to use it. I am experiencing the same.
Thnx in advance!
Who is online
Users browsing this forum: No registered users and 1 guest