This Arduino Entry Exit Monitoring Circuit counts people while entering and leaving place, it uses Arduino UNO R4 WiFi board.
Two IR sensors detect people and two servo motors control entry and exit gates and then sends crowd count to Arduino IoT Cloud.
Hence, this help us know how many people are inside anytime.
Arduino Code:
#include <Servo.h>
#include "thingProperties.h"
Servo entryServo;
Servo exitServo;
int entrySensor = 2;
int exitSensor = 3;
int count = 0;
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
pinMode(entrySensor, INPUT);
pinMode(exitSensor, INPUT);
entryServo.attach(9);
exitServo.attach(10);
}
void loop() {
ArduinoCloud.update();
if (digitalRead(entrySensor) == HIGH) {
entryServo.write(90);
delay(2000);
entryServo.write(0);
count++;
crowdCount = count;
delay(1000);
}
if (digitalRead(exitSensor) == HIGH) {
exitServo.write(90);
delay(2000);
exitServo.write(0);
count--;
if (count < 0) count = 0;
crowdCount = count;
delay(1000);
}
}
Code Explanation:
- Servo.h library used to control motors.
- thingProperties.h is Arduino IoT Cloud library.
- entrySensor and exitSensor are IR sensor pins.
- entryServo and exitServo are servo objects.
- If entry sensor detects person then entry servo opens and count increases.
- If exit sensor detects person then exit servo opens and count decreases.
- crowdCount variable sends value to cloud.
Circuit Working:

Parts List:
Person comes near Entry IR sensor and sensor gives HIGH signal and then Arduino moves entry servo and gate opens.
After few seconds servo goes back and gate closes and then Arduino adds people count.
When person comes near exit IR sensor and sensor gives HIGH signal, then Arduino moves exit servo and gate opens.
After few seconds servo goes back and gate closes and then Arduino reduces people count.
Now Arduino sends count to IoT Cloud and we see real-time crowd on dashboard.
Note:
- If needed use two mini breadboards as it depends on how we organize the circuit.
- MG90S servos take more current so keep them on separate breadboard with proper power.
Formulas:
The following formula applies to the Arduino-Based Entry Exit Monitoring Circuit:
People Count = Entry Count – Exit Count
If Entry sensor detects signal then Entry Count = Entry Count + 1
If Exit sensor detects signal then Exit Count = Exit Count + 1
Power Supply = 2 x 3.7V = 7.4V
Servo need 5V and Arduino board regulates from VIN.
How to Build:
To build a Arduino Based Entry Exit Monitoring Circuit follow the below steps for connections:
- First, gather all the parts as shown in circuit diagram:
IR sensor at Entry:
- VCC go to 5V of Arduino
- GND connect to GND of Arduino
- OUT go to digital pin 2
IR sensor at Exit:
- VCC connect to 5V of Arduino
- GND go to GND of Arduino
- OUT go to digital pin 3
Entry Servo Motor:
- Signal(OUT) connects to digital pin 9
- VCC go to 5V of Arduino
- GND go to GND of Arduino
Exit Servo Motor:
- Signal(OUT) go to digital pin 10
- VCC go to 5V of Arduino
- GND connect to GND of Arduino
Battery connection:
- Two 3.7V batteries connected in series to VIN pin of Arduino UNO R4.
- Battery negative to GND pin of Arduino.
Conclusion:
Overall, this Arduino Entry Exit Monitoring Circuit counts people in room or hall, it uses simple IR sensors and servo gates.
Furthermore, the circuit displays crowd data on the IoT Cloud, it offers an easy and low-cost solution, and schools, offices, malls, libraries and event organizers can use it to monitor crowd levels.