Demid Dabizha 30891
This report presents a project aimed at developing a smart water metering system using computer vision technology. The project utilizes an ESP32-CAM module to capture images of a water meter and applies comuter vision to read the meter's digits. The system integrates with IoT infrastructure to enable remote monitoring and automatic reading of water consumption, facilitating efficient water usage management and billing. Additionally, the project includes designing a custom casing using Fusion 360, ensuring a durable and suitable housing for the device. The implementation aims to enhance accuracy, reduce labor, and provide real-time data access for better resource management.
Water metering is essential for monitoring water usage, managing resources, and billing consumers. Traditional methods of reading water meters manually are labor-intensive and prone to human error. By leveraging computer vision, it is possible to automate this process, thereby improving accuracy and efficiency. This technology is especially effective for use in cases where water meters are located in hard-to-reach places, for example, in a basement or hidden in a wall.
Computer vision, can interpret visual information and convert it into digital data. This advancement allows for the automation of tasks that were previously manual, significantly enhancing the efficiency and reliability of data collection.
The objective of this project is to design and implement a smart water metering system using the ESP32-CAM module. The system will capture images of a water meter, process these images to extract numerical readings, and transmit the data for remote monitoring. The ultimate goal is to provide a cost-effective, accurate, and scalable solution for modern water management systems.
ESP32-CAM-MB: Docking Station for ESP32-CAM:
The ESP32-CAM-MB is a docking station designed specifically for the ESP32-CAM compact camera module. This board features a USB-to-serial interface, simplifying the programming process. It includes two physical buttons, a reset button and a download button, which facilitate easy operation. The ESP32-CAM module plugs directly into this board using pin headers, creating a complete camera module that is both WLAN- and Bluetooth-capable, and can be programmed directly via USB without the need for soldering or additional development boards.
ESP32-CAM: Compact Camera Module:
The ESP32-CAM is a compact camera module that integrates seamlessly with the ESP32-CAM-MB. It is equipped with a high-resolution camera capable of capturing clear images for processing. This module features built-in WiFi and Bluetooth capabilities, making it ideal for IoT applications. The ESP32-CAM handles image capture and data transmission, enabling remote monitoring and control.
MicroSD Card (32GB):
A 32GB MicroSD card is used for storing captured images and configuration files. It offers ample storage space and fast read/write speeds, ensuring efficient handling of image data. It is recomended to use 16 GB SD card, in my case 32 GB worked fine.
USB A to Micro USB Cable: This cable is used to connect the ESP32-CAM-MB to a power source and for initial setup. It ensures a stable power supply and facilitates programming and debugging by providing a direct connection to a computer or other programming device.
WiFi Network: A WiFi network is used for transmitting data from the ESP32-CAM-MB to a remote server or cloud service. It provides a stable and fast connection, enabling reliable data transmission. This network allows for remote monitoring and control, giving users access to water meter readings from anywhere. It also supports the integration of multiple devices, creating a comprehensive smart metering system.
Custom Casing:
A custom casing, designed using Fusion 360, houses the ESP32-CAM-MB and the water meter. This casing protects the electronic components from environmental factors such as dust, moisture, and physical damage. It ensures proper alignment of the camera with the water meter for accurate image capture. The design is compact and providing easy access for maintenance and adjustments.
The setup of the ESP32-CAM water meter reading device involves several steps:
Each step is detailed below to guide through the installation and configuration process.
All needed codes for flashing can be found here: AI-on-the-edge-device
Note: it is recomeneded to use 16GB SD Card. But 32GB worked fine for me.
After verifying that the hardware setup is working correctly, the next step is the software configuration. This involves accessing the device's web interface, capturing a reference image, and setting up alignment references and Regions of Interest (ROIs).
Alignment references ensures that each captured image is correctly aligned with the reference image, improving the accuracy of readings.
ROIs are specific areas of the image where the digits of the water meter are located.
Define ROIs for Each Digit:
The casing for the ESP32-CAM module was designed using Autodesk Fusion 360 and prepared for 3D printing with UltiMaker Cura. These tools were selected for their robust design capabilities and ease of use in preparing models for 3D printing.
The casing was designed specifically to fit the given water meter, ensuring a snug and secure fit. Several key factors were taken into consideration during the design process:
The final physical setup of the smart water metering system includes the ESP32-CAM module mounted securely in its custom-designed casing. The setup is installed over the water meter.
The system successfully captures images of the water meter, processes these images to detect and read the meter's numerical values using Computer vision, and displays the readings on a user-friendly interface. It accurately detects and highlights the numbers on the water meter, ensuring precise reading and data collection. The detected readings are displayed on the interface accessed via the IP address, providing real-time water consumption data for remote monitoring and management. All captured images and processed data are stored for further analysis.
All captured data is stored in a structured format, allowing for historical analysis and tracking of water consumption over time. This data can be used to identify usage patterns, detect anomalies, and generate reports for efficient water management and billing.
The implementation of the Computer vision on the ESP32-CAM demonstrated high accuracy in reading the numerical values from the water meter. The system's ability to correctly detect and interpret the digits is critical for reliable water usage monitoring. However, occasional inaccuracies were observed in the last digit due to variations in lighting conditions and reflections from the water meter cover. But this can be fixed by the methods mentioned earlier in “Dealing with Reflections”.
Integrating the system with Home Assistant adds significant value by enabling easy monitoring and management of water consumption. Connecting the ESP32-CAM to Home Assistant is straightforward; in the settings under “MQTT,” entering the Home Assistant address allows for automatic detection and display of water consumption data in cubic meters (m³). This seamless integration makes it easier for users to incorporate water usage monitoring into their existing smart home setups.
Hardware Issues: One of the primary challenges was getting the ESP32-CAM module to enter flashing mode. Despite trying various methods and configurations, only one out of four ESP32-CAM modules successfully entered flashing mode. This inconsistency suggests that it's crucial to verify the proper functioning of the ESP32-CAM modules before deployment. Ensuring hardware reliability can save significant time and effort during the setup phase.
Camera Setup: Setting up the camera to achieve the correct focus and alignment was another challenge. The process required careful adjustments to the focal length of the OV2640 camera and dealing with reflections on the water meter's protective cover. Removing the glue on the lens to adjust the focus was delicate and needed precision to avoid damaging the camera.
Alignment References: The initial setup of Alignment References posed significant issues. Every time the ESP32-CAM was powered up, the settings were reset, causing the Regions of Interest (ROIs) to shift and making it difficult to accurately capture the numbers. To address this, the Alignment References were turned off. The custom casing ensured that the ESP32-CAM maintained a consistent position, eliminating the need for re-alignment with each restart.
I managed to make a working module for a water meter that is ready for use in household. The ESP32-CAM for smart water metering has shown great potential in automating water usage monitoring. The system accurately reads water meter numbers, even though the protective plastic cover causes “inconvenient” reflections from the LED light.
A major advantage of this project is its low cost. The ESP32-CAM and other components are affordable, making it accessible to many people. Also, the setup process, while requiring some technical skills, is not that complicated. Open-source firmware make it easier to implement.