PIR Sensor Arduino Interfacing

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide the detailed discussion on PIR Sensor Arduino Interfacing. PIR basically stands for Passive Infrared Sensor. Basically PIR is an electronic equipment which is often used to measure the infrared light radiating from the different objects in their field of view. It detects the infrared energy released from animals as well as from human beings, when this energy is higher than the certain threshold level PIR sensor shows an indication correspondingly. The energy detected by PIR sensor is usually in the form of heat i.e. emitted by humans as well as from animals. We can also test and verify our results in Proteus using PIR sensor. I have already shared PIR Sensor Library for Proteus. PIR sensor is most of the time used for sensing the motion of the different objects. It can sense the different objects up to 10 meters. It has three different pins. Each pin is assigned with the different task to be performed when the sensor is in working condition. PIR sensor has several different features like wide voltage supply ranges, automated induction, photosensitive control, low micro-power consumption, high output signal and many more. PIR (Passive Infra Red) sensor is most of the time used in security systems. Moreover, it can be used in OEM applications, automatic illuminating devices, building detection, building automation, alarm & security systems and at a lot more places in real life. The further detail about PIR Sensor Arduino Interfacing will be given later in this tutorial.

PIR Sensor Arduino Interfacing

PIR sensor stands for Passive Infra Red sensors. As it is clear from its name that PIR is an electronic device or sensor used to measure the infrared energy emitted by animals and human beings. This energy is emitted in the form of heat. When this energy is above the certain level, there is algorithm to show an an indication that the desired level has be reached. This tutorial is based on PIR interfacing with Arduino. PIR sensor is shown in the figure below along all of its pin names.
1. PIR Sensor Pins
  • PIR sensor has three pins voltage, output and ground respectively.
  • All of the pins are provided in the table shown in the figure given below.
2. PIR Sensor Pins Description
  • Each pin has different task to perform while the sensor is in working condition.
  • PIR sensor pin descriptions are listed in the table shown in the figure below.
3. PIR Working Principle
  • PIR sensor has two different slot which are sensitive to infrared light/energy.
  • When the sensor is in normal condition, both of the slots measure the same amount of infrared energy radiated by walls etc.
  • When a warm body e.g animals and human beings crosses its coverage area, they first cross PIR sensors's first slot, which produces positive differential change between two slots.
  • When an animal or human being leave from the sensing area, a corresponding negative differential change is produced.
  • By detecting these types of changes PIR sensor can detect the motion of different objects which radiates infrared energy.
  • I have tried to elaborate the PIR working principle through some visuals shown in the figure given below.
  • I have also provided the visuals about how PIR sensor generates an output signal after sensing different objects/
  • PIR sensor object sensing is given in the figure shown below.
4. PIR Sensor Schematic Diagram
  • To understand the internal structure of any electronic device, we must have a look at its schematic diagram.
  • PIR sensor schematic diagram is shown in the figure given below.
5. Apparatus Required
A list of apparatus required for PIR interfacing with Arduino is given below.
  • PIR (Passive Infra Red) Sensor
  • Arduino (Microcontroller)
  • Jumper wires
6. PIR Interfacing with Arduino Wiring Diagram
  • I have already shared a brief article on Interfacing PIR sensor with Arduino.
  • Now, this is a detailed article about the similar topic.
  • I have provided wiring diagram for PIR interfacing with Arduino.
  • You can make the similar wiring diagram and can test and verify your results as well.
  • PIR Sensor Arduino Interfacing wiring diagram is shown in the figure given below.
7. PIR Sensor Arduino Interfacing Source Code and Description
  • If you have never use Arduino software for programming then you should first go through How to Write Arduino Code.
  • I have provided the complete source code for PIR interfacing with Arduino.
  • You just need to copy and paste the entire code and upload it to your Arduino board and observe the results.
  • You can also made the same simulation on Proteus as well and can verify the results.
  • In case of Proteus simulation you must need to know about How to get Hex File from Arduino.
int LED = 13;                
int inputPin = 2;               
int PIR_STATE = LOW;             
int VALUE = 0;                   
 
void setup() {
  pinMode(LED, OUTPUT);      
 
  Serial.begin(9600);
}
 
void loop(){
  VALUE = digitalRead(inputPin); 
  if (VALUE == HIGH) {           
    digitalWrite(LED, HIGH); 
    if (PIR_STATE == LOW) {
      // we have just turned on
      Serial.println("Motion has been detected!");
      PIR_STATE = HIGH;
    }
  } else {
    digitalWrite(LED, LOW); 
    if (PIR_STATE == HIGH){
      // we have just turned of
      Serial.println("Motion has been stopped!");
      PIR_STATE = LOW;
    }
  }
}
  • I have initialized the LED pin, PIR state pin and the pin and a variable for reading sensor's data.
  • Then I have checked whether the detected value from the sensor is above or below the certain level.
  • Then I have decide to be print the certain values on Serial Monitor.
  • If it is above the certain level a message "Motion has been detected" will be displayed on the serial monitor through Serial Communication.
  • If the detected value is below the certain level then the message "Motion has been stopped" will be displayed on the serial monitor in Arduino software.
  • So, that was the brief description of the source code designed for PIR interfacing with Arduino.
  • You can download the complete wiring diagram along with the complete Arduino source code here by clicking on the button below.

8. PIR Sensor Interfacing with Arduino Actual Circuit Diagram
  • I have also provided the actual circuit diagram for PIR interfacing with Arduino.
  • Actual circuit diagram is shown in the figure given below.
9. PIR Sensor Ratings
  • To know the power, current and voltage requirements of an electronic device can be known through its ratings.
  • PIR sensor ratings are listed in the table given in the figure shown below.
10. PIR Sensor Features
  • A device can be popular on the basis of its amazing and unique features, which make it different from other devices.
  • PIR sensor some of the main features are listed in the table given in the figure shown below.
11. PIR Sensor Applications
  • PIR sensor has several different real applications.
  • Some of common applications associated with PIR sensor are provided in the table shown in the figure given below.
  • I have provided a circuit designed for security alarm system, which is its most common application.
  • The complete circuit design for security alarm system is given in the figure shown below.
  • PIR sensor's another application is making a timer circuit using PIR.
  • I have provided timer circuit using PIR sensor, shown in the figure given below.
  • Another most common application of PIR sensor is the motion detection.
  • Motion detection circuit diagram using PIR sensor is shown in the figure given below.
12. PIR Sensor Advantages
  • There are a lot of advantages associated with Passive Infrared Sensor, few of them are given below.
13. PIR Sensor Disadvantages
  • Infrared sensors also have some disadvantages but they are in a very small as compared to its disadvantage.
  • Infrared sensor disadvantage are listed in the table given in the figure shown below.
The tutorial PIR Sensor Arduino Interfacing has provided the detailed discussion about the interfacing of PIR sensor with Arduino. If you feel any problem in PIR Sensor Arduino Interfacing, you can ask me in comments anytime. I will try me level best to entertain you and to solve your problems. I will share further informative topic in my later tutorials. Till then take care and bye :)

DHT11 Arduino Interfacing

Hello everyone! I hope you all will be absolutely fine and having fun. Today, we will have a look at the DHT11 Arduino Interfacing. DHT11 is an embedded sensor, used to measure both temperature and humidity of the surroundings. It is made up of two different parts i.e. capacitive humidity sensor and a thermistor. DHT11 is a slow sensor but is quite efficient for the applications where we need to do some basic analog data exchange. There is a small chip inside this sensor which performs the function of analog to digital to analog conversion and gives the results for temperature as well as for humidity in digital form. This digital signal can be read easily through any micro-controller.

LM335 is another temperature sensor and to understand today's post more properly, you should also go through Introduction to LM335. DHT11 is a low cost sensor and is easily available in the market now a days. This property makes it more popular among the similar type of sensors. It provide precise results with the higher efficiency. It has a small size and low power consumption. It can transmit the signal up to 20 meters. It has four pins whose detail will be explained later. DHT11 has a lot of features including low cost, long term stability, fast response time, excellent quality, long distance signal transmission and many more. In real life DHT11 can be used at several different places e.g. home appliances, weather stations, consumer goods etc. the further detail about DHT11 Arduino Interfacing will be given later in this tutorial.

Where To Buy?
No.ComponentsDistributorLink To Buy
1DHT11AmazonBuy Now
2Arduino UnoAmazonBuy Now

What is DHT11 Sensor?

  • DHT11 is an electronic sensor, consists of 4 pins and is used to measure the temperature and humidity of the surroundings.
  • DHT Pinout is as follows:
    1. Pin#1: Vcc (+5V)
    2. Pin#2: Out (digital)
    3. Pin#3: NC (Not Connected)
    4. Pin#4: GND (Ground)
  • It has both a capacitive humidity sensor and a thermistor embedded in it.
  • It is a low-cost sensor but provides precise results and it gives value once every 2 seconds.
  • DHT11 measures the relative humidity of the surrounding.
  • It is used in home appliances, weather stations, medical humidity control, data loggers, HVAC and at several security places.
  • DHT11 along with its pinout is shown in the figure given below.

DHT11 Pinout

  • Before using any electronic device we must know about the functions of its all pins.
  • DHT Pinout is as follows:
    1. Pin#1: Vcc: We need to provide +5V to this pin.
    2. Pin#2: Out: Output Pin for reading DHT11 data.
    3. Pin#3: NC: It's an open pin and is not connected to anything(For future use).
    4. Pin#4: GND: Need to provide ground to this pin.
  • DHT11 pin description is provided in the below table:

DHT11 Working Principle

  • In order to measure temperature, DHT11 uses a thermistor also known as NTC (Negative Temperature Coefficient) temperature sensor.
  • A thermistor is simply a variable resistor, which changes its resistance with respect to the temperature.
  • A thermistor is made up of sintering of semiconductors in order to provide a large change in its resistance with the small changes in temperature.
  • NTC means the resistance decrease with the increase in temperature.
  • I have provided a visual display of the relation between temperature and resistance for the DHT11 sensor, shown in the below figure:
  • For humidity sensing, DHT11 uses a capacitive humidity sensor.
  • The humidity part consists of two electrodes having moisture-holding substrates in between them.
  • As the humidity level changes, the resistance between both of the electrodes or conductivity also changes correspondingly.
  • This change in conductivity or resistance is estimated and processed by an internal IC.
  • I have also provided the visual description of humidity sensing using DHT11 sensor, as given in the figure shown below.

DHT11 Temperature Sensing Characteristics

  • The temperature sensing characteristics of the DHT11 sensor are listed in the below table:

DHT11 Humidity Sensing Characteristics

  • The humidity sensing characteristics of the DHT11 sensor are listed in the below table:
Note: I have also made some LabVIEW simulations for temperature measuring and conversion, their links are shared below.

Components Required for DHT11 Arduino Interfacing

As its a simple project, so we are going to need few components, listed below:

  • DHT11 Sensor (Temperature and humidity sensor)
  • Arduino UNO (Microcontroller Board)
  • Jumper wires (Male to Female)

DHT11 Arduino Interfacing

  • The connections between Arduino and DHT11 pins are shown in the figure given below.
  • The circuit diagram for DHT11 Arduino Interfacing is given in the below figure:

Arduino Code

  • If you have not written Arduino code before, you must have a look at How to Write Arduino Code.
  • You just need to copy and paste the source code given below into your Arduino software.
  • After that just upload the code into your Arduino board to test the results.
#include<dht.h>// DHT11 humidity sensor library
dht DHT; //Creating sensor object
#define DHT11_PIN 2 // Sensor is connected to Arduino pin 2
void setup()
{
  Serial.begin(9600); //setting baud rate
  Serial.println("   =====================================================");
  Serial.println("   ||   Welcome to Temperarue and Humidity Detector   ||");
  Serial.println("   =====================================================");
  Serial.println("");
  }
void loop()//method used to run the code repeatedly
{
  int chk = DHT.read11(DHT11_PIN); //Reading data from sensor
  Serial.print(" Humidity = ");//prints on the serial monitor
  Serial.print(DHT.humidity);// prints obtained humidity on serial port
  Serial.print(" g/m^3");
  Serial.print("    \tTemperature = ");//prints on the serial monitor
  Serial.print(DHT.temperature, 1);//prints obtained temperature on serial port
  Serial.println(" degrees");
  
  delay(2000);//adding the delay of 2 seconds
  }
  • First of all, I have defined the library for the DHT11 sensor.
  • After that, I have read the humidity and temperature values from DHT11 sensor in digital form.
  • Then I have printed the digital values of both humidity and temperature on the Arduino Serial Monitor.
  • We can print the values obtained from the sensor on the serial monitor using Serial Communication.
  • So that was the brief description about DHT11 interfacing with Arduino.
  • You can download DHT11 library, wiring diagram and complete Arduino source code here by clicking on the button below.

Temperature & Humidity Results on Serial Monitor

  • I have printed the digital values obtained from DHT11 sensors.
  • Both temperature and humidity digital values are given in the figure shown below.

DHT11 Sensor Interfacing with Arduino Circuit Diagram

  • I have provided an actual circuit diagram for DHT11 sensor interfacing with Arduino.
  • Actual circuit diagram is given in the figure shown below.

DHT11 Features

  • The features are such parameters depending upon which a device can flop as well as features that can make a device more popular due to their uniqueness.
  • DHT11's major features are provided in the table given in the figure shown below.

DHT11 Applications

  • Most of the devices are usually known by their range of applications.
  • DHT11 sensor applications are given in the table shown in the figure below.

That is all from today's tutorial. If you have any problem you can ask me in comments any time you want. Till my next tutorial bye :)

Flame Sensor Arduino Interfacing

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide a detailed discussion on Flame Sensor Arduino Interfacing. Flame sensor is an electronic device which is capable of sensing/detection of fire or a high temperature zone. It gives an indication through an LED attached at its top, just after sensing the fire. These type of sensors are usually used for short ranges. They are able to detect the fire up to 3 feet. Flame sensors is the most common device available in the market these days due to its good results and cost efficiency. You should also have a look at Flame Sensor Library for Proteus. Flame sensors are available in the market in two types one having three pins and the other having four pins respectively. Both of the sensors can be easily interfaced to any micro-controller. I am using four pin flame sensor in this tutorial. You will see the complete wiring diagram for interfacing flame sensor with Arduino and the complete Arduino source code and its description as well. Flame sensor can detect fire or any other light sources whose wavelength is in the range of 760nm to 1100nm. This device consists of and IR sensor, an LED for indication, operational amplifier circuit and a potentio-meter. The device is sensitive to flame so when it detects the flame it turns on its LED to show an indication. The sensitivity of the flame sensor can be adjusted according to the requirements. It can be used at different places e.g. in offices, home, institutions, industrial applications.

Flame Sensor Arduino Interfacing

Flame Sensor is an electronic device which is used to sense the fire or any other light having wavelength between 700nm to 1100nm. It consists of either three or four pins both of them are compatible with all micro-controllers. It is sensitive to flame and gives the indication for the presence of the flame. It can be sued in homes, offices, industrial applications. Flame sensor along with its pi names are shown in the figure below.
1. Flame Sensor Pins
  • Flame sensor has four pins with different individual function.
  • Flame sensor pins are given in the figure shown below.
2. Flame Sensor Pins Description
  • Each pin has different tasks to perform.
  • Flame sensor pin descriptions are listed in the table shown in the figure given below.
3. Flame Sensor Working Principle
  • Flame sensor is very sensitive to flame and other lights.
  • Its analog output provides real time output voltage on the thermal resistance.
  • When the temperatures reaches at the certain threshold the output high and low signal threshold adjustable via potentio-meter , Its the task of digital output.
4. Flame Sensor Circuit Diagram
  • Flame sensor diagram is shown in the figure given below.
5. Apparatus Required for Flame Sensor Interfacing with Arduino
  • Arduino UNO (Micro-controller)
  • Flame Sensor
  • Jumper wires
  • Wero board
  • Light or another flame sensor
6. Flame Sensor & Arduino Pin Connections
  • Connections between Arduino and flame sensor pins are given in the table shown in the figure below.
7. Flame Sensor Arduino Interfacing - Wiring Diagram
  • Before hardware interfacing, you can also test your result on Proteus.
  • For Proteus simulation, you need to know about How to get Hex File from Arduino.
  • I have shared a brief tutorial on Interfacing of Flame Sensor with Arduino in my previous tutorial.
  • I have given a completely labeled wiring diagram for Flame Sensor Arduino Interfacing.
  • You can test & verify your results by making the same wiring diagram.
  • Wiring diagram for Flame Sensor Arduino Interfacing is shown in the figure given below.
8. Flame Sensor Interfacing with Arduino Source Code & Description
  • If you haven't written Arduino code ever, you must go through How to Write Arduino Code.
  • You just need to copy & to paste the complete source code given below in your Arduino software.
  • And just upload the code onto your Arduino board in order to verify the results.
int led_pin = 13 ;// initializing the pin 13 as the led pin

int flame_sensor_pin = 2 ;// initializing pin 7 as the sensor output pin
int flame_pin = HIGH ; // state of sensor

void setup ( )  {

  pinMode ( led_pin , OUTPUT ); // declaring led pin as output pin
  pinMode ( flame_sensor_pin , INPUT ); // declaring sensor pin as input pin for Arduino
  Serial.begin ( 9600 );// setting baud rate at 9600
}

void loop ( ) {
   flame_pin = digitalRead ( flame_sensor_pin ) ;  // reading from the sensor
  if (flame_pin == LOW )  // applying condition
  {
    Serial.println ( " FLAME , FLAME , FLAME " ) ;
    digitalWrite ( led_pin  , HIGH ) ;// if state is high, then turn high the led
  }
  
  else
  {
    Serial.println ( " no flame " ) ;
    digitalWrite ( led_pin , LOW ) ;  // otherwise turn it low
  } 
}
  • First of all I have defined the pins for led and the flame sensor.
  • The I have printed the digital information on the Serial Monitor obtained from the flame sensor.
  • The messages are displayed on the serial monitor via Serial Communication.
9. Flame Sensor Interfacing with Arduino
  • The actual circuit diagram for flame sensor interfacing with Arduino.
10. Flame Sensor Applications
  • Flame sensor has a lot of different applications.
  • Some of them are given below.
The tutorial Flame Sensor Interfacing with Arduino has explained the entire necessary detail about the flame sensor interfacing with Arduino. If you have any kind of problem you can ask me in comments anytime. I will try my level best to solve your issues. I hope you have enjoyed this tutorial. I will share other informative topics in my upcoming tutorials. Till my next tutorial take care and bye :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir