AI-Powered Gas Detection System with ElevenLabs Voice Alerts
An intelligent gas leak detection system featuring airplane-style AI voice readouts, real-time monitoring, and live camera streaming
Features β’ Hardware β’ Installation β’ Usage β’ API
This project transforms a Raspberry Pi Zero 2W into an intelligent gas leak detector with professional-grade voice alerts powered by ElevenLabs AI. Inspired by aircraft warning systems, it provides clear, audible notifications for various system states including gas detection, system status, and camera monitoring.
- π€ AI Voice Alerts - ElevenLabs-generated airplane-style voice notifications
- π Real-time Gas Detection - MQ-135 sensor monitoring via GPIO
- πΉ Live Camera Streaming - Pi Camera or USB camera support with web streaming
- π Web Dashboard - Real-time monitoring interface with Socket.IO
- π System Metrics - CPU, memory, temperature, and network monitoring
- π Auto-start Service - Systemd integration for automatic startup
- π SSH Management - Automatic SSH service control
- π Comprehensive Logging - Detailed system and event logging
- π Bluetooth Audio - Support for Bluetooth speakers (Echo Dot compatible)
| Component | Description | Notes |
|---|---|---|
| Raspberry Pi Zero 2W | Main controller | Tested on Raspbian Bookworm |
| MQ-135 Gas Sensor | Air quality/gas detection | Digital output to GPIO17 |
| Pi Camera / USB Camera | Video monitoring | Optional but recommended |
| Power Supply | 5V 2.5A minimum | Ensure stable power |
| Optional: LED | Status indicator | GPIO18 |
| Optional: Bluetooth Speaker | Audio output | For voice alerts |
MQ-135 Gas Sensor:
ββ VCC β 3.3V (Pin 1)
ββ GND β GND (Pin 6)
ββ DOUT β GPIO17 (Pin 11)
Optional LED:
ββ LED β GPIO18 (Pin 12)
chmod +x install.sh
./install.shsudo apt-get update
sudo apt-get install -y \
python3-flask \
python3-gpiozero \
python3-socketio \
python3-eventlet \
python3-psutil \
python3-picamera2 \
python3-opencv \
libcamera-apps \
pigpiopip3 install --break-system-packages flask-socketioCopy the example configuration:
cp bluetooth_config.json.example bluetooth_config.jsonEdit with your device details:
{
"target_device": "XX:XX:XX:XX:XX:XX",
"device_name": "Your-Bluetooth-Device"
}sudo cp gas-sensor-monitor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable gas-sensor-monitor.service
sudo systemctl start gas-sensor-monitor.serviceAccess the monitoring dashboard:
http://<raspberry-pi-ip>:5000
# Start service
sudo systemctl start gas-sensor-monitor.service
# Stop service
sudo systemctl stop gas-sensor-monitor.service
# Restart service
sudo systemctl restart gas-sensor-monitor.service
# Check status
sudo systemctl status gas-sensor-monitor.service
# View logs
sudo journalctl -u gas-sensor-monitor.service -fcd /home/zero2w1
python3 gas_sensor_app.py| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Web dashboard interface |
/api/status |
GET | Current system and sensor status (JSON) |
/api/camera-feed |
GET | Current camera frame (base64) |
/api/health-check |
GET | System health information |
/api/test-voice |
GET | Test voice alert system |
/video_feed |
GET | Live MJPEG video stream |
connect- Client connection establisheddisconnect- Client disconnectionstatus_update- Real-time sensor status updatescamera_frame- Live camera frame updates
# Get system status
curl http://<raspberry-pi-ip>:5000/api/status | python3 -m json.tool
# Get camera feed
curl http://<raspberry-pi-ip>:5000/api/camera-feed
# Health check
curl http://<raspberry-pi-ip>:5000/api/health-check/home/zero2w1/
βββ gas_sensor_app.py # Main application
βββ requirements.txt # Python dependencies
βββ install.sh # Installation script
βββ bluetooth_config.json # Bluetooth configuration (not tracked)
βββ bluetooth_config.json.example # Example config
βββ templates/
β βββ index.html # Web dashboard
βββ static/ # Static assets
βββ logs/
β βββ gas_sensor.log # Application logs
βββ sounds/ # Voice alert audio files
Edit gas_sensor_app.py to customize:
# Web server
HOST = '0.0.0.0'
PORT = 5000
# GPIO pins
GAS_SENSOR_PIN = 17
LED_PIN = 18
# Sensor settings
BOUNCE_TIME = 0.1 # Debounce time in seconds# Check service logs
sudo journalctl -u gas-sensor-monitor.service -n 50
# Verify GPIO permissions
sudo usermod -a -G gpio zero2w1
# Check if port is in use
sudo netstat -tlnp | grep :5000# Check camera detection
vcgencmd get_camera
# Test camera manually
libcamera-hello --list-cameras
# For USB cameras
ls -l /dev/video*sudo usermod -a -G gpio $USER
# Logout and login againThis project uses ElevenLabs AI-powered text-to-speech for generating realistic voice alerts. The alerts are designed to mimic professional aircraft warning systems for clarity and urgency.
- π¨ Gas leak detected
- β System normal
- π System starting
- π₯ Camera status updates
β οΈ System warnings
To regenerate voice alerts, use the included script:
python3 generate_alert_sounds.py- β‘ Ensure adequate power supply (minimum 2.5A recommended)
- π‘οΈ Monitor system temperature to prevent throttling
- π Use 3.3V VCC for MQ-135 sensor (not 5V)
- π§ͺ Calibrate MQ-135 sensor in clean air before use
- π Secure your Raspberry Pi if exposed to network
- OS: Raspbian Bookworm (Debian 12)
- Python: 3.11+
- RAM: Minimum 512MB (Zero 2W has 512MB)
- Storage: 8GB+ SD card recommended
Contributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- ElevenLabs - AI voice generation technology
- Flask - Web framework
- Socket.IO - Real-time communication
- gpiozero - GPIO control library
Created by Asis Panda on September 2025 | Version 1.0