Do-it-yourself Smart Home v2

    Good afternoon, dear% habrausername%!

    Judging by previous posts, many of you are interested in hand-made automation of your home. For a long time I gathered my thoughts and ideas on the basis of building the first “smart home” and now I want to share my best practices with you.

    What we come to and why


    So, you need to decide what we are leaving and where we are coming from. Who is interested in "smart home" v1 - can be found in my profile, in posts. In general and most importantly, we are moving away from the X10 protocol and coming to Z-Wave, from Perl to Java, from webcams to more or less normal IP cameras.
    I will sign in order.

    Z-Wave vs. X10


    What do all these scary words mean? For the smallest and not familiar with the subject, a little bit of excerpts from Wikipedia.
    Let's go - X10:

    X10 is an international open industry standard used to communicate electronic devices in home automation systems. The X10 standard defines the methods and protocol for transmitting control signals for electronic modules to which household appliances are connected using conventional wiring or wireless channels.

    It is distinguished by intelligence and comprehension ... In general, it does not take anything now, except for the price of modules and the ability to install where there is wiring. And here pitfalls pop up, some of which I ran into when installing and operating this protocol:

    • Let's start with an extremely low bit rate. The encoded digital data is transmitted using a radio frequency pulse of a flash frequency of 120 kHz, a duration of 1ms and synchronized with the moment of transition of alternating current through a zero value. For one transition through zero, one bit of information is transmitted. The receiver also forms a waiting window near the voltage transition through 0. The window size is 200 μs. The presence of a flash pulse in the window is a logical "1", the absence is a logical "0". In general, this means that it takes about 1-2 seconds to give a command to the module.
    • Immunity She is extremely small. For example, if neighbor Vasily includes, as usual, his electric welding machine - wait for problems
    • Lack of feedback. She is not there. Not at all. It is impossible to find out the state, although there are rumors about mythical pieces of iron, but I have serious suspicions that they speak of an even more rare animal - the A10 protocol
    • Inability to pass the signal between the phases. If your bulbs are hanging on one phase, and the controller is connected to another - prepare the loot.


    Of the advantages, perhaps, is relative cheapness and a certain freedom from wires.

    And here he comes on the scene, Z-Wave ! Less illuminated protocol than X10 or 1-wire, but rapidly gaining popularity and dropping the price of devices every day.

    Z-Wave is a patented wireless communication protocol designed for home automation, in particular for monitoring and control in residential and commercial buildings. The technology uses low-power and miniature radio frequency modules that are built into consumer electronics and various devices such as lighting, heating, access control, entertainment systems and household appliances.

    The first and perhaps most important difference here is that Z-Wave is a wireless protocol. That is, now we are absolutely not attached to anything (except for sockets for some devices, perhaps). Almost all devices are powered by batteries and, according to statements, live on them for years. Some micromodules are powered directly from the 220V network.
    Also, an undoubted advantage is that it is a mesh network in which each node or device can receive and transmit control signals to other network devices using intermediate neighboring nodes. Mesh is a self-organizing network with routing dependent on external factors - for example, if there is an obstacle between the two nearest network nodes, the signal will go through other network nodes that are in range.
    Iron prices are now not very biting.

    Now about the cons (where without them). The most important and worst minus for me, as a developer of my system, is a closed protocol . Those wishing to receive a specification will have to roll off 10 kilobaks . But, as it turned out, everything is not so bad. Craftsmen have reversed the protocol by the most impossibility and have written an open source implementation called open-zwave . In C ++. There are python binders.

    All in all, not bad. We are going further.

    Perl vs. Java


    It's simple - I started learning Java, and since I wrote boring Hello World and classes about managers and their salary, from which I fall asleep on line 10 of the code, I decided to try to do something really serious. Google, books and your own brains to help. Of course, I invent a lot of bicycles, but where without them, so I ask the guru not to kick - I know everything, I will correct ... Honestly! :) About software - at the end of the post.

    Webcams vs. IP cameras


    Here, too, everything as a whole should be clear. USB-cameras turned out to be unreliable, overheated, the image disappeared. It is long cables, garlands of USB hubs - all, thank God, in the past. Now exclusively wireless IP cameras. By the way, the Chinese have PTZ cameras for a little over $ 60. I don’t have one yet, but I plan to order it.

    Technology


    So, with the protocols, the languages ​​decided. Now we go further. I had to abandon the nettop due to its poor performance. Now for me everything is responsible for the usual desktop a little shaggy years on all the same Ubuntu.

    I want to note that my goal was to get as far as possible from laying wires, because the apartment is removable and moving can happen at any time. That is, the system should be as mobile as possible.
    I will describe the available hardware and how it is all connected:

    • one desktop
    • two IP wireless cameras
    • two active microphones SHOROKH-7
    • three speakers (2 + 1 simplest)
    • two sound cards (built-in + PCI) (the main factor is the presence of a line input)


    I apologize in advance for the quality of the photos - everything is done on a mobile phone.

    The speakers are connected to sound cards, two systems to one through a splitter, the rest - directly. Combined with PulseAudio in one sink - we arrange it, we get sound in the whole apartment.

    image

    With the SHOROKH-7 ​​microphones, it won’t be that simple.

    image

    To begin with, they are active - that is, requiring a 12V power supply. You can take it from our power supply.

    image

    As an audio cord, we use an FTP twisted pair, where one pair goes to the signal and plus, and all the others are twisted into a screen.

    image

    Each microphone is connected to the line (!) Input of its card.

    Everything is simple with cameras - they live on their own, the server side takes the MJPEG and WAV stream from each.

    Z-Wave Devices

    For the test, I purchased a controller, a micromodule dimmer and a leakage sensor.
    For example, the controller looks like an ordinary flash drive:

    image

    And the leakage sensor is the most massive:

    image

    Fibaro micromodule: It

    image

    connects quite simply and according to the instructions:

    image

    There is a video on the network about the installation:



    A very big plus of this piece of iron is that it does not require batteries for operation, a neutral conductor and a mandatory monostable switch. Works great with bi-stable.

    After the first power-up, each device must be included in our network - this is done using the controller, which goes into special mode, and putting the device itself into the network connection mode. As a rule, everything is in the documentation and does not cause problems.

    IRIS-X


    The management system is published under the GPLv3 license. Software is currently able to:

    • Viewing in real time video from cameras
    • Speech recognition and synthesis using Google
    • Discovery and management of Z-Wave network, all devices
    • The interface tweaked with examples twitter bootstrap'a :)
    • Tons of features in the initial implementation phase


    Taking this opportunity, I actively urge you to join the development :)
    Link to GitHub'e: github.com/Neuronix2/IRIS-X

    A couple of screenshots of the interface (the pictures are clickable): I will be happy to answer all your questions. Thank you for attention.











    Also popular now: