GithubHelp home page GithubHelp logo

remipch / energy_monitor Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.38 MB

Measure and display home electric energy production and consumption

License: MIT License

C++ 27.99% Python 46.23% HTML 21.51% Shell 2.14% CSS 2.13%

energy_monitor's Introduction

Energy Monitor

Goal

Measure and display home electric energy production and consumption.

Smartphone screenshots

Architecture

Architecture

Main steps

  • Arduino :
    • read analog inputs :
      • a0 : specific current measurement
      • a1 : specific current measurement
      • a2 : specific current measurement
      • a3 : specific current measurement
      • a4 : specific current measurement
      • a5 : specific current measurement
      • a6 : main voltage measurement
      • a7 : midpoint measurement
    • compute average active power by multiplying instantaneous measurements of :
      • image of the main voltage given by a voltage transformer
      • image of each current given by current transformers
  • Raspberry :
    • request active power image (in mV.V) via USB serial port from Arduino
    • convert from mV.V to Watt, taking into account :
      • voltage transformer ratio
      • current transformers ratio
      • burden resistors
      • optional calibration
    • log measure data in timestamped files:
      • one file per day, one measure per second
      • one file per day, one measure per minute
    • publish results on a custom web server over Wifi :
      • show graphs in minimal web page
    • allow to download measure data

Folder structure

Source and generated files are in the following hardcoded folder structure :

Folder                  Description
----------------------  ---------------------
arduino/                Runs on Arduino
    rms_measure/        Measure analog inputs and compute active power
raspberry/              Runs on Raspberry
    python/             Tools to record data and serve them on http
    web/                Files required to serve http servers
        data/           Generated CSV files of recorded measures
            seconds/    One line per second
            minutes/    One line per minute
        graphs/         Generated SVG images

Config

This project is duplicated in different rooms to do different measurements :

  • garage
  • buanderie

All parameters of all rooms are centralized in python/configs.py.

The only file that depends on the actual room is raspberry/room, it contains the room name used as a key to get the actual parameter values in config.py.

This file is not archived in the git repository and must be manually added before starting energy_monitor.

Install

Dependencies

pip install numpy==1.22.4
pip install pandas
pip install ftfy
sudo apt-get install libatlas-base-dev

Autostart

If Raspberry Pi has been installed with the default desktop, autostart can be setup by adding the following lines to /etc/xdg/lxsession/LXDE-pi/autostart :

@lxterminal -t web_interface -e bash /home/pi/energy_monitor/raspberry/run_web_interface.sh
@lxterminal -t data_recorder -e bash /home/pi/energy_monitor/raspberry/run_data_recorder.sh

(from https://forums.raspberrypi.com/viewtopic.php?t=294014)

Room

Depending on the actual room :

echo garage > /home/pi/energy_monitor/raspberry/room

or :

echo buanderie > /home/pi/energy_monitor/raspberry/room

Serial protocol

Arduino listen text commands from serial port and print measures as numerical text values.

Currently, the only command used by the program on Raspberry is p (active power measurement), the other commands are kept and documented for manual usage.

Commands and measures are terminated by a new line character.

Arduino also prints some comments (line starting with #).

Custom separator

The default separator is a simple space, it can be changed with this command.

  • Command: s<separator>
  • Command example: s;

Active power

Continuously measure, compute and print active power over the given measure duration.

  • Command: r<period_count>
  • Command example: p50
  • Minimal period count: 1
  • Maximal period count: 500
  • Output example:
# Active power, measure_periods_count: 50
#start_time(ms) end_time(ms) A6(mV) A5(mV.V) A4(mV.V) A3(mV.V) A2(mV.V) A1(mV.V) A0(mV.V) samples_count
1413 2437 1159 274 204 245 234 243 298 969
2453 3457 1159 273 202 244 234 244 200 950
3474 4477 1159 277 207 249 239 248 204 950
4494 5518 1161 223 255 295 283 287 236 969
5534 6558 1161 218 250 290 278 282 231 969
6575 7578 1161 218 249 290 277 282 232 950
7595 8639 1161 217 248 289 277 282 231 988

Note : active power values are given in mV.V because they are measured as the multiplication of two analog input voltages. The conversion to Watt is done on the raspberry side by raspberry/python/data_recorder.py using conversion coefficients defined in raspberry/python/configs.py.

Bufferized voltages

Measure and store unfiltered analog voltages as fast as possible. Print them all when the buffer is full (800 total samples). Optional input_mask parameter allows to select a subset of the 8 analog inputs by passing the decimal value of the mask of inputs to activate (for example 128 activates A7 and 65 activates A0 and A6).

  • Command: b<input_mask>
  • Command example: b5
  • Output example:
# Bufferized input
#time(us) A2(mV) A0(mV)
0 1935 2018
256 2003 2096
512 2082 2209
768 2170 2287
1024 2262 2375
1280 2355 2458
1536 2438 2536
1792 2517 2619
3072 2869 2952
3328 2917 2986
[390 remaining lines]

Unfiltered voltages

Continuously measure and print unfiltered analog voltages.

  • Command: u
  • Output example:
# Unfiltered input
#time(ms) A7(mV) A6(mV) A5(mV) A4(mV) A3(mV) A2(mV) A1(mV) A0(mV)
12120 3347 2624 2502 1715 1285 977 2614 2878
12123 3010 2864 2502 2218 1969 1739 2614 2878
12127 2937 2922 2502 2605 2624 2556 2614 2878
12131 2913 2922 2502 2639 2712 2693 2614 2878
12135 2869 2854 2502 2390 2306 2204 2619 2883
12139 2829 2790 2502 2243 2062 1901 2619 2883
12143 2834 2800 2502 2409 2346 2282 2619 2878
12147 2873 2864 2502 2673 2781 2844 2614 2878
12151 2888 2888 2502 2668 2776 2839 2619 2883

RMS voltages

Continuously measure, compute and print RMS voltages over the given measure duration.

  • Command: r<measure_duration_ms>
  • Command example: r500
  • Minimal measure duration: 40 ms
  • Maximal measure duration: 10000 ms
  • Output example:
# RMS voltage, measure_duration: 500 ms
#start_time(ms) end_time(ms) A6(mV) A5(mV) A4(mV) A3(mV) A2(mV) A1(mV) A0(mV) samples_count
32367 32868 39 351 386 439 498 239 39 288
32871 33372 24 356 386 434 493 239 24 288
33374 33874 24 356 386 439 498 239 24 288
33878 34379 24 356 386 439 498 239 24 289
34382 34882 24 356 386 434 493 239 24 288
34885 35386 24 356 386 434 493 239 24 288
35388 35888 24 356 386 434 493 239 24 287

Stop measure

Any unknown command will stop measure.

Material

Credit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.