Another project on the ESP8266 and a water meter
It all started with the fact that in the apartment they finally installed water meters (4 pulse meters, since there are 2 risers) and the question arose as to the easiest way to take readings. And given that one pair of counters was inside the kitchen cabinet, it was decided to try to automate this.
On the Internet you can find a device with a 1-wire bus for a couple of meters at a not very humane price of about 2500 rubles. Also, this decision required to lead the wires to the processing device, which also did not please.
Researches on how to make this device itself led first to arduino + esp8266 as a wifi transmitter, and after diving into the topic, it turned out that esp8266 itself can perfectly cope with this task.
As a result, the following board option was selected and purchased for aliekspers:www.aliexpress.com/snapshot/6483884486.html , she cuts off the battery container and connects the old power supply from the Nokia phone (any PSU of about 5 volts is suitable, since the converter has a 3.3-volt converter on the board).
After a test flashing of the LEDs (the board is flashed with firmware that allows you to blink from the phone), the choice of programming tools has arrived.
Since this is my first experience with MK, I did not want to immediately contact the SDK, study it, configure the compilation environment, etc.
As a result, he chose the NodeMCU project nodemcu.com/index_en.html of Chinese comrades and ESPlorer esp8266.ru/forum/threads/esplorer.34 Victor.
The entry threshold is not high, everything is intuitively clear, but as usual there is a fly in the ointment in the ointment - there is a lack of memory, since the Wirth itself. LUA machine eats enough. It turned out that there is a set of methods that allow you to level the problem (splitting into separate files and executing them in turn, compiling these files), but the memory problem still regularly requires a lot of time to debug and adding a new “piece” of code sometimes entails a redo of everything project.
A few words about the functionality:
The water meter is pulsed - in fact, this is similar to pressing a button (closing the contacts) when the last digit of the meter goes through 0 (or rather, I have it from 9 to 4).
The counter is hung on one of the GPIO ports and ground with a pull-up on power (an internal resistor is used, _PULLUP mode).
2 counters are connected to one MK (it was possible to connect all 4, but the wires are not our method :)).
The thingspeak.com service acts as a data collection and storage system , which removed the question of the availability of a data processing device in the apartment and makes it possible to visually monitor the water flow.
Once a month, data is taken from this service and sent to the PGU portal in Moscow (this is a separate topic, since I have not found an officially normal way to get the data, and the current solution used by the traffic analysis tools of the Android application is extremely raw). In principle, if there was an official data sending API, you could force thingspeak to send this data yourself (I think this will come 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 helped try to repeat all this on arduino. As a result, the second week, one of the devices runs on it.
Of course, the arduino for esp8266 is still quite raw, but the overall impression is very good. Problems with resources that were constantly pursued when working with nodemcu are gone, there is enough memory, the basic libraries are working. There was a desire to use MK for something else.
PS: I didn’t specifically describe the programs themselves, since it’s not difficult to write them, and you can get a lot of pleasure from the investigation with specific problems :). For those who are interested in the result, I recommend paying attention to the projecthomes-smart.ru/index.php/oborudovanie/bez-provodov-wi-fi/62-besprovodnoj-datchik-na-baze-esp8266-dlya-servisa-narodmon-ru , which knows a lot of things out of the box.
On the Internet you can find a device with a 1-wire bus for a couple of meters at a not very humane price of about 2500 rubles. Also, this decision required to lead the wires to the processing device, which also did not please.
Researches on how to make this device itself led first to arduino + esp8266 as a wifi transmitter, and after diving into the topic, it turned out that esp8266 itself can perfectly cope with this task.
As a result, the following board option was selected and purchased for aliekspers:www.aliexpress.com/snapshot/6483884486.html , she cuts off the battery container and connects the old power supply from the Nokia phone (any PSU of about 5 volts is suitable, since the converter has a 3.3-volt converter on the board).
After a test flashing of the LEDs (the board is flashed with firmware that allows you to blink from the phone), the choice of programming tools has arrived.
Since this is my first experience with MK, I did not want to immediately contact the SDK, study it, configure the compilation environment, etc.
As a result, he chose the NodeMCU project nodemcu.com/index_en.html of Chinese comrades and ESPlorer esp8266.ru/forum/threads/esplorer.34 Victor.
The entry threshold is not high, everything is intuitively clear, but as usual there is a fly in the ointment in the ointment - there is a lack of memory, since the Wirth itself. LUA machine eats enough. It turned out that there is a set of methods that allow you to level the problem (splitting into separate files and executing them in turn, compiling these files), but the memory problem still regularly requires a lot of time to debug and adding a new “piece” of code sometimes entails a redo of everything project.
A few words about the functionality:
The water meter is pulsed - in fact, this is similar to pressing a button (closing the contacts) when the last digit of the meter goes through 0 (or rather, I have it from 9 to 4).
The counter is hung on one of the GPIO ports and ground with a pull-up on power (an internal resistor is used, _PULLUP mode).
2 counters are connected to one MK (it was possible to connect all 4, but the wires are not our method :)).
The thingspeak.com service acts as a data collection and storage system , which removed the question of the availability of a data processing device in the apartment and makes it possible to visually monitor the water flow.
Once a month, data is taken from this service and sent to the PGU portal in Moscow (this is a separate topic, since I have not found an officially normal way to get the data, and the current solution used by the traffic analysis tools of the Android application is extremely raw). In principle, if there was an official data sending API, you could force thingspeak to send this data yourself (I think this will come 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 helped try to repeat all this on arduino. As a result, the second week, one of the devices runs on it.
Of course, the arduino for esp8266 is still quite raw, but the overall impression is very good. Problems with resources that were constantly pursued when working with nodemcu are gone, there is enough memory, the basic libraries are working. There was a desire to use MK for something else.
PS: I didn’t specifically describe the programs themselves, since it’s not difficult to write them, and you can get a lot of pleasure from the investigation with specific problems :). For those who are interested in the result, I recommend paying attention to the projecthomes-smart.ru/index.php/oborudovanie/bez-provodov-wi-fi/62-besprovodnoj-datchik-na-baze-esp8266-dlya-servisa-narodmon-ru , which knows a lot of things out of the box.