Do-it-yourself home automation

My article will be useful to those who are just thinking about this kind of system, will help them decide whether to do it themselves, and are mainly focused on collective farm enthusiasts. Initially, I write “automation” and not a smart home, because at this stage there are no smart functions in my control system, now the task was to collect data and manage devices. Everything should change in the future when algorithms appear that will make the house smart. From my point of view, if you can turn on the light from a smartphone, this does not make your home smart. It becomes smart when you have scripts written that help you, make it easier to control your home, and make routine things invisible to you. For example, turn on the light on the porch when the light level is below a threshold, and turn off at two nights, not to include watering if today they promise precipitation with a probability of more than 60 percent, if there is movement in the room, then turn on the lights of the stairs, etc. And only in this case he becomes “smart”.

A bit of lyrics. I always wanted to have a house in the country, for a long time it was decided, because construction is not only a big financial cost, but also a big expense of your personal time, which can be devoted to your favorite hobby, family. Fortunately, one of them I have is just the development of all kinds of unnecessary devices. Somewhere else, at the initial stage, I decided for myself that this could be interesting and, choosing a site, I began to make plans. First, of course, I had to devote a lot of time to issues related to the construction itself, such as the project, the search for builders and all sorts of other troubles. But then, when the box was ready, it was time to think about the home automation system, which is what I like and what I wanted to do, well, it’s just strange for the programmer to get out of the sofa to turn off the light in the bathroom.

Studies began on what is on the market and what you can buy and pre-farm yourself. As it turned out, the market is quite saturated with many solutions, but they lacked it, then they didn’t have a holistic solution that would satisfy me (no, of course, there were solutions, but the cost was 20 tons. I was not satisfied) . For example, Schneider has a good solution based on KNX, on which you can build lighting, roller blinds and ventilation control, but integrating anything other than standard elements into the system is almost impossible, plus you can forget about the web interface and google control, and script automation in general no need to speak. On the other hand, there are enough solutions on the market that are both wireless and friends with Google, and the applications are ready for them, but they have a lot of nuances. that push such decisions to the background. For example, the complexity of simultaneously controlling lighting from conventional switches and from application, it is often impossible at all, or if it is possible it is problematic to implement pass-through switches, but I would like to have a house in which everything works without a smart house in case of its crash. Plus, I didn’t really want to hang a house with a mass of individual boxes, I still don’t understand why the motion sensor, carbon monoxide and temperature should not be placed in one building, even if it would cost more, but I would not have to hang up the whole ceiling with some kind of device , and even change the batteries in them every two years. but I would like to have a house in which everything works without a smart house in case of its crash. Plus, I didn’t really want to hang a house with a mass of individual boxes, I still don’t understand why the motion sensor, carbon monoxide and temperature should not be placed in one building, even if it would cost more, but I would not have to hang up the whole ceiling with some kind of device , and even change the batteries in them every two years. but I would like to have a house in which everything works without a smart house in case of its crash. Plus, I didn’t really want to hang a house with a mass of individual boxes, I still don’t understand why the motion sensor, carbon monoxide and temperature should not be placed in one building, even if it would cost more, but I would not have to hang up the whole ceiling with some kind of device , and even change the batteries in them every two years.

In general, with the words, “tyzh programmer”, I began to think how I would have taken this on my own and what is needed for this. Thinking through the different applications of the system, it became clear that before you do something you need to think hard (it seems obvious, but no, sometimes you want to do something right now) because putting the wiring in the gates and plastering it, there is no way back .

Having formed a wish list, I got the following subsystems:

  • home lighting
  • roleta
  • ventilation flap control
  • motion sensors, light, CO and temperature sensors in rooms
  • automatic watering
  • motion sensors on the site
  • backup power

Initially, I wanted to put everything together on purchased devices and somehow bring them together into a single system, this seemed to be the best option for time / finance and system reliability. Thoughts jumped from one subsystem to another, but no coherent solution was formulated for any of the subsystems, months passed, but no solution was formed, plus the construction itself was distracting, and even winter began (and this is the time of mountains and snowboarding, and this is without all compromises, then it was still so). I had to limit the flight of thought and force myself to work out one subsystem after another, it all started with lighting.

Let's take a quick look at each.

Lighting. From the input it was that the light should work simultaneously from the switches and from the control system (hereinafter ACS), plus there should be the ability to make pass-through switches. For this, the self-propelled guns must at least know whether it is turned on now or not. There were several ideas how to implement this, but I settled on this diagram - a push-button switch - a pulse relay (Elko MR-41) - a discrete output - a discrete input. A discrete output is parallel with a push-button switch, an NO relay contact is for a light bulb, an NC contact is for a digital input for status.

image

From all this it followed that to each lighting point, which should be controlled from both the switch and the self-propelled guns, there should go its own wire from the shield, similarly to the switches. The wiring diagram in the sketchbook really helped to understand the scale of the disaster, there were a lot of wires, but this should not scare a person who decided on a smart home. I recommend not to be lazy and still do this scheme, not necessarily in a sketch, in the future this work will save you a lot of time and help even after years when you need to hang a picture and you will wonder if there is a wire there or not.

Roleta. The difference from light is that the load in this case is not a light bulb but an electric motor, with all that it implies. Just as with lighting, I wanted to have control from a mechanical switch as well as from a control system. Therefore, the circuit turned out as follows: discrete output - contactor and in parallel a push-button switch for each direction of rotation.

image

Ventilation . Everything is simple, I gave it to the SPG, and did not provide for any other control, I hardly ever want to open / close ventilation ducts not from the application. So the circuit - two discrete outputs - a simple Belimo LM24-T drive with ebay for $ 25 without feedback.

image

This is what the actuator mounted on the ventilation flap looks like:

image

Sensorsmotion, light sensors, CO and temperature in the rooms. The market now has a shaft of such devices, but everything with a proprietary interface and connecting them to your home-grown system is quite difficult, and the problem mentioned above is that they are trying to sell each sensor as a separate device in its own case. The last thing I would like to see is the scattering of different devices on the ceiling, but how do you think that all of them need to change batteries and it's scary to become. Also, there is always the possibility that the manufacturer will close the open api of their devices and force you to use only your application as Google recently received from nest and your whole system will fall to pieces. So I made my device on AVR, calling it a “sensor tag” and packing it with everything I needed: a motion sensor with a digital sensitivity adjustment, light, temperature, carbon monoxide sensors, controlled backlight, ESP8266, RS485 with galvanic isolation, 24V power supply. It turned out here is such a device, but in reality it needs to devote a separate article and not really focus on it in this one.

image

image

Automatic watering. It would seem that this is complicated, there should be the simplest device of the discrete output type - a 24V solenoid. But as it turned out, all the irrigation valves are 24V but AC. So I had to make a separate unit with a 24V transformer and a relay unit, which 24V DC switches on 24V DC.

image

Motion sensors on the site. For security sensors, the outputs are NO and NC contacts, so everything is simple here, discrete inputs and everything, but don’t forget about the arrester (the arrester option is suitable for patch panels).

Reserve food.Initially, this was not planned, but over time it became clear that the loss of electricity outside the city was not a state of emergency, but a quite ordinary phenomenon. And although, I believe that the smart home system should be designed so that it can be turned on / off at any time without consequences that are sad for her and the house, I did not refuse backup power. Having decided that since I already have my 24V sensor sensors, 24V drives, I will do all the ACS power supply 24V. It turned out a good bunch of mean well of the power supply, mean well of ups and batteries, it works, checked.

image

After the hardware solution was formed, it seemed as if in a complete system it was possible to proceed to the installation work of the power unit: laying the power wires, wiring the power shield and wiring the low voltage. It turned out frighteningly many wires, but from the weekend to the weekend it became more beautiful and more beautiful, as a result, after a month everything worked out and worked. A bonus was the opportunity to make a temporary control panel for light and roller blinds for builders.

image

image

image

image

The next step was planning the dashboard with the control modules.

System Topology:

image

DI / DO Modules.It was necessary to estimate the topology of the system, which modules are included in it, on which controllers what works. There are many options for implementation, and all of them will be correct if they work. Looking ahead, I will say that I settled on a system of purchased DI / DO modules, which controls the controller on Beaglebone black and the web server on Raspberry Pi. Next, you need to count all the discrete inputs / outputs and their types. Because there was no desire to develop DI / DO modules, I just looked at the market already ready for a reasonable price. I stopped at the Aries modules, in principle, they covered all my management needs:

  1. MV110-8DF, as a discrete input module for 220V signals.
  2. МУ110-16Р, for controlling lighting, roller blinds, ventilation and irrigation valves.
  3. MV110-16DN as a discrete input module for signals from street motion sensors.

These modules are connected to the system via the RS485 ModBus interface, in principle, the industry standard, so there should not be any difficulties with its implementation (you can write support for the main commands yourself or take a ready-made library).

Controller. To communicate with my “sensorortag” modules located in each room and the Aries modules in the dashboard, I needed a controller that could interrogate them via the RS485 interface and had Ethernet to communicate with the server. I considered the option of using the Wiren Board, but they have few RS485 ports and I wanted to do the controller myself. The controller wants to devote a separate article, so here we can mention that it is made on Beaglebone black and has 3 galvanically isolated RS-485 ports and 24V power.

The system for the Beaglebone black controller is built on the basis of Buildroot and brought to the state of running the build - we get the finished image for the SD card. Beaglebone black software consists of: communication core, MQTT gateway and Mosquitto server. The communication core polls the RS-485 ports, forming an internal table of discrete and analog points. The MQTT gateway converts the controller points to the values ​​of the MQTT topics and passes them to the Mosquitto server. Everything is available on this link .

Control panel and signal simulator (lighting, blinds and ventilation):

image

image

Raspberry Pi softwareThis is the Home Assistant. I was pleased with this system, it is very simple, supports a lot of ready-made devices and allows you to write your plugins in python very flexibly. For example, in a couple of weeks I wrote my own MQTT plugins for lighting, roller blinds, alarms and various types of sensors (lighting, CO, movement, temperature) and several types of automation, everything is very flexible and most importantly with a low threshold for entering the system. Home Assistant also supports integration with Google Home and Alexa. You can torment yourself a little and configure it yourself, or make a paid subscription to their service ($ 5 per month) and then the process of synchronizing Home Assistant and Google Home takes two clicks. As a bonus, we get voice control, while in English, but promise to support Russian just about. It looks something like this:

image

In this article I wanted to give an overview of the system and an example of a specific implementation, and I do not pretend to the correctness of the decisions I have chosen. Someone may say that this is a toumach for the house, but someone may benefit. In general, do not be afraid it is exciting, just structure everything well and start. All ideas do not come immediately, they appear in the implementation process, so you will have to change, and more than once. Next, I plan to write about the development of my controller and sensor tag, which as a programmer is more interesting than everything described here.

Also popular now: