Arduino sensors: description, specifications, connection, reviews

The Arduino platform is one of the best for the design of various automated systems. Moreover, many universities and colleges use Arduino to introduce students to the field of robotics. Indeed, Arduino is a very light, but at the same time powerful platform for constructing various robots and smart systems. And of course, so that it all takes less time, ready-made sensors are sold. There are a lot of them in stores, so it's pretty hard to get confused in choosing the right one. In this article, we will look at some of the main Arduino sensors and how they work.

Sensors for Arduino

Where could I buy

The fact is that sensors in our stores cost a lot of money. And if you are going to start studying the Arduino platform, then you just need to know where you can buy them at a low price. The answer is simple - Chinese shops. It can be Aliexpress, Joom, Pandao and others. Almost all stores buy sensors there and sell them with a huge margin, which reaches up to 300%. Of course, you will have to wait a while, and you can’t be sure of the quality of the goods, but paying for the same sensor three times as much is also not worth it. Example: on Aliexpress there is a set of 36 sensors, which costs 800 rubles. The same set in a Russian store is sold for 3.5 thousand rubles. Therefore, you decide.

Where to buy sensors for arduino

Servo

The servo drive is used in the design of robots and various smart systems. With the help of a servo, you can open the door, find out the degree of rotation and much more. But basically it is used to create robots. Maximum angle of rotation of the servo: 180 degrees. But sometimes on the expanses of Aliexpress you can see options with a rotation angle of 360 degrees. This is quite a basic element, almost all lessons on Arduino with sensors begin with it. The servo is easy to connect, the control code is very simple.

To connect the servo, only three wires are used: ground, power, logic. The signal wire (usually yellow or brown) is connected to any pin with support for PWM (wide pulse modulation) on the Arduino.

Connecting Servo to Arduino

Code example:

#include <Servo.h> //       Servo servo1; //   servo  "servo1" void setup() //  setup { servo1.attach(11); //      11 } void loop() //  loop { servo1.write(0); //     0 delay(2000); //  2  servo1.write(90); //     90 delay(2000); //  2  servo1.write(180); //     180 delay(2000); //  2  } 

First, add the library that is already in the Arduino to the code, then indicate which contact the servo drive is connected to. As you can see, working with a servo drive is really very simple, control is only one operator.

Price on Aliexpress: 80-100 rubles.

DHT-11

DHT-11 is used to measure temperature and humidity. This temperature sensor for Arduino is the most popular because of its price and features. Measures temperature in the range from 0 to 50 degrees, and humidity from 20 to 80%. Also on sale is another version of this sensor, DHT-22, its measurement range is larger, but it also costs several times more. For simple projects, its use is not advisable, so everyone prefers DHT-11, which does an excellent job with measurements. Power can be supplied from 3.3 to 5V. In general, the sensor itself has 4 connection pins, but there are DHT-11 modules on sale, it is much more convenient to work with them, since connecting through 3 contacts does not need to be tormented with resistors.

Connection. This temperature sensor is connected to the Arduino using three contacts: ground, power and logic.

Connect dht11 to arduino

Code example:

 #include "DHT.h" #define DHTPIN 2 //    ,     DHT dht(DHTPIN, DHT11); void setup() { Serial.begin(9600); dht.begin(); } void loop() { delay(2000); // 2   float h = dht.readHumidity(); //  float t = dht.readTemperature(); //  if (isnan(h) || isnan(t)) { // .     ,  « »,     Serial.println(" "); return; } Serial.print(": "); Serial.print(h); Serial.print(" %\t"); Serial.print(": "); Serial.print(t); Serial.println(" *C "); //    } 

At the very beginning, as with a servo drive, a library is connected. By the way, about the library. Initially, it is not in the Arduino package, this library needs to be downloaded. There are several versions of this library, in our example the most standard one is used. Be careful when downloading, as the syntax may be different and the code will not work. Then it is also written to which contact the sensor and its version are connected (DHT11 or DHT22). As with the servomotor, working with this sensor for the Arduino is very easy, only a few operators are used. By the way, often the servo drive and dht11 work together, for example, when creating automatic windows that will open if the room or greenhouse is too hot.

Price on Aliexpress: 80-100 rubles.

Soil moisture sensor

This sensor is used in the design of automatic irrigation. Using it, you can measure soil moisture, then process these data and, if necessary, water the plant. There are many variants of this sensor on sale for the Arduino, but the FC-28 is popular. Quite a budget option, so everyone loves and uses it in their projects. The sensor has two probes that conduct electricity through the earth. With dry soil, resistance is greater, and with wet soil less. Basically, this sensor is used only in small projects, this is due to the fact that the probes are made of poor material and sooner or later during active work they become corroded, after which the sensor stops working. The service life of the sensor can be increased if it is activated only when taking data from the soil, for example, every 6 hours. Some craftsmen even change probes to better ones made by their own hands, or even from scratch they assemble a humidity sensor for the Arduino.

Connecting a soil moisture sensor is quite simple. Usually, a potentiometer and a comparator are included with it to control the sensitivity of the sensor. In total, he has three contacts: logic, power and earth. It can be connected to both digital and analog contacts. By the way, working in analog mode is more convenient.

Connecting a soil moisture sensor to an arduino

Code example:

 int sensor_pin = A0; int output_value ; void setup() { Serial.begin(9600); Serial.println("   "); delay(2000); } void loop() { output_value= analogRead(sensor_pin); output_value = map(output_value,550,0,0,100); Serial.print(" : "); Serial.print(output_value); Serial.println("%"); delay(1000); } 

First of all, we determine the contacts to which the sensor is connected to the Arduino. Then we read the data from it and display them. As with other sensors, working with the FC-28 is quite easy. And all thanks to ready-made libraries and sensors.

Price on Aliexpress: 30-50 rubles.

PIR sensor

This motion sensor for Arduino is used in the design of various security systems. Detects moving elements from 0 to 7 meters. We will not consider the principle of operation, we will proceed immediately to the connection of this sensor to the Arduino.

Judging by the reviews, it is also connected using three contacts: logic, power and ground. It works through digital outputs.

Connecting a motion sensor to an arduino

Code example:

 #define PIN_PIR 2 #define PIN_LED 13 void setup() { Serial.begin(9600); pinMode(PIN_PIR, INPUT); pinMode(PIN_LED, OUTPUT); } void loop() { int pirVal = digitalRead(PIN_PIR); Serial.println(digitalRead(PIN_PIR)); //   if (pirVal) { digitalWrite(PIN_LED, HIGH); Serial.println("Motion detected"); delay(2000); } else { //Serial.print("No motion"); digitalWrite(PIN_LED, LOW); } } 

We determine the contacts to which the sensor is connected, and then check for movement. It is very convenient and easy to work with it, but there are cases of false positives.

Price on Aliexpress: 30-50 rubles.

Draw conclusions

Above were considered the main sensors for the "Arduino", which are the very first to be studied by beginner radio amateurs. As you can see, they are quite inexpensive, they connect easily, and reading data takes just a couple of lines. In addition to them, there are still a huge number of other sensors, even there are for measuring the pulse! It is most profitable to purchase them on Aliexpress kits, so they will cost even cheaper. It's easy to create, the main thing is to remember the three basic rules of robotics!

Source: https://habr.com/ru/post/G44131/


All Articles