📜 ⬆️ ⬇️

Another project on the ESP8266 and a water meter

It all started with the fact that the water meters were finally installed in the apartment (4 impulse counters, as 2 risers) and the question was how simple it is to take readings. And if you consider that one pair of counters was inside the kitchen cabinet, it was decided to try to automate it.

On the Internet, you can find a device with a 1-wire bus for a couple of meters for a not very humane price of about 2500 rubles. Also, this decision required to lead the wires to the processing device, which was also not pleasant.

Research on how to make the device itself, led first to arduino + esp8266 as a wifi transmitter, and after immersing in the topic it turned out that esp8266 itself can cope with this task perfectly.

')
As a result, the following board option was selected and purchased for aliexpress: www.aliexpress.com/snapshot/6483884486.html , it cuts off the battery container and connects the old power supply from a Nokia phone (any BP of about 5 volts is suitable, since The board is worth the converter in 3.3).

After the test flashing of the LEDs (the board is stitched with firmware, which allows blinking from the phone), a selection of programming tools has arrived.

Since this is my first experience with MK, I did not want to immediately get involved in the SDK, study it, set up a compilation environment, etc.
As a result, I chose the NodeMCU project nodemcu.com/index_en.html Chinese comrades and ESPlorer esp8266.ru/forum/threads/esplorer.34 Victor.

The threshold of entry is not high, everything is intuitive, but as usual there is a fly in the ointment - lack of memory, as Wirth herself. LUA car eats enough. It turned out that there is a set of techniques that allow to level the problem (splitting into separate files and running in turn, compiling these files), but the problem with memory still regularly requires a lot of time to debug and add a new “piece” of code sometimes entails reworking everything project.

A few words about the functional:
The water meter is pulsed - in essence, this is similar to pressing a button (closing contacts) when the last digit of the meter goes through 0 (or rather, I have from digit 9 to 4).

The counter is hung on one of the GPIO ports and the ground with a power lift (using an internal resistor, _PULLUP mode).
2 counters are connected to one MK (it was possible to connect all 4, but the wires are not our method :)).

The system for collecting and storing data is the service of thingspeak.com , which removed the question of the availability of a device for processing this data in an apartment and makes it possible to visually monitor water consumption.

Once a month, data is collected from this service and sent to the PGU portal of Moscow (this is a separate topic, since I did not find the normal way to discard the data, and the current used solution obtained from the traffic analysis tools of the android application is extremely raw). In principle, if there was an official data sending API, then it would be possible for thingspeak to send this data to itself (I think and come to this in the future), but for now there is a small script on external hosting that does this.

After almost 2 months of operation, the project esp8266.ru/arduino-ide-esp8266 was discovered, which encouraged me to try to repeat all this on the arduino. As a result, the second week one of the devices works on it.

Of course, the arduino for esp8266 is still quite raw, but the overall impression is very good. Problems with resources that are constantly pursued when working with nodemcu are gone, there is enough memory, basic libraries are working. There was a desire to apply MK for something else.

PS: Specially did not describe the programs themselves, since it is not difficult to write them, and you can get a lot of pleasure from the proceedings with specific problems :). For those who are interested in the result, I recommend to pay attention to the project homes-smart.ru/index.php/oborudovanie/bez-provodov-wi-fi/62-besprovodnoj-datchik-na-baze-esp8266-dlya-servisa-narodmon-ru , which "out of the box" can do many things.

Source: https://habr.com/ru/post/256247/


All Articles