ESP32 takes readings from water meters and transmits them “where needed”

There are hundreds of articles online about using ESP32 to take meter readings, but almost all of them are about integration with a smart home. My implementation option solves a practical problem – it simply transmits the readings itself, relieving me of this task.

The main difference between my solution and those I have seen is maximum autonomy and ease of control and management. ESP32 independently communicates with a website that receives meter readings using a built-in http client. The process is controlled and managed by the telegram bot built into the ESP32.

The project itself is published here.

I began to solve this problem by studying the API of the sites that I used to transmit readings. In my case it was websites https://www.mosenergosbyt.ru/ And https://mosobleirts.rf/. I explored the API in a trivial way, using F12 in my browser. We launch the page debugging mode, enable recording, authenticate, transmit readings and examine POST methods that usually transmit and receive json objects as responses.

I didn’t like the API of the Mosenergosbyt website. They use plugins and for different cities and streets API requests can vary significantly, making the publication of the results of the work practically useless and uninteresting. But the Mosobleirts website has a fairly clear and unified API.

I’ll say right away that I immediately discarded the Housing and Communal Services GIS due to the complexity of authentication, linking to government services and 2FA. However, if there is a token authorization system and someone knows how to use it, then it would be interesting to adopt such experience.

It was decided to control the process using a telegram bot built into the ESP32 itself. The bot is based on the library https://github.com/GyverLibs/FastBot The bot allows you to set initial reading values, adjust them as necessary, view the current status, control the process of transmitting readings, and at the same time remind you of the date of the next meter verification.

The meters, of course, must be equipped with reed switches, the pulses of which are read by the controller. I tried options for counting pulses based on interrupts, and with hardware and software anti-bounce protection. I settled on software protection based on timers. It turned out to be the most practical and reliable option. Test operation for two months showed almost 100% accuracy of pulse counting. This option does not require any wiring; the wires from the meters can be connected directly to the controller pins. The calculated values ​​are stored in the controller’s non-volatile memory to survive power outages.

In short, this is probably all the most interesting things about my craft. If anyone is interested in this, I would be happy to answer questions and write more detailed material.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *