Skip to content

HW-PiCollector is a lightweight and modular data collection system for residential energy monitoring. It leverages HomeWizard devices (P1 and kWh 1/3-phase meters) connected to a Raspberry Pi, collecting electricity consumption and production data in real-time.

License

Notifications You must be signed in to change notification settings

BricePetit/HW-PiCollector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ HW-PiCollector

Open-source Raspberry Pi-based smart energy data logger and sync system using HomeWizard and Cassandra.

Python License Platform Database

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.


🎯 Objective

  • 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.

πŸ“¦ Features

  • 🏠 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.

πŸ”Œ Component Overview

πŸ–₯️ System Services

  • 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

πŸ› οΈ Ansible Deployment Scripts

  • 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 RPi
  • deploy_packages.yml: Installs required system packages and Python dependencies
  • activate_services.yml: Enables and starts the systemd service on the RPi
  • monitor_sensors.yml: Monitors disk usage, memory, CPU, and HomeWizard connectivity

πŸ” Secure VPN Connection

  • 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

πŸ’Ό Dependencies

🐍 Python Version

This project is developed and tested with Python 3.12.

πŸ“ Raspberry Pi Environment

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.yml Ansible playbook.
No manual installation is required on the Raspberry Pi.

πŸ› οΈ The full Python environment setup (including system packages and virtualenv creation)
is handled by the deploy_packages.yml script for consistent and reproducible deployments.

πŸ—„οΈ Backend (Cassandra Synchronization)

The following additional packages are required on the backend server to enable synchronization with Cassandra:

pandas
cassandra-driver
bcrypt

☁️ Deployment Context

  • 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

πŸ’‘ Applications

  • Smart metering of households
  • Solar self-consumption analysis
  • Microgrid monitoring and simulation
  • Academic and applied research in energy forecasting

πŸ”’ Security Notice

  • 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.

πŸ“ Project Structure

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.)

πŸ“ƒ License

MIT License β€” see LICENSE


🀝 Acknowledgments

This project is developed within the context of academic collaboration with UniversitΓ© Libre de Bruxelles (ULB).


πŸ“§ Contact

πŸ‘€ Brice Petit

πŸ“§ brice[dot]petit[at]ulb[dot]be

πŸ“ IRIDIA, ULB β€” Brussels, Belgium

About

HW-PiCollector is a lightweight and modular data collection system for residential energy monitoring. It leverages HomeWizard devices (P1 and kWh 1/3-phase meters) connected to a Raspberry Pi, collecting electricity consumption and production data in real-time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages