No description
Find a file
Finn Christiansen c554194fb5
All checks were successful
/ Python-PEP8 (push) Successful in 12s
💚 Fix PEP8 warnings
2024-10-11 22:31:28 +02:00
.forgejo/workflows 👷 Add Forgejo workflow 2024-10-11 22:23:47 +02:00
app 💚 Fix PEP8 warnings 2024-10-11 22:31:28 +02:00
migrations 💚 Fix PEP8 warnings 2024-10-11 22:31:28 +02:00
screenshots Updates! InfluxDB and .env support 2024-10-08 22:04:32 +02:00
.env.example 🔐 add EnvironmentFile to systemd service 2024-10-08 22:15:04 +02:00
.gitignore 💚 Fix PEP8 warnings 2024-10-11 22:31:28 +02:00
apache2_sample_config.conf Publish first version 2021-01-24 13:58:29 +01:00
config.py Publish first version 2021-01-24 13:58:29 +01:00
grafana.json Add Grafana dashboard 2024-10-11 22:06:52 +02:00
LICENSE Initial commit 2021-01-24 13:29:39 +01:00
powermeter.py 💚 Fix PEP8 warnings 2024-10-11 22:31:28 +02:00
powermeter.service 🔐 add EnvironmentFile to systemd service 2024-10-08 22:15:04 +02:00
powermeter.wsgi don't need to insert that path 2021-01-24 17:47:58 +01:00
README.md 📝 update Readme 2024-10-11 22:05:39 +02:00
requirements.txt Publish first version 2021-01-24 13:58:29 +01:00

powermeter

A simple Pyhton script to mesaure you electricity consumption using the LED on a electricity meter and a digital light sensor.

You either can use InfluxDB to store the data or a built in Flask application.

Hardware setup

Connect the light sensor to your Pi:

VCC: 5V
DATA: GPIO 27
GND: GND

Software setup

  • Copy the .env.example to /etc/powermeter-environment and change it to your needs.
  • Acivate at least InfluxDB (which I would recommend) or Flask output.

Clone this repository, configure .env file, setup systemd service:

git clone https://code.f2n.me/finn/powermeter.git
cd powermeter
cp .env.example /etc/powermeter-environment
cp powermeter.service /etc/systemd/system/powermeter.service
systemctl enable powermeter
systemctl start powermeter

For Flask app also to the following steps:

virtualenv .
pip install -r requirements.txt
cp apache2_sample_config.conf /etc/apache2/sites-available/powermeter.conf # modifiy to fit your needs
a2ensite powermeter
systemctl reload apache2

Developing (Flask app)

For developing run this (you need to create database and user first):

export FLASK_ENV=development
export APP_DEVELOPMENT_DATABASE_URI=postgres://username:passwort@hostname/database
flask run

Future thoughts

  • build container for flask app
  • Microcontroller edition
  • and more

Screenshots

Node-RED usage example:

Node-RED Dashboard

Grafana Dashboard example (InfluxDB datasource):

Grafana Dashboard