Homemade sensors for Arduino. Smart home based on Arduino: step-by-step assembly instructions. What solutions does Arduino offer?

Good afternoon, today I will share instructions for making a clock with a room thermometer( DIY Arduino clock). The clock runs on Arduino UNO; the WG12864B graphic screen is used to display 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 anyone 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 will need:

Arduino UNO (Or any other Arduino compatible pay)
- 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
- Fine file
- Nail polish (black or body color)
- Some thin plastic or cardboard
- Electrical tape
- Connecting wires
- Circuit board
- Buttons
- Soldering iron
- Solder, rosin
- Double sided tape

Preparing the graphic screen.
At first glance, connecting the screen poses many problems and difficulties. But if you first understand 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, 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 is WG12864B3 V2.0. The display can be connected to Arduino via serial or parallel port. When using with Arduino UNO, it is better to choose the connection via serial port– then we will need only 3 microcontroller outputs, instead of at least 13 lines when connected via a parallel port. Everything connects quite simply. There is one more nuance: you can find two display options on sale, with a built-in potentiometer (to adjust 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 installing a 100 Ohm current limiting resistor for the backlight. By connecting 5 volts directly, there is a risk of burning out 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 everything behind the screen and bring out 5 wires from it connecting to the Arduino UNO. The end result should look something like this:


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

And the diagram for screens of option B:



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

Preparing the board with buttons.
To set the time and date on the watch we will use three buttons. For convenience, we solder three buttons on the circuit board and remove the wires.


We connect as follows: we connect the wire common to all three buttons to the “GND” of the Arduino. The first button, which is used to enter the time setting mode and switch by time and date, is connected to “Pin 2”. The second, the button to increase the value, is to “Pin 3”, and the third, the button to decrease the value, is to “Pin 4”.

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


In front of the screen, along the edge, we glue double-sided foam tape, preferably black.


Connect the screen to Arduino:


We connect the plus from the battery compartment to the “VIN” of the Arduino, the minus to the “GND”. We place it behind the Arduino. Before installing it in the case, do not forget to connect the temperature sensor and the board with buttons.


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

Output to the screen is carried out through the U8glib library:

To edit and fill a sketch, you need to install these two libraries. There are two ways to do this. Simply unzip these archives and place the unzipped files in the “libraries” folder located in the Arduino IDE installation folder. 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 - Connect 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 Sketch menu again – Connect Library. At the very bottom of the drop down list you should see new library. Now the library can be used in programs. Don't forget to restart the Arduino IDE after all this.

The temperature sensor operates using the One Wire protocol and has a unique address for each device - a 64-bit code. It is not practical to search for this code every time. Therefore, you must first connect the sensor to the Arduino, upload the sketch found in the menu File – Examples – Dallas Temperature – OneWireSearch. Next, launch Tools - Port Monitor. Arduino must 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 the 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 the seconds next to the “Data” inscription. This is necessary to accurately set the passage 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 correct it was 500000

I empirically determined the number at which the clock runs quite accurately. If your clock is fast, you should increase this number; if it’s behind, decrease it. To determine the accuracy of the move, you need to display the seconds. After precise calibration of the number, seconds can be commented out and thus removed from the screen.

Integrated systems for managing housing utilities, known as “ Smart House"are gaining more and more popularity. Widespread implementation of these systems is hampered by sufficient high cost of components elements and installation work. A smart home based on Arduino is a solution that is quite accessible to everyone who has at least a little knowledge of electronics.

What is Arduino

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

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

On a small printed circuit board a microcontroller, some discrete elements, quartz and different kinds connectors, including vertical pins, with the help of which shelving structures are assembled with the addition of expansion cards. Atmega family chips are used as microcontrollers. The controller type determines functionality boards depending on the number of inputs and outputs.

Such a widespread moduleArduino Unowith microcontrollerAtmega328 has the following characteristics:

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

Digital Contacts can be programmed to perform a specific function. It can be an input or an output. These inputs/outputs can work with devices that require only two levels to operate. This is a logical one or level close to the supply voltage and a logical low level corresponding to zero. On digital inputs You can connect two-level sensors. These include a magnet-reed switch pair. This sensor reacts to the opening of doors and windows. Many security and fire alarm sensors operate on this principle.

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

Analog inputs, through analog-to-digital converters, transmit information about the status of temperature sensors, light sensors and some other devices to the controller. By comparing sensor readings with commands stored in memory, the central unit of the system can control devices that require a smooth change in power. Six outputs connected to a pulse-width modulator allow smooth control of 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 Arduino Mega. Mounted on a printed circuit board controllerAT mega 2560 , discrete elements, USB connector port for power connection. The board has 54 universal pins 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 around 1,500 rubles. The easiest way to program it is with personal computer via 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 limited current. To organize a management system household appliances external power modules, communication devices and other devices will be required. This is not a problem since there are a large number of peripheral modules designed 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
  • Module remote control IC2262/2272

The sensor that detects gas leaks 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 may be part of automated system light control. It consists of two independent channels with individual sensitivity adjustment. The outdoor temperature sensor is designed to operate at temperatures from -55 to +125 degrees. The room temperature and humidity sensor is designed. Temperature range from 0 to +55 0 C and humidity from 20 to 90%.

Since the supply voltage of Arduino modules ranges 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 a logical unit potential of +5 volts, the relays allow switching loads in AC circuits up to 10 amperes at voltages up to 250 volts.

They can be used to turn electrical outlets, electric pumps and other systems on and off.

The remote control module consists of a remote control and a receiving device. The remote control is equipped with four buttons and transmits 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 microcontrollers.

Organization of the Smart Home system

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

Programming microcontrollers of the Arduino line carried out in C/C++ language.

To begin with, you can write simple programs that can turn an LED on and off or control the operation of a microelectric motor. There are many examples of such programs. They use simple operators like: if, while, then and others. They allow even schoolchildren to write programs. When the first programs are executed correctly, you can try to assemble more complex devices that will use PWM outputs for smooth light control.

In order to make a “Smart Home” using 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 performed based on signals from external sensors, and some based on timer signals. When a person gets up for work in the morning, the Arduino controller will turn on the electric kettle or coffee maker based on a timer signal. If it is dark outside, which is detected by the external sensor, the lamp in the room will gradually light up. A comfortable room temperature can also be set for both sleeping and waking up.

For a small number of functions, an 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 will need a motion detector. If the smart system is installed in the kitchen, it is necessary to provide automatic switching on hoods, domestic gas leakage sensor and water leakage sensor. As a fire alarm element, a smoke detector must be installed in the room.

Conclusion

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

I was passing by, I looked, and here they write interesting things about various homemade products. I also recently made something, let me write, I think, maybe it will be useful to someone, or it will just be interesting. We are talking about budget DIY sensor hardware for embedding into switch and socket panels.

But let's take things in order.

I have been interested in automation systems for Smart Homes for a relatively long time. I have several here now different systems connected into one whole. There are both industrial and homemade components. I want to tell you about the last homemade product.

Some time ago, on the Internet, I came across the MySensors home automation system. Quite a developed (and constantly being further developed) wireless system based on Arduino and nRF24L01+. However, it’s not about who is interested - look at the source.

The main advantages of the system for me were good software support, bidirectional communication, availability of components and their low cost.

Having played enough with development boards, I decided to develop a device that can be adequately integrated into a home interior (WAF cannot be ignored). The result is a device that, along with others, can be recessed into the wall in a standard 63mm box.

This is the first assembly, I will try to make the subsequent ones more carefully. The large hole (for the light sensor) will be covered with a plexiglass rod.

In semi-assembled form it looks like this:

View from the other side:

It all consists of a (Chinese) 8MHz/3.3V Arduino Pro Mini, nRF24L01+ radio module, HC-SR510 motion sensor, DHT22 sensor (temperature and humidity), BH1750 light sensor and a standard JUNG plug (you can probably use others, like Gira , Berker, etc. I just used what was at hand). Total cost about $15.

The PCB is designed by Eagle. Sources. Ordered from ITEADStudio, it was done well (except for the silk, the inscriptions turned out so-so).



Probably the font is too small and thin. It looked good on the gerbera.



During the assembly process, some minor inconveniences were discovered; some things could be improved, but overall the board is quite usable.

The idea for this project appeared and captivated me during my vacation.

The thought went something like this: “It would be cool to have a robotic arm that could be controlled by my own!” And after some time I began to develop and implement this project. I hope you find it interesting!

The main components of the project are the glove and the robotic arm itself. Arduino was used as a controller. The movement of the robotic arm is provided by servomotors. The glove is equipped with bending sensors: variable resistors that change their bending resistance. They are connected to one side of the voltage divider and fixed resistors. The Arduino reads the change in voltage as the sensors bend and transmits the signal to the servo motors, which rotate proportionally. A video of the working project is below.

The hand design is taken from the open-source project InMoov. On the project page you can download 3-D models of all nodes and print them on a 3-D printer.

Below are all the steps to implement your own glove-controlled robotic arm.

Necessary materials

For the project you will need:

All! You can start your robotic arm project!

Printing a hand

The hand is part of an open-source project called InMoov. This is a robot that is printed on a 3-D printer. The hand is just a separate unit of the overall structure. Download from this page and print the following details:

Auriculaire3.stl

WristsmallV3.stl

Just in case, I’m attaching a clickable list of parts, because some of them have been removed from the main project page.

RobCableFrontV1.stl

RobRingV3.stl (I had to make extra holes in this part to make my servos fit)

RobCableBackV2.stl

RobServoBedV4.stl

(These are two “skin” parts - they are not necessary from the point of view of structural rigidity and its functioning)


In total it took about 13-15 hours to print. Depends on print quality. I used the MakerBot Replicator 2X. I recommend printing finger details on a standard or high resolution to avoid unwanted friction in the structure.


Connecting bend sensors to Arduino

To connect bend sensors to Arduino, we need to include a voltage divider in the circuit. Bend sensors are essentially a variable resistor. When used in conjunction with constant resistor, you can monitor the difference in voltage of the two resistors. You can track the difference using Arduino analog pins. The connection diagram is shown below (red connector is voltage, black is ground, blue is the connector of the signal itself, which connects to the analog input of the Arduino).


The resistors in the photo have a nominal value of 22 kOhm. The colors of the wires correspond to the colors shown in the connection diagram.

All GND pins from the sensors are connected to a common ground. Ground goes to the GND pin on the Arduino. +5V on Arduino is connected to the common power supply pin from all sensors. Each blue signal connector connects to a separate analog input on the microcontroller.




I assembled the circuit on a small circuit board. It is advisable to choose smaller board sizes in order to attach them to a glove in the future. You can attach our assembled diagram to the glove using an elementary thread and a needle. In addition, do not be lazy and immediately use electrical tape on the exposed contacts.




Installing sensors on the glove

We can start installing the sensors and our circuit board on the glove itself. First, drill a small hole in the plastic of the sensors. Holes are drilled in places where the sensing element has ended. IMPORTANT! Never drill a hole into sensitive material. After this, put on a glove. Make marks with a pencil or pen at the top of each joint. You will use these places to mount the sensors. The bend sensors are attached with ordinary thread. Sew the sensors to the glove. Use the hole you made on the ends of the sensor. In places where the joints are marked, the sensors are “grabbed” by the thread on top. All this is shown in more detail in the photo below. The circuit board is sewn to the glove in a similar manner to the sensors. Please note that for the fingers to move, you must leave a certain margin of length of the conductors. This must be taken into account when installing our circuit board and choosing the length of the connectors from it to the sensors.






I won't go into detail about this step. It is covered in great detail on the InMoov website (under "Assembly Sketches" and "Assembly Help"):

When you assemble the arm, make sure that the nodes are installed correctly in terms of orientation in space. Don't forget to drill out the holes in the fingers of the robotic arm for 3 mm fasteners to reduce friction between the joints. From the outside I filled the bolts with glue.


Don't rush to install the line. First check the functionality of the servo motors.

Checking servomotors

At this point, the servos should already be installed in the back of your robotic arm. To connect the servos to the Arduino and power supply, I used a small breadboard. Connect each servo motor's positive pin (red) to one breadboard rail and the negative pin (black or brown) to the other rail.

IMPORTANT! Remember to connect the Arduino pin to the negative rail: remember that all the ground pins must be connected to each other. The VCC pin can connect to different power supplies, but the GND must be the same.

Download the program to the Arduino (the program file is attached). Make sure that the connections of sensors, servomotors, etc. It was right. Put on the glove and turn on the Arduino. The servo motors should rotate depending on which finger you move. If the servos move, then everything is working!


If you are a more experienced Arduino user and know how to check the current values ​​from the bend sensors, you can adjust the range in the program to suit your realities. I'm assuming that all bend sensors are roughly the same, but if they are not, calibrating the sensors will definitely help you.

If the servos are not working correctly, make sure that you have connected them correctly (for example, when I was working on this project, I, as usual, forgot to connect the GND pin of the Arduino to the GND of the power supply and all the servos. In this case, nothing will work). Make sure everything works out before moving on.

Adding fishing line

Adding fishing line is probably the most difficult and demanding part of the robotic arm project. There are instructions for this on the InMoov website. The concept is simple, but its implementation is practically not so easy. Please note that this part of the project requires focus and patience. The only difference between my version and the design on InMoov is the use of glue. Thanks to this, we can get more flexible settings when calibrating the servos. To do this, just melt the glue and tighten the bolts we need. Although, of course, the reliability of the design decreases. In the end, after final setup and calibration, we can use a different fixation option at any time.

To calibrate the servos, rotate the rotors so that the fingers of the robotic arm are on the table. Connect your Arduino and power supply. Align the drive rockers so that when the arm is fully “lying,” the tension is maximum.


Explaining the calibration process is quite difficult. In addition, the instructions with InMoov, for example, did not suit me. That is, when fastening, you need to show your imagination and adapt to your realities - such as: the type of rocking chair, the type of fishing line or thread, design and assembly errors, the installation distance of the servomotors relative to the joints of the robotic arm.

Fortunately, this is the last stage of the project!

Afterword


Despite the fact that there are much more complex and precise (and also expensive) designs, the above project is very interesting and has excellent potential for practical application. Such designs should not be used in direct contact with a person, due to the lack of accuracy of the concept itself. But industry, medicine, etc. For tasks without increased requirements for the accuracy of joint movements, our robotic arm is quite suitable. Well, from the point of view of further “upgrading” the hand, this field is generally unplowed. Starting from wireless control, ending with the replacement of drives, dimensions, and the development of additional degrees of freedom.

This is why I love Arduino: you can very quickly and for little money put together a breadboard or prototype of a device that is not only easy to program, but can also perform real interesting tasks.

Leave your comments, questions and share personal experience below. New ideas and projects are often born in discussions!

I have long wanted to automate the process of drying the bathroom after bathing. I have had many reviews on the topic of humidity. I decided to introduce into life (so to speak) one of the methods of combating it. By the way, in the winter we dry our clothes in the bathroom. It is enough to turn on the exhaust fan. But monitoring the fan is not always convenient. So I decided to install automation on this matter. The first implementation experience was unsuccessful. There was a review. But I didn't give up...

When I moved into a new apartment, I almost immediately installed a fan with a check valve in the hood. A fan is necessary to dry the bathroom after bathing. A check valve is needed to prevent foreign odors from neighbors from entering the apartment (when the fan is silent). It happens. All the ventilation ducts are individual, but they apparently saved cement when laying them. The smell probably passes through the cracks.
I have different options for fans. There are simple ones, some with a timer (time interval adjustment), as in the photo.


This is exactly what I used 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 for drying clothes is the balcony. It may go dark in the bathroom. Drying requires either low humidity or air circulation. Fulfilling both conditions is the best option. A fan should have solved this problem. At first I did just that. The main thing is not to forget to turn it off. While the fan is operating, the window must be opened slightly. Don’t you need to remind me about the school problem with a swimming pool and two pipes? In order for the air to escape into the hood, it must enter the apartment from somewhere. Those who have wooden windows and not plastic will have no problems. Enough cracks. But with plastic ones, the apartment turns into a terrarium.
That’s when I started thinking about automating the process. This is exactly why I ordered the sensors.
I have already shared my sad experience of implementing my idea. This is the module. It cannot work IN PRINCIPLE. But it will not remain idle. And there will be use for it.


(Supply voltage: 5V. Maximum load: 10A 250V AC and 10A 30V direct current). I use it as a relay block. This is enough for a regular fan.
I also drew a diagram of the module. There will be no connection problems.


The red LED indicates the presence of supply voltage. Green – relay activation. I replaced the useless sensor (humidity sensor, it is no longer there) with a 10 kOhm resistance. And also added more resistance. It will go to the “smart” block. Both are 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 by 3.3V. The relay block is controlled by low level. A high level turns off the relay (fan). The firmware takes this into account.
The circuit is based on a comparator based on LM393. The trimming resistor was originally intended to adjust the operating threshold of the humidity relay. You may have to twist it a little.
Can be used simple blocks relay. They are for sale. I will use what was left after the last unsuccessful attempt.
It's time to see what form the AM2302 (DHT22) sensors arrived in. I ordered three at once. I think that this will not be limited only to the bathroom. There are a lot of ideas in my head. Where can I find the time and desire to implement them?


The sensors were sealed in antistatic bags. Everything is in the mind. The soldering is neat. Claims for appearance I do not have. Even the board was 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
There are minimal parts on the board. The sensors are non-separable, so I didn’t break them.
It's time to get down to business. I have already shown some of what I will use. I also need a 5V power supply. I will make it from an old (no longer needed) phone charger.

This charger does not have a USB connector. 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 of the KREN5 stabilizer. There is nothing complicated about this. Anyone who is familiar with a soldering iron knows. And whoever is not friends is reading the topic in vain.


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


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


The block diagram of my idea looks simple.


But of course there are nuances.
All that remains is to create a fan control program.
There are several conditions:
1. The fan turns on when the humidity reaches more than 68%.
2. Operating time (timer) 5 minutes.
3. Transfer of temperature and humidity data via WIFI (just in case).
4. WIFI mode indication.
If we focus on condition No. 1, then the simplest Arduino will be enough. But I only have one Arduino board, and there are three WIFI modules :)
For me personally, the most difficult part is drawing up a program, which is a little (to put it mildly) not my topic. But life flows and carries ever-increasing masses of people along its course. I will explore the vast expanses of Arduino using the example of a DHT22 humidity sensor and a WIFI module. But if I succeeded, then so can you.
First, some information for dummies like me.
The Arduino IDE program does not have enough settings for the boards that I will use. For example, ESP8266 needs to be added.

Adding components using the ESP8266 as an example.

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



An Internet connection is required. Necessarily!
Then I go to the board manager.
Tools→Board:…→Board Manager.


I find my module. I choose latest version. I click install.


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

Connecting the library using the example of the DHT22 sensor.

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


A tab like this appears.


I indicate the storage location…Open.
The library is connected.


Just a little bit left to do :)
The connection 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 in the sketch.

Filling the sketch.

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


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


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

I press the button to download.


The sketch is compiled. Long enough.


At this time you need to press reset on assembled circuit module.

In this case, GPIO 00 is at zero.
Here's 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 ESP201 ";s += "

"; //s += "Status - Actions - Config"; s += "

ESP 201 module"; s += " "; if (isnan(dhtTemp)) s += " Temperature: Reading 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 + = "Hood: Off."; else s += "Hood: On."; "; server.send(200, "text/html", s); ) void setup() ( delay(1000); Serial.begin(115200); Serial.println(); Serial.print("Configuring access point. .."); /* You can< 68) { digitalWrite(ledPin, HIGH); Serial.println("ledPin HIGH"); } else { digitalWrite(ledPin, LOW); Serial.println("ledPin LOW"); } }
remove the password parameter if you want the AP to be open. */ WiFi.softAP(ssid, password);
After uploading the sketch, I connect the GPIO to +3.3V to confirm programming. Then I turn it off. The firmware is uploaded.


I'm assembling the circuit on a breadboard. I'm checking everything. Works. But not everything is as good as we wanted. In the range I need, Chinese sensors underestimate readings by 5-6%.


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

This is what the internet page looks like if you connect 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. Those who have a regular fan will have to solve this problem at the software level.
My next task is to assemble all this according to the diagram, but not on a breadboard, and test it within a month. All changes can be made during operation. What to do and where to insert it, I wrote everything.
A few words about mounting the sensor. I don’t recommend sticking it into the ventilation duct. The reason is simple. Even in the cleanest and most well-kept apartment there is dust, which, when the fan is turned on, rushes there (to the veterinary drain). But a year ago I took out the fan and thoroughly cleaned it.


In order not to frequently change sensors 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 humidity control “coefficients” yourself, you need to be at least a little in the know. If you don’t have devices like these at home...


Without them, it will be very difficult for you to do anything on this topic.
That's all.
Everyone decides for themselves how to properly use the information from my review. If something is unclear, ask questions. I hope it helped at least someone. Perhaps someone will want to help me. I'll be very grateful.
Good luck everyone!
Functionality check:


To be continued…

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

I'm planning to buy +51 Add to favorites I liked the review +26 +65