Measure dB level, display, and take action.
My first project published on r/raspberry_pi got very nice feedback and made it to the Top 10 of 2025 posts.
Published with the tongue in cheek title "Raspberry Pi decibel monitor + SNMP = instant parental justice", it
showed how I hooked a dB sensor and an LCD screen to throttle bandwidth on the network switch to a loud gaming kid. "More yell ? More ping :Γ"
Here are all the details and code.
This project has been a lot of fun with my kid actually (details in the Reddit thread comments). The idea was the following :
- Measure noise level in dB
- Display noise level
- Take measure accordingly : throttle bandwidth on the network to induce lag if threshold surpassed
Per popular demand I'm publishing all my code, but... It's not like there a magical universal command to adjust bandwidth on your home network switch. It's dependant on your network switch, if capable at all.
The code presented here will serve more as a starting point for your own project. Light some LEDs ? Fiddle with an SNMP capable switch ? Play a warning sound ? It all depends on your needs and hardware capability.
- Sound sensor from PCB Artist (~$22)
- 1.28 inch round LCD screen from Waveshare (~$15)
- A Raspberry (I used a Pi 3 A+ for the record)
- (A network switch with SNMP support)
Out of the box, the "measure and display" parts are fully functional. Everything can be configured via an .env file : copy .env-example and adjust.
utils/sensor.pyhas the very simple code to measure dB level- In
utils/lcd.pyyou will find everything to display on the LCD screen. It generates an image on the fly with all the info, using a template image found inassets/db_levels - You will want to edit and customize
utils/actions.pyto code what action you will want to take. There are placeholders and messages logged to help you through it, but you will be on your own.
You will find the exact code I used to throttle and restore the bandwidth on my network switch but, again, this won't work for you.
You will need to sudo apt get install i2c-tools, and pip install the following :
dotenvpillowspidevnumpysmbusRPi.GPIO
Prototype :
My second Python project π
Everything licensed under the WTF Public License. 