Use app_usb.py for real MQ-135 sensor readings:
-
Hardware Setup:
- Connect MQ-135 sensor to Arduino analog pin A0
- Upload
arduino_mq_sensor.inoto your Arduino - Connect Arduino to your computer via USB
-
Run the App:
python app_usb.py
- Auto-detects Arduino port (Windows/Linux/Mac)
- If detection fails, edit line 23:
SERIAL_PORT = 'COM3'(or/dev/ttyUSB0)
-
Open Dashboard:
- Visit: http://localhost:5000
- Real-time data updates every second
Use app.py for realistic fake data (no Arduino needed):
-
Run the App:
python app.py
- Simulates realistic pollution patterns
- Time-based variations (rush hours, clean periods)
- Random events (spikes, gradual changes)
-
Open Dashboard:
- Visit: http://localhost:5000
- Perfect for demos and testing
- Real-time graph (Plotly) - Last 15 seconds of data
- AQI levels with color-coded status (Good 🟢, Moderate 🟡, Unhealthy 🟠, Very Unhealthy 🔴)
- 10 Gas measurements - CO₂, CO, NO₂, NH₃, Benzene, Toluene, Alcohol, Acetone, H₂S, Smoke/PM2.5
- Gas harm table with health risks and streetlight solutions
- Mobile responsive design
- Formspree feedback form (ID: xvgeqywp)
- Windows: Device Manager → Ports (COM & LPT) → COM?
- Linux:
ls /dev/ttyUSB*orls /dev/ttyACM* - Mac:
ls /dev/cu.*
- Close Arduino IDE Serial Monitor before running the app
- Check USB cable connection
- Linux users: Add user to
dialoutgroup:sudo usermod -a -G dialout $USER - Verify Arduino is running
arduino_mq_sensor.ino
app.py- Demo mode with realistic simulated dataapp_usb.py- Real Arduino USB data mode (⭐ NEW)app_ard.py- Legacy Arduino reader (use app_usb.py instead)arduino_mq_sensor.ino- Arduino sketch for MQ-135 sensorair_quality_dashboard.html- Web dashboard UIrequirements.txt- Python dependencies