Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Zephyrus - Smart Air Quality & Safety Monitoring System

Symfony PostgreSQL MQTT License

An intelligent IoT system that monitors air quality and environmental conditions in real-time, featuring live dashboards, threshold alerts, and comprehensive data analytics.

Zephyrus Dashboard

πŸš€ Features

  • Real-time Monitoring: Track temperature, humidity, CO2 levels, and noise in real-time
  • IoT Integration: MQTT-based sensor communication for scalable device management
  • Live Dashboard: Beautiful, responsive dashboard with auto-refreshing charts
  • Smart Alerts: Color-coded status indicators for quick health assessment
  • Data Persistence: PostgreSQL database for historical data analysis
  • Flexible Architecture: Easy to add new sensors and monitoring parameters

πŸ› οΈ Tech Stack

Backend

  • Symfony 8 - Modern PHP framework
  • PostgreSQL 15 - Robust relational database
  • Doctrine ORM - Database abstraction layer
  • PHP 8.2+ - Latest PHP features

IoT Layer

  • Eclipse Mosquitto - MQTT message broker
  • php-mqtt/client - MQTT client library
  • Python 3.x - Sensor simulation

Frontend

  • Chart.js - Interactive data visualization
  • Vanilla JavaScript - No framework overhead
  • Responsive CSS - Mobile-friendly design

DevOps

  • Docker - Containerized MQTT broker
  • Git - Version control

πŸ“‹ Prerequisites

  • PHP 8.2 or higher
  • Composer
  • PostgreSQL 15+
  • Docker
  • Python 3.x (for sensor simulator)
  • Git

πŸ”§ Installation

1. Clone the Repository

git clone https://github.com/SamaD-01/zephyrus.git
cd zephyrus

2. Install Dependencies

cd symfony-api
composer install

3. Configure Environment

Copy the example environment file and configure your database:

cp .env.example .env

Edit .env:

DATABASE_URL="postgresql://YOUR_USER:YOUR_PASSWORD@127.0.0.1:5432/zephyrus?serverVersion=15&charset=utf8"

4. Set Up Database

php bin/console doctrine:database:create
php bin/console doctrine:migrations:migrate

5. Start MQTT Broker

docker-compose up -d

6. Install Python Dependencies

cd iot-simulation
pip install paho-mqtt

πŸš€ Running the Application

You need 3 terminals running simultaneously:

Terminal 1: Symfony Web Server

cd symfony-api
symfony server:start

Access dashboard at: http://127.0.0.1:8000

Terminal 2: MQTT Subscriber

cd symfony-api
php bin/console mqtt:subscribe

Terminal 3: Sensor Simulator

cd iot-simulation
python sensor_simulator.py

Project Structure

zephyrus/
β”œβ”€β”€ symfony-api/              # Symfony backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Command/         # MQTT subscriber command
β”‚   β”‚   β”œβ”€β”€ Controller/      # API & Dashboard controllers
β”‚   β”‚   β”œβ”€β”€ Entity/          # Database entities
β”‚   β”‚   └── Repository/      # Data repositories
β”‚   β”œβ”€β”€ templates/           # Twig templates
β”‚   β”œβ”€β”€ docker-compose.yml   # MQTT broker configuration
β”‚   └── mosquitto.conf       # Mosquitto settings
β”œβ”€β”€ iot-simulation/          # IoT sensor simulator
β”‚   └── sensor_simulator.py  # Python MQTT publisher
└── docs/

πŸ”Œ API Endpoints

Get Latest Readings

GET /api/readings/latest

Response:

[
  {
    "id": 1,
    "deviceId": "simulator-sensor-001",
    "temperature": 22.5,
    "humidity": 45.0,
    "co2": 800,
    "noise": 40.2,
    "timestamp": "2026-01-16 12:30:45"
  }
]

Get Chart Data

GET /api/readings/chart

Response:

{
  "labels": ["12:30:45", "12:30:50", ...],
  "datasets": [...]
}

🎨 Dashboard Features

  • Real-time Cards: Live sensor values with color-coded status

    • 🟒 Green: Normal
    • 🟑 Yellow: Warning
    • πŸ”΄ Red: Critical
  • Charts: Multi-line chart showing all metrics over time

  • Auto-refresh: Updates every 5 seconds

  • Responsive Design: Works on desktop, tablet, and mobile

πŸ§ͺ Testing

Test MQTT Connection

# Subscribe to test topic
docker exec -it zephyrus_mqtt mosquitto_sub -h localhost -t "test/topic"

# Publish test message (in another terminal)
docker exec -it zephyrus_mqtt mosquitto_pub -h localhost -t "test/topic" -m "Hello!"

Test Database Connection

php bin/console dbal:run-sql "SELECT COUNT(*) FROM sensor_reading"

πŸ” Security Considerations

For Production:

  • Change default MQTT credentials
  • Enable MQTT authentication
  • Use HTTPS/WSS for web traffic
  • Implement user authentication
  • Add rate limiting
  • Enable CORS properly
  • Use environment variables for secrets

πŸ› Troubleshooting

MQTT Connection Failed

# Check if container is running
docker ps

# Restart MQTT broker
docker-compose restart mqtt

# Check logs
docker logs zephyrus_mqtt

Database Connection Error

# Verify PostgreSQL is running
# Check DATABASE_URL in .env
php bin/console doctrine:database:create

Charts Not Showing Data

  • Check browser console (F12) for errors
  • Verify API endpoints return data: /api/readings/chart
  • Ensure sensor simulator is running

πŸš€ Future Enhancements

  • Discord/Email alert system
  • Multi-device management panel
  • AI anomaly detection
  • Historical data export (CSV/Excel)
  • Multi-room/location support
  • Mobile app
  • Cloud deployment (AWS/Heroku)
  • Real ESP32 hardware integration

πŸ“– Documentation

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Abdessamad

πŸ™ Acknowledgments

  • Symfony Framework
  • Eclipse Mosquitto
  • Chart.js
  • PostgreSQL Community

⭐ Star this repository if you find it helpful!

About

IOT and Symfony Air Quality Monitor

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages