Ever felt you want to connect to something that don't support any digital or analog signal to read? That’s how I felt about the water usage meter that is connected to my house before I got hold of an ESP32-CAM module.
The water usage meter, at least those I’ve seen in Sweden, has not yet embraced the digital era. It is a simple mechanical device that you manually read once per year and report to the water provider. The solution I eventually came up with was to mount an ESP32-CAM module in a custom made camera holder that I 3D-printed at my local maker-space. A cheap macro camera lens intended for smart phones is used to improve the image quality since the camera is mounted ~3cm from the meter gauges.
The module acquire an image of the fastest rotating gauge and tracks the angular difference of the gauge between two consecutive images. To get the angle of the gauge, some image analysis is done on the acquired image. The result is then sent over MQTT.
The water usage data is consumed by my Raspberry Pi based home display which also displays the hourly and daily water usage.
To measure consumption, the angle of a gauge arrow is found by aquire an image of the fastest rotating gauge. When the angle has been calculated it is compared with the angle from the previous image result. If the angle has changed, the consumption can be derived from the angular difference.
- Fetch image from the camera module (jpeg)
- Convert to RGB-values
- Crop image to configured bounding box.
- Convert to HSL (hue, saturation, lightness ) values. Keeping saturation only.
- With the saturation only image, a summation filter is rotated 360° around the center of the image. The filter is rotated 1° per iteration. The angle where the highest sum is calculated is in the direction of gauge arrow.
The image analysis parameters (bounding box and filter length) can be set through HTTP requests. Next step will be to have the device automatically calibrate to the gauge.
Comments