ESP8266 + Gas / Water monitoring
As a part of my home automation, I want to collect data on our Power, Gas and water usage. I already covered the power usage in a previous post, so this will describe my setup to monitor our water usage.
Fortunately, our gas meter (Pipersberg G4 RF1 c) and water meter (Sensus 620) both have a small metal and plastic disc, which spins. These are for the “Cyble” system. The gas/water company can get “cyble monitors” which allow for remote meter reading. You can occasionally find the sensors on Ebay, however they have a battery (non-replaceable but a ten year lifespan), and they are very expensive (more than 100 euros).
I figured I could build something for much cheaper, and do it without batteries. I ended up using:
- Wemos D1 board (around $5)
- Inductive Proximity Sensor, (around $2 each)
This will work on any meter which is able to work with the Cyble system (there is usually a “c” in the model number). You may have to re-position the sensor to fit your meter. You can often tell by looking at the meter if this will work. In my case, the water meter has the disc clearly visible:
The theory is, that as we use water, the little disc spins. The inductive proximity sensor will “sense” the metal part of the disc, but not the plastic part. Every liter of water that I use, this disc spins once. Most meters have a similar way of reading them — sometimes it’s a magnet (which you could then use a magnetic reed switch or hall effect sensor), and sometimes one of the digits (usually 0 or 6) have an infrared reflector on it (my gas meter’s 6 also has this). You could then use a TCRT5000 sensor to catch these.
Physical Mounting
I developed the following model in FreeCAD (FCSTD Source / STL), which will allow for the attachment of the sensor right over the disc (it’s important to mount the sensor at the side of the spinning disc, and not center it on the disc precisely). The wholes allow for reading of the meter without removing the attachment:
The Gas meter has a similar disc, however this is not visible. It does work exactly the same as the water meter, and pulses once per ten liters of gas. It is behind the round plastic circle just below the display of the meter:
Similar to the water meter, I made a “cap” which covers the gas meter’s face. The files can be downloaded here: FCSTD Source / STL.
Mounted, they look like this:
I would say, not tee bag! I’m curious what the meter reader is going to say when they visit.
Electronics
This was a bit challenging, as these inductive sensors use 6-24V. The goal is to power this from a cell phone USB charger, so I want to boost the 5v up to the necessary 12V. I had a boost converter in my parts, as well as a digital logic translator.
Software
I have chosen the ESP8266 firmware “Tasmota”, because it is very easy to use and allows for many configurations without having to re-compile and re-flash the ESP8266.
Install the Tasmota according to the regular instructions. Once it is installed, connect to the wifi hotspot and choose Configuration -> Module. Instead of being a “Sonoff Basic”, you need to change it to Generic Sonoff and hit save. Once it restarts, under Configuration -> Module and you should have the following options. It is important to set the two inputs D5 and D6 (as wired above) to Counter1 and Counter2:
You will also need to make use of the Tasmota Custom Commands to change the Debounce on the counters. As the disc rotates under the sensor, before it’s under the sensor it may trigger a few times, as well as when it moves away it may trigger it. Without debouncing, this would count as 5 rotations of the disc, however it really only passed once:
To change this, visit “http://<ip-of-the-module>/cm?cmnd=CounterDebounce%2080” – where 80 sets it to 80ms. I found this to be a decent value where the counter according to the Wemos matched the display of the meter.
Once this is done, flush the toilet, cook some bacon and check your counter values: