Do-it-yourself Smart Home system

A couple of weeks ago in our chat appeared this message:











And a little later - this is:











The author of the messages is Zhenya, a programmer, head of the training department and electronic engineer. At the age of 5, he noticed that if you pull a motor out of a tape recorder, connect a light bulb to it and start turning it on, the light bulb will light up. At six - that if the motor reverses the polarity of the connection, it will spin in the other direction. At 18 he entered Measuring Innovative Technologies at the Polytechnic. And at 24 he came to work at Sibiriks.







This is because the goal of the whole undertaking is not the Smart House and the weather station as such. The goal is to scratch your hands (because it itches) and prevent them from oxidizing (because of the gold alloy). So everyone who wonders why spend time when you can just buy such devices - go to the forest-DNCom. And for those who are interested in the topic of DIY electronics (or DIY electronics, which is also not shameful), you can scroll further.









It seems to me that any person should have some kind of hobby, besides work. Do something with your own hands. This is a good emotional discharge (the main thing is not to become a routine - at work, even as diverse and interesting as programming), routine is almost inevitable, and yes, to your hobby). The most interesting thing is symbiosis, when your hobby becomes useful and in demand for business.

- Vladimir Zavertylov, head of Sibiriks Studio









Arduino



Zhenya made the first version of the Smart Home two and a half years ago on arduino.







Arduino is a small board with a microcontroller, memory and contacts, to which you can connect bulbs, motors, sensors and in general everything that works from electricity. You write a C ++ program, load it into the memory of the arduino microcontroller, and it controls all the connected devices. This is how cool gadgets are created - a watering system for a summer cottage, for example, or a robot that brings you slippers.











The first theme that Eugene made on arduino is a toy. Two sensors, two participants. Each holds a hand over its sensor. When the toy pickles, you need to sharply remove your hand. The toy measures the reaction time up to 100 seconds and says who the champion is. Hacked with his wife. Conveniently - whoever loses is washing the dishes).











When everything became clear with arduino, Eugene decided, of course, to make a Smart House (an electronic engineer). I connected a security system (motion sensor and door opening sensor) and a thermometer (DHT11 temperature and humidity sensor) to arduino and was not satisfied. Communication between all devices was via a 433 MHz radio channel and turned out to be unstable. Eugene struggled with the radio signals of month 2, and then decided not to fight, but to remake the smart home server on the Raspberry Pi.









Raspberry pi



Raspberry Pi is already a full-fledged computer. Yes, single board. Yes, the size of a credit card. Yes, it is much inferior in power to modern large computers. But it can run the Linux operating system. This means you can switch from C ++ to higher languages ​​- java script, php. And these are already native languages ​​for Zhenya. But most importantly, the Raspberry Pi allows you to get away from 433 radio signals and go to all the well-known and beloved wi-fi, which works stably.











Design



Usually you are either an electronics engineer or a designer. Eugene, as we recall, decided on this as early as 5 years old, so there were troubles with the design. But not for long. Because soon he went to the CEO of Sibiriks and asked for help. A month later, he had already drawn the interface of the Smart House by our designer.











































System



Zhenya wrote the system in 4 months. Worked for about 2.5 hours a day. One and a half hours before work (he got up early, because in the evening he had a son, household chores, playing Civilization with his wife) and an hour during lunch at work.







The idea was for the system to scale unlimitedly. He is now a simple guy and he needs only basic functionality in a smart house (weather station, security system, video surveillance). But if tomorrow he is tired of pressing buttons and switches and he wants the lighting to follow him, the stove turns on cotton, and the automatic blinds on the windows close in the sun, he should be able to fasten all this functionality.







Therefore, the system is organized in this way: you create a folder in the Smart Home with a module, describe its operation and it is easily integrated into the system. Now there are 9 modules. There are physical modules (those that have a physical device), and there are logical modules (those that are needed for the system to work).









Functional



Weather station







For the weather station, Zhenya took 4 main parameters that make it possible to understand whether you die or not (temperature, humidity, atmospheric pressure, carbon dioxide concentration in the air). The creation of a weather station was sponsored by the studio’s general director on the condition that Zhenya will make another such one in the studio (already done). With us, it is connected via wi-fi not to the Smart Home, but to the Zabbix, a server monitoring system that monitors various parameters, from the temperature of hard drives to the load on the network, and displays it all in the form of beautiful graphs. Now there is also a graph of the temperature in the office.







We planned to connect a CO2 sensor to our Zabbix, output it to a plasma and monitor the atmosphere. The very first experiments showed that mount-screw-makers mounted the inflow to us so-so. Using an electronic endoscope, we found out that the inflow went through a small crack in the siding of the building (it is relatively new). Cursing obscene words, we fitted the tower and remounted everything humanly. Now, in the morning, the sensor shows CO2 in the region of 500, for dinner it rises to 800, which, in general, is normal.

- Vladimir Zavertylov, head of Sibiriks Studio







CCTV







When they installed CCTV cameras on Zhenin’s house, which can be monitored via the phone application, it turned out that they were made on a very popular service - a macroscope, and they have api access. Zhenya has connected surveillance cameras to his Smart Home. It's funny that they work better in the Smart House than in the application. The application is dumb wildly. And in the Smart Home, the cameras open.







Security







The last person to leave the house presses the button and the system arms. When someone arrives, the motion sensor understands this. The system starts to pick, like deactivate security or I'm right now screaming. To deactivate security, you need to attach your electronic key, the system will recognize it and calm down.









Developments







All events registered by the system are displayed here.









System







Here you can see the system parameters: processor temperature graph, IP address, processor load, battery.







Scenarios







It contains the reaction of the system to an event. Reactions are set from a computer.









Body



The case is that thing which was developed 5 hours, and was printed 28 hours. It was printed on an old home 3d-printer. For reference - if the print lasts about 4 hours, it already takes a long time. And here - 28. It took 16 hours to the bottom of the case. On the top - 6. This is a party for the whole day - you launch a 3D printer and it prints, you can not interrupt. If the light, for example, turns off at 98% of the print, then you just throw the plastic for 15 hours. Fortunately, this did not happen. Another thing happened: due to a flaw in the design (too thin walls in the figured hole for the speaker), the lid had to be reprinted. That is, the total print took about 28 hours. Almost the entire plastic coil has gone.









Vote



Speech-to-text







The system can speak and understands what you are saying to it. You press a button, say a phrase, and it converts it into text . Converting voice to text is a wildly difficult task. Google knows how to do it, but for the money. And the first rule of a DIY project is no monthly fees. As it turned out, the latest versions of chrome have a built-in voice recognition tool. The only caveat is that the connection must be either https or localhost. A smart home is just such a system: the client and server are on the same machine, so it was possible to connect via localhost.







Team response







The second service is called dialogflow. The trick is that you specify a phrase template, for example: “What is the weather like tomorrow?” And indicate that the word “tomorrow” is a variable of type date. And now you can ask any question: “What is the weather on September 20?”, “What is the weather like the day after tomorrow?”, “What is the weather in 3 days?” And the system understands that this data type is date, converts it to the program date and responds on her. This whole topic is on neural networks, and it is trainable. If you said, “What will the weather be like today?” And the system didn’t understand, it says “I didn’t understand”, and you go to the server and teach it directly with your hands that this phrase means “What is the weather like?” And it remembers. Neural network training takes place by access: when registering on the service, access keys for api are issued, access to the agent’s personal account, you can train this agent and give someone the right to use it.







There is another cool topic in dialogflow - microdialogs. You ask a question, for example, “How are you?” And ask the patterns of answers to it: “I haven’t given birth yet”, “Everything is in chocolate, even the display”, “We have business, and the prosecutor’s business”, “Oh, that's it” - and each time the system will randomly choose from these options the answer to this question.







It turns out that the service sends the trigger itself to the Smart Home, which must be executed and a possible phrase for the answer, the House catches this phrase and then the task is the other way round: tts, that is, text to speech.







Text-to-speech







Yandex is good at doing this. There you can choose not only the voice (several options for female and male voices), but also the mood (funny, sad, angry, neutral). Yandex has a very simple and shareware api (with a limit of about 10 thousand conversions per day).







Thus, a cycle turned out: you pronounce a phrase, the system understands it, pronounces something in response and performs some action. So, for example, setting the alarm by voice works. You say: "Set the alarm on Tuesday at 7 o’clock." And on Tuesday at 7, the Smart House will wake you.







SMS



It’s good if the Smart House can notify you of a fire or opening a door when you are not at home, right? There is such a module - called sim800L. This is a gps modem, which is a full-fledged phone. He knows how to make calls, answer calls, send / receive sms, access the Internet using gprs, determine location using cell towers, etc. The idea was this: order this module, insert a SIM card into the Smart Home, set up some some tariff so that there is no subscription fee at all, drop 500 rubles there and until they are spent (1 rubles per SMS), and this is, at least for a year, forget about all this.







But it turned out that at the peak this shawl at the time of searching for networks consumes 2 Amperes of current. The Smart Home has a power module, a cord enters there, there is a battery and the battery exits power to the system. A battery can provide a maximum of 3 amperes of output. That is, 3 Amperes of constant consumption by the whole system is the edge. And, if you add this gsm module to raspberry, it will be cut down. She does not have enough current, and she just goes out. The only solution to the problem is to send the SMS sending module in a separate box. Then there you can provide uninterrupted power for 2 Amps. And just connect via Wi-Fi to Smart Home. That is, the Smart House says to the module: “Send such a text message”, and the module sends. Now Zhenya needs to buy a couple of pieces of iron, and the module will be ready.









Expenses
  • Raspberry Pi - 1500 rub.
  • Display - 2500 rubles.
  • Weather station details - 1500 rubles. (the most expensive part is a CO2 sensor, 1100 rub.)
  • Every little thing, like a microphone, computer speakers, small, desktop, the cheapest ones to get an amp from there - let it be 500 rubles.
  • Backup power fee - 1500 rubles.
  • Printing a case weighing 300 grams (2 rubles per gram, taking into account the consumption of plastic and electricity) - 600 rubles. If you print to order, it will cost more, perhaps about 1,500 rubles.


Total: 8,100 rubles.









A little lyrics in the end



Electronic engineers are people who look fascinated at a three-digit number on the display and say:

- Look how cool!

You look at the same number and say uncertainly:

- Cool, yeah…

“What do you see?” - they test you.

You try:

- 328?

And of course you don’t get it. Because it is not just 328. This is an awesome dynamic display.








All Articles