A production-grade embedded sensor data acquisition and processing framework for IoT systems. Supports multi-sensor fusion, real-time filtering, MQTT/HTTP telemetry, OTA firmware updates, and a live monitoring dashboard β all in Python.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Dashboard (Web UI) β
β Real-time charts & alerts β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β WebSocket / REST
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Middleware Layer β
β ββββββββββββ ββββββββββββ βββββββββββββ β
β β MQTT β β HTTP β β Data β β
β β Broker β β REST API β β Logger β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Processing Core β
β ββββββββββββ ββββββββββββ βββββββββββββ β
β β Kalman β β Sensor β β Anomaly β β
β β Filter β β Fusion β β Detector β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Hardware Abstraction β
β βββββββ βββββββββ βββββββ ββββββββ βββββββββββ β
β βBME280β βMPU6050β βADS β βGPS β βUltrasonicβ β
β βT/H/P β βIMU β β1115 β βNEO-6Mβ βHC-SR04 β β
β βββββββ βββββββββ βββββββ ββββββββ βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
IΒ²C SPI UART GPIO
| Category | Feature | Description |
|---|---|---|
| Sensors | 8+ drivers | BME280, MPU6050, ADS1115, GPS NEO-6M, HC-SR04, DHT22, BH1750, INA219 |
| Processing | Kalman filter | Adaptive noise estimation with configurable process/measurement noise |
| Processing | Sensor fusion | Multi-sensor weighted fusion with confidence scoring |
| Processing | Anomaly detection | Z-score & sliding window anomaly detection with alerts |
| Protocols | MQTT 3.1.1/5.0 | Async publish/subscribe with QoS levels, TLS support |
| Protocols | HTTP REST | RESTful API for sensor data retrieval and configuration |
| Protocols | Modbus RTU | Industrial protocol support for legacy equipment |
| Middleware | Data logger | SQLite + CSV + JSON logging with rotation and compression |
| Middleware | OTA updates | Over-the-air firmware update mechanism |
| Middleware | Watchdog | Hardware/software watchdog with auto-recovery |
| Dashboard | Web UI | Real-time monitoring with charts, alerts, and system health |
| Testing | 50+ tests | Unit, integration, and hardware simulation tests |
embedded-sensor-system/
βββ src/
β βββ drivers/ # Hardware sensor drivers
β β βββ base_sensor.py # Abstract sensor interface
β β βββ bme280.py # Temperature/Humidity/Pressure
β β βββ mpu6050.py # 6-axis IMU (Accel + Gyro)
β β βββ ads1115.py # 16-bit ADC
β β βββ gps_neo6m.py # GPS receiver
β β βββ hcsr04.py # Ultrasonic distance
β β βββ dht22.py # Temperature/Humidity
β β βββ bh1750.py # Ambient light
β β βββ ina219.py # Current/Power monitor
β βββ core/ # Signal processing engine
β β βββ kalman_filter.py # Kalman filter implementation
β β βββ sensor_fusion.py # Multi-sensor data fusion
β β βββ anomaly_detector.py # Anomaly detection engine
β β βββ pid_controller.py # PID control loop
β β βββ ring_buffer.py # Lock-free circular buffer
β βββ protocols/ # Communication protocols
β β βββ mqtt_client.py # MQTT pub/sub client
β β βββ http_api.py # REST API server
β β βββ modbus_rtu.py # Modbus RTU master/slave
β βββ middleware/ # System services
β β βββ data_logger.py # Multi-format data logging
β β βββ ota_updater.py # OTA firmware updates
β β βββ watchdog.py # System watchdog
β β βββ config_manager.py # YAML/JSON configuration
β β βββ event_bus.py # Pub/sub event system
β βββ utils/ # Utilities
β βββ fixed_point.py # Fixed-point math (no FPU)
β βββ crc.py # CRC-8/16/32 checksums
β βββ bitfield.py # Register bit manipulation
β βββ retry.py # Retry with backoff
βββ tests/ # Test suite
βββ examples/ # Usage examples
βββ configs/ # Configuration files
βββ dashboard/ # Web monitoring UI
βββ scripts/ # Deployment scripts
βββ docs/ # Documentation
βββ .github/workflows/ # CI/CD
βββ requirements.txt
βββ setup.py
βββ README.md
git clone https://github.com/Hayder-IRAQ/embedded-sensor-system.git
cd embedded-sensor-system
pip install -r requirements.txt
pip install -e .from src.drivers.bme280 import BME280
from src.core.kalman_filter import KalmanFilter
# Initialize sensor on I2C bus
sensor = BME280(bus_id=1, address=0x76)
# Apply Kalman filtering for noise reduction
kf = KalmanFilter(process_noise=0.01, measurement_noise=0.1)
while True:
reading = sensor.read()
filtered = kf.update(reading.temperature)
print(f"Temp: {filtered:.2f}Β°C | Humidity: {reading.humidity:.1f}%")from src.core.sensor_fusion import SensorFusion
from src.drivers.bme280 import BME280
from src.drivers.dht22 import DHT22
fusion = SensorFusion(strategy="weighted_average")
fusion.add_source("bme280", weight=0.7, sensor=BME280(bus_id=1))
fusion.add_source("dht22", weight=0.3, sensor=DHT22(pin=4))
result = fusion.read("temperature")
print(f"Fused temp: {result.value:.2f}Β°C (confidence: {result.confidence:.0%})")from src.protocols.mqtt_client import MQTTClient
from src.drivers.bme280 import BME280
mqtt = MQTTClient(broker="mqtt.example.com", port=8883, tls=True)
sensor = BME280(bus_id=1)
async def publish_telemetry():
await mqtt.connect()
while True:
data = sensor.read()
await mqtt.publish("sensors/env", data.to_json(), qos=1)
await asyncio.sleep(5)python -m pytest tests/ -v --tb=shortLaunch the real-time monitoring dashboard:
python dashboard/app.py
# Open http://localhost:8050# configs/system.yaml
system:
name: "weather-station-01"
sample_rate_hz: 10
log_level: INFO
sensors:
bme280:
bus: 1
address: 0x76
oversample: 16
mpu6050:
bus: 1
address: 0x68
accel_range: "4g"
gyro_range: "500dps"
processing:
kalman:
process_noise: 0.01
measurement_noise: 0.1
anomaly:
method: "zscore"
threshold: 3.0
window_size: 100
telemetry:
mqtt:
broker: "mqtt.example.com"
port: 8883
tls: true
topic_prefix: "iot/sensors"
qos: 1| Platform | Status | Notes |
|---|---|---|
| Raspberry Pi 4/5 | β Full support | Primary development target |
| Raspberry Pi Pico W | β MicroPython | Via MicroPython compatibility layer |
| ESP32 | β MicroPython | WiFi + BLE capable |
| BeagleBone Black | β Full support | Industrial-grade |
| Jetson Nano | β Full support | GPU-accelerated processing |
| Desktop (Simulated) | β Full support | For development and testing |
See CONTRIBUTING.md for guidelines.
MIT License β see LICENSE for details.