Energy, heat and water: part two
Consider the next stage in the development of a smart home scheme from improvised means :) (continued, first article here ).
Monitoring is still in a single display interface (Zabbix), notification - through a single alert-ing mechanism. But management is something new. About it - further.
Yes, this is a hackneyed topic, devices - a dime a dozen! Everything works out of the box!
So I was thinking and wrong again. There are really many ready-made solutions, but to find a comprehensive solution with the ability to remotely control and monitor, but without using someone’s “cloud” / someone’s personal account, turned out to be an almost impossible task. Well, ok, collective farm again, let's try to solve the problem without a soldering iron and coding.
Total I need:
The ball valve was looking for better quality - not noname. I chose the gidrolock ultimate solution based on bugatti 3/4 cranes. The electric drive works from 12V.
What can control a 12V crane? There were several options for controllers that implement the logic "I see the sensor is triggered, I do the action." In principle, what you need, but it would be nice to have some kind of API for remote control. Firstly, this will make it possible to hang all possible places with leakage sensors, and block water only in one place (albeit with some delay for the time of collecting the state and sending the reaction). Secondly, the procedure will be remote, which means that it will be possible to turn off the water, for example, in the absence of the owners of the house. The solution appeared suddenly. I remembered that even once I “felt” a contraption with similar logic and all kinds of handles, called netping. It turned out that they even solved a similar problem. A link to the description of howto is at the end of the article.
+ You need another 0.5A power supply to power the netping device (not included). The power relay is used to close / open the control wire of the ball valve to the ground. When the wire is connected to the ground, the tap closes, when it opens, it opens.
We connect everything according to the scheme from howto (for example, we put the relay on the first netping line, and the leakage sensor on the fourth). We translate the first line into the output mode based on logic. We make the dependence of the 1st line on the 4th. We check the sensor, lowering it into a puddle. Netping internal logic will automatically shut off the tap.
How now to manage remotely?
Netping has a built-in SNMP server with management capabilities. To manage netping, I implemented my own OIDs, the MIB table for each of the devices is available on the developer's site. It also has a web server with management support via URL-encoded commands.
Consider both options:
Check the logic value for the line:
Set the logic value to 0 (apply voltage, close the relay - the valve opens):
Set the logic value to 1 (remove the voltage, open the relay - the valve opens):
In OID .1.3.6.1.4.1.25728.8900.1.1.3.N, N is the line number (1-4).
An important nuance is that switching will work only if the line is set to “output” mode. If the line is configured in the "output logic" mode (for example, for quick response from leak detection by the sensor), netping will not control the signal on the line outside its logic (that is, it will not respond to external commands). How to be? You can simply switch the line mode before starting a manual command. Via HTTP, this is done like this:
Bonuses:
Pressure - to quickly detect leaks (including very small / cumulative).
Temperature - the sensor installed on the return. According to its values, for example, conclusions can be drawn about the current mode of operation of the boiler, pump in the circuit, etc.
The sensors are ordered on aliexpress, an example of the name: "DC 5V G1 / 4 Pressure Sensor." There are "non-Chinese" counterparts, but much more expensive. Those who do not want to take risks, I would recommend taking Honeywell, there are several models, for example MLH200PSL01A. In my case, one Chinese man has been living for a couple of months in an environment with water under a pressure of 1 bar with a temperature of 20-60 centigrade in the heating circuit, and the second 3-4 bar at the water inlet (cold). The sensor is analog. The signal from it still needs to be converted. The DS2438AZ circuit comes to the rescue. It can convert an analog signal to a digital signal and transmit readings using the 1wire protocol. In essence - ADC. The chip is ideally integrated into the topology implemented in the first article. Additionally, you need to connect the VCC (+ 5V) and GND terminals directly to the sensor. There is voltage on the third wire of the sensor,
An additional bonus of the DS2438 chip is that it also displays the input voltage of the network, which can be useful for debugging and further development of the network. Also, a temperature sensor is built into it. An important point - in the digitemp utility, you must explicitly indicate the presence of this chip in the topology using the additional flag "-A".
With temperature, everything is simpler. Ebay / aliexpress: 1 wire thread sensor. we get the data on the 1wire bus immediately in the right form without additional blackjacks. For example, I ordered a sensor with a 1/2 inch plumbing fit and a 6mm steel probe sticking out.
Construct: We
connect both sensors to the general topology and add additional item to zabbix.
In fact, everything did not take off at once. With the introduction of these two sensors, miracles began to occur in the entire 1wire topology - from the disappearance of sensors to the readings of their boundary values. The first assumption is that there is not enough stress. Attempts to replace the USB hub, the use of an active hub did not work. As a result - I ordered a new “network master”, now based on FTDI FT232 - everything began to work stably with it. To work with such a wizard, you need to use the digitemp_DS9097U utility. But I decided to switch to owfs in working with sensors, abandoning the point calls of digitemp using zabbix_agent on each of the item. This relieves the headache of competitive requests, which is why timeouts were periodically observed. If I'm not mistaken, owfs even has some kind of built-in caching mechanism.
In openwrt, the owfs package was installed and mounted by the FS command:
owfs --allow_other -d / dev / ttyUSB0 / root / 1wire
Mounting was added to the /etc/rc.local autostart.
Now this is quite simple - we duplicate the approach described in paragraph 1 for the water main. However, I could not install the sensor in the water line where the 1wire network passes. I didn’t drag the cable to a new place, I decided to try the solution of remote data capture using an ADC with a wifi interface from radioseti. The solution can connect to a wifi access point, has a built-in web server and is able to transmit the values of connected sensors via the http protocol. For a change - it suits. As a bonus - you can pick up other sensors (including other 1wire) to this device, i.e. in theory, for example, organize another remote 1wire segment. The device turned out to be quite intuitive, at the first start it starts in the access point mode. We connect, enter the settings for connecting to our wifi, remove the jumper and place it in the range of the wifi signal. We take information for example through curl -ssensor_ip / sensors or directly with an HTTP poll in zabbix.
Constructive:
1wire sensor segment:
network master based on FTDI FT232
3 DS18B20
sensor chips 1 1/2 sensor probe DS18B20
1 DS2438 ADC
1 1/2 pressure sensor
1 pulse counter DS2423
pulse water meter
Wi-fi sensor segment:
RS-20
1 1/2 pressure sensor
Netping segment (LAN connection):
netping i / o v2
1 dry contact moisture sensor
2 gidrolock bugati ultimate taps + 2 BM8070D relays UPS
segment (USB connection):
PL2303
UPS Energy PN-750
Tasks to be solved:
- Leakage protection
+ Remote control
+ Know the status of the water inlet (blocked or open) - Know the pressure and temperature of the coolant in the heating circuit
- Know the pressure in the water supply system
Monitoring is still in a single display interface (Zabbix), notification - through a single alert-ing mechanism. But management is something new. About it - further.
1. Leakage protection
Yes, this is a hackneyed topic, devices - a dime a dozen! Everything works out of the box!
So I was thinking and wrong again. There are really many ready-made solutions, but to find a comprehensive solution with the ability to remotely control and monitor, but without using someone’s “cloud” / someone’s personal account, turned out to be an almost impossible task. Well, ok, collective farm again, let's try to solve the problem without a soldering iron and coding.
Total I need:
- motorized ball valve
- leak detector
- a certain controller with a monitoring and control interface
- power relay
The ball valve was looking for better quality - not noname. I chose the gidrolock ultimate solution based on bugatti 3/4 cranes. The electric drive works from 12V.
What can control a 12V crane? There were several options for controllers that implement the logic "I see the sensor is triggered, I do the action." In principle, what you need, but it would be nice to have some kind of API for remote control. Firstly, this will make it possible to hang all possible places with leakage sensors, and block water only in one place (albeit with some delay for the time of collecting the state and sending the reaction). Secondly, the procedure will be remote, which means that it will be possible to turn off the water, for example, in the absence of the owners of the house. The solution appeared suddenly. I remembered that even once I “felt” a contraption with similar logic and all kinds of handles, called netping. It turned out that they even solved a similar problem. A link to the description of howto is at the end of the article.
+ You need another 0.5A power supply to power the netping device (not included). The power relay is used to close / open the control wire of the ball valve to the ground. When the wire is connected to the ground, the tap closes, when it opens, it opens.
We connect everything according to the scheme from howto (for example, we put the relay on the first netping line, and the leakage sensor on the fourth). We translate the first line into the output mode based on logic. We make the dependence of the 1st line on the 4th. We check the sensor, lowering it into a puddle. Netping internal logic will automatically shut off the tap.
How now to manage remotely?
Netping has a built-in SNMP server with management capabilities. To manage netping, I implemented my own OIDs, the MIB table for each of the devices is available on the developer's site. It also has a web server with management support via URL-encoded commands.
Consider both options:
Check the logic value for the line:
Crane status
snmpget -v 2c -c SWITCH 192.168.8.5 .1.3.6.1.4.1.25728.8900.1.1.3.1
SNMPv2-SMI::enterprises.25728.8900.1.1.3.1 = INTEGER: 1
или
curl http:///<имя_пользователя>:<пароль>@192.168.8.5/io.cgi?io1
Set the logic value to 0 (apply voltage, close the relay - the valve opens):
The crane is closing
snmpset -v 2c -c SWITCH 192.168.8.5 .1.3.6.1.4.1.25728.8900.1.1.3.1 i 0
или
curl http:///<имя_пользователя>:<пароль>@192.168.8.5/io.cgi?io1=0
Set the logic value to 1 (remove the voltage, open the relay - the valve opens):
The crane opens
snmpset -v 2c -c SWITCH 192.168.8.5 .1.3.6.1.4.1.25728.8900.1.1.3.1 i 1
или
curl http://<имя_пользователя>:<пароль>@192.168.8.5/io.cgi?io1=1
In OID .1.3.6.1.4.1.25728.8900.1.1.3.N, N is the line number (1-4).
An important nuance is that switching will work only if the line is set to “output” mode. If the line is configured in the "output logic" mode (for example, for quick response from leak detection by the sensor), netping will not control the signal on the line outside its logic (that is, it will not respond to external commands). How to be? You can simply switch the line mode before starting a manual command. Via HTTP, this is done like this:
Line mode control
Bonuses:
- A good bookmark for the future is the ability to connect as many active remote leakage sensors as you like. The main thing is to figure out how to get them into the general topology. It will be possible to block the water further by logic on the same openwrt.
- Due to the presence of 4 controllable lines in netping, you can add a couple more taps to the system (also through a relay). I did just that - I built a separate tap on the irrigation line of the site. Now you can turn on / off watering remotely.
- Netping has its own zabbix template for all devices. Available on their site, uses SNMP.
2. Pressure and temperature of the heat carrier in the heating circuit
Pressure - to quickly detect leaks (including very small / cumulative).
Temperature - the sensor installed on the return. According to its values, for example, conclusions can be drawn about the current mode of operation of the boiler, pump in the circuit, etc.
The sensors are ordered on aliexpress, an example of the name: "DC 5V G1 / 4 Pressure Sensor." There are "non-Chinese" counterparts, but much more expensive. Those who do not want to take risks, I would recommend taking Honeywell, there are several models, for example MLH200PSL01A. In my case, one Chinese man has been living for a couple of months in an environment with water under a pressure of 1 bar with a temperature of 20-60 centigrade in the heating circuit, and the second 3-4 bar at the water inlet (cold). The sensor is analog. The signal from it still needs to be converted. The DS2438AZ circuit comes to the rescue. It can convert an analog signal to a digital signal and transmit readings using the 1wire protocol. In essence - ADC. The chip is ideally integrated into the topology implemented in the first article. Additionally, you need to connect the VCC (+ 5V) and GND terminals directly to the sensor. There is voltage on the third wire of the sensor,
An additional bonus of the DS2438 chip is that it also displays the input voltage of the network, which can be useful for debugging and further development of the network. Also, a temperature sensor is built into it. An important point - in the digitemp utility, you must explicitly indicate the presence of this chip in the topology using the additional flag "-A".
With temperature, everything is simpler. Ebay / aliexpress: 1 wire thread sensor. we get the data on the 1wire bus immediately in the right form without additional blackjacks. For example, I ordered a sensor with a 1/2 inch plumbing fit and a 6mm steel probe sticking out.
Construct: We
connect both sensors to the general topology and add additional item to zabbix.
A spoon of tar
In fact, everything did not take off at once. With the introduction of these two sensors, miracles began to occur in the entire 1wire topology - from the disappearance of sensors to the readings of their boundary values. The first assumption is that there is not enough stress. Attempts to replace the USB hub, the use of an active hub did not work. As a result - I ordered a new “network master”, now based on FTDI FT232 - everything began to work stably with it. To work with such a wizard, you need to use the digitemp_DS9097U utility. But I decided to switch to owfs in working with sensors, abandoning the point calls of digitemp using zabbix_agent on each of the item. This relieves the headache of competitive requests, which is why timeouts were periodically observed. If I'm not mistaken, owfs even has some kind of built-in caching mechanism.
In openwrt, the owfs package was installed and mounted by the FS command:
owfs --allow_other -d / dev / ttyUSB0 / root / 1wire
Mounting was added to the /etc/rc.local autostart.
3. Pressure in the water supply system
Now this is quite simple - we duplicate the approach described in paragraph 1 for the water main. However, I could not install the sensor in the water line where the 1wire network passes. I didn’t drag the cable to a new place, I decided to try the solution of remote data capture using an ADC with a wifi interface from radioseti. The solution can connect to a wifi access point, has a built-in web server and is able to transmit the values of connected sensors via the http protocol. For a change - it suits. As a bonus - you can pick up other sensors (including other 1wire) to this device, i.e. in theory, for example, organize another remote 1wire segment. The device turned out to be quite intuitive, at the first start it starts in the access point mode. We connect, enter the settings for connecting to our wifi, remove the jumper and place it in the range of the wifi signal. We take information for example through curl -ssensor_ip / sensors or directly with an HTTP poll in zabbix.
Constructive:
The current composition of the complex:
1wire sensor segment:
network master based on FTDI FT232
3 DS18B20
sensor chips 1 1/2 sensor probe DS18B20
1 DS2438 ADC
1 1/2 pressure sensor
1 pulse counter DS2423
pulse water meter
Wi-fi sensor segment:
RS-20
1 1/2 pressure sensor
Netping segment (LAN connection):
netping i / o v2
1 dry contact moisture sensor
2 gidrolock bugati ultimate taps + 2 BM8070D relays UPS
segment (USB connection):
PL2303
UPS Energy PN-750
Scheme:
Charts:
References:
- Netping Leakage Blog
- Netping v2 Documentation (including SNMP and URL-Encoded)
- Passport-description of the gidrolock crane
- WIFI ADC radioseti