Final-year projects / Smart city

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.

ESP32Mini or Major projectECE, CSE, EEE, Diploma
ESP32TWO14.1 mAFeatured
Parts
₹2,386
Build
12 weeks
Board
ESP32
Objectives
6

Block diagram

Inputs
  • TWO
    Two IR sensors per roadMeasure short and long queues
  • Emergency buttonGives an ambulance priority
  • ESP32
    CameraCaptures a photo when the event happens+
Controller
  • ESP32
    ESP32Shares green time
Outputs
  • Signal LEDsRed, amber and green for four roads
  • 12:45
    Countdown displaysShow seconds left
  • CLOUD
    Cloud dashboardStores readings, plots trends and sends alerts+

Objectives

  1. To estimate queue level (none, short, long) on each of four roads.
  2. To set each green time between 10 and 60 s in proportion to demand.
  3. To give priority to an emergency vehicle on request.
  4. To compare average waiting time with a fixed-time plan in a simulation of the model.
  5. To capture and store an image automatically when an event is detected.
  6. To publish readings over MQTT and show them on a live dashboard with threshold alerts.

Parts and specifications

Total about ₹2,386 at typical online prices. Tap a part for its pinout and datasheet notes.

Design calculations

Demand levels

Near sensor only = short queue (weight 1); near and far = long queue (weight 2); none = 0.

Green split

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.

Webster's cycle

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

SignalPin or connection
Road 1 to 4 near sensorsGPIO 32, 33, 25, 26
Road 1 to 4 far sensorsGPIO 27, 14, 12, 13
Signal LEDs (12)Through two 74HC595 shift registers on GPIO 23 (data), 18 (clock), 5 (latch)
TM1637 displaysShared CLK GPIO 19, DIO 4, 16, 17, 15
Emergency buttonGPIO 34 (external pull-up)

Firmware outline

  1. Each cycle, read all sensors (debounced over 3 s) and set weights.
  2. Compute green times with a 10 s minimum and 60 s maximum.
  3. Run the phases: green with countdown, 3 s amber, all-red 1 s.
  4. If the emergency button is pressed, finish the current amber safely and give that road green.
  5. Log weights and green times to compare with a fixed plan.

Test plan

TestExpected result
One road with a long queueThat road gets the longest green
All roads emptyMinimum greens
Emergency on road 3Road 3 green within one amber
Fixed vs adaptive over 20 cycles in the modelAverage 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.

1. Why a minimum green?
2. Why all-red time?
3. How would real systems sense queues?
4. What is Webster's formula for?
5. Why shift registers?

Make it yours

One or two upgrades for a mini project, two to four for a major one.

Build these first

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.