Density-based smart traffic signal
Fixed-time signals give a green light to empty roads while queues build on busy ones. A signal that measures queue length on each road and shares green time in proportion cuts waiting time at junctions.
- Parts
- ₹2,386
- Build
- 12 weeks
- Board
- ESP32
- Objectives
- 6
Block diagram
- Two IR sensors per roadMeasure short and long queues
- Emergency buttonGives an ambulance priority
- CameraCaptures a photo when the event happens+
- ESP32Shares green time
- Signal LEDsRed, amber and green for four roads
- Countdown displaysShow seconds left
- Cloud dashboardStores readings, plots trends and sends alerts+
Objectives
- To estimate queue level (none, short, long) on each of four roads.
- To set each green time between 10 and 60 s in proportion to demand.
- To give priority to an emergency vehicle on request.
- To compare average waiting time with a fixed-time plan in a simulation of the model.
- To capture and store an image automatically when an event is detected.
- To publish readings over MQTT and show them on a live dashboard with threshold alerts.
Parts and specifications
- ESP32 DevKit V1Dual-core 240 MHz, 520 KB SRAM, Wi-Fi + Bluetooth, 3.3 V logic, 12-bit ADC (use ADC1 pins when Wi-Fi is on)₹450Buy
- IR obstacle sensor moduleReflective IR pair with LM393, 2 to 30 cm set by trimmer, digital out, sunlight can false-trigger₹320Buy
- Junction model board₹300
- ESP32-CAM with OV2640ESP32 + 4 MB PSRAM + 2 MP OV2640 camera, microSD slot, needs 5 V 500 mA for stable Wi-Fi₹550Buy
Total about ₹2,386 at typical online prices. Tap a part for its pinout and datasheet notes.
Design calculations
Near sensor only = short queue (weight 1); near and far = long queue (weight 2); none = 0.
Cycle 120 s minus 4 × 3 s amber = 108 s green. Green_i = 10 + (108 − 40) × w_i / Σw. Weights 2, 1, 1, 0 give 44, 27, 27, 10 s.
C0 = (1.5L + 5) / (1 − Y), where L is lost time and Y the sum of flow ratios. L = 12 s, Y = 0.6 gives C0 = 57.5 s, a check on the fixed cycle.
Pin map
| Signal | Pin or connection |
|---|---|
| Road 1 to 4 near sensors | GPIO 32, 33, 25, 26 |
| Road 1 to 4 far sensors | GPIO 27, 14, 12, 13 |
| Signal LEDs (12) | Through two 74HC595 shift registers on GPIO 23 (data), 18 (clock), 5 (latch) |
| TM1637 displays | Shared CLK GPIO 19, DIO 4, 16, 17, 15 |
| Emergency button | GPIO 34 (external pull-up) |
Firmware outline
- Each cycle, read all sensors (debounced over 3 s) and set weights.
- Compute green times with a 10 s minimum and 60 s maximum.
- Run the phases: green with countdown, 3 s amber, all-red 1 s.
- If the emergency button is pressed, finish the current amber safely and give that road green.
- Log weights and green times to compare with a fixed plan.
Test plan
| Test | Expected result |
|---|---|
| One road with a long queue | That road gets the longest green |
| All roads empty | Minimum greens |
| Emergency on road 3 | Road 3 green within one amber |
| Fixed vs adaptive over 20 cycles in the model | Average wait compared |
These rows start your results table when you plan the project.
Viva practice
Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 5.
Make it yours
One or two upgrades for a mini project, two to four for a major one.
Datasheets and sources to cite
- IRC:93 Guidelines on design of road traffic signals
- Webster, Traffic signal settings (1958)
- Espressif ESP32 datasheet
About this project
How much does the density-based smart traffic signal project cost?
About ₹1,686 for the parts in the base list: ESP32 DevKit V1, IR obstacle sensor module × 8, LED 5 mm red with 220 Ω × 4, LED 5 mm yellow with 220 Ω × 4, LED 5 mm green with 220 Ω × 4, TM1637 4-digit display × 4, 74HC595 shift register × 2, Push button 12 mm, Breadboard 830 points × 2, Junction model board.
How long does it take?
About 8 weeks for the base project, built on an ESP32. Each upgrade adds time.
Which branches is it suitable for?
Electronics and Communication, Computer Science / IT (IoT, AI), Electrical and Electronics, Diploma (any electronics branch), as a mini or major project.
Which pins and design calculations does it use?
Road 1 to 4 near sensors on GPIO 32, 33, 25, 26; Road 1 to 4 far sensors on GPIO 27, 14, 12, 13; Signal LEDs (12) on Through two 74HC595 shift registers on GPIO 23 (data), 18 (clock), 5 (latch). Worked calculations on this page: demand levels, green split, webster's cycle.
How do I test it?
One road with a long queue: That road gets the longest green. All roads empty: Minimum greens. Emergency on road 3: Road 3 green within one amber. Fixed vs adaptive over 20 cycles in the model: Average wait compared.
What are the objectives?
To estimate queue level (none, short, long) on each of four roads. To set each green time between 10 and 60 s in proportion to demand. To give priority to an emergency vehicle on request. To compare average waiting time with a fixed-time plan in a simulation of the model.
