Hi learner! I hope you are doing great. Today, I am sharing version 3.0 of the PIR sensor library for Proteus. We have already shared V1.0 and V2.0 of the PIR Sensor Library. PIR Sensor V1.0 Library for Proteus adds a digital PIR Sensor in Proteus, while the PIR Sensor V2.0 Library adds an analog PIR Sensor to simulate. These libraries were loved by the users and this motivated us to work more on it.
PIR V3.0 is analog in nature, has an error-free structure and the Pinout structure is better organized. Moreover, the design is improved a little bit and we have omitted the website link from the sensor to make it look professional.
Same as the previous version, this PIR has four pins and the details of each of them will be discussed in detail later. Therefore, don’t worry if you have no experience with the sensors in Proteus. Let's discuss the basic introduction of the PIR sensor:
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Battery 12V | Amazon | Buy Now | |
2 | Resistor | Amazon | Buy Now | |
3 | LCD 20x4 | Amazon | Buy Now | |
4 | PIR Sensor | Amazon | Buy Now | |
5 | Arduino Uno | Amazon | Buy Now |
Here are a few of the Embedded Projects in which we have used PIR sensor, you should have a look:
Generally, the real-time PIR sensor has three pins and these are used for different purposes. It is important to connect all of these correctly to get the output. Here is the description of each pin:
If these pins are set properly, the circuit works fine. The sensor we have designed has a fourth terminal called TestPin. Proteus is the simulation software therefore, it is not possible to provide the motion. TestPin is used to provide the motion by the user.
We know that Proteus does not have a built-in PIR sensor therefore, we have created this library so that you may use it in the circuits. For this, you have to download and install the PIR Sensor library in your proteus software. Here is the download link for the installation, simply download the zip file.
PIR Sensor Library for Proteus V3.0
The zip file has another folder named “Proteus simulations” where you can find the resources of projects containing simple working of PIR Sensor and PIR Sensor interfaced with Arduino UNO and LCD.
Now, open your Proteus software and if was opened already, restart it to index the PIR sensor library with it.
Here, you can see it has the minimum text on it and the size is smaller than the previous version so that you may fix it in your large and complex projects without any problem. Now, I am deleting two sensors and will work only on the remaining two.
This sensor will not work unless you add the HEX file to it. For this, follow the steps given:
Now, we will design two circuits of PIR sensor V3.0. The first will be simply made with the basic components and the other one will have the Arduino UNO interfaced with the LCD so that we may get the more user-friendly results. Let's hover over your Proteus workspace to make the simple PIR circuit.
The following Components are required for setting the PIR sensor.
Go to the “Pick library” button type the names of the components one by one and select them.
The real-time PIR sensor does not require the LC circuit but in Proteus, the peak-to-peak values are generated which needs to be converted into RMS values and that's why we used this LC filter.
Now, hit the play button to check the values of the PIR sensor.
Now, if you want to make your project more user-friendly, an LCD is the best option. To link these, I have used the Arduino UNO and through the code, the values of the PIR reading are shown on the LCD. I have interfaced the TEP LCD 20X4 with the Arduino and simply connected the output of PIR with the analog pin of Arduino. The circuit now looks like the following image:
Once your simulation is ready, you have to paste the code into Arduino.exe.Open your software and paste the given code there.
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int SensorPin = A0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("www.TheEngineering");
lcd.setCursor(4,1);
lcd.print("Projects.com");
lcd.setCursor(0,2);
lcd.print("Analog Value: ");
lcd.setCursor(0,3);
lcd.print("Voltage: ");
}
void loop() {
int SensorValue = analogRead(SensorPin);
float SensorVolts = analogRead(SensorPin)*0.0048828125;
lcd.setCursor(14, 2);
lcd.print(SensorValue);
lcd.setCursor(9, 3);
lcd.print(SensorVolts);
lcd.print(" V");
delay(1000);
// sensorValue = analogRead(sensorPin);
// lcd.setCursor(4,2);
// lcd.print(sensorValue);
// delay(1000);
}
The same code is also given in the zip file you have downloaded.
When the code is run on the Arduino.exe, it provides the HEX file in the compilation details. You have to copy the address of the HEX file and insert it into the Arduino in Proteus. For this, follow these steps:
Go to the Proteus and double-click on the Arduino to open the properties panel. Now paste the path of the HEX file here. The circuit is now ready to work. If you are stuck at this step, you should have a look at How to get Hex File from Arduino.
Now it's time to run the simulation. So hit the Play button and you will see that the output is shown on the screen.
The analog values can be changed through the potentiometer of the testPin. The analog values of the motion sensor along with the voltages are shown on the LCD. I hope your circuit worked the same as mine. If you are facing any type of issue, you can contact us.