Skip to content
Β 
Β 

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Noise Traffic Light 🚦

A real-time noise monitor that displays sound levels as a traffic light using RGB LEDs.

πŸ“‹ Features

  • Real-time noise detection via I2S MEMS microphone
  • 3-color traffic light display:
    • 🟒 GREEN – Noise is low (quieter than threshold)
    • 🟑 YELLOW – Noise is moderate (within range)
    • πŸ”΄ RED – Noise is high (exceeded threshold)
  • 12 NeoPixel RGB LED strip for bright, visible feedback
  • A-weighted sound level measurement (dBA) for realistic perception
  • Configurable thresholds via persistent storage

πŸ”§ Hardware Setup

Pin Configuration

Component Pin Color Description
WS2812 LED Data GPIO 2 - NeoPixel strip (12 LEDs)
I2S L/R Select GPIO 4 Green Microphone channel select (set HIGH = RIGHT channel)
I2S Word Select GPIO 5 Blue Microphone L/R clock
I2S Serial Clock GPIO 6 White Microphone bit clock
I2S Serial Data GPIO 7 Yellow Microphone audio data
Power (5V) 5V - USB power supply
GND GND - Ground

Wiring Diagram

ESP32                          I2S Microphone (e.g., INMP441)
───────                        ──────────────────
GPIO 4 (green, HIGH)───────────→ L/R (channel select = RIGHT)
GPIO 5 (blue) ─────────────────→ WS (L/R Clock)
GPIO 6 (white) ─────────────────→ SCK (Bit Clock)
GPIO 7 (yellow)─────────────────→ SD (Serial Data)
GND ───────────────────────────→ GND
3V3 ───────────────────────────→ VDD (if 3.3V version)
ESP32                          NeoPixel Strip (WS2812)
───────                        ──────────────────
GPIO 2 ────────────────────────→ DI (Data In)
5V ────────────────────────────→ 5V
GND ───────────────────────────→ GND

πŸ“Š How It Works

Audio Processing Pipeline

  1. I2S Sampling (48 kHz, 32-bit)

    • Captures continuous audio from the microphone
    • High-precision digital sampling
  2. IIR Filtering

    • Equalizer filter (INMP441): Flattens microphone frequency response
    • A-weighting filter: Mimics human ear sensitivity (emphasizes mid-frequencies)
  3. Sound Level Calculation

    • Converts filtered samples to dB (decibels)
    • Uses microphone calibration: 94 dB SPL reference
    • LEQ (Equivalent Continuous Sound Level) over 0.15 second blocks
  4. Decision Logic

    if (Leq < dB_min)     β†’ GREEN   (quiet)
    if (dB_min ≀ Leq < dB_max) β†’ YELLOW  (moderate)
    if (Leq β‰₯ dB_max)     β†’ RED     (loud)
    

🎚️ Configuration

Default Thresholds

dB_min_default = 40   // Below 40 dB β†’ GREEN
dB_max_default = 60   // Above 60 dB β†’ RED

Recommended Settings

Environment dB_min dB_max Notes
Library/Silent 30 50 Very quiet spaces
Classroom 40 60 Normal teaching
Active classroom 45 70 Group work sessions
Workshop 60 80 Tolerate machinery

🌐 WiFi & Web Configuration

Access Point Mode

The device operates as a WiFi Access Point (AP) that you can connect to:

  • SSID (Network Name): NoiseLight
  • Password: 12345678
  • IP Address: 192.168.4.1
  • Port: 80 (HTTP)

Setup Instructions

  1. Connect to the device's WiFi:

    • Open your device's WiFi settings (phone, tablet, laptop)
    • Select network NoiseLight
    • Enter password: 12345678
  2. Open the configuration page:

    • Open browser and go to: http://192.168.4.1
    • The web interface will load automatically
  3. Configure settings in real-time:

    • Live dB level display updates every 200ms
    • All sliders update preview instantly
    • Press Save Configuration to persist settings to device storage

Web Interface Features

Noise Light Web Interface

Display Mode

  • Traffic Light: All LEDs show single color (GREEN/YELLOW/RED)
  • VU Meter: LEDs create gradient bar showing sound intensity

LED Settings

  • Brightness: 0–255 (default: 57)
  • Color Selection: Choose custom colors for each noise level

Switchover Points (dB)

  • Floor Level: Noise floor baseline (default: 37 dB)
  • Greenβ†’Yellow: Transition threshold (default: 52 dB)
  • Yellowβ†’Red: Alert threshold (default: 62 dB)
  • Color Preview: Visual bar shows LED colors across dB range

Response Timing

  • Decay Time: How long to hold current color after sound stops (0–3000 ms, default: 2400 ms)
  • Response Time: Minimum update interval between LED changes (0–500 ms, default: 50 ms)

Persistent Storage

All configuration changes are automatically saved to ESP32's NVS (Non-Volatile Storage):

  • Settings survive power loss
  • Load automatically on device startup
  • Accessible via /api/config endpoint

πŸš€ Building & Uploading

Prerequisites

  • PlatformIO (VS Code extension or CLI)
  • Arduino IDE (optional, for direct compilation)

Build

# Using PlatformIO
platformio run -e esp32-s3-devkitc1-n4r2

# Or in VS Code: Ctrl+Shift+B β†’ Build

Upload

# Using PlatformIO
platformio run -t upload -e esp32-s3-devkitc1-n4r2

# Or in VS Code: Ctrl+Shift+B β†’ Upload

πŸ“ˆ Serial Output

The device outputs dB measurements to the serial monitor (115200 baud):

Leq: 45.3 dB | Min: 40 | Max: 60 | GREEN
Leq: 62.1 dB | Min: 40 | Max: 60 | RED
Leq: 55.2 dB | Min: 40 | Max: 60 | YELLOW

πŸ”§ Calibration

Microphone Sensitivity

If readings are consistently off:

  1. Measure known sound level (e.g., using phone app)
  2. Compare with serial output
  3. Adjust MIC_OFFSET_DB in main.cpp:
    #define MIC_OFFSET_DB 3.0103  // Increase/decrease calibration offset

Optimal Setup

  • Mount microphone in center of room
  • Avoid placing near walls or corners (reflections)
  • Keep away from vibration sources
  • Ensure clear air path (not covered)

πŸ”΄ Troubleshooting

Issue Cause Solution
Always GREEN Microphone not connected Check I2S pins (GPIO 4,6,7)
Always RED Calibration off Adjust MIC_OFFSET_DB
No serial output Wrong baud rate Set to 115200
No LED response Wrong LED pin Verify GPIO 2 connection
Microphone noise floor high Electrical noise Shield data lines, check power supply

πŸ“š References

πŸ“ License

This project is adapted from deciLight (GPL-3.0). Licensed under GNU General Public License v3.0.

🎨 Future Enhancements

  • IR remote control for threshold adjustment
  • MQTT integration for remote monitoring
  • WiFi display (web dashboard)
  • Multiple noise zones (classroom network)
  • Adjustable color mapping
  • Sound event logging

About

Visual Noise Monitor & Educational Tool

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages