Design and implement a smart traffic light controlled by internet of things

The rise of the population produces an increase in the number of vehicles on the road, which creates heavy traffic in the roads and that causes many issues for the citizens and traffic cops an extra two emergency instances so it is necessary with developing technology to solve this problem. In this research, we used the Arduino UNO microcontroller board to build a new smart traffic light controller (STLC). Signal lights produce traffic congestion, and the system makes every attempt to alleviate it. In this paper, we designed a smart traffic control system by using Arduino to solve the problem of congestion at the intersection of the Dor al Moalemen in Wasit City, working to prevent traffic jam and reduce time, Using Arduino mega, ultrasonic sensor, and a camera esp32, the suggested technique analyses and manages everyday traffic at a three-line intersection. Furthermore, the suggested system achieves three-line intersection sync and implements a balance between the number of vehicles on each side and the green light. When traffic violation happens, the camera will capture the car number and send it to the database by using telegram.


Introduction
Traffic lights, which have been used to govern traffic flow at traffic signals, intersections, rail trains, and other locations since 1912, are signaling devices. The green light indicates that traffic may proceed in the direction indicated, the yellow light alerts drivers to prepare for a short interview, and the red light stops all traffic [1]. The necessity for a smart traffic light management system has been raised in Iraq because of the enormous amount of time are stopping at each road intersection. In my country, the present traffic signal system is still based on the old traditional traffic of a system based on a timer, and traffic is sometimes manually managed through human involvement. Furthermore, the growth in vehicle numbers imported into Iraq, particularly after 2003, Because the current road grid was never enlarged or repaired to manage the increased number of vehicles traveling along Iraqi roadways, huge traffic jams ensued [2]. Because of all of this, street crossings became uncontrollably packed. It resulted in extremely long wait times at intersections and a rise in the incidence of motor vehicle accidents. So, to reduce the time spent waiting at each traffic and minimize any accidents, we considered traffic control with a smart traffic light system [3,4]. One of the most important aspects of Intersection control is transportation technology to increase traffic safety and relax traffic. In nonsignalized crossroads, drivers rely on physical contact to safely arrange their journey. The installation of traffic signals has improved the flow of traffic at intersections. Congestion, pollutants, and accidents can all be reduced with the proper installation of traffic lights and signal control systems. Because of its reliability and cost-effectiveness, The initial control strategy, a pre-determined (static) Traffic Light Control management system, is presently being used in numerous crossings around the world [5,6]. As the result, the number of cars is increasing day by day and the pollution increases in congestion. As result our solution will reduce the traffic jams then pollution will reduce also. In this paper, we use Arduino mega, ultrasonic sensor, and a camera esp32, the suggested technique is used to analyze and manage everyday traffic at a three-line intersection.

Related work
The goal of this article is to contribute to the development of directional signs by inventing a centralized traffic signal control system that makes use of a one-of-a-kind wireless communication system. The most prevalent forms of urban junctions were studied to establish the system's efficiency. For network traffic lights, direct control routines were created, offering a complete control system for unusual conditions. Finally, safety protocols were developed to communicate the traffic signal system lamps' operational condition to central management. Using a logic analyzer connected to the outputs for every focal group, it was possible to create an operational phases timing diagram with each traffic light. As a result, the system was validated based on the similarities between theoretical and practical timing diagrams [7][8][9]. The design and implementation of this investigation are described in this study of an autonomous traffic light management system with congested road timing for enhancing traffic flow efficiency on city roads. It is also highlighted how the planned smart traffic light system will aid in the regular updating of these durations in an automated manner, as well as the importance of altering current traffic signal timing lengths to durations that vary based on the number of vehicles in the avenues. To do so, an IoT system that is based on the Raspberry Pi system and a PIR sensor will be constructed, with flexibility and a design for adding camera-related capabilities in mind [10]. This study looks into how RFID may be utilized as a sensor to monitor traffic jams at every intersection of a roadway utilizing RFID readers and labels. The purpose of this research is to make fixed and planned traffic light behavior dynamic. The study presents a novel technique for making signal timing responsive to current traffic congestion. The suggested intelligent system maintains the dynamic schedules of traffic lights by sensing the frequency of traffic to avoid congestion using IoT-enabled sensors, which provide current and robust communication technologies for residents [11,12]. This study employs the Internet of Things (IoT) and application development to provide a real-time traffic control management system. The density of traffic is measured using ultrasonic sensors. The system controller analyzes sensor data and then makes a decision. It uses a traffic management algorithm to set traffic signal timing and communicates Using a Wi-Fi module, information to a cloud server. The proposed technology can forecast the likelihood of the crossroads is congested. If an emergency car is spotted, the junction is given precedence, with a longer signal time. When a vehicle runs a red light, the system can detect it and issue a fine, which may be paid via the Traffic Wallet mobile application. This method is both cost-effective and simple to implement [13][14][15]. This project uses computer vision technology to distinguish road lane lines and over 40 different traffic lights. In this project, we will examine the smart city (SMC) concept and offer a model for developing a traffic management system (TMS) built on the SS network to handle traffic concerns in an SMC environment [16,17]. This work develops an autonomous approach to adjust traffic signal time using artificial intelligence techniques and a picture of cars at traffic lights. The algorithm is validated by comparing its results to those obtained manually. The suggested algorithm, when implemented in a mode of transportation, will govern traffic flow and eliminate wasted travel and time spent waiting on roadways [18,19].

System components
A detailed description of the components for this type of control is given in this section.

In the ESP32-CAM
is a full-featured microprocessor with a micro SD card slot and a constructed video camera. It is low-cost and simple to use, making it ideal for IoT devices that require complex functions like image tracking and identification.
The following is a list of the ESP32-CAM specifications:  The smallest Wi-Fi BT SoC module (802.11b/g/n)  Limited 32-bit CPU that can also function as an application processor  600 DMIPS overall processing power, up to 160MHz processor  Additional 4MPSRAM, created 520 KB SRAM

Arduino mega
The Arduino Mega is an ATmega2560-based microcontroller board. A 16 MHz crystal oscillator, 54 digital input/output ports (14 of which can be used as PWM outputs), 16 digital inputs, 4 UARTs (hardware serial connections), a Connector, a power jack, an ICSP header, and a reset button are all found on this board. It includes everything you'll need to get starting with the Arduino, including a USB cable to connect it to a computer and an AC-to-DC converter or battery to power it. Because a plastic base plate protects the Mega, there was no need to be concerned with intentional electrical discharge. The Mega 2560 R3 adds SDA and SCL pins to the AREF. In addition, two extra pins have been added near the RESET pin. For example, the IOREF enables the shields to adjust to the power level by the board. The other is unrelated and will be used later. All existing shields are compatible with Mega 2560 R3, but can also adapt to new shields that need these extra pins [20,21].

Ultrasonic sensor
The HC-SR04 ultrasonic distance sensor is seen here. This low-cost sensor provides non-contact measurement of 2cm to 400cm with a 3mm ranging accuracy. Each HC-SR04 module comes equipped with ultrasonic transmitters, a receiver, and a control circuit. On the HC-SR04, only four lines require attention: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground) (Ground). Setting up and using this sensor with your next range-finding project will be a breeze [22].

Servo motor
It is a motor that rotates with a great degree of precision. A control circuit is typically found in servomotors, which provides feedback on the present position of a motor shaft, allowing them to turn to great precision. When you wish to spin an item at a certain angle or range, use this command, you use a servomotor. It is made up of nothing more than a basic motor and a servomechanism. A DC servomotor runs on a DC power source, whereas an AC servomotor runs on an AC power supply. For this lesson, we will just talk about how a DC servomotor works. In addition to these major classes, there are many other types of servomotors depending on the type of gear arrangement and operational characteristics. Using a gear arrangement on a servo, we can build a high-speed servomotor in a smaller and lighter design.

System implementation (methodology)
With the ultrasonic sensor, our smart traffic system will be implemented by installing ESP 32 cam, which collected the number of cars on each side if there is a side traffic jam, and the other side is empty, the camera will send a signal to Arduino to traffic to open green light to reduce traffic jam. In addition, when a car crosses the red light, the ultrasonic sensor will send a signal to the camera to take a picture of the car number and send it via telegram and save it in the database as shown in figure 5. The following steps are used to implement our smart traffic light management system. Below pattern: 1-Our work includes a traffic light with three sides 2-The ESP32 cam will calculate the number of cars on each side when the side have a number of cars and light of this side is red light will turn the green light 3-Ultrasonic sensor works when the car crosses the red light side will send the signal to the camera to take picture of the car number below. 4-The pictures of cars crosses will send to the database by using the telegram app.

Circuit diagram
This is system architecture is shown in figure 6, which is consists of Arduino mega, ultrasonic sensor, cam esp32 & servo motor, smart traffic light appliances that represented by ( three streets, three-color lights (red, yellow, green )) which is shown in figure 6. We have three lines have three lights (green, red, yellow), eertt ultrasonic sensors detect a car violating a red traffic light then send the signal to the servo motor have cam esp32, each street we give angle the street number 1 0 angles, street number 2 90 angles, street number 3 180 angle servo motor will move with cam esp32 to that side a car violation a red traffic light to take picture car number and send it to our database by using telegram. Figure 6. Circuit diagram The projected system can be developed more by adding IoT, cloud computing and ZigBee technologies as future works [23][24][25].

Conclusion
We designed a smart traffic control system using Arduino to solve the problem of congestion at the intersection of the Dor al Moalemen region, working to prevent traffic jam and reduce time, Using Arduino mega, ultrasonic sensor, and a camera esp32, the suggested technique analyses and manages everyday traffic at a three-line intersection. Humidity and temperature variations do not affect the system's accuracy. Furthermore, the suggested system achieves three-line intersection sync and implements a balance between the number of vehicles on each side and the green light. In the case of traffic violation, the camera will capture the car number and send it to the database by using telegram.