Raspberry pi for home automation. Smart home control system based on Raspberry Pi

Hello, friends

After I tested the capabilities of the Domoticz smart home control system on my desktop computer and made sure that it perfectly complements and even replaces Mi Home - the standard one Xiaomi system- I decided to purchase a separate single-board computer for her - Raspberry Pi. And in this review I will tell you about my experience.

Introduction

For those who haven’t read my first review about Domoticz - . Literally after the first successful experiments, I got excited about the idea of ​​a separate hardware base for it; a desktop PC is not suitable as a working platform. I decided on the Raspberry Pi Model 3 B, a compact but powerful single-board computer based on the BCM2837 SoC processor with 4 Cortex-A53 cores, operating at 1.2GHz, 1GB of RAM and wireless Wi-Fi modules and Bluetooth 4.1.

Set

I included 4 items in my order -

What’s interesting is that the store has two modifications - Chinese and English. At the time of purchase, the Chinese one was $7 cheaper, so I took it. What is Chinese there is honestly a mystery to me.

Copper heatsinks for Raspberry Pi - product page

For a complete set you will also need microSD card- at least 4 GB and HDMI cable. I had both a cable and a 32 GB card in my stash, so I didn’t buy it.

What's in the package

After the allotted time - a little more than two weeks, the courier brought the parcel with my order.


Let's take a closer look. Power supply with Type C plug and micro-USB connector.


The declared maximum current is 2A at a voltage of 5V.


Test switching on with a load of 2A shows some voltage drop, but within acceptable limits, the power supply is more or less honest.


A set of three copper radiators in a bag for passive cooling.


All radiators have a square shape, two radiators with pins and a side length of about 12 mm and one flat with a side length of about 15 mm.


The case is made of dark plastic with an embossed image of a raspberry on the lid.


Case dimensions - approximately 90 by 65 mm



The case is disassembled into 5 parts - everything is held in place by latches, no screws.


The accessories are finished - it's time to move on to the most important thing

RASPBERRY PI 3 MODEL B

Raspberry Pi 3 Model B is the direct successor to Raspberry Pi 2 Model B. The board is fully compatible with its predecessor, but is equipped with greater performance and new communication tools:
64-bit quad-core ARM processor Cortex-A53 with a clock frequency of 1.2 GHz on a Broadcom BCM2837 single-chip chip; built-in Wi-Fi 802.11n and Bluetooth 4.1.
In addition, the processor has ARMv53 architecture, which means you can use your favorite operating system: Debian Wheezy, Ubuntu Mate, Fedora Remix and even MS Windows 10.


Technical specifications more details

CPU - Broadcom BCM2837, ARM Cortex-A53 Quad Core, 1.2 GHz
Number of processor cores - 4
GPU - VideoCore IV 3D
RAM - 1 GB
Storage - microSD
Networking capabilities
Ethernet 10/100
WiFi 2.4G 150 mb/s
Video output - HDMI
USB ports - 4
Wireless capabilities - Bluetooth
Audio output - 3.5 Jack
85.6 x 53.98 x 17mm, 45 grams


The box contains documentation and a quick installation booklet - by the way, on English language, as well as a bag of thick brown paper with a computer.


On one of the long sides of the computer there are micro USB ports for power, full-size HDMI port, CSI-2 Camera port - for connecting a camera via the MIPI interface, 3.5 mm audio jack. Also on the top side there is a processor module and an Ethernet/USB Hub lan9514-jzx


On the front side there are 4 USB ports and an Ethernet port


On the other side of the motherboard there are 40 general purpose input/output (GPIO) pins.


On the second end side there is a DSI Display Port for connecting a standard display


On the bottom side of the board there is an LPDDR2 SDRAM memory module - EDB8132B4PB-8D-F


And a micro-SD slot for a memory card


Copper heatsinks are placed on the USB/Ethernet Hub and the processor on one side


And on the memory chip on the other. This heatsink is flat - does not interfere with the installation of the computer board in the case


Everything fits into the case perfectly, screw connections no - it sits on plastic ledges.


All cutouts on the case exactly match the computer connectors



To start we need external monitor(TV) with HDMI input, USB keyboard, it will be more convenient if the mouse and power supply are the same. A monitor, keyboard and mouse will only be needed at the time of installation; then only the power supply will be sufficient.


Operating system installation

For installation operating system, first of all you need to download the archive with distribution kits - from here. While the almost one and a half gigabyte archive is downloading, download the utility for formatting the SD card - SD Card Formatter - from here. This distribution is much more compact - only 6 MB, so without wasting time, install the program


and, after installation, insert the memory card into the card reader (you have a card reader, don’t you) and launch SD Card Formatter. In the Options menu you need to set “FORMAT SIZE ADJUSTMENT” to “ON”


After waiting for the download of the large distribution to complete, open the resulting archive and unpack its contents onto a freshly formatted flash drive.

The next step is the first launch of the Raspberry Pi (a flash drive with a recorded distribution, of course we install it into it). Sorry about the quality of some the following photos- from the TV screen:(

When you first start it, the menu for selecting the operating system starts - what to install, and the list even contains Windows version 10 for Raspberry Pi. At this stage, you can select the language (at the bottom of the screen) - Russian is available and will connect to Wi-Fi networks - Wi-Fi button networks


The software I need is Raspbian based on Linux Debian- presented in two versions, lite and full, with a graphical interface. I chose the full version


After this, we can calmly go drink tea with bagels; installation will take a long time.


Periodically measuring the temperature during installation, the maximum I saw was 38 degrees.

After the installation is complete and the computer restarts, the Raspbian desktop loads


The only thing I did here was to enable SSH in the settings - in order to manage the system from a desktop PC, I already did everything else through the terminal.


To control Raspberry from a desktop PC, we need any terminal program, I use good old Putty


Default username and password - pi And raspberry. To change the password, use the command passwd.


eth0 is Ethernet

lo is local interface 127.0.0.1

wlan0 is the wi-fi interface


and in order to edit the settings file, enter the command

sudo nano /etc/dhcpcd.conf

and in the file that opens, scrolling to the end, add the necessary settings depending on which interface we will use.

For example, we want to use the address 192.168.0.222, mask 255.255.255.0, gateway address and DNS - 192.168.0.1

For Ethernet we insert

static ip_address=192.168.0.222/24
static routers=192.168.0.1

interface wlan0
static ip_address=192.168.0.222/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1


To exit the editor press ctrl+x
To save changes, press “Y” and then enter

Installation of Domoticz

Most of the setup work has already been completed, now we need to install the Domoticz system. This is done with one command -

sudo curl -L install.domoticz.com | sudo bash

Which initializes the process of loading and installing the system


During the installation process, the installer will ask questions about the installation location, etc. - I left all these points by default.


After successful installation, the installer will write the addresses and ports of the Domoticz system web interface


But, to work with the Xiaomi gateway, we need a beta version of the system. Updating to the latest beta version is carried out using the commands

cd ~/domoticz
sudo ./updatebeta


After this, we can start adding devices to the Domoticz system - I already talked about this in my previous review about it.


On this moment I have already transferred all my working scripts from the Windows version to Raspberry - by the way, it’s worth adding that both systems coexist peacefully at the same time. To ensure uninterrupted power supply to a minicomputer, it is enough to use a PowerBank, which allows you to simultaneously power the device and receive power from an external source.

Video version of the review:

All my reviews of Xiaomi devices in chronological order - List

I hope the review was useful and interesting, thank you for your attention.

Introduction

This project dates back to 2014, when I was faced with the task of providing remote control heating devices in their country house. The fact is that my family and I spend almost every weekend at the dacha. And if in the summer we, having been delayed for one reason or another in the city, arrived at the house and could immediately go to bed, then in the winter, when the temperature drops to -30 degrees, I had to spend 3-4 hours heating the house. I have seen the following solutions to this problem:

    "Bad decision"- you can leave heaters with built-in thermostats on at the minimum temperature to maintain heat. Actually, there is nothing “smart” in this solution, but 24/7 operating heating devices in a wooden country house do not inspire confidence. I wanted at least minimal control over their condition, automation and some kind of feedback;

    GSM sockets- my neighbors use this solution summer cottage. If someone is not familiar with them, then this is simply an adapter controlled via SMS commands, which is plugged into an outlet, and the heater itself is plugged into it. Not the most budget-friendly solution if you need to heat the whole house - link to the market. I see it as the simplest and least labor-intensive to implement, but it has disadvantages during operation, such as: a whole bunch of SIM cards and work to maintain their positive balance, since each room requires at least one heater, limitations and inconvenience of their control SMS means;

  1. "Smart House"- actual solutions built on the implementation of " smart home".

As the most promising solution, I chose the third option and the next question on the agenda was “Which implementation platform should I choose?”


I don’t remember how much time I spent searching for suitable options, but in the end, from budget solutions available in stores, I found systems: NooLite and CoCo (now renamed Trust). When comparing them, the decisive role for me was that NooLite has an open and documented API for managing any of its blocks. At that time there was no need for it, but I immediately noted the flexibility it could provide in the future. And the price of NooLite was significantly lower. In the end, I chose NooLite.

Implementation 1 - NooLite automation

The NooLite system consists of power modules (for different types of loads), sensors (temperature, humidity, motion) and equipment that controls them: radio remote controls, wall switches, USB adapters for a computer or a PR1132 Ethernet gateway. All this can be used in various combinations, connected to each other directly or controlled via USB adapters or a gateway; you can read more about this on the manufacturer’s official website.


For my task, I chose the PR1132 Ethernet gateway as the central element of a smart home, which will control power units and receive information from sensors. For the Ethernet gateway to work, you need to connect it to the network with a cable; it does not support Wi-Fi. At that time, I already had a network organized in my house, consisting of an Asus rt-n16 WiFi router and a USB modem for accessing the Internet. Therefore, the entire installation of NooLite for me consisted only of connecting the gateway with a cable to the router, placing radio temperature sensors in the house and mounting power units in the central electrical panel.


NooLite has a range of power blocks for different connected loads. The most “powerful” unit can control a load of up to 5000 W. If control is required greater load, as in my case, you can connect the load through a controlled relay, which, in turn, will be controlled by the NooLite power unit.




Connection diagram



Ethernet gateway PR1132 and Asus router rt-n16



Wireless temperature and humidity sensor PT111



Electrical panel and power block for external installation SR211 - later, instead of this block, I used a block for internal installation and placed it directly in the electrical panel


The PR1132 Ethernet gateway has a web interface through which the binding/unbinding of power units, sensors and their control is carried out. The interface itself is made in a rather “clumsy” minimalist style, but this is quite enough to access all the necessary functionality of the system:




Settings




Control




Page of one group of switches


Details about binding and setting up all this are again on the official website.


At that moment I could:

  • control heaters while in local network a country house, which was not very useful based on the original task;
  • create on/off timers by time and day of the week.

It was the automation timers that solved my initial problem for a while. On Friday morning and afternoon the heaters were turned on, and by evening we arrived at a warm house. In case our plans changed, a second timer was set, which turned off the batteries closer to night.

Implementation 2 - remote access to a smart home

The first implementation allowed me to partially solve my problem, but I still wanted online management home and the presence of feedback. I started looking for options for organizing access to the dacha network from outside.


As I mentioned in the previous section, the dacha network has access to the Internet via usb modem one of the mobile operators. Default mobile modems have a gray IP address and cannot get a white fixed IP without additional monthly expenses. With such a gray IP, various no-ip services will not help.


The only option that I could come up with at that time was VPN. I had a VPN server configured on my city router, which I used from time to time. I needed to set up a VPN client on my country router and register static routes to the dacha network.




Connection diagram


As a result, the country router constantly maintained a VPN connection with the city router, and to access the NooLite gateway I needed to connect via VPN to the city router from the client device (laptop, phone).


At this stage I could:

  • access your smart home from anywhere;

In general, this covered the original task almost 100%. However, I realized that this implementation was far from optimal and easy to use, since each time I had to perform a number of additional steps to connect to the VPN. For me this was not a big problem, but for the rest of the family it was not very convenient. Also in this implementation there were a lot of intermediaries, which affected the fault tolerance of the entire system as a whole. However, for some time I settled on this option.

Implementation 3 - Telegram bot

With the advent of bots in Telegram, I took note that this could become a fairly convenient interface for managing a smart home and, as soon as I had enough free time, I started developing in Python 3.


The bot had to be located somewhere and, as the most energy-efficient solution, I chose the Raspberry Pi. Although this was my first experience working with it, there were no particular difficulties in setting it up. Image to memory card, ethernet cable to the port and via ssh - full-fledged Linux.


As I already said, NooLite has a documented API, which was useful to me in at this stage. To begin with, I wrote a simple wrapper for more convenient interaction with the API:


noolite_api.py

""" NooLite API wrapper """ import requests from requests.auth import HTTPBasicAuth from requests.exceptions import ConnectTimeout, ConnectionError import xml.etree.ElementTree as ET class NooLiteSens: """Class for storing and processing information received from sensors So far there is no such processing """ def __init__(self, temperature, humidity, state): self.temperature = float(temperature.replace(",", ".")) if temperature != "-" else None self.humidity = int(humidity) if humidity != "-" else None self.state = state class NooLiteApi: """Basic wrapper for communicating with NooLite""" def __init__(self, login, password, base_api_url, request_timeout=10): self .login = login self.password = password self.base_api_url = base_api_url self.request_timeout = request_timeout def get_sens_data(self): """Receiving and pacing xml data from sensors:return: list of NooLiteSens objects for each sensor:rtype: list """ response = self._send_request("()/sens.xml".format(self.base_api_url)) sens_states = ( 0: "Sensor bound, pending information update", 1: "The sensor is not bound", 2: "There is no signal from the sensor", 3: "The battery in the sensor needs to be replaced" ) response_xml_root = ET.fromstring(response.text) sens_list = for sens_number in range(4): sens_list.append(NooLiteSens(response_xml_root.find("snst()".format(sens_number)).text, response_xml_root.find("snsh()".format(sens_number)).text, sens_states.get(int(response_xml_root. find("snt()".format(sens_number)).text)))) return sens_list def send_command_to_channel(self, data): """Sending a request to NooLite Send a request to NooLite with url parameters from data:param data: url parameters:type data: dict:return: response """ return self._send_request("()/api.htm".format(self.base_api_url), params=data) def _send_request(self, url, **kwargs): """Sending a request to NooLite and processing the returned response Sending a request to a url with parameters from kwargs:param url: url for the request:type url: str:return: response from NooLite or exception """ try: response = requests.get( url, auth=HTTPBasicAuth(self.login, self.password), timeout=self.request_timeout, **kwargs) except ConnectTimeout as e: print(e) raise NooLiteConnectionTimeout("Connection timeout: ()".format(self.request_timeout )) except ConnectionError as e: print(e) raise NooLiteConnectionError("Connection timeout: ()".format(self.request_timeout)) if response.status_code != 200: raise NooLiteBadResponse("Bad response: ()".format( response)) else: return response # Custom exceptions NooLiteConnectionTimeout = type("NooLiteConnectionTimeout", (Exception,), ()) NooLiteConnectionError = type("NooLiteConnectionError", (Exception,), ()) NooLiteBadResponse = type("NooLiteBadResponse", (Exception,), ()) NooLiteBadRequestMethod = type("NooLiteBadRequestMethod", (Exception,), ())



telegram_bot.py

import os import logging import functools import yaml import requests import telnetlib from requests.exceptions import ConnectionError from telegram import ReplyKeyboardMarkup, ParseMode from telegram.ext import Updater, CommandHandler, Filters, MessageHandler, Job from noolite_api import NooLiteApi, NooLiteConnectionTimeout,\ NooLiteConnectionError, NooLiteBadResponse # We get configuration data from the file config = yaml.load(open("conf.yaml")) # Basic logging settings logger = logging.getLogger() logger.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime) s - %(filename)s:%(lineno)s - %(levelname)s - %(message)s") stream_handler = logging.StreamHandler() stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) # Connect to the bot and NooLite updater = Updater(config["telegtam"]["token"]) noolite_api = NooLiteApi(config["noolite"]["login"], config["noolite"]["password"], config["noolite "]["api_url"]) job_queue = updater.job_queue def auth_required(func): """Authentication decorator""" @functools.wraps(func) def wrapped(bot, update): if update.message.chat_id not in config["telegtam"]["authenticated_users"]: bot.sendMessage(chat_id=update.message.chat_id, text="You are not authorized.\nTo authorize, send /auth password.") else: return func(bot, update) return wrapped def log(func): """Logging decorator""" @functools.wraps(func) def wrapped(bot, update): logger.info("Received message: ()".format(update.message.text if update.message else update.callback_query.data)) func(bot, update) logger.info("Response was sent") return wrapped def start(bot, update): """The command to start interacting with the bot""" bot. sendMessage(chat_id=update.message.chat_id, text="To get started, you need to log in.\n" "To log in, send /auth password.") def auth(bot, update): """Authentication If the password is correct, then in response comes the smart home control keyboard """ if config["telegtam"]["password"] in update.message.text: if update.message.chat_id not in config["telegtam"]["authenticated_users"]: config ["telegtam"]["authenticated_users"].append(update.message.chat_id) custom_keyboard = [ ["/Turn_heaters", "/Turn_heaters"], ["/Turn_spotlight", "/Turn_spotlight"], ["/Temperature "] ] reply_markup = ReplyKeyboardMarkup(custom_keyboard) bot.sendMessage(chat_id=update.message.chat_id, text="You are logged in.", reply_markup=reply_markup) else: bot.sendMessage(chat_id=update.message.chat_id, text=" Incorrect password. ") def send_command_to_noolite(command): """Processing requests in NooLite. *\n`()`".format(e), parse_mode=ParseMode.MARKDOWN) return if sens_list.temperature and sens_list.humidity: message = "Temperature: *()C*\nHumidity: *()%*". format(sens_list.temperature, sens_list.humidity) else: message = "Failed to receive data: ()".format(sens_list.state) logger.info("Send message: ()".format(message)) bot.sendMessage (chat_id=update.message.chat_id, text=message, parse_mode=ParseMode.MARKDOWN) @log @auth_required def send_log(bot, update): """Getting a log for debugging""" bot.sendDocument(chat_id=update.message .chat_id, document=open("/var/log/telegram_bot/err.log", "rb")) @log def unknown(bot, update): """Unknown command""" bot.sendMessage(chat_id=update .message.chat_id, text="I don't know such a command") def power_restore(bot, job): """Executed once when the bot is started""" for user_chat in config["telegtam"]["authenticated_users"]: bot.sendMessage(user_chat, "Enable after reboot") def check_temperature(bot, job): """Periodic temperature check from sensors If the temperature is lower than the set minimum, we send a notification to registered users """ try: sens_list = noolite_api.get_sens_data () except NooLiteConnectionTimeout as e: print(e) return except NooLiteConnectionError as e: print(e) return except NooLiteBadResponse as e: print(e) return if sens_list.temperature and \ sens_list.temperature< config["noolite"]["temperature_alert"]: for user_chat in config["telegtam"]["authenticated_users"]: bot.sendMessage(chat_id=user_chat, parse_mode=ParseMode.MARKDOWN, text="*Температура ниже {} градусов: {}!*".format(config["noolite"]["temperature_alert"], sens_list.temperature)) def check_internet_connection(bot, job): """Периодическая проверка доступа в интернет Если доступа в интрнет нет и попытки его проверки исчерпаны - то посылаем по telnet command router to restart it.


If Internet access does not appear after this, reboot the Raspberry Pi """ try: requests.get("http://ya.ru") config["noolite"]["internet_connection_counter"] = 0 except ConnectionError: if config[ "noolite"]["internet_connection_counter"] == 2: tn = telnetlib.Telnet(config["router"]["ip"]) tn.read_until(b"login: ") tn.write(config["router" ]["login"].encode("ascii") + b"\n") tn.read_until(b"Password: ") tn.write(config["router"]["password"].encode("ascii ") + b"\n") tn.write(b"reboot\n") elif config["noolite"]["internet_connection_counter"] == 4: os.system("sudo reboot") else: config[" noolite"]["internet_connection_counter"] += 1 dispatcher = updater.dispatcher dispatcher.add_handler(CommandHandler("start", start)) dispatcher.add_handler(CommandHandler("auth", auth)) dispatcher.add_handler(CommandHandler("Temperature ", send_temperature)) dispatcher.add_handler(CommandHandler("Turn on_heaters", heaters_on)) dispatcher.add_handler(CommandHandler("Turn off_heaters", heaters_off)) dispatcher.add_handler(CommandHandler("Turn on_spotlight", outdoor_light_on)) dispatcher.add_handler(CommandHandler( "Turn off_spotlight", outdoor_light_off)) dispatcher.add_handler(CommandHandler("log", send_log)) dispatcher.add_handler(MessageHandler(, unknown)) job_queue.put(Job(check_internet_connection, 60*5), next_t=60*5) job_queue .put(Job(check_temperature, 60*30), next_t=60*6) job_queue.put(Job(power_restore, 60, repeat=False)) updater.start_polling(bootstrap_retries=-1)




This bot runs on the Raspberry Pi under Supervisor, which monitors its state and launches it upon reboot.


How the bot works

  • When starting the bot:
  • sends a message to registered users that it is turned on and ready to work;
  • monitors Internet connection. When working via mobile Internet, there were cases when it disappeared. Therefore, a periodic check for connection availability was added. If the specified number of checks fails, then first the script reboots the router via telnet, and then, if this does not help, the Raspberry Pi itself;
  • monitors the indoor temperature and sends a notification to the user if it drops below a specified threshold;

executes commands from registered users.

  • The commands are hardcoded and include:
  • turning on/off heaters;
  • turning on/off the street spotlight;
  • obtaining a log file for debugging.

Example of communication with a bot:



As a result, all family members and I received a fairly convenient interface for managing a smart home via Telegram. All you need to do is install the telegram client on your device and know the password to start communicating with the bot.


As a result I can:

  • control your smart home from anywhere from any device with your account Telegram;
  • receive information from sensors located in the house.

This implementation solved the initial problem 100% and was convenient and intuitive to use.

Conclusion

Budget (at current prices):

  • NooLite Ethernet gateway - 6,000 rubles
  • NooLite power sensor for load control - 1,500 rubles
  • NooLite temperature and humidity sensor - 3,000 rubles (cheaper without humidity)
  • Raspberry Pi - 4,000 rubles

The result was quite flexible budget system, which can be easily expanded as needed (NooLite gateway supports up to 32 channels). My family and I can easily use it without having to do any additional actions: went to telegram - checked the temperature - turned on the heaters.


In fact, this implementation is not the last. Just a week ago, I connected this entire system to Apple HomeKit, which allowed me to add control through the iOS Home app and corresponding integration with Siri for voice control. But the implementation process deserves a separate article. If the community is interested in this topic, I am ready to prepare another article in the near future.



DIY smart home on Raspberry Pi

1.4 (28.89%) 9 votes

Now it is impossible to ignore innovations and modern technologies that are firmly rooted in our lives: mobile communications, the Internet, computer devices and homes in which every household process is controlled from a tablet or phone. Such houses are called “Smart Homes”. These are homes in which you can control everything from turning on the lights or heating with the snap of your fingers to activating occupancy systems that will help keep your home safe while no one is in it.

Such dwellings are based on sensors and controllers that respond to thermal energy, noise and movement. The simplest of such sensors we can see in large shopping centers, in which the doors open automatically as soon as you approach them. Can't believe that such a system can be an integral part of your life? Have to.

If you want to minimize the effort required when performing household activities such as washing, cooking or cleaning, the Smart Home project is simply created for you.

Project "Smart Home"

The concept of the “Smart Home”

Of course, every automated and automatic equipment must have a program. The success of your “Smart Home” will depend on it. Such equipment adaptation programs require some knowledge and experience in the fields of programming and electronics.

However, if you are new to this, have little knowledge of programming and do not have the necessary experience with electronics, we recommend that you use programs that are most adapted for novice users.

Creating a “Smart Home” without your own efforts involves large investments, which not everyone can afford at the moment. But if you understand the concept of how the devices work, you can easily assemble one with your own hands.

Raspberry Pi or Smart Home Automation

Raspberry Pi is the company that created the Raspberry minicomputer. This device simplifies Smart Home automation as much as possible and has an extremely attractive price compared to competitors with lower quality equipment.

  • Initially, 2 configurations of the Raspberry Pi mini-computer were invented:
  • model A;

model B.

Appearance of Raspberry Pi model B (with installed flash card) Both versions are powered by a 700 MHz ARM11 processor, but have. different memory Typically, Model B has a quantity random access memory, 2 times higher than model A.

Therefore, A is 256 MB, and B is 512 MB. Therefore, Model A was not withdrawn from international production, as it had another significant advantage. It included support for an Ethernet port, allowing access to the Internet. Also, the Raspberry Pi company did not stop there and later released an updated version of model B. The improved version had a more compact design and also included 4 USB ports, which is 2 times the number in the previous model.

A Raspberry mini-computer can control which will make it easier to automate your home or apartment. With the RaZberry board from Z-Wave, your mini-computer will truly become the brains of your entire system. Z-Wave is a wireless automation standard. It does not require any additional wiring or repair work, which has a better effect on the economics of your project. Wave is also incredibly easy to install. This allows even a beginner in the field of electronics to cope with the task on their own. Are you experiencing performance issues? Don't worry, Z-Wave performance can be increased by installing additional devices, just like in a regular computer.

Changing components or upgrading them will improve the performance of the device. Wave also regularly conducts affordable training and education for experienced installers on installation and adaptation to specific Z-Wave systems.

Z-Wave Controller Fibaro Home Center 2 If you are not confident in your capabilities, or you lack experience, Z-Wave is ready to provide a full range of services for installation or configuration of Z-Wave equipment throughout Russia. You can also always use them accessible base

knowledge or ask questions on the technical support website. Also using Raspberry systems

Pi, you can build your own real video surveillance system from a regular webcam and a single-board computer and monitor any object via the Internet, wherever your camera is located.

However, you do not have to view or check video surveillance every minute. At the end of the working day, you can calmly review the main events that occurred during the day and were seen by your camera.

Using a Raspberry Pi system and a webcam you can conduct video surveillance "Smart home" is complex system

, which, in addition to following the instructions you set in the program, can perform actions based entirely on the originality of a particular situation. In another sense, this is a “smart” system that can independently find a way out of situations based on what is happening.

Making your home as comfortable as possible and adapting it to your lifestyle has now become possible with the help of Smart Homes and Raspberry Pi mini-computers.

Hello, friends

In my reviews of smart home devices from the Xiaomi ecosystem, I have already mentioned the name Domoticz several times. Finally, I got around to sharing my work on this topic, and telling what it is and how you can complement the standard capabilities of a smart home from Xiaomi using this system. It’s impossible to tell this in one review, but you have to start somewhere - let’s go...

Introduction - a few words about Domoticz

1. What is Domoticz?
This is open source multi-platform software aimed at creating a smart home control system. Supports a large number of various devices different vendors, including working with Xiaomi devices.
2. What Xiaomi devices can be managed by Domoticz?
I will only talk about those devices that I have personally tested. At the moment, you can control the Xiaomi Gateway - and all the devices it controls - buttons, opening and motion sensors, ZigBee sockets, Aqara switches. Yeelight lighting gadgets are also supported - RGBW and White lamps, ceiling lamp Celling Light.
I read about working with miflora bluetooth sensors.
3. Why do I need Domoticz?
The system has more flexible options for setting up scenarios - for example, checking the activity of the device, something that is not in MiHome, or creating variables - which allow one condition - for example, pressing a key - to perform different actions, depending on the value of the variable.
Scripts created in Domoticz do not depend on Chinese servers and the availability of the Internet.
Domoticz expands the functionality of devices - for example, new actions “free fall” or “alert” for a cube, or “Long Click Release” for a button.
4. If I use Domoticz, will I not be able to work with MiHome?
Both systems live perfectly in parallel - the functionality of MiHome is completely preserved, it’s just that some of the scripts will live in one system and some in the other. In principle, all scenarios can live in Domoticz.
5. Why do I need MiHome if I use Domoticz?
At least for adding new devices. The choice is yours - but my opinion is that at the moment Domoticz is best used as an addition to MiHome
6. What is needed to connect Xiaomi devices to Domoticz?
I want to reassure you right away - there is no need for soldering irons, programmers or dancing with tambourines. You also don’t need Linux or virtual machines - you can try everything right on your working Windows, and if you like it, then it makes sense to allocate a separate hardware platform for it, for example the hero of today’s review.
Literally after the first successful experiments on my desktop PC, I got excited about the idea of ​​a separate hardware base for Domoticz. I decided on the Raspberry Pi Model 3 B - a compact but powerful single-board computer based on a BCM2837 SoC processor with 4 Cortex-A53 cores, operating at a frequency of 1.2GHz, 1GB of RAM and Wi-Fi and Bluetooth 4.1 wireless modules. .

Set

I included 4 items in my order -

Payment screen


Raspberry Pi Model 3 B Motherboard -
What’s interesting is that the store has two modifications - Chinese and English. At the time of purchase, the Chinese one was $7 cheaper, so I took it. What is Chinese there is honestly a mystery to me.
Case for Raspberry Pi Model 3 B -
Power supply HN - 528i AC / DC 5V 2A -
Copper heatsinks for Raspberry Pi -
For a complete set you will also need a microSD card - at least 4 GB and an HDMI cable. I had both a cable and a 32 GB card in my stash, so I didn’t buy it.

What's in the package

After the allotted time - a little more than two weeks, the courier brought the parcel with my order.


Let's take a closer look. Power supply with Type C plug and micro-USB connector.


The declared maximum current is 2A at a voltage of 5V.


Test switching on with a load of 2A shows some voltage drop, but within acceptable limits, the power supply is more or less honest.


A set of three copper radiators in a bag for passive cooling.


All radiators have a square shape, two radiators with pins and a side length of about 12 mm and one flat with a side length of about 15 mm.


The case is made of dark plastic with an embossed image of a raspberry on the lid.


Case dimensions - approximately 90 by 65 mm




The case is disassembled into 5 parts - everything is held in place by latches, no screws.


The accessories are finished - it's time to move on to the most important thing
RASPBERRY PI 3 MODEL B
Raspberry Pi 3 Model B is the direct successor to Raspberry Pi 2 Model B. The board is fully compatible with its predecessor, but is equipped with greater performance and new communication tools:
64-bit quad-core ARM Cortex-A53 processor with a clock frequency of 1.2 GHz on a Broadcom BCM2837 single-chip chip; built-in Wi-Fi 802.11n and Bluetooth 4.1.
In addition, the processor has ARMv53 architecture, which means you can use your favorite operating system: Debian Wheezy, Ubuntu Mate, Fedora Remix and even MS Windows 10.


Technical specifications more details
CPU - Broadcom BCM2837, ARM Cortex-A53 Quad Core, 1.2 GHz
Number of processor cores - 4
GPU - VideoCore IV 3D
RAM - 1 GB
Storage - microSD
Networking capabilities
Ethernet 10/100
WiFi 2.4G 150 mb/s
Video output - HDMI
USB ports - 4
Wireless capabilities - Bluetooth
Audio output - 3.5 Jack
85.6 x 53.98 x 17mm, 45 grams


The box contains documentation and a quick installation booklet - by the way, in English, as well as a bag of thick brown paper with a computer.


On one of the long sides of the computer there are micro USB ports for power, a full-size HDMI port, CSI-2 Camera port - for connecting a camera via the MIPI interface, and a 3.5 mm audio jack. Also on the top side there is a processor module and an Ethernet/USB Hub lan9514-jzx


On the front side there are 4 USB ports and an Ethernet port


On the other side of the motherboard there are 40 general purpose input/output (GPIO) pins.


On the second end side there is a DSI Display Port for connecting a standard display


On the bottom side of the board there is an LPDDR2 SDRAM memory module - EDB8132B4PB-8D-F


And a micro-SD slot for a memory card


Copper heatsinks are placed on the USB/Ethernet Hub and the processor on one side


And on the memory chip on the other. This heatsink is flat - does not interfere with the installation of the computer board in the case


Everything fits into the case perfectly, there are no screw connections - it sits on plastic protrusions.


All cutouts on the case exactly match the computer connectors




To start, we need an external monitor (TV) with an HDMI input, a USB keyboard, it will be more convenient if there is also a mouse and power supply. A monitor, keyboard and mouse will only be needed at the time of installation; then only the power supply will be sufficient.

Operating system installation

To install the operating system, first of all you need to download the archive with distribution kits - . While the almost one and a half gigabyte archive is downloading, we download the utility for formatting the SD card - SD Card Formatter -. This distribution is much more compact - only 6 MB, so without wasting time, install the program


and, after installation, insert the memory card into the card reader (you have a card reader, don’t you) and launch SD Card Formatter. In the Options menu you need to set “FORMAT SIZE ADJUSTMENT” to “ON”


After waiting for the download of the large distribution to complete, open the resulting archive and unpack its contents onto a freshly formatted flash drive.
The next step is the first launch of the Raspberry Pi (a flash drive with a recorded distribution, of course we install it into it). Sorry for the quality of the next few photos - from the TV screen :(
When you first start it, a menu for selecting the operating system starts - what to install, and the list even includes a version of WIndows 10 for Raspberry Pi. At this stage, you can select a language (at the bottom of the screen) - Russian is available and connect to the Wi-Fi network - the Wi-Fi networks button


The operating system I need - Raspbian based on Linux Debian - is presented in two versions, lite and full, with a graphical interface. I chose the full version


After this, we can calmly go drink tea with bagels; installation will take a long time.


Periodically measuring the temperature during installation, the maximum I saw was 38 degrees.
After the installation is complete and the computer restarts, the Raspbian desktop loads


The only thing I did here was to enable SSH in the settings - in order to manage the system from a desktop PC, I already did everything else through the terminal.


To control Raspberry from a desktop PC, we need any terminal program, I use good old Putty


Default username and password - pi And raspberry. To change the password, use the command passwd.


I recommend immediately setting a static IP address for Raspberry. You can find out current addresses using the command ifconfig , Where
eth0 is Ethernet
lo is local interface 127.0.0.1
wlan0 is the wi-fi interface

And in order to edit the settings file, enter the command
sudo nano /etc/dhcpcd.conf
and in the file that opens, scrolling to the end, add the necessary settings depending on which interface we will use.
For example, we want to use the address 192.168.0.222, mask 255.255.255.0, gateway address and DNS - 192.168.0.1
For Ethernet we insert
interface eth0

static routers=192.168.0.1

For wifi
interface wlan0
static ip_address=192.168.0.222/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1


To exit the editor press ctrl+x
To save changes, press “Y” and then enter

Installation of Domoticz
Most of the setup work has already been completed, now we need to install the Domoticz system. This is done with one command -
sudo curl -L install.domoticz.com | sudo bash
Which initializes the process of downloading and installing the system


During the installation process, the installer will ask questions about the installation location, etc. - I left all these points by default.


After successful installation, the installer will write the addresses and ports of the Domoticz system web interface


But, to work with the Xiaomi gateway, we need a beta version of the system. Updating to the latest beta version is carried out using the commands
cd ~/domoticz
sudo ./updatebeta



Now the Domoticz system is available via the web interface:

Now is the time to start adding Xiaomi devices. But first -

Preparatory work

So, what do you need to start working with Domoticz?
IP Address Reservation
The first thing you need to do is set static IP addresses for the devices you plan to manage - for now this is a gateway and lamps. This is done on your home router using a DHCP client table that looks something like this -


and information from the Network info tabs of the gateway and lamp control plugins, where the MAC addresses of devices are indicated


Using this information, you need to register the issuance of permanent IP addresses to these devices - since they will be controlled via IP, and if the address is changed, Domoticz will lose contact with it. The address reservation table looks something like this -

Developer Mode

Developer mode must be activated. For the Xiaomi Gateway, you need to go to the menu, select the about option, at the bottom of the screen where the version is written (2.23 for me) - click on it until two new options appear in the menu, they can be in Chinese, in my example - in English Click on the first of the two - local area network communication protocol, activate the top switch in the menu and write down the gateway password.


For lamps, everything is simpler - you need to install the Yeelight application, if you have not installed it yet, and for each lamp - go to the menu, developer mode - enable

Adding devices

To add devices, go to the Settings - Hardware tab
127.0.0.1:8080/#/Hardware (instead of 127.0.0.1 - the address of your Domoticz)
We select the type of Xiaomi Gateway device, call it something, indicate its IP address, which we reserved on the router, and enter the password received in the developer mode window. Port - it works for me on port 54321. The Domotics wiki describes the connection indicating port 9898


To add lamps, just add the YeeLight LED device - you don’t need to specify addresses, the lamps will pull themselves up.


The sensors connected to the gateway will not all be connected at once; this process may take an hour or more - you need to wait. This is due to the fact that ZigBee devices are activated only at the moment of data transmission. You can push the process a little - by opening and closing windows with sensors, breathing on temperature sensors, turning sockets on and off - in a word, forcing devices to transmit data.

Devices

MUCH more devices will be added than you expect :) A list of them is available on the Settings - devices tab.
127.0.0.1:8080/#/Devices


For example, each temperature and humidity sensor will be added as three devices, separately temperature, separately humidity, and all together. Sockets - separate socket ( controlled device) separately - as an energy consumption sensor. But the gateway has a separate backlight, a separate alarm siren, a separate alarm clock, a door bell and a volume control. In order to add a device to the list of used ones, you need to click the green arrow at the end of the line. Remove from used - blue arrow. We don’t add what we don’t need.
Devices added for use are located in several tabs -

Switches

This tab contains all managed devices
127.0.0.1:8080/#/LightSwitches
Switches, buttons, lamps, etc. Here we can turn on, turn off, and do any actions with devices manually.

For example, select the sound that will sound on the gateway, or the color of the light on an RGB lamp, or the brightness on a white lamp.

Temperature

This tab groups climate sensors - humidity and temperature
127.0.0.1:8080/#/Temperature
At first, they are all called the same, you can determine which one is which by their readings and checking with the Mi Home application, after which they can be renamed accordingly.

Auxiliary

The gateway light sensor is grouped here - although its readings are very strange, as well as energy consumption meters for sockets.
127.0.0.1:8080/#/Utility

Scenarios

To create scenarios, you need to go to the tab - Settings - Advanced - Events. Scripting is available in two versions - block and scripting in the lua language.

Example scripts

When learning to work with Domoticz, it’s best to start with blocks. Here everything is divided into groups and creating scenarios is quite simple. An example of a simple scenario on blocks is turning on the light when motion is detected, and turning it off a minute after the motion sensor switches to off status. After compiling the script, you need to name it, check the Event active: - option to enable it and save it.

Exactly the same script in lua

Examples of using

I will pay more attention to specific scenarios in other reviews; here, as an example, I will give a scenario that IMPOSSIBLE implement in Mi Home, namely a two-button Aqara switch with disconnection of wires - left button will work as intended - breaking and connecting the phase, and the right one - not connected to the line (to power the switch, it is enough to connect only one of the buttons) - will turn on and off the Yeelight lamp, which has no physical connection to the switch.
In this scenario, the status of the Yeelight lamp will be checked, the value of the On or Off switch itself will not matter. If the state of the lamp is other than Off, it means it is working and will be turned off, and if it is turned off, it will be turned on.

With this, I will complete the introductory part on Domoticz; if the topic is interesting, I will continue, there is still a lot of interesting things.

Video version of the review (2 parts) -



Thank you for your attention. I'm planning to buy +164 Add to favorites I liked the review +99 +231

It is difficult to ignore technological innovations that have long become part of everyday life. Among such familiar things as the Internet or smartphones, the smart home especially stands out, helping to combine used gadgets and household appliances into a single network for more comfortable and simpler management. It is easy to customize a smart home to suit your own needs by introducing new modules into the network and programming them to perform specified scenarios. The sensors used in the process of controlling the house are triggered:

  • To the sound;
  • On the move;
  • For thermal energy.

Simple sensors are even presented in shopping malls, where they monitor the automatic opening of doors and perform other tasks. It may be hard to believe that a smart home can become an integral element of a person’s life, but it is true. To reduce your labor costs and train devices to perform simple functions independently, you only need to implement a smart home project that facilitates all this.

How a smart home works

For automated technology, software is used that allows you to perform various tasks with her help. Programs are also used in a smart home, expanding the functionality of its capabilities. To program the operation of the device, you must have certain skills. Therefore, for novice owners, the best choice would be to use applications that have already been adapted to the requirements of ordinary users.

When developing a smart home, you can choose from several options. In the first case, a ready-made solution will be used, which will remain installed on site. This option requires a minimum of effort, but its cost is significant. Not everyone can afford to implement such a project. Another solution is to understand the concept itself, which will allow you to create and assemble a smart home yourself in the future.

The work process depends on the correctness of the calculations made by the owner, which leads to lower costs. Assembling a smart home yourself is not difficult if you approach the matter with care and understanding. As a result, this will save money and allow you to gain some skills in handling modules.

Smart home automation process

It is easy to make devices used every day work according to a given scenario if you use the appropriate control unit for this. The Raspberry Pi company has developed a minicomputer that is suitable for solving this problem. The device is compact and efficient, and also makes project automation simple and straightforward. Raspberry is inexpensive, especially when compared with other manufacturers that have presented their products on the market. But this did not stop the company from offering truly high-quality equipment that has become popular. Initially, the company developed two variations of the minicomputer:

  • Initially, 2 configurations of the Raspberry Pi mini-computer were invented:
  • model A;

Visual design and packaging

These devices are controlled by an ARM11 chipset with a performance of 700 MHz. The differences between the variations are the amount of memory on board. Thus, product B is equipped with a 512 MB RAM bar, which is twice the performance of model A with 256 MB. As a result, the company came to the decision to release both variations simultaneously, especially since minicomputer A had additional advantages. It was equipped Ethernet port allowing you to connect to the network. The company continued to work on modernizing its products, rethinking the second version of the computer. This led to the appearance of an improved version B, which became even more compact and also received stylish design. Among the design developments, it is worth noting the presence of 4 USB connectors, which is 2 times the number of ports of this type for the previous version.

Read also: Is your home safe for the environment?

The device has proven itself in the field of creating smart homes. The low price makes Raspberry an excellent choice for building an entire project, and the versatility of a minicomputer can handle complex tasks. Automation of devices based on such a unit becomes the best among available solutions.

Raspberry is capable of controlling Z-Wave devices, making it easier to control home appliances. Installing the RaZberry board in a miniPC makes the control unit productive and reliable. Z-Wave represents the modern standard for a smart home made possible through a wireless technology process. As a result, the owner has the opportunity to refuse to use additional elements and consumables, reducing overall costs. Managing Z-Wave is easy. Therefore, a person who has no practical experience in working on such projects can implement a smart home.

An additional benefit is the ability to upgrade an existing board. So, if there is a decrease in performance, which is no longer sufficient for the modules to operate, then Z-Wave can be upgraded using auxiliary elements, as is the case with improving a standard PC. Performing an upgrade eliminates the need to completely change the device.

Controller from Z-Wave

If the user does not have enough experience or free time to complete the installation, then Z-Wave can offer services for setting up or installing equipment in any region of the Russian Federation. Any questions can be resolved using the extensive database located in free access, or using technical support. Raspberry has proven itself with the best side and in the field of video surveillance. Using a board and a standard webcam, the user receives a system that is capable of broadcasting an image to the network, regardless of the location of the tracking device. Monitoring an object becomes even easier, since there is no need to constantly monitor the situation. It is enough to track the main events at the end of the work to find out about any incidents recorded by the video camera.

A modern smart home is a multifaceted system that is responsible for performing preset tasks and also provides access to actions that are based on preset algorithms. This makes the project more autonomous and independent of human commands. A smart home independently looks for solutions in difficult situations, based on previous experience.

Designing such a house is not difficult, especially with careful planning. As a result, the owner becomes the recipient of enormous benefits due to his innovations. Having decided on the features of automation, you can significantly reduce time consumption, as well as save energy resources and increase safety for home residents. Convenience is determined by the selected components on which the project is based, so Raspberry will become a reliable assistant in creating a smart home.

Smart home on Raspberry Pi

As is known, many functions performed household appliances, can be automated without much effort, and managing the operation of equipment remotely becomes even easier. Next, the reader can get acquainted with exactly how to develop your project, starting from the capabilities of the Raspberry minicomputer. The main issue will be the development of a controller capable of productively monitoring the lighting in each individual room, as well as adjusting current temperature indicators and other life support parameters in the house. Raspberry Pi will control multimedia equipment, as well as home security elements.

Composition of the control unit

To assemble your smart home, you will first need to purchase all the components included in the minimum configuration:

  • NodeMCU ESP-12E;
  • Volumetric sensor;
  • Temperature sensors;
  • Humidity sensors
  • relay module;
  • memory card;
  • Raspberry Pi 3.

The processor itself, and in this configuration it is the third model, is selected arbitrarily, so another version will be no less efficient and suitable for a smart home. The choice in favor of Raspberry Pi 3 is due to the fact that the unit is equipped with modules wireless communication. You can replace the NodeMCU with an Arduino Nano, or use an auxiliary module for Wi-Fi.

Read also: Multiroom from Rostelecom - features and advantages

The components that make up the control unit must be connected and adjusted. To reduce the cost of time and effort, it will be beneficial to purchase a ready-made solution, like NodeMCU. Power elements are selected in the quantity involved in the project. The presented configuration will require 3 elements. The sensor configuration is determined individually. If desired, you can abandon the volumetric sensor if its use has no logical need.

Installing Raspbian

To cope with the OS installation, you will need to visit the company's official page, where you can always find and download the latest version. Next, the card is formatted to FAT. According to the specified instructions, we build the image for the operating system in use. All that remains is to connect the card to the minicomputer, as well as attach a keyboard and a screen, which can be a TV. The download process usually takes a little time, after which you can start setting up.

So you can set own password and other parameters. You should not change the current boot screen setting, since the graphic part will not be used while the smart home is running. Let's move on to changing the host, located in the Hostname item, and also set SSH, which will allow you to manage the device in the future with greater comfort. When all the settings have been applied, all that remains is to reboot the device by clicking Finish.

WIFI adjustment

When the device is restarted, you should go to the interfaces, where the procedure is as follows:

  • We write the command sudo nano /etc/network/interfaces;
  • Finding the part iface wlan0 inet manual and replace this line with iface wlan0 inet static,
  • Don't forget to indicate your own static IP address.

An example of the work done looks like this:

auto wlan0 allow-hotplug wlan0 iface wlan0 inet static address 192.168.1.150 netmask 255.255.255.0

gateway 192.168.1.1 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf address, netmask, gateway —

but in your case, the setup should be done for your own router.

The next step is to go to the supplicant, where you should specify the following command

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

The window that opens allows you to enter everything necessary settings for wireless network.

Example settings:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

network=( ssid=”your SSID » psk=”your password”)

sudo ifdown wlan0

The process will be completed, after which it remains to specify

sudo ifup wlan0

waiting for the reboot caused by the command to complete

sudo reboot

Provided that all operations are performed correctly, we end up with a fully configured wireless network, to which the device is switched at startup.

Minicomputer update

Before starting further adjustments, you should deal with the system upgrade. The sequence is not complicated:

  • enter sudo apt-get update sudo apt-get upgrade;
  • check the current version with the command g++-4.9 –v and check with the current one;
  • if the version you are using is outdated, then enter sudo apt-get install g++.

Let's move on to installing NODE.JS. This program, starting from the fourth version, supports ARM. In order to install NODE.JS, you will need to set the sequence of commands:

  • curl -sL https://deb.nodesource.com/setup_6.x;
  • sudo -E bash - sudo apt-get install -y nodejs;
  • To check the current version, enter nodejs –v.

Installing HOMEBRIDGE

The first step is to install Avahi and other components that will be required for MDNS to work. Go to the command line and start entering the following sequence

  • sudo apt-get install avahi-daemon avahi-discover libnss-mdns libavahi-compat-libdnssd-dev;
  • sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp;
  • cd /usr/lib/node_modules/homebridge/;
  • sudo npm install --unsafe-perm bignum;
  • cd /usr/lib/node_modules/hap-nodejs/node_modules/mdns;
  • sudo node-gyp BUILDENGINE=Release rebuild.

For testing purposes, perform a test run with the homebridge command, and in response you should expect something like this:

config.json (/home/pi/.homebridge/config.json) not found.

Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

│ 031-45-154 │

Homebridge is running on port 44278

If something similar was obtained, the previous commands were executed and applied correctly. As you can see from the example, the program was unable to detect config.json, which means that you will have to create it yourself:

  • sudo -i;
  • mkdir /root/.homebridge;
  • touch /root/.homebridge/config.json.