🌿 Professional IoT MQTT Server Platform designed for microcontrollers and edge computing.
Ornidia is a production-ready MQTT broker built with hbmqtt and FastAPI, specifically designed for IoT applications supporting:
- ESP32 - Full featured WiFi microcontroller
- ESP8266 - Low-cost WiFi module
- Arduino - Classic microcontroller platform
- Raspberry Pi 3/4 - Single-board computer
✅ Professional MQTT Broker
- Full MQTT 3.1.1 protocol support
- Topic-based publish/subscribe messaging
- QoS levels 0, 1, and 2
- Persistent message storage
- WebSocket support for browser clients
✅ REST API
- Real-time broker management
- Client connection statistics
- Topic subscription monitoring
- Message publishing
- System metrics and health checks
✅ Enterprise-Grade Infrastructure
- Comprehensive logging system
- Configuration management
- Graceful shutdown
- Docker containerization
- Database persistence (SQLAlchemy)
✅ IoT Ready
- Example client implementations for all supported devices
- Pre-configured authentication
- Topic hierarchy best practices
- Payload validation
- Python 3.8+
- pip package manager
- Virtual environment support
- Clone and navigate to project:
cd /path/to/ServidorMQTT- Create virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp .env.example .env
# Edit .env with your settings- Start the server:
python src/main.pyThe server will start both:
- 🔌 MQTT Broker on
0.0.0.0:1883 - 📊 REST API on
0.0.0.0:8000
ServidorMQTT/
├── src/
│ ├── broker/ # MQTT Server core
│ ├── config/ # Configuration & logging
│ ├── api/ # FastAPI REST endpoints
│ ├── database/ # Data models
│ ├── utils/ # Validators & helpers
│ └── main.py # Entry point
├── tests/ # Test suites & examples
├── docs/ # Documentation
└── docker/ # Container setup
See ARCHITECTURE.md for detailed information.
MQTT Settings:
MQTT_HOST- Broker address (default: 0.0.0.0)MQTT_PORT- Broker port (default: 1883)MQTT_MAX_CONNECTIONS- Maximum simultaneous connectionsMQTT_WS_ENABLED- Enable WebSocket support (default: true)MQTT_WS_PORT- WebSocket port (default: 8081)
API Settings:
API_HOST- API addressAPI_PORT- API port (default: 8000)API_RELOAD- Auto-reload on code changes (dev only)
General:
ENVIRONMENT- development | productionLOG_LEVEL- DEBUG | INFO | WARNING | ERRORDEBUG- Enable debug mode
See .env.example for complete list.
GET /healthGET /api/broker/stats # Get broker statistics
POST /api/broker/start # Start broker
POST /api/broker/stop # Stop brokerGET /api/clients # List all clients
GET /api/clients/{id} # Get client details
DELETE /api/clients/{id} # Disconnect clientGET /api/topics # List all topics
GET /api/topics/{name} # Get topic subscribersGET /api/metrics # Get performance metrics
GET /api/version # Get version info
GET /api/config # Get configurationFull OpenAPI documentation available at: /api/docs
// See: tests/fixtures/client_scripts/esp32.ino
// Configure WiFi and MQTT settings
// Upload to ESP32 Dev ModuleKey features:
- WiFi connectivity management
- JSON sensor payloads
- Command subscriptions
- Automatic reconnection
# See: tests/fixtures/client_scripts/raspberry_pi.py
python tests/fixtures/client_scripts/raspberry_pi.pyKey features:
- DHT22 sensor integration
- GPIO control
- Threaded publishing
- Graceful shutdown
See CLIENT_SETUP.md for detailed setup guides.
pytest tests/ -vpytest tests/ -v --integration- Start the server
- Configure client with broker IP/port
- Upload firmware to device
- Monitor via REST API:
curl http://localhost:8000/api/clientspython src/main.pydocker-compose -f docker/docker-compose.yml up- Set
ENVIRONMENT=production - Configure firewall rules
- Set secure
SECRET_KEY - Use reverse proxy (nginx)
- Enable SSL/TLS
See DEPLOYMENT.md for detailed instructions.
Recommended topic structure for IoT applications:
ornidia/
├── sensors/
│ ├── temperature
│ ├── humidity
│ └── pressure
├── devices/
│ ├── esp32_001/
│ │ ├── status
│ │ ├── command
│ │ └── telemetry
│ ├── rpi_001/
│ │ ├── status
│ │ └── command
│ └── arduino_001/
│ ├── status
│ └── command
└── system/
├── broker/status
└── broker/stats
✅ Security
- Change default credentials
- Enable authentication
- Use strong passwords
- Monitor connections
✅ Performance
- Use QoS 1 for most use cases
- Implement client-side reconnection logic
- Monitor active connections
- Set appropriate message intervals
✅ Scalability
- Separate sensor topics by location/type
- Use topic wildcards for subscriptions
- Monitor broker metrics
- Plan for load balancing
✅ Development
- Use meaningful client IDs
- Implement error handling
- Log important events
- Version your configurations
curl http://localhost:8000/api/broker/stats | jqcurl http://localhost:8000/api/clients | jqcurl http://localhost:8000/api/topics | jqcurl http://localhost:8000/api/metrics | jq- Check port availability:
lsof -i :1883 - Review logs:
tail -f logs/mqtt_server.log - Verify configuration in
.env
- Confirm broker is running
- Check firewall rules
- Verify client credentials
- Review client logs
- Monitor active connections
- Check message frequency
- Review broker metrics
- Consider message filtering
Contributions welcome! Please:
- Follow PEP8 style guidelines
- Add tests for new features
- Update documentation
- Create pull requests
MIT License - See LICENSE file
- 📖 Documentation:
docs/ - 🐛 Bug reports: GitHub Issues
- 💬 Questions: GitHub Discussions
- Cluster/Federation support
- Advanced authentication (OAuth2)
- Message filtering
- Admin web dashboard
- Performance tuning for 1M+ connections
- Kubernetes deployment guide
v1.0.0 (Initial Release)
- Core MQTT broker implementation
- REST API for management
- Example clients for all platforms
- Docker support
🌿 Built with ❤️ for IoT Applications | Ornidia Development Team