Wateri: Transferring readings of water to the phone via Wi-Fi (4 years from batteries)
Once I got tired of taking readings of water meters. It was possible to settle a magnet near the counter and calm down on this, but I found this way unsportsmanlike.
My path was not easy and ornate. But the result was a device that transmits readings of water via Wi-Fi to the phone. Simple and clear to use and configure at least a student, even though the
So, we have a little money and a big, but honest desire to simplify our lives without violating the Criminal Code. And so that none of your 220V, servers and heaps of buttons! We look at the readings on the smartphone in the Blynk application or a similar service.
Now sit back in your chair, eat more of these soft French buns and drink some tea. See beautiful photos and listen to my story about what to consider when creating stand-alone devices. But first, a brief description of Waterius.
- meter with wire (output "dry contact")
- Wi-Fi router with internet
- Power supply: 3 AA batteries
- work time 4 years or longer
- 2 water meters
- one single button to configure
- non-volatile memory for readings and network settings
Daily Wi-Fi Transfer
- current readings
- water consumption per day
- supply voltage
- email Letters (body and title can be changed)
Implemented TCP server support and Blynk applications. Add HTTP, MQTT, Modbus TCP, Cayenne clouds, IFTTT, etc. (here is a place for the manifestation of your creative genius).
When you click on the button, Waterius turns on a Wi-Fi access point. Connect, fill out the form, three times bow to the east and say "thank you" to the developers of WiFiManager . You can mentally.
A scattering of radio elements for the assembly of Waterius.
The only way to achieve units of microamps of consumption during pulse counting is to use an economical microcontroller, rather than what you thought. Heart Voteriusa - microcontroller Attiny85 (analogues - MSP430, STM8L). Flush without problems with any Arduino board with any hands that grow above the belt. Attiny85 operates at a frequency of 1 MHz from the internal generator and counts pulses, periodically checking 2 inputs for a short circuit and a button. Sleep current 4 μA at 3V . Fairy tale.
I use ESP8266-01 for Wi-Fi. Consumption during operation 75mA, pulses up to 250mA. Two microcontrollers communicate via i2c bus. The correctness of the choice confirmed the draft meteorological station. ESP8266 is constantly in a dream: the EN pin is pulled to GND through a resistor. The current consumption is less than 10 uA (I came across copies with 0 uA). Once a day, Attiny85 delivers HIGH, ESP8266 wakes up, gets readings from Attiny85, connects to home Wi-Fi and sends data in ~ 4 seconds - which, according to British scientists, is much faster than you usually get manually to these counters.
In the photo a good ESP, consumption jumps 7-11µA. Usually the numbers are 19-23µA.
Other types of sleep Wateriu will not do, although sprinkle it with melatonin to the sounds of a lullaby: Infinite deepsleep with instant wake up on impulse to External reset consumes 20µA and is suitable for frequent data sending. The most economical option: ESP8266 is completely disconnected, but field-effect transistors that are afraid of static electricity will be needed, just like that.
The setup button is located on the SCL line. All Attiny85 pins are busy! For this reason, Waterius does not support “Namur” meter outputs and does not have a leakage sensor.
The LED is connected to an ESP TX pin and is on when ESP is running. Connect the TTL-USB adapter to see the log (interestingly!). At the beginning of the development, I thought that in order to indicate an error, you need to blink an LED, but you will manage - this will only complicate the code.
If you successfully connect to the Wi-Fi router after 3-10 seconds, the LED will go out, and if it continues to light up, connect the phone to Wateri again. Sophisticated technology, nanotechnology, developments of NASA, the teachings of ancient China.
Any one of us knows: a feature of low-power devices is exposure to electromagnetic interference. Therefore, I turned to a familiar electronics engineer and studied literature (+ the most beautiful course Murata ). All pins at ESP and Attiny are pulled to power or GND. Installed capacitors for power. The “dirty” ground of the meters is connected to the “clean” through a 300 ohm resistor, and the outputs themselves through a 3k3 resistor. Everyone would be like that!
We take a plastic bottle ... a joke. I used the compartment on 4 AA batteries. A hole is cut in the cover for the connector, on the side for the LED and the button.
You can use the wiring box (with a 3D printer and other shamanism, experiment yourself, if nnnada).
In github is a single-layer board for LUT and a two-layer board for factory production. Wateri can even make a schoolboy! True, if he does not have a hoverboard and has never twisted a spinner.
The ideal fee does not work right away. The first prototype looked like this:
But the fourth version, which was built, is almost “perfect”:
I could not resist and ordered a pack of cards in Rezonite. It's a thrill!
In Waterius there is a stabilizer MCP1700 on 3B with a very low minimum consumption (several µA). Three AA 1.5V alkaline batteries can discharge almost completely to 3.2 V. Plus, the Attiny85 will have a stable voltage (and less floating frequency , which is good, although in this project it doesn't matter).
The circuit will work without a stabilizer from two AA batteries. Attiny85 should buy version V (powered up to 1.8V). ESP worked "on the Internet" to 2.5V. We will be able to use 40% of the capacity of the batteries (if you do not believe it, see A. Nadezhin’s testing ). If you buy two AA 1.5V 3 A lithium lithium batteries, Waterius will work up to 10 years and at a low temperature, and there - you see - we will build communism.
The lack of tools does not allow me to accurately measure Wateri consumption. At home, he has been working for 45 days, sending readings every 30 minutes (to speed up the discharge). The supply voltage dropped by 0.17V from 4.68V to 4.51V (UPD: 100 days 4.38V). If this goes on, then the batteries will last for 1.5 years. Sending readings once a day is 3 times more economical, so 4 years of work. Yes, I know about the self-discharge of batteries. Datashit energizer and expiration date on packages say it is not strong.
Here is the calculation of battery consumption and the cost of components for the most curious ( Google Table ).
Programmer details (for those who are not tired)
The implementation of counting pulses on interrupts is not suitable, since water can be blocked at the time of the reed switch closure (zone ~ 3 l), and the current will flow through the pull-up resistors. Protection against bounce of contacts will be required: a microcircuit or a delay in the code. I implemented a periodic poll every 250ms and increment (beautiful word, right?) The value only when re-closing. Nothing needs to be soldered, although if you really want, then you can.
To protect against Attiny reload, I save all values to its EEPROM memory. To exceed the 100k record limit, I wrote a ring buffer with a ring label of the current cell. Now I sleep peacefully, which I wish for you. The code provides for the inclusion of logging for debugging. Connect the TTL-USB to the connector of the second counter.
At first I wrote a Telegram bot, but Roskomnadzor blocked Telegram. I had to refuse this decision in order not to launch the proxy server and not to rock the boat. Using Blynk turned out to be optimal (fearless developers struggle with locks). Here is the project QR code . In addition to his application for the phone is the project Cayenne.
Automatic sending to Mosvodokanal is not implemented, since project non-profit, but what our years. Or yours. I do not have the means to maintain my server and "legitimize" the sending procedure, but you ask around friends, all of a sudden ... I will be glad of your help and free thoughts.
Muscovites send readings via SMS, which means that a web server is enough to receive Wateri data and a page from SMS ( github). Moscow Fiddler experts, who use the Moscow State Service application, should be interested in my Python script for sending water readings.
One of the main brakes in creating a new product is perfectionism, as you understand. There is no need to make a new function without checking whether it is needed by consumers. Simple code is easier to develop.
The path to perfectionism is through
- Updating ESP and Attiny firmware via the Internet
- support https or encryption
- server where the user could upload his script to send readings of water.
- use of STM8L / MSP430 (they are more economical and more pins)
- visual check of contact with the meter when connected
- specify the period of sending email. letters
- support outputs "Namur" at the counter
- leakage sensor
- crane control
- electricity meter support
Thanks to Ivan Kovalenko and Ivan Ganzha for advice on electrical engineering, Aigul, Lapinu E.N. for the correct approach to life and dad for the fact that I can not only program, but also solder, and you - for attention!
I would welcome any suggestions, pool requests and criticism!
We heat up a soldering iron! Project on github