Difference between revisions of "RPiWaterMeter"

From wiki.breedveld.net
Jump to: navigation, search
Line 24: Line 24:
 
If you want the same Board it's called:<br>
 
If you want the same Board it's called:<br>
 
"MT3608 DC-DC Adjustable Boost Module Feed Converter  Voltage Regulator Module 2A Max 2 V-24 V to 5 V-28 V"<br>
 
"MT3608 DC-DC Adjustable Boost Module Feed Converter  Voltage Regulator Module 2A Max 2 V-24 V to 5 V-28 V"<br>
 +
Update: There are also sensors working at 5 Volt, this is a lot easier. In the time I build this, I didn't find them.<br> 
 
<br>
 
<br>
 
The output is connected to one of the GPIO's of the Pi, which first should configured as input, in my case I use GPIO28 (pin38/BCM20).<br>
 
The output is connected to one of the GPIO's of the Pi, which first should configured as input, in my case I use GPIO28 (pin38/BCM20).<br>
Line 85: Line 86:
 
     return commandArray
 
     return commandArray
 
<br>
 
<br>
[https://github.com/akamming/domoticz-watermeter or use the Domoticz plugin from Akamming]
+
[https://github.com/akamming/domoticz-watermeter You can also use the Domoticz plugin from Akamming]
  
<br><br>
+
<br>
 
'''Partlist:'''<br>
 
'''Partlist:'''<br>
 
Total Costs: about 10 Euro<br>
 
Total Costs: about 10 Euro<br>

Revision as of 11:42, 3 February 2021

Water usage measurement with a Raspberry Pi
In my case I use Domoticz, but it also works with Home-Assist and other products.

It works with a magnetic sensor, which can be used because of the half-metal rotor of watermeters in my country (Netherlands)
For magnetic sensor I use the LJ12A3-4-Z/B from the well known company in China.
You can use most types but be sure to buy the OC (Open-Collector) version, because most sensors use higher voltages than the Raspberry Pi, and you won't damage your Pi.

The sensor should be placed on the side of the rotator, not in the middle.

With a piece of aluminium it's easy to mount on the meter:

RPi watermeter sensor.jpeg

RPi watermeter beugel.jpeg


Shematics:

RPi watermeter schematics.jpeg

The sensor needs 9-36 Volt, a Raspberry Pi only can deliver 5 and 3.3 Volt.
You can use an extra 12 Volt adapter, but I don't like that......
I use an adjustable chopper board (also from China), adjusted as 12 Volt.
If you want the same Board it's called:
"MT3608 DC-DC Adjustable Boost Module Feed Converter Voltage Regulator Module 2A Max 2 V-24 V to 5 V-28 V"
Update: There are also sensors working at 5 Volt, this is a lot easier. In the time I build this, I didn't find them.

The output is connected to one of the GPIO's of the Pi, which first should configured as input, in my case I use GPIO28 (pin38/BCM20).
The led will show if it works, for every pulse 1 liter water is detected.

The diode is not needed if you use 1 Pi.
I use a Raspberry Pi Cluster, so I can do a failover.
The board is connected on 1 Pi, the other Pi is connected to the same pins: 6 and 38.
For the Power (pin 2) a diode is needed, 1 for each Pi, while it's a bad idea to connect the power to multiple Pi's.

First tested it with an experiment board:

RPi watermeter experiment.jpeg

To test it on a pi you need the gpio command:
if not installed:
sudo apt-get update
sudo apt-get install wiringpi
change GPIO 28 (BCM=20 and pin=38) as input:
sudo /usr/local/bin/gpio export 20 in
Put this line somewhere in a startup file, so it will stay that way, after reboot,
best below in /etc/rc.local (without sudo)
to show the states:
sudo gpio readall


This is the result:

RPi watermeter board.jpeg

All welded on an experiment board, for the Rpi, with a long pin connector, so you can stack other boards.
I use a RJ11 connector to connect the sensor.

Complete mounted on the Pi:

RPi watermeter complete.jpeg



Mounted in my Pi-Cluster, above the UPS-board:

Pi Cluster.jpg



Yust like a Christmas-Tree:

Pi Cluster Running.jpg



To get is working in Domotics:
Add "Generic sysfs GPIO" at Hardware.
The GPIO device will be added automatically after 1 pulse, I named it "WaterMeterPulse"
Add a virtual Sensor type "RFXMeter counter", I Called it "WaterMeter"
To get it working, add a lua script:

   -- sript_WaterMeter.lua
   -- 2018-09-04 v1.00 Roland Breedveld
   commandArray = {}
       if (devicechanged['WaterMeterPulse'] == 'Open') then
           water=otherdevices['WaterMeter']
           print("water impulse received: current liter: " .. water)
           water = water + 1
           --change 372 tot the ID of your WaterMeter device.
           commandArray['UpdateDevice']='372|0|'..water
       end
   return commandArray


You can also use the Domoticz plugin from Akamming


Partlist:
Total Costs: about 10 Euro
I ordered most parts at the well known Chinese site.
- LJ12A3-4-Z/B magnetic sensor
- aluminium strip 20x2.5cm, bended:4.5-11-4.5cm, with a ca 12mm hole
- MT3608 DC-DC Adjustable Boost Module Feed Converter Voltage Regulator (or external 12 Volt power supply)
- Led 2mm, green or red.
- resistor 680 Ohm
- capacitor ca. 100 nF
- RPi experiment board, I used: "DIY Proto HAT Shield Extension Board for Raspberry Pi GPIO Board"
- Connector, with long pins: "20 Pins Female Pin Header 2.54m Pitch Extra Tall Female Dual Row Short Pin Headers PCB Connector"
- optional: diode 1N4148 or something like that (1 for each RPi)
- RJ11 connector, but every other connector will be fine.