Smart home based on Arduino controllers: design and organization of controlled space

The development of automation tools has led to the creation of complex systems that improve the quality of human life.Many well-known manufacturers of electronics and software environments offer ready-made standard solutions for various objects.

Even an inexperienced user can develop independent projects and assemble a “smart home” using Arduino to suit their needs. The main thing is to understand the basics and not be afraid to experiment.

In this article we will look at the principle of creating and the main functions of an automated home based on Arduino devices. We will also consider the types of boards used and the main modules of the system.

Creating systems on the Arduino platform

Arduino is a platform for developing electronic devices with automatic, semi-automatic or manual control. It is made according to the principle of a designer with clearly defined rules of interaction between elements. The system is open, which allows third-party manufacturers to participate in its development.

Classic «smart House» consists of automated blocks that perform the following functions:

  • collect the necessary information through sensors;
  • analyze data and make decisions using a programmable microprocessor;
  • implement the decisions made by issuing commands to various devices.

The Arduino platform is good precisely because it is not locked into a specific manufacturer, but allows the consumer to choose the components that suit him. Their selection is huge, so you can realize almost any idea.

We recommend checking out the best smart devices for the home.

Arduino Starter Kit
To learn how to work with Arduino, you can purchase a Starter Kit on the manufacturer’s website. Knowledge of technical English is required, since the documentation is not Russified

In addition to the variety of connected devices, the programming environment implemented in C++ adds variety. The user can not only use the created libraries, but also program the reaction of system components to emerging events.

Main board elements

The main element of a “smart home” is one or more central (mother) boards. They are responsible for the interaction of all elements. Only after identifying the tasks that need to be solved can you begin to select the main node of the system.

The motherboard combines the following elements:

  • Microcontroller (processor). Its main purpose is to output and measure voltage in the ports in the range of 0-5 or 0-3.3 V, store data and perform calculations.
  • Programmer (not available on all boards). Using this device, a program is written into the microcontroller’s memory according to which the “smart home” will work. It is connected to a computer, tablet, smartphone or other device using a USB interface.
  • Voltage regulator. A 5 volt device is required to power the entire system.

Several board models are produced under the Arduino brand.They differ from each other in form factor (size), number of ports and memory capacity. It is based on these indicators that you need to choose a suitable device.

Original Arduino board
It is better to purchase Arduino boards and shields for them from the manufacturer, as they are of better quality than compatible devices produced in China

There are two types of ports:

  • digital, which are marked on the board with letters "d";
  • analog, which are marked with the letter "a".

Thanks to them, the microcontroller communicates with connected devices. Any port can work both to receive a signal and to send it out. Digital ports marked “pwm” are designed to input and output a PWM (pulse width modulation) signal.

Therefore, before purchasing a board, it is necessary to at least approximately estimate the level of its load on various devices. This will allow you to determine the required number of ports of all types.

It should be understood that the smart home system does not necessarily have to be connected to a control unit based on a single motherboard. Functions such as, for example, turning on artificial lighting in the local area depending on the time of day and maintaining a water reserve in the storage tank are independent of each other.

From the standpoint of ensuring the reliability of the electronic system, it is better to separate unrelated tasks into different blocks, which the Arduino concept makes it easy to implement. If you combine many devices in one place, then the microprocessor may overheat, conflict of software libraries and difficulties in finding and eliminating software and hardware faults.

Arduino based robot
Connecting many different types of devices to one board is usually used in robotics, where compactness is important. For a “smart home” it is better to use its own base for each task

Each microprocessor is equipped with three types of memory:

  • Flash Memory. Main memory where system management program code is stored. A small part of it (3-12%) is occupied by a built-in bootloader program.
  • SRAM. RAM, where temporary data necessary for running the program is stored. It features high operating speed.
  • EEPROM Slower memory where data can also be stored.

The main difference between types of memory for data storage is that when the power is turned off, the information that is recorded in SRAM is lost, but remains in EEPROM. But the non-volatile type also has a drawback - a limited number of write cycles. This is something to keep in mind when creating your own applications.

Unlike the use of Arduino in robotics, most smart home tasks do not require a lot of memory either for programs or for storing information.

Types of boards for assembling a smart home

Let's look at the main types of boards that are most often used when assembling smart home systems.

View #1 - Arduino Uno and its derivatives

The most commonly used boards in smart home systems are Arduino Uno and Arduino Nano. They have sufficient functionality to solve typical problems.

Powering the Arduino board from batteries
Having full-length boards powered from 7-12 Volts provides many advantages. First of all, this is the possibility of long-term autonomous operation from standard batteries or rechargeable batteries

Main parameters of Arduino Uno Rev3:

  • processor: ATMega328P (8 bit, 16 MHz);
  • number of digital ports: 14;
  • of which with PWM function: 6;
  • number of analog ports: 6;
  • flash memory: 32 KB;
  • SRAM: 2 KB;
  • EEPROM: 1 KB.

Not long ago, a modification was released - Uno Wi-Fi, which contains an integrated ESP8266 module that allows you to exchange information with other devices using the 802.11 b/g/n standard.

The difference between the Arduino Nano and its larger counterpart is that it does not have its own 12 V power socket. This is done to achieve a smaller device size, which allows it to be easily hidden in a small space. Also for these purposes, the standard USB connection is replaced by a chip with a mini-USB cable. Arduino Nano has 2 more analog ports compared to Uno.

There is another modification of the Uno board - Arduino Mini. It is even smaller than Nano, and much more difficult to work with. Firstly, the lack of a USB port creates a problem with the firmware, since you will have to use a USB-Serial Converter for this. Secondly, this board is more picky when it comes to power supply - it is necessary to provide an input voltage range of 7-9 V.

For the reasons described above, the Arduino Mini board is rarely used for smart home operation. It is usually used either in robotics or in the implementation of ready-made projects.

View #2 - Arduino Leonardo and Micro

The Arduino Leonardo board is similar to the Uno, but a little more powerful. Another interesting feature of this model is that it is identified as a keyboard, mouse or joystick when connected to a computer. Therefore, it is often used to create original gaming devices and simulators.

Dimensions and weight of Arduino boards
Table of sizes and dimensions of Uno, Leonardo and their miniature analogues. The developers did not follow the logic in the names - “nano” should be the smallest

The main parameters of Arduino Leonardo are as follows:

  • processor: ATMega32u4 (8 bit, 16 MHz);
  • number of digital ports: 20;
  • of which with PWM function: 7;
  • number of analog ports: 12;
  • flash memory: 32 KB;
  • SRAM: 2.5 KB;
  • EEPROM: 1 KB.

As can be seen from the list of parameters, Leonardo has more ports, which allows this model to be loaded with a larger number of sensors.

Also for Leonardo there is a miniature analogue with absolutely identical characteristics called Micro. It does not have a 12V power supply and instead of a full USB input there is a chip for a mini-USB cable.

The Leonardo modification called Esplora is a purely gaming model and is not suitable for the needs of a “smart home”.

View #3 - Arduino 101, Arduino Zero and Arduino MKR1000

Sometimes the operation of smart home systems implemented on the basis of Arduino requires a lot of computing power, which 8-bit microcontrollers are not able to provide. Tasks such as voice or image recognition require a fast processor and a significant amount of RAM for such devices.

To solve such specific problems, powerful boards that operate according to the Arduino concept are used. The number of ports they have is approximately the same as that of Uno or Leonardo boards.

Arduino 101 board
Arduino 101 has the same dimensions as Uno or Leonardo, but weighs almost twice as much. The reason for this is the presence of two USB inputs and additional chips

One of the easiest to use yet powerful boards, Arduino 101 has the following characteristics:

  • processor: Intel Curie (32 bit, 32 MHz);
  • flash memory: 196 KB;
  • SRAM: 24 KB;
  • EEPROM: no.

Additionally, the board is equipped with BLE functionality (Bluetooth Low Energy) with the ability to easily connect ready-made solutions, such as a heart rate sensor, receiving information about the weather outside the window, sending text messages, etc. A gyroscope and an accelerometer are also integrated into the device, but they are used mainly in robotics.

Another similar board, Arduino Zero, has the following indicators:

  • processor: SAM-D21 (32 bit, 48 MHz);
  • flash memory: 256 KB;
  • SRAM: 32 KB;
  • EEPROM: no.

A distinctive feature of this model is the presence of a built-in debugger (EDBG). With its help it is much easier to find errors when programming the board.

Debugging a program for Arduino
When writing voluminous code, even a highly qualified programmer experiences errors. To find them, use a debugger

Arduino MKR1000 is another model suitable for high-power computing. It has a microprocessor and memory similar to the Zero. Its main difference is the presence of an integrated Wi-Fi chip with the 802.11 b/g/n protocol and a crypto chip with support for the SHA-256 algorithm to protect transmitted data.

View #4 - Mega family models

Sometimes it is necessary to use a large number of sensors and control a significant number of devices. For example, this is necessary for the automatic operation of distributed air conditioning systems, which maintain a certain temperature for individual zones.

For each local area, it is necessary to monitor the readings of two temperature sensors (the second is used as a control one) and, in accordance with the algorithm, adjust the position of the damper, which determines the volume of warm air entering.

If there are more than 10 such zones in a cottage, then more than 30 ports are needed to control the entire system. Of course, you can use several Uno-type boards under the common control of one of them, but this creates additional switching difficulties. In this case, it is advisable to use models of the Mega family.

Arduino Mega board
The size of the Mega family boards (101.5 x 53.4 cm) is larger than that of the previously reviewed models. This is a technical necessity - otherwise such a number of ports cannot be placed

The Arduino Mega board is based on a fairly simple 8-bit 16 MHz microprocessor aTMega1280.

It has a large amount of memory:

  • flash memory: 128 KB;
  • SRAM: 8 KB;
  • EEPROM: 4 KB.

But its main advantage is the presence of many ports:

  • number of digital ports: 54;
  • of which with PWM function: 15;
  • number of analog ports: 16.

This board has two modern varieties:

  • Mega 2560 is based on the aTMega2560 microprocessor, characterized by a large amount of flash memory - 256 KB;
  • Mega ADK, in addition to the aTMega2560 microprocessor, is equipped with a USB interface with the ability to connect to devices based on the Android operating system.

The Arduino Mega ADK model has one feature. When connecting a phone to a USB input, the following situation is possible: if the phone needs charging, it will begin to “pull” it from the board. Therefore, there is an additional requirement for the electricity source - it must provide a current of 1.5 amperes. When powering via batteries, this condition must be taken into account.

Powering the Arduino from a set of batteries
You can make autonomous power supply for Arduino using connected batteries or accumulators.By combining serial and parallel connections you can achieve the desired voltage and long operating time

Due is another model from Arduino that combines the power of a microprocessor with a large number of ports.

Its characteristics are as follows:

  • processor: Atmel SAM3X8E (32 bit, 84 MHz);
  • number of digital ports: 54;
  • of which with PWM function: 12;
  • number of analog ports: 14;
  • flash memory: 512 KB;
  • SRAM: 96 KB;
  • EEPROM: no.

The analog contacts of this board can work both in the usual 10-bit resolution for Arduino, which is made for compatibility with previous models, and in 12-bit, which allows you to receive a more accurate signal.

Features of module interaction via ports

All modules that will be connected to the board have at least three outputs. Two of them are power wires, i.e. “ground”, as well as a voltage of 5 or 3.3 V. The third wire is logical. It transmits data to the port. To connect the modules, special wires grouped in groups of 3 are used, which are sometimes called jumpers.

Since Arduino models usually have only 1 voltage port and 1-2 ground ports, in order to connect several devices you will need to either solder wires or use breadboards.

Using a Development Board
You can connect not only the power and ports of the Arduino board to the breadboard, but also other elements, such as resistance, registers, etc.

Soldering is more reliable and is used in devices that are subject to physical impact, such as control boards for robots and quadcopters. For a smart home, it is better to use development boards, as it is easier both when installing and when removing the module.

Some models (for example, Arduino Zero and MKR1000) have an operating voltage of 3.3 V, so if a higher value is applied to the ports, the board may be damaged. All information on power supply is available in the technical documentation for the device.

Add-on boards (shields)

To increase the capabilities of motherboards, Shields are used - additional devices that expand the functionality. They are manufactured for a specific form factor, which distinguishes them from modules that are connected to ports. Shields are more expensive than modules, but working with them is easier. They are also equipped with ready-made libraries with code, which speeds up the development of your own control programs for a smart home.

Proto and Sensor shields

These two standard shields do not add any special functionality. They are used for more compact and convenient connection of a large number of modules.

Proto Shield is an almost complete copy of the original in terms of ports, and you can glue a development board in the middle of the module. This makes it easier to assemble the structure. Such add-ons exist for all full-length Arduino boards.

Motherboard and Proto Shield
Proto Shield is placed on top of the motherboard. This slightly increases the height of the structure, but saves a lot of space in the plane

But if there are a lot of devices (more than 10), then it is better to use more expensive Sensor Shield switching boards.

They do not have a bradboard, but all port pins are individually supplied with power and ground. This allows you to avoid getting tangled in wires and jumpers.

Sensor Shield for Arduino board
The surface area of ​​the motherboard and sensor boards is the same, but there are no chips, capacitors and other elements on the shield. This frees up a lot of space for full connections.

This board also has connectors for easily connecting several modules: Bluetoots, SD cards, RS232 (COM-port), radio and ultrasound.

Connecting auxiliary functionality

Shields with functionality integrated into them are designed to solve complex but typical problems. If you need to implement original ideas, it is better to choose a suitable module.

Motor Shield. It is designed to control the speed and rotation of low-power motors. The original model is equipped with one L298 chip and can drive two DC motors or one servo at the same time. There is also a compatible third-party part that has two L293D chips with the ability to control twice as many drives.

Relay Shield. A frequently used module in smart home systems. A board with four electromechanical relays, each of which allows the passage of current with a force of up to 5A. This is enough to automatically turn on and off kilowatt devices or lighting lines designed for 220 V alternating current.

LCD Shield. Allows you to display information on a built-in screen, which can be upgraded to a TFT device. This extension is often used to create weather stations with temperature readings in various living spaces, outbuildings, garages, as well as temperature, humidity and wind speed outside.

Board with LCD screen
The LCD Shield has built-in buttons that allow you to program information scrolling and select actions to send commands to the microprocessor

Data Logging Shield. The main task of the module is to record data from sensors onto a full-format SD card up to 32 Gb with support for the FAT32 file system. To record to a micro SD card you need to purchase an adapter.This shield can be used as an information storage, for example, when recording data from a DVR. Manufactured by the American company Adafruit Industries.

SD Card Shield. A simpler and cheaper version of the previous module. Many manufacturers produce such extensions.

Ethernet Shield. Official module for connecting Arduino to the Internet without a computer. There is a slot for a micro SD card, which allows you to record and send data via the World Wide Web.

Wi-Fi Shield. Allows wireless exchange of information with support for encryption mode. Serves to connect to the Internet and devices that can be controlled via Wi-Fi.

GPRS Shield. This module is usually used to communicate between a smart home and its owner via mobile phone via SMS messages.

Smart home modules

Connecting modules from third-party manufacturers and the ability to work with them using the built-in programming language is the main advantage of the open Arduino system compared to “branded” smart home solutions. The main thing is that the modules have a description of the received or transmitted signals.

Ways to obtain information

Information input can be done through digital or analog ports. It depends on the type of button or sensor that receives the information and transmits it to the board.

Analog and digital signal
For a computer program, a digital signal corresponds to periods with “0” and “1”, and an analog signal determines the range of values ​​​​in accordance with its dimension

A signal to the microprocessor can be sent by a person who uses two methods for this:

  • Pressing a button (key). The logical wire in this case goes to the digital port, which receives the value “0” if the button is released and “1” if it is pressed.
  • Rotating the rotary potentiometer (resistor) cap or shifting the engine lever. In this case, the logical wire goes to the analog port. The voltage passes through an analog-to-digital converter, after which the data goes to the microprocessor.

Buttons are used to start an event, for example, turning lights, heating or ventilation on and off. Rotary knobs are used to change the intensity - increase or decrease the brightness of the light, the volume of the sound or the speed of rotation of the fan blades.

Rotary potentiometer with cap
A potentiometer is a simple device, so it is very cheap. Its main characteristics are electrical resistance and rotation angle

Sensors are used to automatically determine environmental parameters or the origin of an event.

The following types are most in demand for smart home operation:

  • Sound sensor. Digital versions of this device are used to activate an event using clap or voice. Analog models allow you to recognize and process sound.
  • Light sensor. These devices can operate in both visible and infrared ranges. The latter can be used as a fire warning system.
  • Temperature sensor. Different models are used for indoors and outdoors, since the external ones are better protected from moisture. There are also remote devices on the wire.
  • Air humidity sensor. The DHT11 model is suitable for indoors, and the more expensive DHT22 for outdoors. Both devices can also provide temperature readings. Connect to a digital port.
  • Air pressure sensor. Analog barometers from Bosh have proven themselves to work well with Arduino boards: bmp180, bmp280. They also measure temperature.The bme280 model can be called a weather station, since it also provides an additional humidity value.
  • Motion and presence sensors. They are used for security purposes or to automatically turn on lights.
  • Rain sensor. Reacts to water entering its surface. It can also be used to trigger an alarm for leaks in the plumbing or heating circuit.
  • Current sensor. They are used to detect non-working electrical appliances (burnt out lamps) or to analyze voltage to prevent overload.
  • Gas leak sensor. Used to detect and respond to increased concentrations of propane.
  • Carbon dioxide sensor. It is used to determine the concentration of carbon dioxide in living rooms and in special rooms, such as wine cellars, where fermentation occurs.

There are many more different sensors for specific tasks, for example, for measuring weight, water flow speed, distance, soil moisture, etc.

Wind speed measuring device
Some sensors, such as the anemometer, which measures wind speed and direction, are complex electromechanical instruments

Many sensors and sensors can be made independently using simpler components. It will cost less. But, unlike the use of serial devices, you will have to spend time on calibration.

Control of devices and systems

In addition to collecting and analyzing information, a “smart home” must respond to emerging events. The presence of advanced electronics on modern household appliances allows you to access them directly using Wi-Fi, GPRS or EtherNet. Typically, Arduino systems implement switching between a microprocessor and high-tech devices via Wi-Fi.

In order to use Arduino to turn on the air conditioner when the temperature in the house is high, block the TV and Internet at night in the children's room, or start the heating boiler when the owners arrive, you need to perform three steps:

  1. Install the Wi-Fi module on the motherboard.
  2. Find unoccupied frequency channels to avoid system conflict.
  3. Understand device commands and program actions (or use ready-made libraries).

In addition to “communicating” with computerized devices, tasks often arise that involve performing some mechanical actions. For example, you can connect a servo drive or a small gearbox to the board, which will be powered from it.

5 volt servomotor
The servo drive consists of a motor and several gearboxes. Therefore, despite the low current (5 V), it can develop decent power, which is enough, for example, to open a window

If it is necessary to connect powerful devices operating from an external power source, two options are used:

  1. Inclusion in the relay circuit.
  2. Connecting a power switch and triac.

Included in an electrical circuit electromagnetic or solid state relay closes and opens one of the wires according to a command coming from the microprocessor. Their main characteristic is the maximum permissible current (for example, 40 A) that can pass through this device.

As for connecting a power switch (mosfet) for direct current and a triac for alternating current, they have a lower permissible current (5-15 A), but can smoothly increase the load. It is for this purpose that PWM ports are provided on the boards. This property is used when regulating lighting brightness, fan speed, etc.

Using relays and power switches, you can fully automate all electrical circuits at home and start the generator in the absence of current. Therefore, on the basis of Arduino, it is possible to implement autonomous provision of an apartment or building, including all particularly important functions - heating, water supply, drainage, ventilation and security system.

Do you want your home to become smarter, but with programming for “you”? In this case, we recommend looking at ready-made solutions from Xiaomi and Apple, which are easy to install and configure even for a beginner. And you can set commands and control their implementation even from your smartphone.

Read more about smart home from Xiaomi and Apple in the following articles:

Conclusions and useful video on the topic

An example of a self-assembled entry-level workpiece for a “smart home”:

The openness of the Arduino platform allows the use of components from various manufacturers. This makes it easy to design a “smart home” to suit the user’s needs. Therefore, if you have at least minor knowledge in the field of programming and connecting electronic devices, this system is worth paying attention to.

Are you familiar with the Arduino platform in practice and want to share your experience with newcomers to this matter? Maybe you would like to supplement the above material with useful recommendations or comments? Write your comments under this publication.

If you have any questions about designing an automated home system based on Arduino, ask them to our experts and other site visitors in the block below.

Add a comment

Heating

Ventilation

Electrics