8000 GitHub - grilloandrea6/energy_monitoring_stallaini
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

grilloandrea6/energy_monitoring_stallaini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Energy Monitoring Stallaini

This repository contains the code and documentation for the Energy Monitoring Stallaini project.

The first-goal is to provide a system to monitor, remotely-control, and automate the energy system in Stal 8797 laini.

A long-term goal would be to have a system that can be generalized and used in other contexts.

Table of Contents

Stallaini Energy System

The energy system in Stallaini is an off-grid photovoltaic system based on a Studer system with a Pylontech battery. It is composed of the following components:

  • 9x 260 Wp solar panels
  • 2x Pylontech US5000 batteries
  • Studer XTM 4000-48 Inverter
  • Studer VarioTrack 65A MPPT
  • Studer RCC-02 Remote Control
  • Studer Xcom-CAN interface
  • Petrol generator (backup)

Main loads

  • Main water pump - extracting water from the well. 2,2kW meaning around 50A at 48V
  • Water heater - 1,5kW
  • Kitchen and oven - up to 2kW
  • Other appliances - secondary water pump (from the tank to the house), fridge, lights, irrigation pump, etc.

Features

The system interacts with the user using a Telegram bot, which has the following functions:

  • Authenticate users with a password.
  • Get the current status of the battery and the energy system.
  • Get the statistics for several time spans:
    • Last 3 hours
    • Last 2 days
    • Last month

Example of the statistics plot for the last 2 days: Example of the statistics plot for the last month (whole month data still not available):

IT Architecture

A Raspberry Pi 4 is connected to the Studer system and the battery through a CAN bus.

The Raspberry Pi 4 is connected to the internet using a 4G modem with limited connection traffic (200MB/month). Therefore, the system is designed to minimize the data usage for the local Pi.

To be able to access remotely the Raspberry Pi even behind a mobile network (using CGNAT), the Pi is connected to a VPN server. A Wireguard VPN is used.

Both the VPN server and the Telegram Bot are hosted on another Raspberry Pi, that is connected to the internet without traffic limitation, and is provided with a public IP. In the future, the server might be migrated to a cloud service.

The local Raspberry Pi runs a Python script that reads data from the CAN bus and sends it to the server through a simple API developed in python with very optimized data usage. The data is sent once every minute, which provides a good tradeoff between granularity for monitoring and data usage.

The following data is sent:

  • Battery voltage
  • Battery state of charge
  • Battery state of health
  • Battery current (provides general information about energy produced - energy consumed)
  • Battery temperature
  • Charge voltage - voltage at which the battery can be charged
  • Charge and discharge current limits

The server stores the data in a SQLite3 database. The data is then used to provide a Telegram bot that can be used to monitor the system. The bot is protected with a password that is set in the configuration file. The bot provides current status and statistics for the last 3 hours, 2 days, and month to the users. The statistics are provided in the form of plots generated using the matplotlib library.

Configuration and Usage

To use the system you need the following components:

  • Computer Connected to the CAN bus together with the Studer system and the battery. In this case I used a Raspberry Pi 4 with a MCP2515 as a CAN to SPI converter.
  • A server to host the API and the Telegram bot. Without the internet connection limitation this can be hosted on the same machine connected to the energy system. My instance is currently hosted on another Raspberry Pi.

The steps to configure the system are the following:

  • Create the Telegram Bot - use the BotFather to generate API keys for a bot. Save the API key in the server/config.py file together with the password that will be used to authenticate users to the bot.
  • Configure services using provided files:
    • server/service_files/stallaini-server.service - systemd service to run the API server.
    • server/service_files/telegram-bot.service - systemd service to run the Telegram bot.
    • local-client/service_files/stallaini_client.service - systemd service to run the Python client.

ToDo

  • Get data from the Studer system (data about inverter status, MPPT status, etc.).
  • Send notifications for logged users for events (battery alarm, battery low, heavy load on for too much time, etc.).
  • Improve granularity of consumption management (add power meters for main loads).
  • Add weather data to the system (e.g. solar irradiation).
  • Add a clearer schema to the docs, section Stallaini Energy System.
  • Start working on automation features (automatic management of well pump and water heater).
  • Migrate the server to a cloud service.
  • Save authenticated users in the database.
  • Remove hardcoded data in the repo and create an installation script (move service files to the right place and enable them).
  • Save data locally when connection is not available.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0