Next Article in Journal
A Systematic Review and Multifaceted Analysis of the Integration of Artificial Intelligence and Blockchain: Shaping the Future of Australian Higher Education
Previous Article in Journal
Internet of Things Adoption in Technology Ecosystems Within the Central African Region: The Case of Silicon Mountain
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

An IoT-Enhanced Traffic Light Control System with Arduino and IR Sensors for Optimized Traffic Patterns

Scientific Affaires Department, University of Information Technology and Communications, Baghdad 00964, Iraq
*
Author to whom correspondence should be addressed.
Future Internet 2024, 16(10), 377; https://doi.org/10.3390/fi16100377
Submission received: 28 August 2024 / Revised: 21 September 2024 / Accepted: 23 September 2024 / Published: 18 October 2024

Abstract

:
Traffic lights play an important role in efficient traffic management, especially in crowded cities. Optimizing traffic helps to reduce crowding, save time, and ensure the smooth flow of traffic. Metaheuristic algorithms have a proven ability to optimize smart traffic management systems. This paper investigates the effectiveness of two metaheuristic algorithms: particle swarm optimization (PSO) and grey wolf optimization (GWO). In addition, we posit a hybrid PSO-GWO method of optimizing traffic light control using IoT-enabled data from sensors. In this study, we aimed to enhance the movement of traffic, minimize delays, and improve overall traffic precision. Our results demonstrate that the hybrid PSO-GWO method outperforms individual PSO and GWO algorithms, achieving superior traffic movement precision (0.925173), greater delay reduction (0.994543), and higher throughput improvement (0.89912) than standalone methods. PSO excels in reducing wait times (0.7934), while GWO shows reasonable performance across a range of metrics. The hybrid approach leverages the power of both PSO and GWO algorithms, proving to be the most effective solution for smart traffic management. This research highlights using hybrid optimization techniques and IoT (Internet of Things) in developing traffic control systems.

1. Introduction

Urban areas around the world are facing major traffic jams, which lead to longer travel times, higher fuel use, and more pollution [1]. During rush hours, severe traffic bottlenecks cause delays and economic losses. Traditional traffic lights, which run on fixed timers without considering real-time traffic, can exacerbate these issues; moreover, they have a limited capacity to adapt to changing traffic conditions and may actually increase traffic [2]. Cars often sit at red lights even when no other cars are crossing, and poor light synchronization causes stop–start driving patterns [3]. These systems also slow down emergency responses and often do not provide safe crossing conditions for pedestrians, thereby causing more accidents. Inefficient traffic management also results in greater emissions from idling cars, wasted fuel, and air pollution.
A major drawback of traditional traffic lights is that they cannot adapt to real-time conditions. They cannot handle sudden changes in traffic, such as accidents or road closures, because they follow pre-set timers. They are difficult to update as cities grow because they require manual adjustments that take time and may be ineffectual [4]. These operations have high maintenance costs, do not integrate well with other traffic operations, and are not suited to smart city initiatives. Traditional timed lighting systems operate on a fixed cycle, making them static. Their lack of flexibility has several negative consequences, an example of which is increased congestion during peak hours when the set green light is not sufficient for the volume of traffic, resulting in long queues of vehicles [5].
However, effective traffic management techniques are essential for the modern urban environment, in which traffic conditions are constantly changing throughout the day. Traditional systems with fixed deadlines fail to accommodate these differences, leading to congestion and delays. To address this, traffic light control systems must be capable of autonomously adjusting signal timings in real time based on current traffic conditions. By responding dynamically to variations in traffic flow, these systems can optimize the durations of green lights, reduce vehicle waiting times, improve the efficiency of traffic flow, and minimize congestion. Traffic signal control can be understood as a discrete-event system wherein changes in traffic signals are triggered by specific events, such as the presence or absence of vehicles at an intersection. Unlike traditional fixed-cycle systems, intelligent event systems can adjust signaling times based on real-time traffic conditions. This approach enables traffic signals to respond to fluctuating volumes of vehicles and flow patterns, thereby allowing for more efficient control of intersections. By continuously monitoring traffic and adapting the durations of green lights accordingly, discrete-event systems can reduce congestion, minimize wait times, and improve overall traffic flow. This real-time, event-driven approach is essential for managing the complex and ever-changing traffic conditions of urban areas.
As cities grow within smart framework technologies, IoT technologies like Arduino and IR (infrared) sensors represent a promising solution. These technologies provide real-time traffic data, allowing traffic lights to adjust dynamically. This improves traffic movement, reduces congestion, and enhances overall urban mobility.
The purpose of this paper is to evaluate and compare the effectiveness of PSO, grey wolf optimization (GWO), and the PSO-GWO hybrid method in managing traffic signals. The proposed method utilizes IoT-enabled sensor data to improve traffic flow, reduce delays, improve overall traffic management, and ultimately identify the most effective traffic management system.
An IoT-enhanced traffic light system implemented on Iraq’s streets may significantly improve the movement of traffic, anticipate congestion, and enhance overall safety. By applying optimized traffic signals using real-time data from these sensors, this method will ensure the safe movement of traffic during its increase in volume and reduce fuel use and emissions. It is cost-effective and scalable, making it very suitable for cities that have limit resources and conducive to the broader development of infrastructure and environmentally friendly policies.

2. Literature Review

Reference [6] used the Welch–Powell algorithm to operate traffic lights at intersections in Bandung and focused specifically on optimizing signal timing based on traffic capacities, thereby refining traffic operation and reducing wait times. Subsequent analysis of traffic data established that the algorithm significantly improved traffic light accuracy, which is also important in reducing the time users spend on the road. Precisely, at the Pasteur Interchange intersection of Bandung, the algorithm served to optimize the durations of traffic lights, improving on the scheme currently employed by the Bandung transportation office; it reduced the number of waiting cars and refined the movement of traffic more broadly. This method was applied to decrease the volume of traffic and increase safety, which led to economic and social benefits. However, the study was limited by its dependence on precise and complete traffic data and the need to precisely parallel local traffic designs, intersection features, and road structures for successful application, all of which compromise its generalizability; that said, the study did produce valuable insights into traffic regulation in similar areas.
Reference [7] used real-time traffic data and IoT sensors to observe the negotiation of traffic and the movements of emergency vehicles, demonstrating that integrating the IoT can streamline the response of emergency vehicles through more effective navigation. The aforementioned IoT-enabled traffic management system improved the provision of emergency services by reducing waiting times, increasing safety, and optimizing resources. However, the potential variation in traffic operations and differences in infrastructure between areas may limit the applicability of this study. These conclusions build upon broader suggestions for improving IoT-based traffic management in urban areas and highlight the need for further research on the benefits and limitations of this technology. The work underlines the potential of green lights to transform the movement of emergency vehicles and the management of traffic. By reducing waiting times, this IoT method can save lives, minimize car damage, and enhance the accuracy with which emergency services are provided. As this method is developed, more surveys and IoT-based designs—such as Green Lights Ahead—may lead to smarter, more effective area transportation systems. This study demonstrates the integration of IoT technology into traffic management, which especially benefits emergency response vehicles. IoT sensors have helped to improve the navigation and coordination of emergency vehicles by improving traffic signals in real time. Despite achieving good results in urban areas, this system faces limitations related to the diversity of infrastructure in some areas, indicating the need for further research to discover the full potential of IoT-based traffic management systems.
Reference [8] uses NodeMCU ESP8266, IR sensors, and the Firebase database to advance the detection of cars and reduce waiting times caused by traffic congestion. When detecting an emergency, the light turns green immediately and remains green for the following 10 s to clear the street, thereby allowing the car to pass through without congestion. The model prototype successfully achieved its goals and could be controlled via the Firebase dataset, which also allowed for manual operation in the event that the sensor failed. Although this method proved to be effective, it faces challenges related to the sensor’s sensitivity to the vehicle’s distance and speed, which require further research.
Reference [9] integrated advanced machine learning methods to develop traffic operation and road safety via smart traffic lights. These methods used real-time traffic monitoring and applied an algorithm for adaptive signal control in response to automated traffic light sequences based on current conditions. For example, one method demonstrated improvements in traffic precision, reduced travel times, and alleviated congestion using both simulations and real-time experiments. Traditional traffic light operations frequently fail to adapt to varying conditions, which causes congestion and delays on the roads. This method improved traffic flow and safety, demonstrating the potential to change the way traffic is managed in urban areas. However, the study highlighted the need for better predictive models and the challenges of implementing such a system on a broader scale.
Reference [10] proposes a new quantitative linear quadratic (QLQR) control system integrated with software-defined networking (SDN). The QLQR component improves traffic signal control at intersections, while SDN prevents congestion by adjusting signal timing. By constantly monitoring traffic, the system aims to reduce queue length, reduce waiting times, and improve vehicle availability and speed in real time. The proposed SDN-QLQR system is validated through simulation using the SUMO tool with traffic data from an Indian city. The results show significant improvements in performance metrics such as line length, wait time, throughput, and vehicle speed compared to other state-of-the-art methods, including LQR (linear quadratic regulator), MP (max-pressure), DTLC (dynamic traffic light controller), and SOTL (self-organizing traffic lights). The SDN-QLQR system, although promising in the simulation, lacks robustness. It does not address connectivity, latency, or different traffic conditions. The study also failed to address the cost and effectiveness of implementing such a system within large urban networks. Relying on SUMO simulations alone may not adequately capture their physical complexity. Future work should focus on empirical testing and addressing these limitations to ensure effective implementation of this framework.
Reference [11] highlights the potential of computer vision-enhanced traffic lights to improve traffic management in Kazakhstan. By analyzing real-time data from sensors and cameras, these smart traffic signals can optimize traffic flow, reduce congestion, and enhance overall urban efficiency. While the proposed approach offers several advantages, it is important to consider the limitations and challenges associated with its implementation. Further research and adaptation may be necessary to ensure its effectiveness in diverse urban environments.
In [12], the authors propose a traffic light system (DTLS) that uses computer vision to improve traffic in cities. The system uses the YOLO object detection algorithm to estimate the number of vehicles on the road and adjust traffic signals accordingly. This helps to reduce congestion and improve traffic flow. The system also includes a method for prioritizing traffic based on delays experienced by vehicles at different intersections. Within this model, priority is given to traffic arriving from areas with long waiting times, which can help reduce overall congestion. In addition, the system provides a green light for emergency vehicles. This ensures that emergency vehicles can pass through roads without delaying traffic. The system is designed to be energy-efficient and uses wireless communication technology, which reduces costs and increases sustainability. Overall, DTLS has the potential to improve traffic flow in urban areas. By using computer vision and intelligent algorithms, the system can help to reduce congestion, improve traffic flow, and reduce emissions. The article’s DTLS system, although promising, faces potential weaknesses such as inaccurate object detection, overhead, communication delay, cost, and privacy concerns. These things can hinder its effectiveness and real-world implementation.
Reference [13] details a software-defined traffic light system (SD-TLP) to improve the response time of emergency medical vehicles (EMVs) in urban areas. The system uses a central controller to make initial decisions based on global traffic conditions, selecting the nearest emergency center and the best route for the EMV. The SD-TLP system works by detecting accidents, selecting the nearest emergency center, choosing the best route, scheduling traffic signals, and restoring traffic signals after the EMV has passed through the intersection. The authors evaluated the SD-TLP system using cement in the city of Tabriz, Iran. The results showed that the system can significantly reduce EMV response time while reducing traffic congestion. The SD-TLP system has many advantages, including the ability to reduce both EMV response time and the adverse effects of traffic, its ease of implementation, and its scalability. However, the SD-TLP system also has some limitations, such as the need for a central controller, which may be difficult to implement in large cities and may not be effective in areas with heavy traffic.
The authors of [14] propose an IoT-based traffic management system with which to address traffic congestion and safety issues. The system uses IoT sensors, communications technology, and data analytics to improve traffic flow and reduce congestion, fuel consumption, and emissions. While the framework shows potential, it lacks specificity in its implementation and may face challenges in scalability, data privacy, and integration with existing infrastructure. The article does not specify the types of sensors, communication protocols, or data analysis algorithms that will be used within the system. Additionally, the article does not discuss the potential costs and benefits of implementing such a system. Such a system may encounter difficulties when scaled up to large cities and may struggle to ensure data privacy and security; its integration alongside existing traffic infrastructure may be complex.
The authors of [15] propose a new ITS model that is capable of predicting multimodal vehicle movement using machine learning and deep learning algorithms. The model includes data collection, algorithm implementation, and performance metrics using R-squared, RMSE (root mean square error), and MAE (mean absolute error). Different algorithms such as random forest, LSTM (long short-term memory), linear regression, and bagging are combined, resulting in a high efficiency of 93.52%. While the study demonstrates the feasibility of the proposed system, it does not contain detailed information about data collection methods, algorithm parameters, and actual testing.
The authors of [16] propose a new traffic control system using piezoelectric sensors at T-junctions. In detecting the presence of multiple vehicles, the system aims to improve traffic flow and reduce congestion. The system consists of a piezoelectric sensor, a microcontroller, LEDs, and other components. Although the project shows potential, it lacks specific details about sensor placement, communication protocols, and algorithm implementation. In addition, this study did not address potential challenges such as sensor noise, environmental factors, and integration with traffic management systems. Further research is needed to address these limitations and evaluate the effectiveness of the proposed system in real traffic situations.
In [17], the authors present a new approach to urban mobility that integrates unmanned aerial vehicles (UAVs) and visible light communication (VLC) technology into a smart city’s traffic management system. They highlight the inadequacy of traditional traffic control methods in handling higher volumes of traffic in urban areas. Drones incorporating the YOLO algorithm are used to detect traffic jams in real time through photography and analysis. This information is then transmitted to traffic lights, allowing for dynamic adjustment. Visible light communication (VLC), as a form of communication existing between drones and traffic signals, has been proposed as an energy-efficient alternative to radio frequency-based systems. This study presents a new theory of communication that adapts to different traffic conditions, demonstrating the potential of the system to produce an efficient urban transportation system. The paper has some major weaknesses, however. Because it relies on image data, additional sensors cannot be incorporated. There is limited discussion of the size of the system and actual testing in large cities. Security issues encountered by networks, especially VLC, are not addressed therein. In addition, there is no comprehensive analysis of the energy efficiency of the system. Addressing these issues will improve the efficiency and effectiveness of the system.

3. Traffic Lights Design

This research uses traffic light data collected from sensors programmed with Arduino Mega, which is installed within traffic lights at road intersections. The sensor’s electronic circuit involves light-dependent resistors (LDRs) and laser sensors. Each side of the traffic light is designed with three pairs of LDRs and lasers; the lasers are adjusted to shine directly onto the LDRs. When the laser beam senses the car on a side road, the LDR detects the change in light intensity, indicating the presence of a vehicle. The data are processed by Arduino, leading to a decision to adjust the operation of traffic lights with specific routine timings; these timings are optimized for efficient traffic movement.
Additionally, we use an ESP8266 module connected to Arduino Mega. This module sends details of road events to the ThingSpeak IoT platform in real time. The data saved in the channel in ThingSpeak IoT include the ID of each road and the number of vehicles; in this way, the system can manage traffic lights more efficiently.
In the event that one street has more cars than the others, this method can increase the time allocated to movement along this road by extending the duration of the green light, thus easing traffic. In this research, the proposed technique proved able to manage such scenarios and avoid any latency in traffic by implementing even traffic movement.

3.1. System Design

The proposed system uses an Arduino Mega microcontroller to control each of four traffic lights on each sidewalk at an intersection. Each sidewalk has pairs of LDRs and laser light sensors focused on these LDRs. When a car moves through and interrupts the laser light beam, the circuit detects it. The circuit is connected to ThingSpeak IoT using a Wi-Fi module (ESP8266), which sends real-time road information (i.e., the number of cars on each road) to the ThingSpeak platform to be saved.

3.2. Hardware Components

The circuit designed uses Arduino Mega to control the single traffic lights at the intersection. Each side of the road is equipped with three types of LDRs and laser sensors pointed at each LDR. The distance between each pair is determined based on the average distance between the two cars.
When a car interrupts the laser beam, a standard LDR detects the light source, signaling that Arduino Mega must process the information. The system then adjusts traffic signals according to their actual speed to improve traffic congestion.
The ESP8266 Wi-Fi system sends the current status of each line (number of cars, traffic light conditions) to the ThingSpeak platform. This allows remote monitoring and further data analysis to improve traffic management systems. This combination of IoT technology and Arduino provides a simple and effective solution to the challenges of modern traffic management. A schematic diagram of the hardware components is presented in Figure 1.

4. Hybrid Optimization Methods for Traffic Signal Timing Precision

In this research, MATLAB-2023b is used to implement PSO, GWO, and hybrid optimization techniques to enhance the signals within traffic light management by optimizing traffic signal times using real-time road information. Information on the number of cars and the status of each traffic signal is collected and sent to the ThingSpeak platform using an ESP8266 module. MATLAB then retrieves these data from ThingSpeak and processes them as for to the optimization algorithms.
Optimization techniques are utilized to analyze traffic signal data and make appropriate decisions about the operation of traffic lights. The output of these techniques is a decision on timing, which is then sent back to the controller (Arduino Mega) and, in this case, is used to adjust the traffic light signals.

5. Implementation

5.1. Hardware Setup

We initiated the process by connecting the Arduino Mega, which serves as the system’s main controller. Then, we connected the four traffic lights to the Arduino Mega and placed three pairs of LDR sensors and lasers on each sidewalk. The devices were aligned to face the LDRs, with the spacing between each pair made to match the spacing between the drives. This setup allowed for accurate vehicle detection, as the laser interrupted the LDRs when cars passed by.

5.1.1. Connecting the Sensors

In designing the hardware, we connected each pair of LDRs and lasers to the Arduino Mega. Each sensor connected to a specific pin on Arduino to detect interruptions in the laser lights caused by passing vehicles; we had to ensure a secure connection to produce accurate sensor readings.
In this setup, the LDR is connected to the Arduino pin A0 through a 10K resistor, forming a voltage divider. The laser is placed on the side of the road, directly facing the LDR. When the laser beam hits the LDR, the Arduino reads a small voltage from A0, indicating that the beam has not been interrupted. If a car interrupts the beam, the resistance of the LDR increases, creating a voltage at A0. The Arduino can detect this change and activate various functions, such as changing traffic lights or counting pedestrians. One pair of LDR and laser beam components is illustrated in Figure 2.

5.1.2. Communication Module

We connected the ESP8266 Wi-Fi module to the Arduino Mega, which allowed the system to send data to the ThingSpeak IoT platform. ESP8266 was connected to the Arduino Mega via serial communication, thereby ensuring a correct data transfer configuration.
To upload each track’s LDR data to ThingSpeak using ESP8266 and Arduino Mega, the Arduino read the values from the LDR sensors placed on each road and processed them to determine the state of the road. The ESP8266 was connected to a Wi-Fi network and sent an HTTP GET request to ThingSpeak with the processed LDR value. The state of each road was sent as a separate (e.g., road1ldr1, road1ldr2) element of the request, using the ThingSpeak API key to obtain authorization. This allowed road conditions to be monitored through the ThingSpeak dashboard.

5.2. Configuring the Software

In MATLAB, the environment was configured to receive data from ThingSpeak. Then, an interface was used to communicate with the ThingSpeak API and retrieve real-time data from the sensors. We utilized advanced algorithms—such as particle swarm optimization (PSO) or grey wolf optimization (GWO)—to analyze the data and determine which traffic signal should be prioritized based on current traffic conditions.

5.3. Testing and Configuration

We performed tests to ensure that all components worked together, the sensors correctly detected vehicles, and that data were being transmitted correctly to ThingSpeak. We created systems to adjust for any differences in sensor readings or communication delays.

5.4. Development and Activation

We used MATLAB to process data from ThingSpeak and advanced algorithms to determine the optimal settings for traffic signals. We then adjusted the system based on the ensuing results to improve traffic flow and reduce congestion.

5.5. Circuit Diagram

We now present a circuit diagram detailing the steps taken by the traffic signal control system and the relationship between its various components:
  • Arduino Mega is the main microcontroller of the system; it controls traffic signal operations and processes sensor data.
  • Traffic lights: Four traffic lights are connected to Arduino Mega. Each traffic light has a set of pins connected to specific digital instruments on Arduino, allowing the color of the traffic lights (red, yellow, or green) to be controlled.
  • Each side street is equipped with two LDR sensors and a laser. Lasers are used in LDRs to detect the presence of a vehicle.
  • Each laser is connected to a power supply and the ground, with the output signal connected to an analog input port on the Arduino.
  • Each LDR is connected to a voltage divider circuit, which outputs a signal proportional to the received light. This signal is connected to an analog input pin on the Arduino to detect the motor.
  • The ESP8266 Wi-Fi Module is used to send sensor data to the ThingSpeak IoT platform.
  • The ESP8266 is connected to a power supply of 3.3 V or less.
  • The TX (transmit) and RX (receive) ports of the ESP8266 are connected to the corresponding RX and TX ports on Arduino Mega for the purpose of serial communication.
  • An attached power supply provides power for Arduino Mega, traffic lights, sensors, and the ESP8266 module. The power supply is maintained at a level sufficient for all components, and they are properly connected to prevent electric shock.
  • Additional resistors for LDR circuits, capacitors for fixed voltage, and connectors for secure wiring are included in the system.

5.6. System Operation

Our proposed system uses lasers and light-emitting diode (LED) sensors to detect vehicles and send data to Arduino. Each side of the road has three sensors. Each pair includes a laser and an LDR. The laser sends a beam of infrared radiation through the path, and the LDR receives this beam. When a vehicle crosses the road, it blocks the laser beam, resulting in less light reaching the LDR. Arduino detects this change and knows that the vehicle is present. This information can be sent to IoT platforms like ThingSpeak for monitoring and analysis. This setting helps better manage traffic by providing real-time information about vehicle availability, which can reduce congestion and improve mobility.
The traffic control system works in real time to control traffic lights according to current conditions. The sensors detect the front of the car and send these data to Arduino. Arduino immediately processes this information to determine which traffic light should be green. This real-time decision helps to adjust traffic signals according to current traffic conditions, allowing for smoother movement and reduced delays. By regularly updating traffic signal timings based on live data, the system ensures that traffic flows efficiently and reduces congestion.

6. Testing and Measuring Performance: Analysis of PSO, GWO, and Hybrid PSO-GWO Methods

6.1. Particle Swarm Optimization: Testing and Performance

  • Initialization:
Swarm setup involved initializing a set of candidate traffic light schedules (particles) with random positions (schedules) and velocities (rate of change).
In this application of particle swarm optimization (PSO) to the control of traffic signals, our goal was to optimize the priority given to each street at a four-way intersection. Table 1 shows the PSO limits of the optimization process, and Table 2 shows its parameters.
  • Fitness Function:
The fitness function evaluates how well a given set of parameters (in this case, the traffic light schedules) perform in optimizing traffic movement and reducing delays. The objective is to minimize traffic congestion and improve overall traffic precision. The parameters of the fitness function define how each traffic light operates, affecting the duration of green, yellow, and red phases. In the case of traffic light optimization, the objective function is expressed as follows:
J = w 1 × t o t a l d e l a y + w 2 × t o t a l w a i t t i m e w 3 × t o t a l t h r o u g h p u t
where the total delay is the sum of delays experienced by cars at intersections (measured in seconds). The totalwaittime is the total time cars spend waiting at the traffic lights (measured in seconds). Total throughput is the number of cars passing through the intersection within a given time period (measured in minutes). Weights w 1 , w 2 , a n d   w 3 are used to prioritize different aspects of performance. Typically, delays and wait times are minimized, while throughput is maximized.
  • Evaluation and Update:
In the provided PSO code for optimizing traffic light schedules, the evaluation step calculates how well each proposed solution (traffic light priorities) performs. Initially, the algorithm converts continuous parameter values into discrete priorities by rounding them. The objective function then loads traffic data, splitting them into training and testing sets to evaluate performance. Although the traffic simulation function currently uses a placeholder value, its purpose is to simulate traffic movement based on priorities and then return a measure of precision. The fitness score is computed by negating the results of traffic movement, aligning with PSO’s minimization approach wherein a lower fitness score reflects better performance.
The update step adjusts each particle’s position and velocity based on its performance. Each particle’s velocity is updated using a formula that incorporates its previous best position and the global best position, as adjusted by inertia and random factors. This velocity is then used to update the particle’s position. After each position update, the fitness of each particle is reassessed. If a particle’s new fitness improves upon its personal best, that best is updated, and similarly, the global best is updated if the current particle’s fitness surpasses the global best. This iterative process balances the exploration of new solutions and the exploitation of known effective solutions, guiding the swarm towards the optimal traffic light scheduling for maximum precision.
Table 3 displays the results of the (PSO), showing the priority given to each street and the corresponding objective performance value, which shows the best traffic flow achieved during the optimization process.
Street1 Priority (3.186): Street1 is given the highest priority, indicating that it receives more green time than other streets, possibly due to a higher volume of traffic.
Street2 Priority (1.689): Street2 has a low priority, meaning it has less green light time, indicating less traffic.
Street3 Priority (1.174): Street3 receives the lowest priority, indicating that it has the smallest volume of traffic.
Street4 Priority (3.914): Street4 has the highest priority, indicating that it experiences heavy traffic and needs more green light time.
Best objective performance value (0.998): this value represents the closest solution found by PSO, with a value close to 1 indicating that the optimization system has successfully balanced traffic between all four routes.

6.2. Grey Wolf Optimization: Testing and Performance

  • Initialization:
Grey wolf setup: We initialized a set of candidate traffic light schedules (wolves) with random positions (schedules) and velocities (rate of change). Each wolf represented a potential solution to the traffic light scheduling problem. The initialization involved setting the positions of these wolves within predefined bounds, wherein each street is assigned a priority value ranging from 1 to 4.
In this application of GWO to traffic signal control, our goal was to optimize the priority given to each street at a four-way intersection. Table 4 shows the limits of the GWO optimization process, and Table 5 shows the parameter set.
  • Fitness Function:
The fitness function evaluates how well a given set of traffic light priorities can optimize the movement of traffic and reduce delays; the goal is to minimize traffic congestion and enhance overall traffic precision. The fitness function considers various performance metrics such as delay, wait time, and throughput. The objective function is expressed in Equation (1).
  • Evaluation and Update:
In the provided GWO code used to optimize traffic light schedules, within the evaluation step, we calculate the effectiveness of each candidate schedule. The traffic simulation function is employed to simulate traffic conditions based on a given set of priorities. Although its current iteration uses a placeholder, it is designed to measure the precision of traffic movement. The fitness score is derived by negating the movement of traffic and aligning with GWO’s minimization approach, wherein a lower fitness score indicates better performance.
The update step adjusts each wolf’s position based on their performance relative to the top-performing wolves (alpha, beta, and delta wolves). The update to be applied is calculated by averaging the positions of these top wolves and incorporating randomness to explore new potential solutions. This iterative process involves recalculating fitness scores and updating each wolf’s position and velocity accordingly. If a wolf’s new fitness represents an improvement on its personal best, that best is updated; similarly, the global best is updated if the current wolf’s fitness surpasses the global best. This process continues until convergence or the maximum number of iterations is reached, balancing the exploration of new solutions and the exploitation of existing effective solutions to identify the optimal schedule for this traffic light. The final results, including the best priority settings and corresponding fitness values, are presented herein.
Table 6 displays the GWO results, showing the priority given to each street and the corresponding objective performance value, which shows the best traffic flow achieved during the optimization process.
Street1 Priority (3.315): Street1 is given a higher priority, which means it receives more green light time compared to some other streets, likely due to a higher traffic flow.
Street2 Priority (2.636): Street2 has a moderate priority, reflecting a balanced traffic demand that does not require excessive green light time but still needs some attention.
Street3 Priority (4.000): Street3 is assigned the maximum possible priority, indicating it experiences the heaviest traffic and therefore needs the greenest light time to reduce congestion.
Street4 Priority (1.294): Street4 receives the lowest priority, likely due to light traffic, resulting in minimal green light time.
Best objective function value (0.99889): This value, close to 1, suggests that the GWO algorithm has found an optimized solution with which traffic can be well managed, ensuring efficient flow at the intersection.

6.3. Hybrid PSO and GWO: Testing and Performance

  • Initialization:
Swarm setup involved initializing a set of candidate traffic light schedules (particles) with random positions (schedules) and velocities (rate of change) for PSO and random positions for GWO. The parameters of priorities were set to ensure that each street received a priority value of between 1 and 4.
In this application of PSO-GWO to the control of traffic signals, our goal was to optimize the priority assigned to each street at a four-way intersection. Table 7 shows the limits of the PSO-GWO optimization process, and Table 8 shows its parameters.
We also set parameters for both PSO and GWO, including the number of particles/wolves and iteration limits.
  • Fitness Function:
The fitness function evaluates how well a given set of parameters (or traffic light schedules) perform in optimizing traffic movement and reducing delays. The ultimate aim is to minimize traffic congestion and improve the overall precision with which traffic is managed. The parameters of the fitness function define how each traffic light operates (i.e., the duration of its green, yellow, and red phases).
  • Evaluation and Update:
Evaluation (hybrid approach): The evaluation step calculates how well each proposed solution (i.e., each traffic light’s priority) performs. Initially, the algorithm converts continuous parameter values to discrete priorities by rounding. The objective function loads traffic data, splits them into training and testing sets, and evaluates performance. The traffic simulation function uses these priorities to simulate traffic movement, later returning a measure of precision. The fitness score is computed by negating the traffic movement result, which aligns with PSO’s and GWO’s minimization of the objective function.
Update (hybrid approach): the update step combines PSO and GWO strategies to adjust the particles’ positions and velocities as well as the wolves’ positions, based on their performance.
PSO update: Each particle’s velocity is updated using a formula that incorporates its previous best position and the global best position, as adjusted by inertia and random factors. This velocity updates the particle’s position.
GWO update: For each wolf, new positions are calculated based on the alpha, beta, and delta wolves’ positions. The new positions are then bounded within previously defined limits. The best wolf’s position is updated if the new position yields a better fitness value.
This iterative process balances the search for new solutions and the use of existing effective solutions, guiding the algorithm to the best traffic light schedule for optimal accuracy. The algorithm terminates when there is no further improvement in health or when the mean is reached.
Table 9 displays the PSO--GWO results, showing the priority allocated to each street and the corresponding objective performance value, which represents the optimal traffic flow achieved during the process.
Street1 Priority (3.912): Street1 is assigned a high priority, indicating a need for more green light time, likely due to heavy traffic.
Street2 Priority (1.5572): Street2 is given a lower priority, meaning it experiences lighter traffic and requires less green light time.
Street3 Priority (1.9302): Street3 receives moderate priority, indicating balanced traffic flow with occasional congestion.
Street4 Priority (1.2084): Street4 is assigned the lowest priority, reflecting minimal traffic and reduced green light time.
Best objective function value (0.99999): this near-perfect value indicates that the hybrid PSO-GWO algorithm has achieved an almost optimal solution, efficiently balancing traffic flow across all streets and minimizing congestion.

6.4. Results

6.4.1. Fitness Value vs. Iterations

The chart below shows the evolution of fitness values across iterations for the PSO, GWO, and hybrid PSO-GWO methods. Each line represents the average fitness score of the swarm or pack for each replicate.
The PSO method starts with a fit value of approximately −0.7 and increases continuously until it reaches a value of approximately −0.2. This indicates a rapid improvement in the quality of the solution. The GWO method starts at −0.5 and shows a significant difference every time it is used, eventually settling at −0.4. This shows that GWO can explore a wide range of information but is intelligently integrated. The PSO-GWO hybrid method combines the initial convergence speed of PSO with the higher search capabilities of GWO. The fit value of the hybrid system initially follows a similar path to PSO but benefits from GWO analysis, finally obtaining a fit value of around −0.35, indicating a consistent improvement process. Figure 3 shows the fitness values vs. iterations for the three methods.

6.4.2. Traffic Movement Precision

The bar graph below shows the average traffic flow achieved by each optimization method.
The average traffic values for each method are as follows: PSO 0.330601, GWO 0.69259, and hybrid PSO-GWO 0.925173. The hybrid approach shows greater accuracy, demonstrating its greater ability to improve traffic light scheduling. Figure 4 shows the precision with which traffic moves when each of the three proposed methods is implemented.

6.4.3. Delay Reduction

The chart below shows the total reduction in delay that was achieved with each optimization method.
The average reduction in delay is 0.25148 for PSO, 0.820957 for GWO, and 0.994543 for hybrid PSO-GWO. The combined method is demonstrably the most effective in reducing traffic delays. Figure 5 shows the reduction in delay when utilizing the three proposed methods.

6.4.4. Wait Time Reduction

The bar graph below shows the overall reduction in time spent waiting at traffic lights when using each route.
The average reduction in waiting time is 0.7934 for PSO, 0.56133 for GWO, and 0.102104 for hybrid PSO-GWO. Interestingly, PSO is the most effective at reducing waiting time, followed by GWO; the hybrid method did not particularly impact this specific metric. Figure 6 shows the average reduction in waiting time for the three proposed methods.

6.4.5. Throughput Improvement

The bar graph below shows the increase in total capacity (that is, the number of vehicles passing through the intersection) of each road.
The index of performance improvement is 0.2090 for PSO, 0.6563 for GWO, and 0.89912 for hybrid PSO-GWO. The hybrid approach has far more momentum, demonstrating its ability to increase traffic flow. Figure 7 shows the improvement in performance achieved by the three methods.

6.4.6. Best Objective Function Value

The bar graph below compares the best objective function values obtained by the PSO, GWO, and hybrid PSO-GWO methods.
Results: The best objective function values are 0.99888 for PSO, 0.99733 for GWO, and 0.999145 for the hybrid PSO-GWO method. The hybrid method returns the highest objective function value, making it the optimal solution among the three methods for enhancing our control of traffic lights. Figure 8 shows the best objective function results of the three methods.

6.4.7. Cumulative Traffic Movement over Time

The chart below shows the volume of traffic as it changes over time after implementing the optimal traffic signal schedule specific to each road.
The PSO method produces a steady increase in traffic over time. The GWO route follows a similar trend to PSO but features a slightly smaller traffic flow. The hybrid PSO-GWO method maintains the most smooth and continuous flow of traffic over time. Figure 9 shows the cumulative movement of traffic over time.
The PSO method starts with a fitness value of about −0.7 and gradually improves, converging to a value of about −0.2. This indicates a rapid improvement in the quality of the solution. The GWO method starts at −0.5 and shows a significant difference every time it is used, eventually settling at −0.4. This shows that GWO can explore a large breadth of information but is intelligently integrated. The PSO-GWO hybrid method combines the initial convergence speed of PSO with the higher search capabilities of GWO. The fit value of the hybrid system initially follows a similar path to PSO but also benefits from GWO analysis, finally resulting in a fit value of around −0.35, which indicates a process of consistent improvement.

6.5. Method Comparison

The PSO method allocated traffic light priority to both Street1 and Street4, while Street2 and Street3 were given lower priority. This setting produced a high accuracy score of 0.9981, which means the traffic flow is very good, but there is still potential for further optimization.
The GWO method assigned different priorities, with Street3 given the highest priority. This method produced an accuracy of 0.9989, which indicates minimal traffic.
The hybrid PSO-GWO approach performed the best, achieving an almost perfect precision score of 0.99999. Its priorities were more evenly balanced, with slightly higher priority allocated to Street1.
Compared to other systems, such as [6] use of the Welch–Powell algorithm for signal optimization and [7] use of IoT traffic control for emergency vehicles, hybrid PSO-GWO offers the greatest increase in scale and flexibility. While these systems focus on specific situations, such as emergency vehicle priority or increased signal timing, the integrated approach is suitable for traffic flow and multi-objective optimization, resolving the complexities of traffic jams.
Likewise, ref. [8] on using NodeMCU ESP8266 and IR sensors was successful for emergency vehicle detection but faced difficulties regarding sensor use and delivery. In turn, our integrated approach reduces reliance on external equipment and manual intervention, making it more robust and efficient in handling diverse and wide-ranging traffic situations.

7. Discussion

In this study, we implemented and compared three methods for traffic signal optimization —particle swarm optimization (PSO), grey wolf optimization (GWO), and hybrid PSO-GWO. Our results show that the PSO-GWO hybrid is generally the best approach; it prompted a significant improvement in efficiency within traffic relative to standard PSO or GWO techniques. The hybrid approach effectively combined the convergence speed of PSO, which excels in reducing traffic wait times, with the powerful searching power of GWO, which adjusts signal times to reduce congestion and improve overall performance. This flexibility made their combination particularly effective in managing dynamic traffic conditions in real time, which is essential in large urban areas.
While simulation created a controlled environment in which to test the system, its real-world application will be further complicated by factors such as unpredictable driver behavior, variable road infrastructure, weather conditions, and sensor reliability. Moving on to real-world testing is essential if we are to verify the robustness of the PSO-GWO hybrid system.
Such testing may include deploying the system at a controlled intersection equipped with traffic sensors and cameras to evaluate performance metrics such as reducing waiting times, increasing productivity, and responding to traffic congestion. Although logistical challenges—such as gaining approval to develop and upgrade infrastructure—are expected, real-world testing will provide important insights into how our systems can be improved.
The current study focuses on small settlements, but expanding the system to control large cities with dense settlements and traffic congestion will bring additional challenges. Urban areas with larger traffic patterns and higher PSO-GWO volumes will require algorithm optimization to coordinate multiple intersections at the same time, ensuring traffic flows efficiently through the network. Future research could test the system’s performance in major cities through simulations that combine real-time data, signal alignment, and dynamic traffic adjustments to determine its scale and efficiency.
In real-world traffic systems, challenges such as sensor failures or network delays can significantly impact performance. The approach to improving PSO-GWO should include strategies to address these issues and ensure reliability. For example, sensor failure can be reduced by increasing redundancy through multiple sensors or other detection methods such as cameras or GPS data. In addition, the system can switch to backup mode with conventional traffic in the event that a sensor fails. Network delays can be addressed by using statistics to calculate traffic patterns when data are delayed in real time, ensuring smooth operation. Future projects could explore dynamic reconfiguration to accommodate sudden changes, such as accidents or road closures, by prioritizing emergency routes and redistributing traffic.
The current system was designed primarily to improve traffic flow using a hybrid PSO-GWO system, with no specific attention paid to pedestrians or emergency vehicles. While our focus is still on improving traffic efficiency through machine learning and optimization, future developments could include features that separate and prioritize emergency vehicles such as ambulances and fire trucks. Such augmentations could include sensors or communication systems that detect pedestrian activity and emergency vehicles, prompting algorithms to adjust traffic signals in order to accommodate people and diffuse congestion in situations of emergency.

8. Conclusions

In this study, we compared three methods for optimizing traffic light control—particle swarm optimization (PSO), grey wolf optimization (GWO), and a hybrid PSO-GWO. The hybrid PSO-GWO method performed the best overall. It improved the precision of traffic movement, reduced delays, and increased throughput more effectively than the other methods. PSO was best at reducing waiting times, but the hybrid method combined the advantages of both PSO and GWO, making it the most effective overall. This shows that hybrid optimization methods can be very useful in confronting complex issues such as traffic management. Future research could look at using these hybrid methods in other areas of smart city planning.

Author Contributions

Conceptualization, K.R.Q. and N.M.N.; methodology, K.R.Q.; software, A.J.J.; validation, K.R.Q., N.M.N. and A.J.J.; formal analysis, N.M.N.; investigation, K.R.Q.; resources, A.J.J.; data curation, K.R.Q.; writing—original draft preparation, K.R.Q.; writing—review and editing, A.J.J.; visualization, N.M.N.; supervision, K.R.Q.; project administration, K.R.Q.; All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The original contributions presented in the study are included in the article, further inquiries can be directed to the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Shafik, A.K.; Eteifa, S.; Rakha, H.A. Optimization of vehicle trajectories considering uncertainty in actuated traffic signal timings. IEEE Trans. Intell. Transp. Syst. 2023, 24, 7259–7269. [Google Scholar] [CrossRef]
  2. Ottom, M.A.; Al-Omari, A. An adaptive traffic lights system using machine learning. Int. Arab. J. Inf. Technol. 2023, 20, 407–418. [Google Scholar] [CrossRef]
  3. Reddy, R.; Almeida, L.; Gaitán, M.G.; Santos, P.M. Synchronous Management of Mixed Traffic at Signalized Intersections toward Sustainable Road Transportation. IEEE Access 2023, 11, 64928–64940. [Google Scholar] [CrossRef]
  4. Du, W.; Ye, J.; Gu, J.; Li, J.; Wei, H.; Wang, G. Safelight: A reinforcement learning method toward collision-free traffic signal control. Proc. AAAI Conf. Artif. Intell. 2023, 37, 14801–14810. [Google Scholar] [CrossRef]
  5. Yuloskov, A.; Bahrami, M.R.; Mazzara, M. Traffic Light Algorithms in Smart Cities: Simulation and Analysis; Springer: Berlin/Heidelberg, Germany, 2023. [Google Scholar]
  6. Suhriya, N.H.; Prihandini, R.M.; Alvina, D.; Jannah, R. Optimization of Traffic Light Settings at Bandung Uses Welch Powell’s Algorithm. 2023. Available online: https://www.researchgate.net (accessed on 22 September 2024).
  7. Methul, S.; Kaswa, S. Green Lights Ahead: An IoT Solution for Prioritizing Emergency Vehicles. J. Ubiquitous Comput. Commun. Technol. 2023, 5, 250–266. [Google Scholar] [CrossRef]
  8. Qin, T.X.; Azzali, F. Smart Traffic Light Monitoring System for Emergency Vehicle using IoT. Multidiscip. Appl. Res. Innov. 2023, 4, 24–29. [Google Scholar]
  9. Gaikwad, V.; Holkar, A.; Hande, T.; Lokhande, P.; Badade, V. Smart traffic light system using internet of things. In Data Science and Intelligent Computing Techniques; SCRS Publications: Delhi, India, 2023. [Google Scholar]
  10. Sachan, A.; Kumar, N. SDN-enabled Quantized LQR for Smart Traffic Light Controller to Optimize Congestion. ACM Trans. Internet Technol. 2024, 24, 1–24. [Google Scholar] [CrossRef]
  11. Belgibaev, B.; Mansurova, M.; Abdrakhim, S. Smart traffic lights with video vision based on a control minicomputer in Kazakhstani megacities. Procedia Comput. Sci. 2024, 231, 792–797. [Google Scholar] [CrossRef]
  12. Hazarika, A.; Choudhury, N.; Nasralla, M.M. Edge ML Technique for Smart Traffic Management in Intelligent Transportation Systems. IEEE Access 2024, 12, 25443–25458. [Google Scholar] [CrossRef]
  13. Bagheri, N.; Yousefi, S.; Ferrari, G. Software-defined traffic light preemption for faster emergency medical service response in smart cities. Accid. Anal. Prev. 2024, 196, 1–12. [Google Scholar] [CrossRef] [PubMed]
  14. Khadotraa, K.; Rajb, S. Optimizing Urban Traffic Flow with Iot-Based Traffic Management Systems. Multidiscip. J. Curr. Res. 2023, 1, 128–134. [Google Scholar]
  15. Alkarim, A.S.; Al-Ghamdi, A.S.M.; Ragab, M. Ensemble Learning-based Algorithms for Traffic Flow Prediction in Smart Traffic Systems. Eng. Technol. Appl. Sci. Res. 2024, 14, 13090–13094. [Google Scholar] [CrossRef]
  16. Akinwumi, S.A.; Okeke, J.C.; Ayanbisi, O.W. Design and Construction of a Density-Controlled Traffic Light System. WSEAS Trans. Circuits Syst. 2024, 22, 158–165. [Google Scholar]
  17. Guzman, G.J.; Baeza, V.M. Enhancing Urban Mobility through Traffic Management with UAVs and VLC Technologies. Drones 2024, 8, 7. [Google Scholar] [CrossRef]
Figure 1. Schematic diagram of hardware.
Figure 1. Schematic diagram of hardware.
Futureinternet 16 00377 g001
Figure 2. Schematic diagram of the LDR and laser.
Figure 2. Schematic diagram of the LDR and laser.
Futureinternet 16 00377 g002
Figure 3. Fitness values across iterations for the three proposed methods.
Figure 3. Fitness values across iterations for the three proposed methods.
Futureinternet 16 00377 g003
Figure 4. Precision of traffic movement for the three proposed methods.
Figure 4. Precision of traffic movement for the three proposed methods.
Futureinternet 16 00377 g004
Figure 5. Reduction in delay when using the three proposed methods.
Figure 5. Reduction in delay when using the three proposed methods.
Futureinternet 16 00377 g005
Figure 6. Average reduction in waiting time for the three proposed methods.
Figure 6. Average reduction in waiting time for the three proposed methods.
Futureinternet 16 00377 g006
Figure 7. Throughput improvement for the three proposed methods.
Figure 7. Throughput improvement for the three proposed methods.
Futureinternet 16 00377 g007
Figure 8. Best objective function results of the three proposed methods.
Figure 8. Best objective function results of the three proposed methods.
Futureinternet 16 00377 g008
Figure 9. Result of cumulative traffic movement over time for three methods.
Figure 9. Result of cumulative traffic movement over time for three methods.
Futureinternet 16 00377 g009
Table 1. Lower and upper bounds of PSO initial parameters.
Table 1. Lower and upper bounds of PSO initial parameters.
PSO Lower/Upper BoundRange
Lower bound (each street needs at least priority 1)[1, 1, 1, 1]
Upper bound (each street can have at most priority 4)[4, 4, 4, 4]
Table 2. PSO parameters, including the number of particles and maximum number of iterations.
Table 2. PSO parameters, including the number of particles and maximum number of iterations.
PSO ParametersParameter
Swarm size30
Max. iterations100
Table 3. PSO evaluation.
Table 3. PSO evaluation.
Street1 PriorityStreet2 PriorityStreet3 PriorityStreet4 PriorityBest Objective Function Value
3.1862355261.689143341.1741853223.9145815630.998103677
Table 4. Lower and upper bounds of initial GWO parameters.
Table 4. Lower and upper bounds of initial GWO parameters.
GWO Lower/Upper BoundRange
Lower bound (each street needs at least priority 1)[1, 1, 1, 1]
Upper bound (each street can have at most priority 4)[4, 4, 4, 4]
Table 5. GWO parameters, including the number of wolves and iteration limits.
Table 5. GWO parameters, including the number of wolves and iteration limits.
GWO ParametersParameter
Number of wolves30
Max. iterations100
Table 6. GWO evaluation.
Table 6. GWO evaluation.
Street1 PriorityStreet2 PriorityStreet3 PriorityStreet4 PriorityBest Objective Function Value
3.31492.636441.29370.99889
Table 7. Lower and upper bounds of GWO initial parameters.
Table 7. Lower and upper bounds of GWO initial parameters.
PSO and GWO Lower/Upper BoundsRange
Lower bound (each street needs at least priority 1)[1, 1, 1, 1]
Upper bound (each street can have at most priority 4)[4, 4, 4, 4]
Table 8. PSO-GWO parameters: number of swarms and wolves and iteration limits.
Table 8. PSO-GWO parameters: number of swarms and wolves and iteration limits.
Swarm Size (PSO) and (GWO)30
Max. iterations100
Number of swarms and wolves30
Table 9. Evaluation of hybrid PSO-GWO.
Table 9. Evaluation of hybrid PSO-GWO.
Street1 PriorityStreet2 PriorityStreet3 PriorityStreet4 PriorityBest Objective Function Value
3.9121.55721.93021.20840.99999
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Qasim, K.R.; Naser, N.M.; Jabur, A.J. An IoT-Enhanced Traffic Light Control System with Arduino and IR Sensors for Optimized Traffic Patterns. Future Internet 2024, 16, 377. https://doi.org/10.3390/fi16100377

AMA Style

Qasim KR, Naser NM, Jabur AJ. An IoT-Enhanced Traffic Light Control System with Arduino and IR Sensors for Optimized Traffic Patterns. Future Internet. 2024; 16(10):377. https://doi.org/10.3390/fi16100377

Chicago/Turabian Style

Qasim, Kian Raheem, Noor M. Naser, and Ahmed J. Jabur. 2024. "An IoT-Enhanced Traffic Light Control System with Arduino and IR Sensors for Optimized Traffic Patterns" Future Internet 16, no. 10: 377. https://doi.org/10.3390/fi16100377

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Article metric data becomes available approximately 24 hours after publication online.
Back to TopTop