<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=GPIO_water_meter</id>
	<title>GPIO water meter - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=GPIO_water_meter"/>
	<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=GPIO_water_meter&amp;action=history"/>
	<updated>2026-09-18T20:44:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=GPIO_water_meter&amp;diff=17305&amp;oldid=prev</id>
		<title>Walter vl: Walter vl moved page GPIO meter to GPIO water meter</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=GPIO_water_meter&amp;diff=17305&amp;oldid=prev"/>
		<updated>2022-03-29T15:06:56Z</updated>

		<summary type="html">&lt;p&gt;Walter vl moved page &lt;a href=&quot;/GPIO_meter&quot; class=&quot;mw-redirect&quot; title=&quot;GPIO meter&quot;&gt;GPIO meter&lt;/a&gt; to &lt;a href=&quot;/GPIO_water_meter&quot; title=&quot;GPIO water meter&quot;&gt;GPIO water meter&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:GPIO Water meter}}&lt;br /&gt;
&lt;br /&gt;
Analog water meter reading with line sensor on GPIO Raspberry Pi.&lt;br /&gt;
&lt;br /&gt;
==Hardware==&lt;br /&gt;
&lt;br /&gt;
*Water sensor (any model with a rotating disk with different infrared reflection should do)&lt;br /&gt;
*Raspberry Pi Zero W with pre-soldered GPIO pins (any RPi will do)&lt;br /&gt;
*Line sensor (at least with digital out, prefereably also analog out to ease debugging. Working on 3.3V or 5.0V, I used https://www.hackerstore.nl/Artikel/26)&lt;br /&gt;
*Jumper cables to connect to RPi (easier than soldering)&lt;br /&gt;
*Adruino or oscilloscope (optional but recommended to ease electronic debugging)&lt;br /&gt;
*Some metal/wood/putty/screws for sensor mounting&lt;br /&gt;
&lt;br /&gt;
==Install==&lt;br /&gt;
&lt;br /&gt;
===Arduinoscope===&lt;br /&gt;
&lt;br /&gt;
If you have an arduino: get arduinoscope working http://www.instructables.com/id/Another-Arduino-Oscilloscope/&lt;br /&gt;
&lt;br /&gt;
===Debug with oscilloscope===&lt;br /&gt;
&lt;br /&gt;
Connect line sensor to oscilloscope, then try to find the best orientation to detect the contrast in reflection. For me this was under a ±45 degree angle with the plastic window of the water meter, I got a contrast of ±0.5V to ±2.5V.&lt;br /&gt;
&lt;br /&gt;
===Calibration===&lt;br /&gt;
&lt;br /&gt;
Once you are comfortable you know how the sensor works, mount it. Optionally use the potentiometer to adjust the digital out threshold. This should ideally be in the midpoint of the min and max voltage. For me this was at ±1.5V ((2.5+5)/2).&lt;br /&gt;
&lt;br /&gt;
==Software==&lt;br /&gt;
&lt;br /&gt;
===Set up domoticz===&lt;br /&gt;
&lt;br /&gt;
#Create dummy hardware, note idx&lt;br /&gt;
#Create virtual water sensor, using JSON&lt;br /&gt;
##&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;curl --insecure &amp;quot;https://127.0.0.1:10443/json.htm?type=createvirtualsensor&amp;amp;idx=&amp;lt;dummy hardware idx&amp;gt;&amp;amp;sensorname=Water&amp;amp;sensortype=113&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;curl --insecure &amp;quot;https://127.0.0.1:10443/json.htm?type=setused&amp;amp;idx=&amp;lt;id of sensor just created&amp;gt;&amp;amp;name=RFXMeter&amp;amp;switchtype=2&amp;amp;used=true&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Edit name of virtual sensor via web interface&lt;br /&gt;
#Update RFX division to 1000 for water in Domoticz setting (if you&amp;#039;re updating per liter)&lt;br /&gt;
#Test updating&lt;br /&gt;
##&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;curl --insecure &amp;quot;https://127.0.0.1:10443/json.htm?type=command&amp;amp;param=udevice&amp;amp;idx=24&amp;amp;svalue=1&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add script===&lt;br /&gt;
&lt;br /&gt;
See https://github.com/tvwerkhoven/water_meter_reader/blob/4bb9f2d1f59e44a8b9769b6ad2a4dc31ccb84237/water_worker.py&lt;br /&gt;
&lt;br /&gt;
===Run at startup===&lt;br /&gt;
&lt;br /&gt;
Add &lt;br /&gt;
 @reboot /home/pi/meter_water/water_worker.py&lt;br /&gt;
to crontab using crontab -e as any user&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&lt;br /&gt;
*https://www.domoticz.com/forum/viewtopic.php?f=28&amp;amp;t=17123&amp;amp;p=139918&amp;amp;hilit=water+meter#p139918&lt;br /&gt;
*https://www.raspberrypi.org/documentation/usage/gpio/&lt;br /&gt;
*https://www.domoticz.com/wiki/Python_-_Read-out_of_DDS238_kWh-meter_and_upload_to_Domoticz_and_to_PVOutput#Creating_the_Shell_script_used_in_cron&lt;br /&gt;
*https://gpiozero.readthedocs.io/en/stable/api_input.html#line-sensor-trct5000&lt;br /&gt;
*http://www.instructables.com/id/Another-Arduino-Oscilloscope/&lt;/div&gt;</summary>
		<author><name>Walter vl</name></author>
	</entry>
</feed>