Repair Design Furniture

Homemade sensors for arduino. Homemade motion sensors (temperature, humidity, lighting) for the Smart Home based on the MySensors system. Getting to know Arduino

Recall that the basis of this project is Arduino. It performs a number of important functions: it reads data from the IR sensor, processes signals, reacts to movements, and USB notifies the computer about the need to send a message. In this article, we will consider two questions:

  1. Connecting a PIR sensor to Arduino;
  2. How to set up the relationship between the sensor and automatic e-mail sending .
Required for the project:
  • Arduino UNO (you can choose on Aliexpress).
  • PIR sensor.
  • Bradboard.
  • Bundle of wires.

All listed items for assembly can be seen in the photos:

First of all, you need a PC with an internet connection. We used Raspberry Pi.

We connect the PIR sensor to the Arduino kit:

To carry out this step, you need to take the wires that come from the sensor and attach them to the platform. Next, you will be given a photo with a diagram:

Working with a sketch

When motion occurs, the Arduino using USB Serial should send an email. Of course, if you send an e-mail with any movement that occurs, the mailbox will be full. Therefore, we fixed it this way, if there is a short period of time between two signals, an email with the following text will be sent:

int pirpin = 7; int minSecsBetweenEmails = 60; // 1 min long lastSend = -minSecsBetweenEmails * 1000; void setup() ( pinMode(pirPin, INPUT); Serial.begin(9600); ) void loop() ( long now = millis(); if (digitalRead(pirPin) == HIGH) ( if (now > (lastSend + minSecsBetweenEmails * 1000)) ( Serial.println("MOVEMENT"); lastSend = now; ) else ( Serial.println("Too soon"); ) ) delay(500); )

« MinSecsBetweenEmails" - this variable can be switched to other values ​​that will be convenient for the user. For example, you can set the interval to one minute, which means that the next e-mail will be sent only after 60 seconds.

"last send" will help you track the time at which the last message was sent. This variable is initialized with a negative number, which is equal to milliseconds, which is indicated in "MinSecsBetweenEmails" . As a result, we get a guarantee that after starting the sketch in Arduino, the PIR sensor will immediately start.

Due to what we can calculate milliseconds, compare their number with the time of the last sensor operation? All thanks to a built-in feature called Millis. In the event that motion is detected, but little time has passed since the last activation of the sensor, letters with the text will be sent "Too soon".

This feature needs to be tested first. To do this, open Serial Monitor. Let's see what it looks like next:

After you are convinced of correct operation, you can write a program in Python, it is used to process signals from the platform.

How to install PySerial and Python:

The Linux operating system has Python automatically installed. Windows does not have this feature, so you need to install the program yourself. PySerial acts as a library to help communicate with Arduino.

Installing Python:

It's not uncommon for Python 3 to cause problems when working with PySerial, especially if you're on Windows. To avoid this, instead of the third version, you can download Python 2 .

After completing the installation of the program in the Start menu, you can find a special group. When we move on to the library installation process, we will need to cooperate with Python using the command line. Therefore, it is better to immediately add the desired directory to PATH. Below you can see an auxiliary photo:

To add a directory, we need: open the control panel, find the “System Properties” section in it. Then we press the key, which is called "Environment Variables" (Environment Variabes), a window will pop up in front of us. At the bottom of it should be "Path", which must be selected. Now click on "Edit" - Change and complete the process by clicking on "variable value". You cannot delete the text that you received, you should add the following inscription to it - ";C:\Python27". Do not forget to put ";" after each folder that is indicated in the text. Now we check whether the input "Path" is correct. To do this, enter the word "python" in the command line. If there are no errors, the screen will display the following image:

Install PySerial:

Regardless of the operating system used, download the .tar.gz installation package for PySerial 2.6 from. This site can help you do just that - //pypi.python.org/pypi/pyserial . We get a file called pyserial-2.6.tar.gz. If you are using Windows, then you will need to unpack the files to the selected folder. This is not a standard ZIP file, you will have to do additional steps - download 7-zip (you can do it here - //www.7-zip.org/ ). For a Linux system, you need to use a terminal session, give the “CD” command in it, specify the name of the folder into which you downloaded pyserial-2.6.tar.gz. To unpack you need to enter:

$ tar -xzf pyserial-2.6.tar.gz

After that, you need to run the command:

sudo python setup.py install

Python

You will need to create a separate program to work with Python. You need to copy the code into a file with the same name - "movement.py". On Linux, you can use the "nano" editor, while on Windows, you need to create a file using the Python "IDLE" editor. It is available in the start menu.

import time import serial import smtplib TO=" [email protected]"GMAIL_USER=" [email protected]" GMAIL_PASS = "putyourpasswordhere" SUBJECT = "Intrusion!!" TEXT = "Your PIR sensor movement detected" ser = serial.Serial("COM4", 9600) def send_email(): print("Sending Email") smtpserver = smtplib. SMTP("smtp.gmail.com",587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(GMAIL_USER, GMAIL_PASS) header = "To:" + TO + "\n" + "From: " + GMAIL_USER header = header + "\n" + "Subject:" + SUBJECT + "\n" print header msg = header + "\n" + TEXT + " \n\n" smtpserver.sendmail(GMAIL_USER, TO, msg) smtpserver.close() while True: message = ser.readline() print(message) if message == "M" : send_email() time.sleep(0.5)

This is shown in the following picture:

After the changes, the program will start using the command line:

python movement.py

So the installation is complete.

The possibilities don't stop there, there are extensions that allow you to receive messages with temperature reports or other information.

Attached files :

Homemade temperature and humidity sensor DHT11 and DHT22 - connecting to Arduino Biometric lock - assembly of the control board and programming of the microcontroller

Good afternoon, today I will share the instructions for making a clock with a room thermometer ( Do-it-yourself clock on arduino). The clock is powered by an Arduino UNO, and a WG12864B graphic screen is used to display the time and temperature. As a temperature sensor - ds18b20. Unlike most other clocks, I will not use RTS (Real Time Clock), but will try to do without this additional module.

Arduino circuits are distinguished by their simplicity, and everyone can start learning Arduino. You can read about how to connect libraries and flash arduino in our article.

Let's get started.

To create this clock, we need:

Arduino UNO (Or any other Arduino compatible board)
- Graphic screen WG12864B
- Temperature sensor ds18b20
- Resistor 4.7 Kom 0.25 W
- Resistor 100 ohm 0.25 W
- Battery compartment for 4 AA batteries
- Matching box
- small file
- Nail polish (black or body color)
- Some thin plastic or cardboard
- Insulating tape
- Connecting wires
- Circuit board
- Buttons
- soldering iron
- Solder, rosin
- Double sided tape

Preparing the graphic screen.
With the connection of the screen, at first glance, there are many problems and difficulties. But if you first deal with their types, it will become much easier and clearer. There are many varieties and types of screens on the ks0107/ks0108 controller. All screens are usually divided into 4 types:
Option A: HDM64GS12L-4, Crystalfontz CFAG12864B, Sparkfun LCD-00710CM, NKC Electronics LCD-0022, WinStar WG12864B-TML-T
Option B: HDM64GS12L-5, Lumex LCM-S12864GSF, Futurlec BLUE128X64LCD, AZ Displays AGM1264F, Displaytech 64128A BC, Adafruit GLCD, DataVision DG12864-88, Topway LM12864LDW, Digitron SG12864J4, QY-1286 4F, TM12864L-2, 12864J-1
Option C: Shenzhen Jinghua Displays Co Ltd. JM12864
Option D: Wintek- Cascades WD-G1906G, Wintek - GEN/WD-G1906G/KS0108B, Wintek/WD-G1906G/S6B0108A, TECDIS/Y19061/HD61202, Varitronix/MGLS19264/HD61202

The list is not complete, there are a lot of them. The most common and, in my opinion, convenient WG12864B3 V2.0. The display can be connected to the Arduino via a serial or parallel port. When used with an Arduino UNO, it is better to choose a serial port connection - then we need only 3 microcontroller outputs, instead of a minimum of 13 lines when connected via a parallel port. Everything is connected quite simply. There is one more nuance, on sale you can find two display options, with a built-in potentiometer (for adjusting the contrast) and without it. I chose, and I advise you to do the same, with the built-in one.


This reduces the number of parts and soldering time. It is also worth putting a 100 ohm current-limiting resistor for backlighting. By connecting directly 5 volts, there is a risk of burning the backlight.
WG12864B - Arduino UNO
1 (GND) - GND
2 (VCC) - +5V
4 (RS) - 10
5 (R/W) - 11
6(E)-13
15 (PSB) - GND
19 (BLA) - through a resistor - + 5V
20 (BLK) - GND

The most convenient way is to assemble all this at the back of the screen and bring 5 wires from it to connect to the Arduino UNO. In the end, it should look something like this:


For those who still choose a parallel connection, I will give a connection table.

And the diagram for the screens of option B:



Several sensors can be connected to one communication line. One is enough for our watch. We connect the wire from the “DQ” pin of the ds18b20 to the “pin 5” of the Arduino UNO.

Preparation of the board with buttons.
To set the time and date on the clock, we will use three buttons. For convenience, we solder three buttons on the circuit board and output the wires.


We connect as follows: we connect the wire common to all three buttons to the "GND" Arduino. The first button, it serves to enter the time setting mode and switch by time and date, we connect to "Pin 2". The second, increase value button, to "Pin 3", and the third, decrease value button, to "Pin 4".

Putting everything together.
To avoid a short circuit, the screen should be insulated. We wrap it in a circle with electrical tape, and on the back we attach a bar of insulating material to a double-sided tape, cut to size. Thick cardboard or thin plastic will do. I used plastic from a paper tablet. It turned out the following:


On the front of the screen, along the edge, we glue double-sided tape on a foam base, preferably black.


Connecting the shield to the Arduino:


We connect the plus from the battery compartment to the “VIN” of the Arduino, the minus to the “GND”. Place it on the back of the Arduino. Before installation in the case, do not forget to connect the temperature sensor and the button board.


Preparing and filling the sketch.
The temperature sensor requires the OneWire library.

Screen output is done through the U8glib library:

To edit and fill the sketch, you need to install these two libraries. This can be done in two ways. Just unpack these archives and place the unpacked files in the "libraries" folder located in the folder with the Arduino IDE installed. Or the second option is to install the libraries directly in the programming environment. Without unpacking the downloaded archives, in the Arduino IDE, select the menu Sketch - Include Library. At the very top of the drop-down list, select Add .Zip Library. In the dialog box that appears, select the library you want to add. Open the menu Sketch - Include Library again. At the very bottom of the dropdown list, you should see the new library. Now the library can be used in programs. Don't forget to restart the Arduino IDE after all this.

The temperature sensor works according to the One Wire protocol and has a unique address for each device - a 64-bit code. It is not practical to look for this code every time. Therefore, you must first connect the sensor to the Arduino, fill it with the sketch located in the menu File - Examples - Dallas Temperature - OneWireSearch. Next, run Tools - Port Monitor. Arduino should find our sensor, write its address and current temperature readings. We copy or simply write down the address of our sensor. Open the sketch Arduino_WG12864B_Term, look for the line:

Byte addr=(0x28, 0xFF, 0xDD, 0x14, 0xB4, 0x16, 0x5, 0x97);//address of my sensor

We write the address of your sensor between curly braces, replacing the address of my sensor.

Stock:

//u8g.setPrintPos(44, 64); u8g.print(sec); // Output seconds to control the correctness of the move

Serves to display seconds next to the inscription "Data". This is necessary to accurately set the course of time.
If the clock is fast or behind, you should change the value in the line:

If (micros() - prevmicros >494000) ( // change to something else to adjust it was 500000

I empirically determined the number at which the clock is accurate enough. If your clock is fast, you should increase this number, if you are behind, decrease it. To determine the accuracy of the move, you need the output of seconds. After precise calibration of the number, seconds can be commented out and thus removed from the screen.

I have long wanted to automate the process of drying the bathroom after bathing. I had a lot of reviews on the topic of humidity. I decided to implement (so to speak) one of the methods of dealing with it. By the way, in winter we dry our clothes in the bathroom. It is enough to turn on the exhaust fan. But monitoring the fan is not always handy. So I decided to put automation on this case. The first implementation experience was unsuccessful. The review was. But I didn't give up...

When I moved into a new apartment, I almost immediately put a fan with a check valve in the hood. A fan is needed to dry the bathroom after bathing. A non-return valve is needed to prevent foreign odors from neighbors from entering the apartment (when the fan is silent). It happens. All ventilation ducts are individual, but cement was apparently saved during laying. Probably the smell passes through the cracks.
Fans I have a variety of options. There are simple ones, there are with a timer (time interval adjustment), as in the photo.


That's what I've been using to this day.
In this particular case (who does not have a fan with a timer), everything can be done at the software level.
Since I live in an apartment "anthill", the only place to dry clothes is the balcony. In the bathroom, it can fade. Drying requires either low humidity or air circulation. Fulfilling both conditions is the best option. The fan was supposed to solve this problem. At first, that's exactly what he did. The main thing is not to forget to turn it off. While the fan is running, it is necessary to slightly open the window. Do you need to remind about the school problem with a pool and two pipes? In order for the air to go into the hood, it is necessary that it enter the apartment from somewhere. Who has wooden windows, not plastic ones, there will be no problems. Enough cracks. But with plastic, the apartment turns into a terrarium.
That's when I started thinking about automating the process. That's why I ordered the sensors.
I have already shared the sad experience of implementing my idea. Here is that module. It can't work in PRINCIPLE. But nothing will remain. And he will be used.


(Power supply voltage: 5V. Maximum load: 10A 250V AC and 10A 30V DC). I use it as a relay box. For a normal fan, this is enough.
I also drew a diagram of the module. There will be no connection problems.


The red LED indicates the presence of the supply voltage. Green - relay actuation. I replaced the useless sensor (humidity sensor, it no longer exists) with a 10kΩ resistance. And also added more resistance. It will go to the "smart" block. Both highlighted in red. All this should eliminate possible misunderstandings. After all, the relay unit is powered by a voltage of 5V, and the “smart” unit is powered by 3.3V. The relay block is controlled by a low level. A high level turns off the relay (fan). The firmware takes this into account.
The circuit is based on a comparator on the LM393. The trimmer resistor was originally designed to set the threshold for the humidity switch. It may need to be rotated a bit.
You can use simple relay blocks. They are for sale. I will use what is left after the last unsuccessful attempt.
It's time to look in what form the AM2302 (DHT22) sensors arrived. I ordered three at once. I don't think it's limited to the bathroom. There are a lot of ideas in my head. Where would only find the time and desire to implement them.


The sensors were sealed in antistatic bags. All in the mind. The soldering is accurate. I have no complaints about the look. Even the board is washed.


Here's what it says on the store page:

AM2302 Humicap digital temperature and humidity module is a digital output signal containing a calibrated temperature and humidity combined sensor. It uses a dedicated digital modules capture technology and the temperature and humidity sensor technology to ensure that products with high reliability and excellent long-term stability. Sensor includes a capacitive humidity sensing element and a high-precision temperature measurement devices, and with a high-performance 8-bit microcontroller connected. Therefore, the product has excellent quality, fast response, anti-interference ability, high cost and other advantages. Ultra-small size, low power consumption, signal transmission distance up to 20 meters. Making it the best choice for all kinds of applications and even the most demanding applications.
Specification:
Dimension: 40 x 23mm
Weight: 4g
Voltage: 5V
Port: digital two-way single bus
Temperature range: -40-80 °C ± 0.5 °C
Humidity: 20-90%RH±2%RH
Platform: Arduino, SCM
Package included:
3 x Sensor Module
On the board of parts at least. The sensors are non-separable, did not break.
It's time to get down to business. Part of what I will use, I have already shown. I also need a 5V power supply. I will make it from an old (already unnecessary) charger for the phone.

This charger does not have a USB port. Well, it’s very old (I recommend using newer ones, they have 5V output). Therefore, the output is 7V. I had to solder the MC stabilizer KREN5. There is nothing difficult in this. Who is friends with a soldering iron, he knows. And who is not friends, in vain reads the topic.


Don't be too scared, I made a makeshift. After debugging the mechanism, everything will look decent. Maybe I'll change the charger. It all depends on the result with which I will come to the finish line. I will install it locally (permanently) after a “comprehensive testing”. You may have to use the winter / summer version of the software. The temperature and humidity characteristics of the air in winter/summer are different.
I also need the WIFI module from the previous review.


A converter cable (USB To RS232 TTL UART) is useful for programming the WIFI module.


The block diagram of my idea looks simple.


But of course there are nuances.
It remains to make a program for controlling the fan.
Several conditions:
1. The fan turns on when the humidity reaches more than 68%.
2. Working time (timer) 5 minutes.
3. Transferring temperature and humidity data via WIFI (just in case).
4. Mode indication by WIFI.
If you stop at condition number 1, then the simplest Arduino will suffice. But I only have one Arduino board, and there are three WIFI modules :)
For me personally, the most difficult place is the preparation of the program, a little (to put it mildly) is not my topic. But life flows and carries in its course more and more masses of people. I will comprehend the vast expanses of Arduino using the example of a DHT22 humidity sensor and a WIFI module. But if I succeeded, then you can too.
First some information for dummies like me.
The Arduino IDE program is missing in the settings of those boards that I will use. For example, ESP8266 needs to be added.

Adding components on the example of ESP8266.

First of all, I downloaded and installed the Arduino IDE on my computer. Then I run the program.
File→Settings→Insert link in add. links → click OK. Link:



This requires an internet connection. Necessarily!
Then I go to the board manager.
Tools→Board:…→Board manager.


Finding my module I choose the latest version. I click install.


The downloaded Arduino IDE program also lacks libraries for sensors. For example, the DHT22 library must also be added.

Connecting the library using the DHT22 sensor as an example.

First, I download an archive like DHT.zip from the Internet. Finding is not a problem.
Then I launch the Arduino IDE program.
Sketch→Include Library→Add zip library.


A tab like this one appears.


Specify storage location…Open.
The library is connected.


There is little left to do :)
The wiring diagram for the humidity sensor may vary. Mine came as a module with three pins and resistors already installed on the board.

And finally, filling the sketch.

Sketch fill.

I open the finished sketch. In my case, "WiFi-DHT22_AleksPoroshin68.ino.


The Arduino IDE will start automatically.
Then I connect the programmer, go to the tools and connect the Com-port. The one to which it is connected is highlighted. I will activate it. There are three of them on my netbook: these are com6, com8 and com10.


I'm learning firmware. You can change the access name and password.

I click the download button.


The sketch is being compiled. Long enough.


At this time, you must press reset on the assembled module circuit.

At the same time, GPIO 00 is at zero.
Here is the sketch itself:
#include #include #include #include #include "DHT.h" #define DHTPIN 4 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); float dhtTemp = NAN; float dhtHumidity = NAN; int ledPin = 12; //GPIO 12 /* Set these to your desired credentials. */ const char *ssid = "AleksPoroshin"; const char *password = "12345678"; ESP8266WebServer server(80); /* Just a little test message. Go to http://192.168.4.1 in a web browser * connected to this access point to see it. */ void handleRoot() ( String s = "\r\n ESP201"; s += " "; s += " "; //s += "Status - Actions - Config"; s += "

ESP 201 module

"; s += " "; if (isnan(dhtTemp)) s += " Temperature: Read Error"; else ( s += " Temperature: "; s += dhtTemp; s += " C"; ) if ( isnan(dhtHumidity)) s += " Humidity: Read Error"; else ( s += " Humidity: "; s += dhtHumidity; s += " %"; ) if(digitalRead(ledPin) == HIGH) s + = "Exhaust: Off"; else s += "Exhaust: On"; s += ""; server.send(200, "text/html", s); ) void setup() ( delay(1000); Serial.begin(115200); Serial.println(); Serial.print("Configuring access point. .."); /* You can remove the password parameter if you want the AP to be open. */ WiFi.softAP(ssid, password); IPAddress myIP = WiFi.softAPIP(); Serial.print("AP IP address : "); Serial.println(myIP); server.on("/", handleRoot); server.begin(); Serial.println("HTTP server started"); dht.begin(); Serial.println(" DHT22 init success"); pinMode(ledPin, OUTPUT); ) void loop() ( getDHT(); server.handleClient(); ) void getDHT() ( dhtTemp = dht.readTemperature(); dhtHumidity = dht.readHumidity() +5; if (dhtHumidity< 68) { digitalWrite(ledPin, HIGH); Serial.println("ledPin HIGH"); } else { digitalWrite(ledPin, LOW); Serial.println("ledPin LOW"); } }
Don't scold too hard. I am just learning.
After uploading the sketch to confirm programming, I connect the GPIO to + 3.3V. Then I turn it off. The firmware is loaded.


I'm making a layout on a breadboard. I check everything. Works. But not everything is as good as it should be. In the range I need, Chinese sensors underestimate the readings by 5-6%.


I have more confidence in the German logger. Yes, and the price is several tens of times more. And most importantly, he passed the test.
Introduced an amendment to the program (added 5 units). I agree that this is wrong. But in the range of 40-70% it shows exactly. It is more correct to remove the characteristic and fix the library. I'm not ready for this :). The rest of the sensors also lied. Although all showed approximately the same.

This is what the web page looks like if it connects to my WIFI module:


Passwords and appearances are indicated in the sketch.
Switching occurs at 68% humidity. Everything is clear.


But there is one caveat. And it cannot be ignored. At the border of 68% humidity, the fan can cycle, turning on and off. To solve this problem, you need a timer. I have a fan with a timer. Those. no problem. Anyone who has a regular fan will have to solve this problem at the software level.
My further task is to assemble all this according to the scheme, but no longer on a breadboard model and test it for a month. All changes can be made during operation. What to do and where to insert, I wrote everything.
A few words about the installation of the sensor. I don't recommend putting it in the vent. The reason is simple. Even in the cleanest and most well-groomed apartment there is dust, which, when the fan is turned on, rushes there (to the veterinary canal). But a year ago I took out the fan and thoroughly cleaned it.


In order not to change the sensors often due to their damage, I recommend finding a more suitable place for them, somewhere nearby. Additionally, you can wrap it with a non-woven cloth or something similar to protect it from dust. And you will be happy.
I completely forgot to say that if you want to set the "coefficients" of humidity control yourself, you need to be at least a little in the subject. If you don't have appliances like these at home...


Without them, it will be very difficult for you to do something on this topic.
That's all.
How to properly dispose of the information from my review, everyone decides for himself. If something is not clear, ask questions. Hope it helped at least someone. Perhaps someone will want to help me. I'll be very grateful.
Good luck everyone!
Function check:


To be continued…

The product was provided for writing a review by the store. The review is published in accordance with clause 18 of the Site Rules.

I plan to buy +51 Add to favorites Liked the review +26 +65

Integrated control systems for engineering communications of a dwelling, known as "Smart Home", are gaining more and more popularity. The widespread introduction of these systems is hampered by rather high cost of components elements and assembly work. An Arduino-based smart home is a solution that is quite affordable for anyone who is at least a little versed in electronics.

What is Arduino

Arduino is the brand under which hardware and software for independent construction of automation and telecontrol systems.

In fact, this is a modular constructor with a wide range of capabilities. Arduino hardware is a large assortment of printed circuit boards on which various sensors, actuators, and expansion boards are organized. The core of the system are boards with programmable microcontrollers different levels of complexity from Arduino Pro Mini to Arduino Mega. Expansion boards allow you to use a large number of external devices.

A microcontroller, a few discrete elements, quartz and various types of connectors, including vertical pins, are installed on a small printed circuit board, with the help of which shelving structures are assembled with the addition of expansion cards. Atmega chips are used as microcontrollers. The controller type determines the functionality of the board, depending on the number of inputs and outputs.

So widespread moduleArduino Unowith microcontrollerAtmega328 has the following characteristics:

  • Digital I/O - 14
  • Of these, 6 are PWM
  • Analog inputs - 6
  • Memory - 32 KB
  • Power - 7-12 V
  • Price - 950 rubles

Digital contacts can be programmed to perform a specific function. It can be an entrance or an exit. These inputs/outputs can work with devices that require two levels to function. This is a logical one or level close to the supply voltage and a logical low level corresponding to zero. Two-level sensors can be connected to the digital inputs. These include a pair of magnet-reed switch. This sensor reacts to the opening of doors and windows. Many burglar and fire alarm sensors work on this principle.

Digital outputs can control the operation of electromagnetic relays, which in turn turn on and off the network sockets to which various household appliances are connected. Smart from Arduino will cost much less than a ready-made industrial kit.

Analog inputs through analog-to-digital converters transmit to the controller information about the status of temperature sensors, lighting and some other devices. By comparing the readings of the sensors with the commands stored in the memory, the central unit of the system can control devices where a smooth change in power is required. Six outputs connected to the pulse-width modulator allow smooth control of the load power. For example, adjust the brightness of a lamp, adjust the temperature of a heater, or control the speed of an electric motor.

most powerful and multifunctional board of this line is the Arduino Mega. Mounted on PCB controllerAT mega 2560 , discrete elements, USB connector for power supply. The board has 54 universal contacts that can be programmed to perform I/O functions. 14 of them can control analog devices using pulse width modulation. 16 analog inputs are designed to connect any analog devices.

controller board Arduino Mega costs within 1,500 rubles. It is easiest to program it using a personal computer via a USB port.

Peripheral modules for Arduino

The controller board is the core of the system, but you cannot connect any devices to it. The outputs have a small load capacity and a limited current. To organize a control system for household appliances, external power modules, communication devices and other devices will be required. This is not a problem, since a large number of peripheral modules have been developed for Arduino controllers.

Here are just a few of them:

  • Gas analyzer - MQ-2
  • Light sensor - 2CH-Light-2
  • External temperature sensor - DS18B20-PL
  • Room temperature and humidity sensor – DHT-11
  • Motor Drivers - L298N, L9110
  • Relay modules - 1ch5V, 4ch5V
  • Remote control module IC2262/2272

The sensor that detects gas leakage in the room reacts to propane and butane, which are components of household gas. The module has sensitivity adjustment and analog/digital outputs. The light sensor can be part of an automated light control system. It consists of two independent channels with individually adjustable sensitivity. The outdoor temperature sensor is designed to operate at temperatures from -55 to +125 degrees. The room temperature and humidity sensor is intended for . Temperature range from 0 to +55 0 С and humidity from 20 to 90%.

Since the supply voltage of the Arduino modules lies in the range from 7 to 12 volts, any standard sensors that have the same operating levels can be used to organize a security or fire alarm.

Motor drivers allow you to control single-phase, two-phase, four-phase and stepper motors. With the help of such devices, you can open and close blinds or curtains. Servo drives connected to the drivers allow you to regulate the flow of coolant in heating radiators. Relay keys are indispensable in the "Smart Home" system. Controlled by the potential of a logical unit of +5 volts, the relays allow switching loads in alternating current circuits up to 10 amperes at voltages up to 250 volts.

With their help, you can turn on and off electrical outlets, electric pumps and other systems.

The remote control module consists of a remote control and a receiving device. The remote control is equipped with four buttons and provides transmission of commands to the receiving unit at a distance of up to 100 meters. All peripheral modules have the same supply voltage and are compatible with any Arduino microcontroller.

Organization of the "Smart Home" system

Without certain skills, knowledge of circuit diagrams and the basics of electronics, it is better not to take on the Smart Home system in full.

Programming Arduino microcontrollers carried out in C/C++.

To get started, you can write the simplest programs that can turn on and off the LED or control the operation of the micromotor. There are many examples of such programs. They use simple operators of the form: if, while, then and others. They allow even schoolchildren to write programs. When the first programs are correctly executed, you can try to assemble more complex devices, where PWM outputs will be used to smoothly control the light.

In order to make a "Smart Home" on Arduino with your own hands, you need to draw up a technical project, which will indicate the number of sensors and actuators for each room. You can start with one room, where a few simple functions will be implemented. Some of them will be executed by signals from external sensors, and some by timer signals. When a person gets up for work in the morning, the Arduino controller, at the signal of the timer, will turn on the electric kettle or coffee maker. If it is dark outside, which is detected by the outdoor sensor, the light in the room will light up smoothly. Comfortable room temperature can also be set for both sleeping and waking up.

For a small number of functions, the Arduino Uno microcontroller and a set of peripheral modules are suitable.

To control household appliances, you will need relay keys that will turn electrical outlets on and off. To control the light, you need a motion detector. If the smart system is installed in the kitchen, it is necessary to provide automatic activation of the hood, a domestic gas leakage sensor and a water leakage sensor. A smoke detector must be installed as a fire alarm element in the room.

Conclusion

The Arduino controller will allow you to complete a smart home project and meet a relatively small amount. If we calculate all the costs of equipping a three-room apartment, then the amount is unlikely to exceed 30-40 thousand rubles. If you reduce the number of functions, the budget will be even more modest.