Skip to content

Log your Energy Meter data on a Raspberry Pi and plot graphs of your energy consumption

License

Notifications You must be signed in to change notification settings

samuelphy/energy-meter-logger

Repository files navigation

Energy Meter Logger

Log your Energy Meter data on a Raspberry Pi and plot graphs of your energy consumption. Its been verified to work with a Raspberry Pi with a Linksprite RS485 shield or with generic cheap USB convertor and reading values from WEBIQ131D / SDM120 and WEBIQ343L / SDM630. By changing the meters.yml file and making a corresponding [model].yml file it should be possible to use other modbus enabled models.

Requirements

Hardware

Software

Prerequisite

This project has been documented at Hackster. Please follow the instructions there for more detailed information.

Installation

Install InfluxDB*

Step-by-step instructions
  • Add the InfluxData repository (change the debian release accoring to one you use, below is for buster)
    $ curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
    $ source /etc/os-release
    $ sudo test $VERSION_ID = "10" && echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
  • Download and install
    $ sudo apt-get update && sudo apt-get install influxdb
  • Unmask the influxdb service
    $ sudo systemctl unmask influxdb.service
  • Start the influxdb service
    $ sudo systemctl start influxdb
  • Create the database
    $ influx
    CREATE DATABASE db_meters
    exit

*source

Install Grafana*

Step-by-step instructions
  • Add APT Repository and key
    sudo apt-get install -y apt-transport-https
    sudo apt-get install -y software-properties-common wget
    wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
  • Add Repository to package manager for stable channel
    echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
  • Now install
    $ sudo apt-get update && sudo apt-get install grafana
  • Start the service using systemd:
    $ sudo systemctl daemon-reload
    $ sudo systemctl start grafana-server
    $ systemctl status grafana-server
  • Enable the systemd service so that Grafana starts at boot.
    $ sudo systemctl enable grafana-server.service
    $ sudo service grafana-server start
    $ sudo service grafana-server status
    $ sudo update-rc.d grafana-server defaults
  • Go to http://localhost:3000 and login using admin / admin (remember to change password) *source

Install Energy Meter Logger:

  • Download and install from Github
    $ git clone https://github.com/samuelphy/energy-meter-logger
  • Run setup script (must be executed as root (sudo) if the application needs to be started from rc.local, see below)
    $ cd energy-meter-logger
    $ sudo python setup.py install
  • Make script file executable
    $ chmod 777 read_energy_meter.py
  • Edit meters.yml to match your configuration
  • Test the configuration by running:
    ./read_energy_meter.py
    ./read_energy_meter.py --help # Shows you all available parameters
  • To run the python script at system startup. Add to following lines to the end of /etc/rc.local but before exit:
    # Start Energy Meter Logger
    /home/pi/energy-meter-logger/read_energy_meter.py --interval 60 > /var/log/energy_meter.log &
    Log with potential errors are found in /var/log/energy_meter.log

About

Log your Energy Meter data on a Raspberry Pi and plot graphs of your energy consumption

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages