Foreword
2019 Almost in any electronics store you can buy one of the hundreds of possible sets of smart home. Take and set up in “2 clicks”, connect to the clouds, receive push events in the app / sms, and generally get all the necessary information anywhere in the world.Ideal, but in my case did not work. Several solutions that came to my hands actually turned out to be a limited set of certain functions, covering only part of my requests, and, moreover, imposing almost insurmountable restrictions. And, as is usually the case, the fewer the restrictions, the more you need to dive into the subject area, to think out solutions and architectures yourself. Therefore - the collective farm themselves :)
Tasks
1. obtain information about the quality of the power supply network (power surges, complete blackouts, etc.).
')
2. have full UPS monitoring. And in fact, have this very UPS based on the consequences of n2.
3. receive information about temperature:
- on the street
- houses
- in the attic (when the trash and tomatoes thrown there freeze)
4. Monitor the state of water consumption, alert if consumption has increased (suddenly there is a leakage, you do not weigh all the moisture sensors).
5. Understand when someone is at home to automate the closing / opening of water.
6. Readings of the gas meter and alert when the paid supply is over.
+ Other various sensors (humidity, opening, water pressure, pressure in the heating circuit, etc.).
The global goal is to have a common interface where you can look at it all. Get notes if something went wrong.
And so that there is nothing for it and give not a lot of money for it.
The composition of the complex at the moment
- UPS Energy PN-750 + battery per 100 Ah
- USB-> RS232 converter based on PL2303
- Router Tp-link tl-wr1043nd +
- 1wire network master based on the purchased USB thermometer DS18B20 + PL-2303TA
- 1wire 3 DS18B20 sensors
- 1wire radioseti DS2423 based water meter module
Virtual server with Zabbix server outside the home network.

Stage 1. Infrastructure preparation
First of all, the question of physical reorganization arose: the router was moved to the bedside table near the vent mine, where UPS was planned to be installed. The antenna to the Internet provider Ubiquiti Nanostation Loco M2 PoE was connected to the same outlet as the router in order to continue to be powered by UPS.
I already had a dedicated Zabbix installation on a remote server and some experience with this application, so the theory of organizing the alert-ting, and the dashboard itself was not expected.
The router is flashed in OpenWRT Chaos Calmer, VPN is configured to the network where the Zabbix server was located.
I immediately added metrics in zabbix, having gotten the item template for openwrt. Thus, I was able to monitor both the system and, for example, how many and which MAC addresses are connected to a point. That in the future was supposed to serve as a decision to block the water in the house.
Stage 2. Choosing a UPS
The selection criteria were:
- possibility of gas boiler (buderus)
- from 5 hours of boiler autonomy + internet equipment
- availability of monitoring interface
- low noise level (location - bedside table in the kitchen next to the vent shaft)
- due to limitations of placement and price - preferably one-battery design
Let us understand the possibility of meeting the criteria in order.
The ability of the gas boiler to work is obsulovleny that the boiler requires pure sine, otherwise the pump engine will buzz and wear. About this you can google a lot of articles.
Ordinary (computer UPS) do not give such a sine, producing an approximated sinus.
The second important factor is the presence of a “through neutral”. Everything is a bit more complicated, but it’s also easy to google, so I will not stop. I can only say one thing - without a through neutral, the buderus did not work, or rather, fell into error, because the ionization sensor did not work and the boiler simply did not see the flame.
As a subtotal of choosing UPS, the focus was shifted towards the online and line-interactive UPS.
From 5 hours of autonomy of the boiler + Internet equipment give mainly UPS with external battery.
Due to the limitations of the location and price - preferably one-battery design . Batteries 100ah according to calculations should have been enough for 8+ hours.
The presence of a monitoring interface to at least know when the system has switched to a battery in order to go home in the winter and start a generator. I did not have any special requirements here (as well as implementation experience). I was looking for everything that comes with rs232 or usb interface.
The requirement of
low noise actually turned out to be a serious limitation and threw away a whole class of equipment — online UPS, that is, they all work in the mode of continuous ventilation of the transformer (the fan does not turn off).
Calling to the store "Energy", I got the last PN-750 with rs232 from the shop window. Quite cheap, there were no wires in the kit.
Stage 3: UPS Setup
There are problems connecting the UPS. I bought several USB-> RS232 converters, read on the forums that energy uses the standard Megatec protocol and you can at least work with it through the Upsilon2000 software. But how much I did not fight - there was complete silence on the serial interface. A week later, the ordeals decided to disassemble the UPS and see what was there, spit on the warranty. The problem turned out to be banal - the RS232 board was not connected to the UPS main board, and the connector was slightly broken. Replaced the connector, plugged in and about a miracle, everything took off, although the firmware and issued a strange name UPS - SIN800 (it seems now I understand why the energy in the new models cut rs232).
Under OpenWRT, there was a standard P / O for working with UPS: network ups tools, which has everything you need to display metrics to the console.
root@OpenWrt:/
And the most interesting is that under Zabbix there is a ready-made template for nut. In general, we write a shell script from the tempate set into the zabbix-agent and we have a beautiful picture in the zabbix dynamics. Task 1 and 2 were solved at this stage (and the idea of monitoring total energy consumption appeared in the future).
Stage 4: 1wire and temperature
Some time ago I bought a usb thermometer (combined converter board and sensor) on ebay.
OpenWRT also turned out to be a suitable software, the digitemp_DS9097 utility. It displayed the temperature of a single soldered sensor. After reading that there is a 1wire, I realized that you can try not to be limited to one sensor and pick up the whole sensor bus to the purchased USB-converter. Having taken several DS18B20 chips and “barrels” for a twisted pair in the store, I built a constructive with the removal of the sensor outside the barrel and an internal connection with 3 wires.

I have known about this design for many years, we used this to take readings in data centers, but then I didn’t know about 1wire. When connecting the barrels with each other with standard patch cords and switching this farm with a “USB thermometer”, I got the values from all 3 temperature sensors.

It remains to spread them in locations. The total tire length was about 30 meters. The signal does not disappear. Placed on the street "barrel" filled with glue gun. She lived through the winter.
Stage 5: water
I had to change the water meter at the inlet (it was not pulsed, without a reed switch). Thanks to life in a country house, the plumber does not cause questions. Bought at the nearest plumbing store and replaced. In the new counter one pulse occurs every 10 liters of water. Now these impulses need something to consider.
For some reason, an interesting digital-counter chip, DS2423, was removed from production. But it turned out that the guys from Volgograd (radioseti) have a ready-made device, which, thanks to the built-in battery, also counts the value of the number of pulses when electricity is lost. However, the device itself was adapted to its own network architecture. From RJ-11 connectors to a separate 12V power supply. In my case, I wanted to limit the power supply to the existing bus (5V). I had to bypass the “extra” strapping and solder directly to the DS2423 pins directly. Then the device worked, the values of the registers became visible on the bus. There are two of them, t to the device implies connection to two water meters simultaneously - Cold Water and Hot Water. I have only one water inlet, so I only use the second register for tests.

End result for 1wire topology:
root@OpenWrt:/etc/zabbix
By the way, since the new water meter was installed simultaneously with a digital counter of pulses, it is possible to draw conclusions about the divergence of readings / bounce of contacts. Visually there are almost no such discrepancies (up to several hundred liters for the current reading of 60,000).
Stage 6: Alert
With the help of the collected information, we were able to make useful alerts:
- temperature on the street in sms every morning (+ sensor participation in the narodmon project)
- UPS Battery Transfer Report
- low battery UPS
- low / high voltage message
- message about the heat in the nightstand with the equipment
- message about low temperature in the attic (saving tomatoes)
- message about the “alien / new” mac address in the network
- report high water consumption (for a certain time)
Stage 7: the future
On aliexpress, a “digital manometer” was bought with an rs232 output in the form of USB. But as long as he has not fought him, he does not respond to packages. We will think further. I hope to doge.
I plan to purchase a ball valve control relay (the crane itself is already there) for remote control of the crane and the possible implementation of an automatic shut-off of water in the absence of the owners home.
Somehow to integrate the gallus digital gas meter into the scheme for notification of the ending deposit.
Finally, some graphs:



