This project sets up a Raspberry Pi to read my gasmeter by a metal sensor. The gasmeter is a Pipersberg G4 RF1 c.
The metal sensor must be placed on the gasmeter and will read each 0,01m3 consumption.
The project is inspired by a blog post from rutg3r.com and I adopted it to InfluxDB and gpiozero.
- A Raspberry Pi
- A Metal Inductive Proximity Sensor / Proximity switch operating at 5V. I use the 5V Metal Proximity Switch by DFRobot
Connect the sensor to the Pi's GPIO pins:
Sensor cable color | GPIO pin | Description |
---|---|---|
Black | 6 | Ground |
Brown | 4 | 5V |
Blue | 7 (GPIO4) | Signal |
(see Pi's Pin numbering)
Attach the sensor to the gasmeter and ensure, that the sensor light switches on/off on each 0,01m3 consumption.
Install Docker on the Raspberry Pi and bring up the Docker Compose file.
This will launch InfluxDB and a small Python script which forwards consumption readings at the GPIO pin to InfluxDB.
Navigate to http://<pi host>:8086
and create a Dashboard with the following query
consumption = from(bucket: "sensors")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "gas" and r._field == "consumption")
consumption
|> aggregateWindow(every: 1h, fn: sum)
|> yield(name: "/h")
consumption
|> aggregateWindow(every: 1d, fn: sum)
|> yield(name: "/d")
The Dashboard will show you a per hour and a per day consumption graph: