Do-it-yourself smart home on Arduino on Mega 2560

The Arduino Smart Home system is in great demand among people who want to create maximum comfort in their home and office.

Its peculiarity is the ability to manage various systems without the participation of the owner, and the essence is to combine electronic devices into one network to save electricity, control lighting and electrical appliances, alert unauthorized persons entering the house and solve other problems.

One of the main elements of the smart home system in this case is the Arduino. What it is? How does he work? What functions does it perform? We will consider everything in detail in this article.

What is Arduino?

Arduino (Arduino) is a special tool that allows you to design electronic devices that have a closer interaction with the physical environment in comparison with the same PC, which actually does not go beyond virtual reality.

The platform is based on open source, and the device itself is built on a printed circuit board with software embedded in it.

In other words, Arduino is a small device that provides control of various sensors, lighting systems, receiving and transmitting data.

The Arduino contains a microcontroller, which is a microprocessor assembled on a single circuit. His specialty is the ability to perform simple tasks. Depending on the model, the Arduino device can be equipped with various types of microcontrollers.

There are several models of boards, the most common of which are UNO, Mega 2560 R3.

An equally important feature of the printed circuit board is the presence of 22 leads, which are located around the perimeter of the product. They are analog and digital.

The peculiarity of the latter is to control using only two parameters – a logical one or zero. As for the analog output, there are many small areas between 1 and 0.

Today, Arduino is used to create electronic systems that can receive information from various sensors (digital and analog).

Arduino-based devices can work in conjunction with software on a computer or independently.

As for the boards, you can assemble them yourself or purchase a finished product. Arduino programming is done in the Wiring language.

READ ON TOPIC: Smart home Xiaomi Smart Home, review, equipment, connection and configuration with your own hands, scenarios.

What controls the Arduino?

Due to the large number of pins on the printed circuit board, it is possible to connect many different devices to Arduino, namely:

In addition, a set of sensors is connected to Arduino depending on the tasks assigned to the system. As a rule, light, smoke and air composition, magnetic field, humidity, temperature and other sensors are installed.

Thanks to this feature, Arduino becomes a universal device – the “think tank” of the “Smart Home” system with the ability to be configured to suit the tasks.

The principle of the system

The Arduino device works as follows. Information collected from various sensors in the home is sent wirelessly to a tablet or PC. Further, with the help of special software, data is processed and a specific command is executed.

The main function is performed by the central sensor, which can be purchased or assembled independently. The connectors on the boards are standard, which greatly simplifies the choice of components.

Food

The Arduino is powered through the USB connector or from an external power supply. The voltage source is determined automatically.

If the option with external power not via USB is selected, you can connect the battery or power supply (voltage converter). In the latter case, the connection is made using a 2,1 mm connector with a “+” on the main contact.

The wires from the battery are connected to different terminals of the power connector – Vin and Gnd.

For normal operation, the platform needs a voltage of 6 to 20 volts. If the parameter drops below 7 volts, there may be less voltage on the 5V pin and there is a risk of failure.

If 12 V is applied, the voltage regulator may overheat and damage the board. For this reason, the optimal level is power supply using 7 – 12 V.

Unlike past types of boards, the Arduino Mega 2560 works without the use of an FTDI type USB microcontroller. To ensure the exchange of information via USB, a converter programmed for the USB-to-serial converter is used.

POPULAR WITH READERS: What is a smart home CLAP.

The Arduino has the following power outputs:

  • 5V – used to supply voltage to the microcontroller, as well as other elements of the printed circuit board. The power supply is adjustable. Voltage is supplied through the USB connector or from the VIN pin, as well as from another 5 Volt power supply with the ability to regulate.
  • VIN – used to supply voltage from an external source. The output is necessary when it is not possible to supply voltage via a USB connector or other external source. When voltage is applied to the 2,1 mm jack, this input is used.
  • 3V3 is a pin, the voltage on which is a consequence of the operation of the FTDI chip itself. The current draw limit for this element is 50 mA.
  • GND – ground pins.

Schematic diagram of the board in pdf format can be viewed HERE.

communication

Arduino capabilities allow you to connect a group of devices that provide stable communication with a PC, as well as other elements of the system – microcontrollers or the same Arduino boards.

The ATmega 2560 model features 4 ports through which data can be transmitted for TTL and UART. A special ATmega 8U2 chip on the board transmits the interface (one of them) via the USB connector. In turn, PC programs receive a virtual COM.

There are nuances that depend on the type of operating system:

  • If Linux is installed on the PC, recognition occurs automatically.
  • If you are on Windows, you will need an additional .inf file.

With the help of the monitoring utility, information is sent and received in text format after connecting to the system.

The flashing of the TX and RX LEDs indicates data transmission. A special Software Serial library is used to send information sequentially.

The features of the ATmega 2560 include the presence of SPI and I2C interfaces. In addition, the Arduino includes the Wire library.

Project development

There are many Arduino devices on the market today, with different configurations. But there is no one-size-fits-all solution. Depending on the task at hand, each set is selected individually. To avoid mistakes, project development is required.

What kind of projects can be created on Arduino?

Arduino allows you to create many unique projects. Here are just a few of them:

  • Assembling a Rubik’s Cube (the system solves it in 0,887 s);
  • Humidity control in the basement;
  • Creation of unique paintings;
  • Sending messages;
  • Balancing robot on two wheels;
  • Sound spectrum analyzer;
  • Origami lamp with capacitive sensor;
  • Robotic arm controlled by Arduino;
  • writing letters in the air;
  • Flash control and more.

See also:

Designing a smart home

Consider a situation where you need to make automation for a house with one room.

Such a building consists of five main areas – an entrance hall, a porch, a kitchen, a bathroom, and a living room.

When drafting a project, consider the following:

  • PORCH. The light is turned on in two cases – the owner approaching the house at night and opening the doors (when a person leaves the building).
  • SANUEL. The boiler has a power switch, which turns off when a certain temperature is reached. The boiler is controlled depending on the availability of appropriate automation. When entering the room, the hood should work, and the light will turn on.
  • HALLWAY. This requires turning on the light when dark (automatic), as well as a motion detection system. At night, a low-power light bulb turns on, which eliminates discomfort for other residents of the house.
  • ROOM. The light is turned on manually, but if necessary and the presence of a motion sensor, this manipulation can occur automatically.
  • KITCHEN. Switching on and off the light in the kitchen is carried out manually. Automatic shutdown is allowed in the event of a prolonged lack of movement around the room. If a person starts cooking, the hood is activated.

Heating devices perform the task of maintaining the required temperature in the room. If there are no people in the house, the lower temperature limit drops to a certain level.

After the appearance of people in the building, this parameter rises to its previous value. Air recovery is carried out when the system has detected the presence of the owner. The duration of the process is no more than 10 minutes per hour.

It is worth noting that if smart sockets are planned to be installed in the house, then it is better to use applications on mobile devices, WIFI or via SMS messages to control them.

Visual programming for Arduino can be done using a special FLProg application, which can be downloaded from the official website https://flprog.ru/.

We select the complete set for the project on the example of Arduino Mega 2560 R3

To create a full-fledged Smart Home system and perform its assigned functions, it is important to correctly approach the configuration and selection of equipment.

What is included in the package?

If your goal is an Arduino-based Smart Home, you need to prepare the following equipment – the Mega 2560 R3 board itself, an Ethernet module (ENC28J60), a motion sensor, as well as other sensors and controllers.

In addition, it is worth preparing a twisted pair cable, a resistor, a relay, a switch, and a cable for the Ethernet module.

Additional tools are also needed – screwdrivers, soldering irons, etc.

Please note that it is worth buying kits for mounting the system at certified points. This is due to the fact that electricity is used in the implementation of the project, and the use of a fake can lead to a decrease in the level of security.

All adaptation programs can be found online on the official Arduino website https://arduino.ru. When choosing sensors, it is worth focusing on the tasks that the Smart Home should solve.

As a rule, motion, temperature, door opening and light sensors are required. The role of the door opening sensor can be performed by a conventional reed switch.

The board is flashed using special software designed for various operating systems, including a USB cable. There is no need for programmers.

As for the software that is used in Arduino, it is written in C language. There are certain restrictions on the number of bytes, but the current memory is enough to implement the task.

See also:

Beginning of work

As soon as the necessary equipment is prepared and the project is developed, you can begin to complete the task.

Stages

When organizing a Smart Home system based on Arduino, it is worth acting according to the following algorithm:

  • Installation of program code;
  • Application configuration for the device used;
  • Port forwarding (for router);
  • Conducting tests;
  • Editing and so on.

The Web has all the necessary software for the equipment used – just download it from the official website and install it (see the link above).

The application allows you to see information about the sensors. If required, the IP address settings can be changed.

The sequence of actions when connecting to a computer

To get started with Arduino on Windows, follow these steps:

Working with a router

For the full operation of the Smart Home, it is important to properly handle the router. Here you need to perform the following steps – open the configuration, specify the Arduino IP address, for example, 192.168.10.101 and open the 80th port.

After that, you need to assign a domain name to the address and proceed to the process of testing the project. Please note that for such a system, the use of a public IP address is prohibited, because in this case there is a high risk of hacking through the Network.

See also:

Expansion on Arduino

One of the possibilities of a smart home is the visualization of the state of automation and the processes taking place in the system. To do this, it is recommended to use a separate server that provides state processing (a Node.js program can be used).

The mentioned software technology is used to solve Internet problems, therefore, the Java Script language is used to visualize the “Smart Home” (it is with its help that the handler and server are created). The results can be seen on a computer or PC screen.

To implement the plan, a laptop, a regular PC or a Raspberry Pi is suitable. The use of such a system allows increasing its capabilities. So, if the Arduino board has a small amount of memory, there are no such restrictions on the server. The program is written in such a way as to provide full control of the platform.

If desired, you can set an algorithm that will record the fact that a person is in the house and collect this information. If the owner returns every day around 17.30:XNUMX pm, the boiler or heating devices can be turned on in an hour. Upon arrival home, a person finds himself in a warm building with hot water.

The program can remember the time when the owner goes to rest and turn off the water heating. There are many such nuances that, if necessary, are introduced into the program. It is the presence of an external PC that gives great opportunities to the Arduino controller.

Communication with Arduino

To know what actions to perform, the processor must receive the appropriate command. Communication is carried out using a special language that is adapted to work with Arduino and is quite simple. If desired, it is easy to work in it even in the absence of programming skills.

Formatting and sending a message to the controller is called programming. To simplify the process, the Arduino IDE has been developed, which includes many programs. Their study allows you to get a lot of useful information about working with Arduino.

How can you manage?

As noted, the Node.js server allows you to interconnect hardware in your home. One of the ways to manage processes is cloud services on the web. At the same time, you can turn on the heating or the boiler one to two hours before arrival.

Another way is to manage via messages (MMS or SMS). This option is relevant when there is no connection to the Internet. One of the advantages of the system is the ability to obtain information about a force majeure situation (for example, a leak). The Edison board from Intel helps here.

See also:

In the end, what will we get?

Today, Arduino is in demand among people who know nothing about programming.

The reason for this is a simple interface, as well as a number of advantages – a simple programming language, the ability to create your own algorithm, thanks to open source code, and the ease of transferring programs using a USB cable. The software required for Arduino is available on the Internet, so there are no problems here.

As you can see, Arduino is not just a board that allows you to connect various devices. This is a powerful base that can be used to create a Smart Home. At the same time, there is no need to spend big money for expensive devices, the cost of which is 5-10 times more.

These are the main advantages of the system.

The features of the board include the ability to connect to a computer and get a visualization of processes on the display of a tablet or PC.

Automation control is possible via the Internet or via messages. So Arduino is great for creating devices of increased complexity.

Leave a Reply