The use of several common "Arduino" sensors

Source: Internet
Author: User
because to use the Arduino to do the alarm, learned a few commonly used sensors to use, share with you.

1, Human infrared sensor module hc-sr501

Product parameters

1. Operating voltage: dc5v to 20V
2. Static power consumption: 65 micro-Ann
3. Level output: High 3.3V, Low 0V
4. Delay Time: Adjustable (0.3 seconds ~18 seconds)
5. Block time: 0.2 seconds
6. Trigger mode: L non-repeatable, h repeatable, the default value is H (jumping cap selection)
7. Sensing range: Less than 120 degree cone angle, less than 7 meters
8. Operating Temperature: -15~+70 degree

Introduction: HC-SR501 is an infrared sensor module that relies on the movement of a specific temperature (36-38) to judge the body. Therefore it can be used as the key module of the alarm. In the key places, such as the door, put on such a sensor, can play the role of anti-theft. It has two adjustment knob, one adjusts the furthest detection distance, one adjusts the delay time, the concrete parameter as above. When a person walks through or stays in the sensing range, the module sends a high level signal through the D0.

Sample program:

#define HC-SR 2

void Setup ()  {
  serial.begin (9600);
  Pinmode (hc-sr,input);

}
void Loop ()  {
    if (Digitalread (HC-SR) ==high)
    {
      serial.println ("Someone here!");
    }
    else
    {
      serial.println ("Nobody");
    }
    Delay (+);
}

2. Smoke and combustible gas detection module MQ-2

Product parameters

1, sensitive gas liquefied petroleum gas, propane, hydrogen
2, Boost Chip PT1301
3. Operating voltage 2.5v-5.0v
4, Product size 40.0mm*21.0mm
5, Fixed hole size 2.0mm

Introduction: MQ-2 is a smoke sensing module that uses a resistor that is sensitive to a particular gas or particle to determine whether a combustible gas or smoke particle exists. The output has two ways, the A0 port output the current special gas content reference value (0-1023), basically 100 below the figure is normal. The D0 port outputs a high-level or low-level signal based on the threshold value of the pre-defined reference value. It can be used as an early warning device for liquefied gas leakage and can also be used as auxiliary for judging fire.

Sample program:

#define MQ-D 2
#define MQ-A A0

void Setup ()  {
  serial.begin (9600);
  Pinmode (mq-d,input);
  Pinmode (mq-a. INPUT);
}

void Loop ()  {
    if (Digitalread (mq-d) ==high)
    {
      serial.println ("There is something smell not good...!");
      serial.print ("Value:");
      Serial.println (Analogread (mq-a));
    }
    else
    {
      serial.println ("nothing");
    }
    Delay (+);
}

2, temperature and humidity detection module DHT-11

Product parameters

1 Humidity Measurement range: 20%-95% (0 degree-50 degree range) Humidity measurement error: +-5%
2 Temperature measurement range: 0 degrees-50 degrees temperature measurement error: +-2 degree
3 Operating voltage 3.3v-5v
4 output Form Digital output
5 with fixed bolt hole for easy installation
6 Small Board PCB size: 3.2cm * 1.4cm

Introduction: DHT-11 module is a common temperature and humidity detection module, often used in air-conditioning, automotive, easy to use. The output is different from other modules, and its output requires the Arduino to give two level signals, and then send the data in the form of high-low level send bits. Fortunately, the Arduino has the relevant libraries, so we don't need to understand the implementation of this process unless we explore it. dht11 library files can be downloaded from Baidu, placed in the Arduino IDE under the libraries file can be used.

Sample program:

#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 2

void Setup ()
{
  serial.begin (9600);
}

void Loop ()
{
  serial.println ("\ n");

  Dht11.read (Dht11pin);//This only needs to be read once, the following need to call the corresponding data directly.
  serial.print ("humidity (%):");
  Serial.println (float) dht11.humidity, 2);

  Serial.print ("Temperature (OC):");
  Serial.println (float) dht11.temperature, 2);

  Delay (+);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.