Skip to content

Bust the noise with ease! This Python script analyzes and injects noise events into InfluxDB, publishes MQTT topics, and sends optional notifications via Pushbullet and Discord(if that's what you like).

License

Notifications You must be signed in to change notification settings

silkyclouds/NoiseBuster

Repository files navigation

NoiseBuster Logo

NoiseBuster is an advanced Python application designed to monitor and log noise levels using a USB-connected sound meter. It not only records noise events but also integrates with various services like InfluxDB, MQTT, Discord, and more to provide a comprehensive noise monitoring solution. With features like weather data integration and traffic data collection, NoiseBuster offers a versatile tool for environmental monitoring and analysis.

Live NoiseBuster Running Instance

🚀 Click here to see NoiseBuster in action!

NoiseBuster Dashboard
NoiseBuster Dashboard in Grafana showing noise events over time.

NoiseBuster Analytics
Analysis of noise levels in Home Assistant.


Important Notice

Note: This project, NoiseBuster, created by Raphael Vael, is licensed under the Creative Commons Attribution-NonCommercial (CC BY-NC) License, which means it is free for non-commercial use only. Commercial use requires explicit permission from the project owner.

Discord Server

Join the community on our Discord server to discuss, contribute, and get support: NoiseBuster Discord Server

Features

  • Noise Monitoring: Interfaces with a USB sound meter to monitor and record noise levels in real-time.
  • Data Storage: Stores recorded noise events in InfluxDB for easy retrieval and analysis.
  • MQTT Integration (Optional): Publishes noise levels and events to an MQTT broker for integration with home automation systems like Home Assistant.
  • Weather Data Collection (Optional): Fetches current weather data from OpenWeatherMap API to correlate noise events with weather conditions.
  • Traffic Data Collection (Optional): Integrates with Telraam API to collect traffic data, allowing analysis of noise levels in relation to traffic conditions. Note: A dedicated YOLO-powered traffic counting script is in development and will be available soon.
  • Image Capture (Optional): Captures images using an IP camera when noise levels exceed a specified threshold.
  • Notifications (Optional): Sends notifications via Discord and Pushover when certain events occur (e.g., high noise levels, API failures).
  • Configurable Timezone: Adjusts timestamps according to the specified timezone offset.
  • Error Handling and Logging: Robust error handling with detailed logging for troubleshooting.

Usages

  • Monitor loud traffic, planes, live events, and more.
  • Create insightful graphics to share statistics with authorities.
  • Analyze environmental noise in correlation with weather and traffic data.

Getting Started

Prerequisites

Before using NoiseBuster, ensure the following prerequisites are met:

  • Operating System: Linux-based system (e.g., Ubuntu, Debian, Raspberry Pi OS).
  • Python: Python 3.6 or higher installed.
  • Sound Meter: A USB-connected sound level meter. All models with USB communication capabilities should work. Other types like RS485 models and ESP devices with calibrated microphones could be used but may require additional setup by the user.
  • Internet Connection: Required for API integrations (e.g., OpenWeatherMap, Telraam).
  • Optional but Recommended:
    • InfluxDB 2.x and Grafana: For data storage and visualization. If you want to use these, you need to install them on your own
  • Optional:
    • MQTT Broker: If you wish to publish data to an MQTT broker.
    • Docker: Installed for containerized deployment.

Hardware Recommendations

  • PoE Splitter: If you want to power your device using PoE, consider using a PoE Splitter.
  • IP65 Box: For outdoor usage of your volume meter, I recommend using an IP65 box to protect the device.
  • Volume Meter: I use this USB volume meter, which runs smoothly on a Raspberry Pi and is powered directly through USB.
  • Linux-Compatible Board: Use a Raspberry Pi or any other board capable of running Linux.
  • Virtual Machines and Containers: You can also run NoiseBuster in a VM, LXC, or other virtual environment, and simply pass through the USB volume meter, avoiding dedicated hardware.

Hardware Requirements

  • USB Sound Meter:

    • The application is designed to work with USB-connected sound level meters.

    • Example Device: USB Sound Level Meter on AliExpress

    • Ensure the device supports USB communication.

    • For devices not automatically detected, you may need to specify the USB vendor ID and product ID in the configuration. Use the lsusb command to find these IDs.

      USB Sound Meter Example
      Search for this type of USB meter

  • Camera (Optional):

    • IP Camera: Supports RTSP or HTTP protocols. Provide the camera's URL in the configuration.
    • Raspberry Pi Camera: Connects directly to the Raspberry Pi. Requires the picamera library.

Configuration

All configuration settings are stored in the config.json file. Here is how to set up your configuration:

  1. Open config.json in a text editor.
    Keep all default IP addresses as localhost or 127.0.0.1 to ensure it works out of the box.

  2. Configure each section:

    • InfluxDB Configuration:

      • Set "enabled": true to store data in InfluxDB.
      • Provide your InfluxDB host, port, token, org, and bucket names.
      • Ensure you create buckets named "noise_buster" and "noise_buster_realtime".
      • API Keys: Follow the InfluxDB setup guide to create your organization, buckets, and API tokens.
    • Pushover Configuration (Optional):

      • Set "enabled": true to receive Pushover notifications.
      • Provide your user_key and api_token. Register at Pushover.
    • Weather Configuration (Optional):

      • Set "enabled": true to fetch weather data.
      • Provide your OpenWeatherMap api_key and location. Sign up at OpenWeatherMap API.
    • MQTT Configuration (Optional):

      • Set "enabled": true to publish data to an MQTT broker.
      • Provide your MQTT server, port, user, and password. Learn more at mqtt.org.
    • Camera Configuration (Optional):

      • Set "use_ip_camera": true or "use_pi_camera": true based on your setup.
      • If using an IP camera, provide the ip_camera_url.
    • Device and Noise Monitoring Configuration:

      • Specify the device_name for identification.
      • Set minimum_noise_level in decibels to trigger events.
      • Specify image_save_path where images will be stored.
      • If automatic USB detection fails, provide usb_vendor_id and usb_product_id. Use the lsusb command to find these IDs.
    • Telraam API Configuration (Optional):

      • Set "enabled": true to collect traffic data.
      • Provide your Telraam api_key and segment_id. More info at Telraam.
    • Timezone Configuration:

      • Set timezone_offset relative to UTC.
    • Discord Configuration (Optional):

      • Set "enabled": true to send notifications to Discord.
      • Provide your Discord webhook_url. Create one at Discord Webhooks.
  3. Save config.json.

Running the Script

Using Python Directly

  1. Ensure the USB sound meter is connected to your computer.

  2. Clone the repository using Git:

    git clone https://github.com/silkyclouds/NoiseBuster.git
  3. Navigate to the NoiseBuster directory:

    cd NoiseBuster
  4. Create a virtual environment:

    python3 -m venv env
  5. Activate the virtual environment:

    source env/bin/activate
  6. Install the required dependencies based on your device type:

    • For Raspberry Pi users:

      pip install -r requirements.txt
    • For non-Raspberry Pi users:

      pip install -r requirements_no_pi.txt
  7. Run the application:

    python noisebuster.py

Using Docker Containerized Version

  1. Clone the repository using Git:

    git clone https://github.com/silkyclouds/NoiseBuster.git
  2. Navigate to the NoiseBuster directory:

    cd NoiseBuster
  3. Copy the appropriate requirements file based on your device type:

    • For Raspberry Pi users:

      cp requirements.txt docker/requirements.txt
    • For non-Raspberry Pi users:

      cp requirements_no_pi.txt docker/requirements.txt
  4. Build the Docker image:
    Make sure to specify the correct Dockerfile in the build context.

    docker build -t noisebuster -f docker/Dockerfile .
  5. Run the Docker container:
    Ensure the necessary ports and devices are mapped if required.

    docker run -d --name noisebuster noisebuster
  6. Check the logs:
    This will help you verify if the application is running as expected.

    docker logs noisebuster
  7. Access the application (if applicable):
    Follow any additional instructions specific to accessing the app, such as exposed ports or mapped volumes.

    Check if everything is running fine, if you configured your usb device correctly in your config.json file, you should see dB levels being reported. If you didn't, don't panic, the usb_ids file should get you covered and allow to autodetect your device.

License

This project is licensed under the GNU GPLv3 License. This license allows for free usage and modification of the code for non-commercial purposes. For commercial use, explicit permission from the project owner is required. By choosing this option, I aim to encourage open-source collaboration while maintaining control over commercial applications of NoiseBuster.

Contributing

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Submit a pull request with a detailed explanation of your changes.

I'm actively developing a vehicle detection and counting module based on YOLOv11 to correlate noise events with specific vehicle types. If you're interested in helping improve this model or contributing in other ways, please reach out! Any contributions to the detection and accuracy of vehicle classification would be invaluable.

Next Steps

  • Adding vehicle detection using OpenCV to correlate noise events with specific vehicles.
  • Providing a centralized InfluxDB instance for users to contribute data.
  • Investigating other hardware options like ESP devices for sound monitoring.
  • Implementing better data retention policies to manage database size.
  • A dedicated YOLO-powered traffic counting script is in development and will be available soon.

Project

This project was initiated by Raphael Vael. I welcome anyone interested in improving NoiseBuster to join the effort. Whether it's refining the vehicle detection model, optimizing the noise detection algorithms, or expanding functionality, your input is greatly valued!

This project, NoiseBuster, created by Raphael Vael, is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.

About

Bust the noise with ease! This Python script analyzes and injects noise events into InfluxDB, publishes MQTT topics, and sends optional notifications via Pushbullet and Discord(if that's what you like).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published