Smart Traffic System Group 10
Smart Traffic System Group 10
AIM:
The aim of the experiment is to develop a smart traffic signal system that utilizes IR sensors to
detect vehicle presence, sound sensors to detect horn activity exceeding 70dB, and an OLED
display to raise awareness about the horn noise level. Additionally, the experiment aims to
control the traffic LED signals based on the data collected from these sensors, thus promoting
traffic discipline and reducing noise pollution.
OBJECTIVES:
1. Hardware Setup:
- Assemble the hardware components including NodeMCU, IR sensors, sound sensor, OLED
display, 3 LEDs, and jumper wires.
- Connect the IR sensors and sound sensor to the NodeMCU using jumper wires, ensuring
proper wiring connections.
- Mount the IR sensors and sound sensor at appropriate locations near the traffic signal
pole.
2. Software Development:
- Develop the firmware for the NodeMCU to read data from the IR sensors and sound
sensor.
- Program the NodeMCU to analyze sensor data and control the traffic LED signals
accordingly.
- Implement logic to detect vehicle presence using IR sensors and to detect horn activity
exceeding 70dB using the sound sensor.
By accomplishing these objectives, the experiment aims to demonstrate the feasibility and
effectiveness of using smart technologies to enhance traffic signal control and promote
awareness about noise pollution caused by excessive horn usage.
Components required
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
String apiKey = "15BJ7JOT78FE0RU7"; // Enter your Write API key from ThingSpeak
const char *ssid = "realme C25s"; // replace with your wifi ssid and wpa2 key
const char *pass = "pmishra12";
const char* server = "api.thingspeak.com";
const int ledPins[3] = {D5, D6, D7}; // D1, D2, D3
const int irPin = D8;
int redDuration = 3000; // Red LED duration in milliseconds (3 seconds)
int yellowDuration = 1000; // Yellow LED duration in milliseconds (1 second)
int greenDuration = 3000; // Green LED duration in milliseconds (3 seconds)
WiFiClient client;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
void setup()
{
Serial.begin(115200); //Serial comms for debugging
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //OLED display start
display.display(); //show buffer
display.clearDisplay(); //clear buffer
display.setTextSize(1); //Set text size to 1 (1-6)
display.setTextColor(WHITE); //Set text color to WHITE (no choice lol)
display.setCursor(0,0); //cursor to upper left corner
display.println("Decibelmeter"); //write title
display.display(); //show title
delay(2000); //wait 2 seconds
WiFi.begin(ssid, pass);
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(1);
display.setTextColor(WHITE);
display.print("WiFi connected");
display.display();
delay(4000);
display.clearDisplay();
void loop()
{
int i; // Declare 'i' here
// Turn off the red LED and turn on the yellow LED
digitalWrite(ledPins[0], LOW);
digitalWrite(ledPins[1], HIGH);
delay(yellowDuration); // Wait for the yellow duration
// Turn off the yellow LED and turn on the green LED
digitalWrite(ledPins[1], LOW);
digitalWrite(ledPins[2], HIGH);
delay(greenDuration); // Wait for the green duration
// Draw scale
for(int x =5;x<114;x=x+6){
display.drawLine(x, 32, x, 27, WHITE);
}
// Draw outline of bar graph
display.drawRoundRect(0, 32, 120, 20, 6, WHITE);
// Set bar graph width based on decibel reading
int r = map(db,0,120,1,120);
// Draw bar graph
display.fillRoundRect(1, 33, r, 18, 6, WHITE);
display.display();
GROUP 10
ISHU KANT - 22052730
JAISH NAWED - 22052731
SHIVAM KUMAR - 22052760
ARPREET MAHALA - 22052804
AKSHAT KUTARIYAR - 22052791