PIR Sensor Library for Proteus

Update: Here are the latest versions of this library: PIR Sensor Library for Proteus V3.0 and PIR Sensor Library for Proteus V2.0.


Hello friends, hope you are doing well.  Today, I will share a new PIR Sensor Library for Proteus. PIR Sensor module is not available in Proteus so we can't use it in our simulations. But today, I will share a new PIR Sensor Library for Proteus which can easily simulate PIR Sensor in Proteus software. We are quite happy that we are helping engineers by sharing these new Proteus Libraries.

We all know about PIR Sensor but if you don't know then first read Interfacing of PIR Sensor with Arduino.

As a quick review, a PIR sensor is used to detect motion in the environment and is commonly known as a motion sensor. It's quite helpful in security projects where you need to detect motion. For example in some bank vault where there's no possibility of motion, you can place this sensor and can check if there's any movement. It is also used in home automation i.e. if there's no movement in some room, turn off its appliances. So, in short, the PIR sensor has numerous uses and is used quite a lot in engineering projects.

First of all, I will show you today, How to download this PIR Sensor Library for Proteus and then we will also design a small simulation in Proteus in which I will interface this PIR Sensor with Arduino UNO. You can interface it with any microcontroller i.e. PIC Microcontroller or 8051 Microcontroller. But today, I will interface it with an Arduino microcontroller. As homework, you guys interface it with a PIC Microcontroller or 8051 Microcontroller and share it in comments, it may help others. So, let's get started with the PIR Sensor Library for Proteus:

PIR Sensor Library for Proteus

  • First of all, click on the below button to download the PIR Sensor Library for Proteus:
PIR Sensor Library for Proteus
  • Once you download it, you will get three files in it, named:
    • PIRSensorTEP.LIB
    • PIRSensorTEP.IDX
    • PIRSensorTEP.HEX
  • Place all these three files in the library folder of your Proteus software.
Note:
  • Now open your Proteus software and search for PIR Sensor, you will get a total of four models in it.
  • Place these models in your Proteus workspace and it will look something as shown in the below figure:
  • I have added four models of this PIR Sensor in Proteus Library and you can use any of them.
  • As working is concerned they are all the same but they differ in color.
  • The first color is our normal color, which I always use for my Proteus Libraries while the second one is green, the third is pinkish and the fourth one is blue.
  • This PIR Sensor has a total of four Pins, among which one is Vcc so you need to give +5V at this pin, then there's GND which you need to ground.
  • The OUT pin is our main pin through which we will be getting our output like whether it detects the motion or not.
  • Now, obviously, we can't detect real motion in Proteus Simulation that's why I have placed a TestPin which will be working as a simulation Pin.
  • If TestPin is HIGH, it means the motion is detected and if it's LOW then it means the motion is not detected.
  • Now we have our module in Proteus so one last thing we need to do is add its functionality.
  • So, in order to do so, double-click this PIR sensor and in the Program File section give a path to the file PIRSensorTEP.HEX, which you have placed in the library folder of your Proteus software as shown in the below figure:
  • Now click OK and your PIR Sensor is ready to be used in the Proteus Simulation.
  • So, now let's design a simple example for this PIR Sensor which will help you in understanding this sensor.

PIR Sensor simulation in Proteus

  • Design a simple circuit in Proteus software as shown in the below figure:
  • Now you can see in the above figure that I have placed a PIR Sensor along with Arduino UNO and a Virtual terminal.
  • PIR Sensor is connected to Pin # 2 of Arduino UNO.
  • Now upload the below code in Arduino software and get the hex file. You should read How to get Hex File from Arduino, if you don't know already.
    #define pirPin 2

    int calibrationTime = 30;
    long unsigned int lowIn;
    long unsigned int pause = 5000;
    boolean lockLow = true;
    boolean takeLowTime;
    int PIRValue = 0;

    void setup()
    {
    Serial.begin(9600);
    pinMode(pirPin, INPUT);
    }

    void loop()
    {
    PIRSensor();
    }

   void PIRSensor()
{
     if(digitalRead(pirPin) == HIGH)
     {       
         if(lockLow)
         {    
             PIRValue = 1;
             lockLow = false;
             Serial.println("Motion detected.");
             
             
             delay(50);
         }         
         takeLowTime = true;
       }

       if(digitalRead(pirPin) == LOW)
       {       
           
           if(takeLowTime){lowIn = millis();takeLowTime = false;}
           if(!lockLow && millis() - lowIn > pause)
           {
               PIRValue = 0; 
               lockLow = true;                        
               Serial.println("Motion ended.");
               
               delay(50);
           }
       }
}
  • Now run your simulation, and click the logic button to 1, which will indicate that motion is detected and you will get something as shown in the below figure:
  • Now let's make the logic state to 0, which will indicate that no motion detected, as shown in below figure:
  • So that's how our PIR Sensor is gonna work in Proteus. I hope you are going to like this PIR Sensor Library for Proteus.
  • You can download the simulation by clicking on the below button:
Download PIR Proteus Simulation
  • Here's a YouTube video where I have explained this PIR Sensor Library for Proteus in more detail, so check it out:

That's all for today, hope you have enjoyed it and gonna use it in your projects. If you get into any trouble, ask in the comments and I will try to resolve them as soon as possible. Take care !!! :)

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