A collection of scripts that will be used for monitoring a DIY powerwall
Many thanks to AJW22 for the initial code of getting the data from the cheap chinese BMS
Thanks to this tutorial
- Turn bluetooth on and scan the nearby devices
sudo bluetoothctl
agent on
default-agent
scan on
SQLite installation
sudo apt-get install sqlite3 git python3-venv
Create the database powerwall
sqlite3 powerwall
-
Identify the BMS and connect to it It ends with xiaoxiang BMS
pair [device Bluetooth address]
-
Turn scanning off
scan off
-
You might also want to connect to it by
connect [device Bluetooth address]
-
To exit from the bluetooth interface type
quit
A docker setup is configured to setup a grafana instance as well as a MySQL instance to save the collected data
Once the db instance is up and running, connect to it, create a user on the database that can write data from the pi and grant the user all privileges on the default database
Connect via the container docker exec -t <db-instance> /bin/bash
or from the host mysql -h localhost -P 9033 --protocol=tcp -u root -p
create user 'youruser'@'%' identified by 'your-password';
grant all privileges on powerwall.* to 'youruser'@'%';
-
Clone the code
git clone https://github.com/badili/diy_powerwall_monitoring.git
-
Create a virtual environment using python3.7 The Raspberry Pi OS comes with python 2 and python 3.7 already installed If python3.7 is not installed, install it. Installation steps are out of scope of this documentation
cd diy_powerwall_monitoring
python3.7 -m venv env
- Activate the virtual environment
source env/bin/activate
- Modify the requirements.txt file appropriately. If you are using PostgreSQL make sure to remove the comment tag
- Modify the config file appropriately. A sample config file
demo_config.cfg
has been provided - Install the pre-requisite modules
pip install -r requirements.txt
- xxx