🏆
International Research Platform
Serving Researchers Since 2012

Adaptive Traffic Signal Control System using Density-Based Prioritization Algorithm on ESP 32 Platform

DOI : https://doi.org/10.5281/zenodo.20205923
Download Full-Text PDF Cite this Publication

Text Only Version

Adaptive Traffic Signal Control System using Density-Based Prioritization Algorithm on ESP 32 Platform

Kalpana Pardeshi, Pranali Bable, Mrunal Bhalerao, Manushree Desai

Department of Engineering, Instrumentation and Control Engineering, Vishwakarma Institute of Technology, Pune

Abstract – However, the dramatic increase of urban population and the number of vehicles produced each year has rendered fixed-time traffic light systems obsolete. This is because fixed time traffic light systems operate according to a timing cycle with no consideration for traffic conditions, leading to traffic congestion, fuel waste and environmental pollution. This paper proposes a Density Based Traffic Control system developed on an ESP 32 microcontroller employing Passive Infrared (PIR) sensors for traffic density measurement. Unlike static signal systems, this model makes adjustments to signal timings through real- time analysis of traffic densities. The model also incorporates a scoring mechanism to control traffic at a four-way intersection. Each lane is equipped with two PIR sensors (Near and Far) which can be used to determine the number of vehicles queued on each lane. The data is used to calculate density scores for each lane. If two or more lanes have the same density, the system uses a predefined order (North-East-South-West) for their pri- oritization. Experimental evaluations about the prototype show that the proposed solution reduces waiting time and improves throughput compared with timer-based schemes. The solution is also cost-effective and applicable for large-scale usage in traffic management systems embedded in smart cities.

KeywordsIntelligent Transportation Systems (ITS), ESP 32, PIR Sensors, Traffic Density, Adaptive Control, Smart City

  1. INTRODUCTION

    Over the last few decades, rapid industrial growth and expansion of cities have caused serious challenges for trans-portation infrastructure worldwide. One of the problems that have come with this is traffic congestion becoming a major woe of metropolitan regions causing reduction in mobility, loss of productivity, and urban sustainability in general to suffer. The only transportation systems that would be able to support economy are those that enable the movement of goods, services and workforce to different regions without any hindrances.

    Nevertheless, the fast increase in the ownership of private vehicles has not been at all balanced by the expansion of road infrastructure on an equal scale. In most cities, due to the physical and spatial constraints, the development of road is restricted. As a result, it is very common that intersections are major bottlenecks that hinder general traffic flow because they are the points that limit the capacity in a road network the most. Additionally, the effects of inefficient intersection control go beyond simple delays. At the economic level, the long-lasting

    congestion reduces the available time for productive work significantly because the transportation of goods is delayed and the efficiency of the workforce is also decreased. Therefore, the optimization of the traffic signal system is far more than just an issue of operational efficiency; it is a very important part [13].

    1. Limitations of Conventional Systems

      Despite major breakthroughs in various branches of engi-neering, in many developing countries traffic control systems are still largely based on fixed-time signals at traffic lights. These systems work on an open-loop control principle, mean-ing they run their signal programs following preset timing patterns without taking into account environmental changes in real time. Usually, green and red durations are determined using old traffic data or by manual counts done at one time only.

      The chief drawback of fixed-time control is that it cannot cope with the ever-changing and random nature of city traffic. Traffic patterns seldom run smooth and are often disturbed by situations such as rush hour accidents bad weather, or events. Since fixed-time systems are not capable of handling these variations, their effectiveness drops when conditions are less than ideal.

      Generally, two main types of inefficiencies can be attributed to this limitation:

      • Empty Lane Inefficiency: It is possible for vehicles to be held up at a red light simply because the intersecting lane that has been given the green phase is either empty or has very few vehicles. In this case, the time during which the signal is green but no vehicles are passing through is referred to as dead time, and it leads to inefficient use of intersection capacity.

      • Spillback Congestion: During heavy traffic some lane with a very long queue may get the same green time as a lane which is very lightly loaded. If the discharge time is not long enough, the queue buildup may extend upstream, potentially blocking other nearby intersections and causing the network performance to deteriorate even further.

    2. The Need For Intelligent Transportation Systems (ITS)

      Conventional signal control has not met all expectations; thats why transportation engineering has been increasingly moving to the use of Intelligent Transportation Systems (ITS). ITS main goal is to mix sensing, communication, and com-puter technologies within the current transport infrastructure to allow for adaptive and data-driven traffic management.

      While open-loop systems are quite limited, ITS frameworks are based on a closed-loop control principle. Real-time traffic data collected through sensors is continuously processed by a controller to dynamically regulate signal timings. To achieve this, a variety of advanced traffic detection technologies have been developed. For example, inductive loop detectors placed under the road surface identify the presence of a vehicle with high accuracy, while camera-based systems use computer vi-sion algorithms to determine traffic density and flow patterns. Nonetheless, these methods are a source of major difficulties in practice. Inductive loops demand the physical breaking up of the road for their installation and, due to wear and environmental damage, they carry high maintenance costs. Vision-based systems rely on high-performance processing hardware to analyze live video streams and generally show degraded performance in case of poor lighting, heavy rain, or fog. The most straightforward way to solve this problem is to come up with an alternative that is cheap, reliable, and easy to deploy. This can be done by integrating the new system into existing intersections without requiring major structural changes. We are looking for a solution that not only fits the current infrastructure but also offers great flexibility with very little time and money spent on both installation and operations.

    3. Project Motivation and Proposed Solution

      In this paper, the authors outline how a density-driven intelligent traffic management system was designed and built with the ESP 32 microcontroller and Passive Infrared (PIR) sensors [3]. The main reason for doing this research was to find a way to deal with the inflexibility of fixed-time signal systems through a responsive mechanism that can adjust according to the real-time traffic situation [7].

      In contrast to traditional methods that set signal time regard-less of traffic demand, this system first checks the presence of traffic and then decides which lane to give the green light to. To quantify traffic congestion at a four-way intersection, the paper describes a lane scoing method. There are two PIR sensor in each lane for sensing at different distances. The Near sensor is the one that is placed nearest to the stop line and the Far sensor is the one that is positioned farther upstream along the approach road.

      The Near sensor identifies the presence of vehicles waiting at the intersection which means that there is an active demand for signal clearance. The Far sensor is used to estimate the buildup of queue by detecting the vehicles at a farther distance which is a sign of heavy traffic pressure. The controller by combining these signals, calculates the instantaneous urgency score for each of the four directions (North, East, South, and West). According to the computed scores, the microcontroller

      allocates the green phase to the lane with the greatest traffic demand. In this way, the intersection becomes an adaptive con-trol unit rather than a fixed time-regulated system, which really enhances signal responsiveness and traffic flow efficiency.

    4. Research Objectives

      The main objectives of this research are outlined as follows:

      • Development of a Functional Prototype: Using the ESP 32 microcontroller, LED-based signal indicators, and PIR motion sensors for vehicle detection, develop and build a four-way traffic intersection model that works.

      • Implementation of Adaptive Priority Logic: Create and program a density-based control algorithm that assigns signal priority dynamically according to the actual traffic conditioned. The algorithm should also include a struc-tured handling of tie cases represent situations in which two or more lanes have the same traffic demand.

      • Enhancement of Operational Safety: Develop control logic to include safety measures such as the all-red interval during phase switching to reduce the chances of conflicting vehicle movements and intersection collisions.

      • Performance Evaluation: Measure how the sensor-based system performs compared to traditional fixed-time con-trol models, especially in terms of decreasing the average waiting time and unnecessary vehicle idling.

    These goals will allow the study to present a scalable, energy-saving, and economically viable solution that aligns with the implementation of smart city infrastructures.

  2. LITERATURE REVIEW

    Traffic light regulation has been a major focus of research for a long time. Different methods of sensing and adaptively controlling traffic lights have been developed to make road junctions more efficient. This paper gives a brief overview of the main methods and discusses the shortcomings of the existing traffic light systems that led to the here-presented system design [13].

    1. Image Processing and Computer Vision

      Camera-based systems rely on video cameras and image processing techniques to assess the volume of traffic and identify different types of vehicles [16]. Garg et al. [1] designed a traffic light controller armed with a camera that implements edge detection methodology to control traffic flow. While such systems give the availability of almost minute traffic information, they will be computer intensive and need hardware capable of high performance. Besides, the methods precision will lessen in poor light or bad weather conditions.

    2. Inductive Loop Technologies

      Inductive loop detectors, which have been a traditional choice in the countries with the most advanced technologies mainly through the whole world at large [2], work by sensing variations in the magnetic inductance that are brought about by the presence of metal. Even though these setups are trustworthy, one cannot deny that their implementation by

      way of being embedded in the ground during both initial installation and maintenance phases lead to the necessity for road excavation thus rendering them expensive and creating a disturbance.

    3. Infrared and Ultrasonic Sensors

      Vehicle identification using systems around the principles of line-of-sight through infrared, have been the subject of significant research. Nevertheless, these systems are prone to errors and may be completely blocked due to physical barriers. Although Ultrasonic sensors have been considered, their coverage is limited and reflection quality is highly variable depending on circumstances.

    4. Microcontroller-Based Control Logic

      Prior work demonstrates that low-cost microcontrollers can be used for the implementation of adaptive signal control [4], [8]. However, a large fraction of such systems is nearly exclusively aimed at the prolonging of the green light when detecting vehicle presence only. This paper intends to further develop this idea in a way that signal priority is rearranged on a real time basis according to the traffic density of each lane [7], [15].

    5. Selection of PIR Sensors

    The outcome of the assessment is that Passive Infrared (PIR) sensors have been chosen because they can be installed without breaking the pavement, are very efficient in power, and also are quite simple to interface with microcontrollers. In addition to that, due to their minimal functionality and cheap price, they are perfect candidates for the design of large scale intelligent road traffic systems.

  3. METHODOLOGY/EXPERIMENTAL

    This section describes the hardware specifications, circuit configuration, and algorithmic logic governing the intersection control system.

    1. System Architecture

      The system has a central control unit with distributed sensors and signal indicators connected.

      • Central Processing Unit: ESP32 (WiFi enabled micro-controller)

      • Input Layer: 8 × HC-SR501 PIR motion sensors

        can be directly connected to ESP32 [11] without any change of level (if sensor output is 3.3V tolerant).

        Fig. 1.System Architecture

        2) Passive Infrared (PIR) Sensors: Motion is detected by the HC-SR501 PIR sensors when they notice changes in the infrared radiation [6]. Inside every sensor, there are two potentiometers that can be adjusted individually: one controls the sensitivity or the detection range, and the other controls the time duration of the output signal. Here, we set the time delay to the lowest possible level in order for the ESP 32 to poll very quickly while the sensitivity is turned to a level that can capture the full width of the model lane effectively.

        Deployment Strategy: Two sensors are deployed in each lane. Near sensor is placed right at the stop line of the intersection, whereas the Far sensor is located at a scaled distance upstream. The dual-zone setup allows the system to differentiate between a single vehicle (Score 1) and multiple queued vehicles (Score 2).

        C. Algorithm and Software Logic

        The software is written in C++ with ESP-IDF. The main logic runs a loop() function repeatedly that goes through all the given stages:

        Phase 1: Lane Scoring (Data Acquisition)

        The system continuously reads the digital state of all eight

        • Output Layer: 8 × LEDs (representing red and green signals for four lanes)

        sensors.

        ScoreLane =

        (StateSensor) (1)

    2. Hardware Description

    1. Microcontroller (ESP 32): The ESP32 microcontroller is chosen because it has a powerful processor, built-in WiFi and Bluetooth, and a lot of GPIO pins. It works at 3.3V logic levels, which makes it low power but also means that it needs to be interfaced with other components properly. ESP32 has over 30 GPIOs that can be used to connect sensors and actuators. Compared with Arduino UNO [5], its dual-core processor is capabe of faster data processing. The planned system: Since PIR sensors work on 3.3V logic level, they

      Every sensor produces a Boolean value (0 or 1). Hence the score of a lane at the minimum can be 0 while the maximum may be 2 (if both Near and Far sensors are active).

      • North Score = Nnear + Nfar

      • East Score = Enear + Efar

      • (Repeated similarly for South and West)

    Phase 2: Decision Matrix (Comparison)

    The algorithm determines the maximum score among the four lanes:

    Smax = MAX(SN , SE, SS, SW ) (2)

    If Smax > 0, the system assigns the green signal to the lane with the highest score.

    Phase 3: Conflict Resolution (Tie-Breaking)

    When two or more lanes have the same highest score, it is not allowed to give green signal to all at the same time. Therefore, a fixed priority order is used:

    North= > East= > South= > West

    For instance, if both North and South get a score of 2, North is the one that is given the green light first. Once the lane in North clears (i. e. sensor outputs become 0), the South lane can be considered in the next evaluation cycle.

    Phase 4: Idle Cycle

    If Smax = 0, meaning there is no detected traffic in any lane, then the system switches into round-robin mode as a way to prevent the system from being inactive. The signal will change in the following order:

    North East South West

    Each lane gets a short green time. This allows even those

    vehicles which have not been detected by sensors (for instance, small or low-profile objects) to be regularly served.

    Phase 5: Safety Switching (All-Red State)

    As a safety precaution, the system does not switch directly from one green light that conflicts with another to the other green light. To be on the safe side, there is a transition through the all-red state:

    1. Turn OFF the green light that is ON at present.

    2. Turn ON all red lights.

    3. Take a break for the time defined (ALLREDTIME: 500 ms – 2000 ms).

    4. Turn ON the green light that is next.

  4. RESULTS AND DISCUSSION

    The prototype was made on two breadboards first to create a layout exactly like a four-way intersection (chowk). Lots of hardware stability testing was done as well as checking if the control logic that was implemented was correct and working.

    1. Functional Validation

      The system was evaluated under three representative traffic conditions:

      Case 1: Asymmetrical Traffic (High Load on One Lane)

      • Setup: Both sensors on the North lane were continuously moved, while the other lanes were completely inactive.

      • Observation: On this basis, the system kept the green signal for the North lane. On the serial monitor the readings were: N:2 E:0 S:0 W:0

      • Inference: The controller decided to give priority to the lane where the traffic density was the highest, thus it removed the unnecessary waiting time of the active traffic.

        Case 2: Competitive Traffic (Tie Condition)

      • Setup: The sensors of North and East lanes were acti-vated at the same time.

      • Observation: In accordance with the pre-defined priority levels, the northern lane was given a green light first. Following the GREENTIME period, the system checked

        the traffic situation again. As the traffic from the North stopped, the green signal was promptly given to the East lane.

      • Inference: The mechanism that resolved the tie worked properly, thereby guaranteeing the system to behave in a determined and predictable manner under conditions where the demand is equal.

        Case 3: Intermittent Traffic

      • Setup: Activating the sensors at random times was a way to mimic the changes in traffic flow.

      • Observation: The software gave different outputs accord-ing to different inputs. The complete-all-red transition times were evident at every signal switch, eliminating the possibility of overlapping green signals.

    2. Performance Comparison

      A team compared the theoretical performance of the new adaptive control system against a traditional fixed-time signal system that cycles every 120 seconds.

      TABLE I Performance Comparison

      Parameter

      Fixed-Time System

      Proposed Adaptive System

      Cycle Type

      Static / Pre-programmed

      Dynamic / Sensor-driven

      Avg. Wait (Empty Lane)

      High (Must wait for cycle)

      Near Zero (Immediate switch)

      Throughput

      Constant

      Variable (Optimized for demand)

      Dead Time

      High (Green lights for empty roads)

      Minimal

      Complexity

      Low

      Moderate

    3. Cost and Power Analysis

    It is worth mentioning that the prototype was assembled with less than $20 USD (approx. 1500 INR). The energy consumption of ESP32 (80-240 mA depending on WiFi usage) combined with 8 PIR sensors (approx. 60uA each) plus LEDs is almost a drop in the ocean when compared to

    the running cost of industrial traffic lights. This makes it clear that the solution can economically support the deployment on a large scale in the developing cities where the budget normally limits)

  5. FUTURE SCOPE

    Though aspects of the current prototype pertain to core con-trol logic, it still arouses interest about its practical potential and scalability:

    • IoT and Cloud Connectivity: Future versions of the system might consider exploiting the built-in WiFi of ESP32 to directly send real-time traffic data to cloud platforms, thus not requiring additional communication modules at all. For example, traffic scores in real-time can be sent to a centralized cloud server only [12]. The traffic authorities will then be able to characterize various congestion patterns, prepare heat maps, and from time to time, shortcut the manual visit at the intersection by making changes in operational parameters (for example, the diverting green periods during peak times).

    • Emergency Vehicle Preemption: Currently, the system does not recognize an emergency vehicle. It is expected

      that later on, the systems will take in the use of acoustic sensors or RF-based receivers that can detect the siren frequencies (400-600 Hz) stated. On receiving the mes-sage, the controller negates the standard density logic and grants a green light to the emergency route immediately for a prompt response to the emergency [14].

    • Enhanced Detection Using Computer Vision: De-tecting stationary vehicles by means of PIR sensors may encounter some difficulties as such vehicles do not produce much thermal variation onboard. To counteract this, a low-cost camera module (e. g. ESP32-CAM) can substitute the Far sensor therefore a dual-detection methodology is formulated. The PIR sensors in such a set up will identify presence in near proximity, whereas the vision-based vehicle counting will be done more accurately, thus extending the scope for scoring accuracy [9], [10].

  6. CONCLUSION

The paper outlines steps for designing and building a density-led traffic management system on the ESP32 board. The authors claim that their framework is capable of breaking the fixed-time signal methods monotony by mplementing a real-time sensors based lane ordination system. The main conclusions drawn from this research are as follows:

  • Responsiveness: The solution reacts to the traffic condi-tions variations and by that lowers the time spent waiting unnecessarily in comparison with static timing systems.

  • Improved Detection Accuracy: The use of two sensors (Near and Far) allows distinguishing between low and high traffic densities, which is an enhancement compared to single-sensor methods.

  • Operational Safety: The addition of an all-red change period and a set priority sequence make the signal changes safe even during situations with high or con- flicting demands of traffic.

Given urban growth putting ever-greater pressure on trans- port infrastructure, the kind of smart, budget-friendly control schemes exemplified here are likely to pave the way for nicely balanced, intelligent urban traffic management.

REFERENCES

  1. P. Garg, A. Aggarwal, and S. Sofat, Vision Based Traffic Light Controller, in Proceedings of CIH06, IASTED, 2006, pp. 5661.

  2. J. Smith and L. Doe, Inductive Loop Sensors for Traffic Management: A Review, IEEE Transactions on Intelligent Transportation Systems, vol. 12, no. 3, pp. 601610, 2011.

  3. M. Devi and N. Shanthini, Automatic Traffic Signal Control System Using PIR Sensor, International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering, vol. 5, no. 4,

    pp. 240245, 2016.

  4. K. Vidya and A. Bazila, Density Based Traffic Signal System Using Microcontroller, International Journal of Innovative Research in Sci-ence, Engineering and Technology, vol. 3, no. 3, pp. 221226, 2014.

  5. Arduino, Arduino UNO Rev3 Documentation, [Online]. Available:

    https://docs.arduino.cc/hardware/uno-rev3. [Accessed: Dec. 2025].

  6. Texas Instruments, PIR Sensor Logic and Application Notes, Technical Report SNLA004, 2020.

  7. U. Abubakar et al., Development of a density-based traffic light signal

    system, ASEC 2023, p. 36, 2023.

  8. A. H. M. Alaidi, I. A. Aljazaery, H. T. S. Alrikabi, I. N. Mahmood, and F. T. Abed, Design and implementation of a smart traffic light management system controlled wirelessly by Arduino, International Journal of Interactive Mobile Technologies (iJIM), vol. 14, no. 7, p. 32, 2020.

  9. M. Ashkanani et al., A self-adaptive traffic signal system integrating real-time vehicle detection and license plate recognition for enhanced traffic management, Inventions, vol. 10, no. 1, p. 14, 2025.

  10. A. Hazarika, N. Choudhury, M. M. Nasralla, S. B. A. Khattak, and

    I. U. Rehman, Edge ML technique for smart traffic management in intelligent transportation systems, IEEE Access, vol. 12, pp. 2544325458, 2024.

  11. D. Hercog, T. Lerher, M. Truntic, and O. Tezak, Design and implemen-tation of ESP32-based IoT devices, Sensors, vol. 23, no. 15, p. 6739, 2023.

  12. A. Khan et al., V2I-VTL: IoT-enabled adaptive traffic light controller and emission reduction at intersection, PeerJ Computer Science, vol. 10, p. e2507, 2024.

  13. N. E. Mohamed and I. I. Radwan, Traffic light control design ap-proaches: a systematic literature review, International Journal of Elec-trical and Computer Engineering (IJECE), vol. 12, no. 5, p. 5355, 2022.

  14. P. Murugaiah, B. Bhaskar, A. Periyaswamy, and B. V. Kartheek, Ar-duino based traffic congestion control with automatic signal clearance for emergency vehicles, in AIP Conference Proceedings, vol. 3159, no. 1,

    p. 020040, 2025.

  15. C. R, V. K. S, M. A. A, A. T. T, and K. K, Vehicle density based traffic control system using microcontroller, in 2024 10th Interna- tional Conference on Advanced Computing and Communication Systems (ICACCS), pp. 377381, 2024.

  16. G. Suseendran, D. Akila, D. Balaganesh, V. R. Elangovan, and V. Vi-jayalakshmi, Incremental multi-feature tensor subspace learning based smart traffic control system and traffic density calculation using image processing, in 2021 2nd International Conference on Computation, Automation and Knowledge Management (ICCAKM), pp. 8791, 2021.