Open-source Raspberry Pi-based smart energy data logger and sync system using HomeWizard and Cassandra.
A lightweight and modular data collection pipeline for residential electricity consumption and production monitoring using HomeWizard sensors and a Raspberry Pi. Designed to collect, store, and sync data with a central Cassandra database for smart metering and microgrid analysis.
- Collect real-time (1-second interval) energy data from distributed households.
- Perform asynchronous synchronization to a centralized Cassandra database.
- Remotely monitor Raspberry Pis and connected sensors to ensure operational reliability.
- Preserve data privacy and security through a dedicated ULB VPN tunnel.
- π Real-time energy monitoring for both production and consumption using HomeWizard (P1 and kWh 1/3-phase meters).
- π Lightweight deployment on Raspberry Pi (Linux-based).
- πΎ Local buffering of data in CSV format before synchronization.
- ποΈ Scalable, high-throughput ingestion into a Cassandra time series database.
- π‘ Scheduled synchronization from edge devices to the central database.
- π Secure credential handling and encrypted data transport over VPN.
- βοΈ Automated provisioning, configuration, and updates via Ansible.
- π Resilient systemd service for always-on data collection.
- π§ Explore the project structure for detailed file descriptions.
coomep_data_collection.service- systemd service that launches the data collection script on RPi boot
- Depends on VPN and network availability
- Ensures persistent and automatic restart of the service
deploy_env.yml: Sets up required folders on the Raspberry Pi (e.g./opt/coomep)deploy_files.yml: Copies all necessary scripts, credentials, and configs to RPideploy_packages.yml: Installs required system packages and Python dependenciesactivate_services.yml: Enables and starts the systemd service on the RPimonitor_sensors.yml: Monitors disk usage, memory, CPU, and HomeWizard connectivity
vpn_config.yml(not included): This config connects the RPi to ULB's secure VPN- Ensures secure, encrypted data transmission
- Enables access to the remote Cassandra database
- Required to run the service successfully
This project is developed and tested with Python 3.12.
All Python dependencies required for the Raspberry Pi are specified in requirements.txt.
These include packages needed for real-time data collection, local CSV buffering, and communication with HomeWizard sensors.
β These dependencies are automatically installed using the
deploy_packages.ymlAnsible playbook.
No manual installation is required on the Raspberry Pi.
π οΈ The full Python environment setup (including system packages and virtualenv creation)
is handled by thedeploy_packages.ymlscript for consistent and reproducible deployments.
The following additional packages are required on the backend server to enable synchronization with Cassandra:
pandas
cassandra-driver
bcrypt- Runs on Raspberry Pi devices connected to HomeWizard sensors (P1, kWh meter)
- Collected data is stored locally, then synchronized to a central Cassandra database
- Systemd services and Ansible automation help maintain uptime and deployment consistency
- Smart metering of households
- Solar self-consumption analysis
- Microgrid monitoring and simulation
- Academic and applied research in energy forecasting
- Private files such as credentials.json, vpn_config.yml, or user passwords must not be committed to the repository.
- Ensure that your ansible and systemd scripts reference relative paths or environment variables instead of personal file paths.
HW-PiCollector/
βββ credentials.json # Cassandra credentials (not versioned)
βββ users_config.xlsx # Config for all users and installations
βββ requirements.txt # Python dependencies for Raspberry Pi
βββ systemd/
β βββ coomep_data_collection.service # systemd service for automatic data collection
βββ ansible/
β βββ activate_services.yml # Enable & start the systemd service
β βββ deploy_env.yml # Set up folders and initial environment
β βββ deploy_files.yml # Copy code/config to RPi
β βββ deploy_packages.yml # Install system packages & Python deps
β βββ monitor_sensors.yml # Monitor sensor health and system metrics
β βββ vpn_config.yml # ULB VPN config (not included for security)
βββ src/
βββ collect_homewizard_data.py # Main script to collect sensor data (runs on RPi)
βββ config.py # Shared constants (paths, DB info)
βββ py_to_cassandra.py # Functions to interact with Cassandra
βββ sync_homewizard.py # Sync RPi data to Cassandra
βββ utils.py # Helper utilities (logging, parsing, etc.)MIT License β see LICENSE
This project is developed within the context of academic collaboration with UniversitΓ© Libre de Bruxelles (ULB).
π€ Brice Petit
π§ brice[dot]petit[at]ulb[dot]be
π IRIDIA, ULB β Brussels, Belgium