Difference between revisions of "RPiWaterMeter"

From wiki.breedveld.net
Jump to: navigation, search
Line 1: Line 1:
 
'''
 
'''
Water usage mesurement with a Raspberry Pi'''
+
Water usage mesurement with a Raspberry Pi'''<br>
 
In my case I use Domoticz, but it also works with Home-Assist and other products.
 
In my case I use Domoticz, but it also works with Home-Assist and other products.
 
<br><br>
 
<br><br>
Line 61: Line 61:
 
</div>
 
</div>
 
<br><br>
 
<br><br>
'''Partlist:'''
+
'''Partlist:'''<br>
 
I ordered most parts at the well known Chinese site.<br>
 
I ordered most parts at the well known Chinese site.<br>
 
- LJ12A3-4-Z/B magnetic sensor<br>
 
- LJ12A3-4-Z/B magnetic sensor<br>

Revision as of 08:06, 24 December 2020

Water usage mesurement 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"

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



Partlist:
I ordered most parts at the well known Chinese site.
- LJ12A3-4-Z/B magnetic sensor
- aluminium strip 20x2.5 cm
- 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 4 Model B / 3B+ / 3B Red RPI 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.