Skip to content

ekuijpers/energymonitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

scripts for forwarding energy and energy data

1. Functionality

Python scripts collects information about energy and temperature to a Prometheus client, which is forwarded to a prometheus server and Grafana for visualisation and monitoring. The exampe is based on the TPLink HS110 smartplug. This alows for a cost-effective measurement of power usage and temperature monitoring for computers.

smartplug

The script is based on trying a similar monitoring application based on an INA219 monitoring interface in combination with a Raspberry Pi.

sensor

2. Installation

2.1 Libraries

The following python libraries need to be installed:

  • python 2.7: the scripts are based on python 2.7
  • lm-sensors: a package to allow use of computer sensors
$ sudo apt-get install lm-sensors

# Run the mkdev.sh script in the lm-sensors source.

$ sensors-detect
# answer questions 
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +54.0°C  (crit = +103.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +55.0°C  (high = +84.0°C, crit = +100.0°C)
Core 0:         +54.0°C  (high = +84.0°C, crit = +100.0°C)
Core 1:         +53.0°C  (high = +84.0°C, crit = +100.0°C)
Core 2:         +54.0°C  (high = +84.0°C, crit = +100.0°C)
Core 3:         +52.0°C  (high = +84.0°C, crit = +100.0°C)

asus-isa-0000
Adapter: ISA adapter
cpu_fan:     1800 RPM
temp1:        +54.0°C  

2.2 Networking

Configure the HS110 client wireless interface. In Ubunto this can be done using Hidden Wi-Fi network and adding a hotspot. Using netdiscover the network address can be identified.

Depending on the Linux networking configuration the MAC address should be coupled with a fixed ip-adresss. Using the NetworkManager under ubuntu addresses will be generated. The configuration taking into account mac-addresses for the smartplug is ill-defined and requires experimenting.

2.3 Prometheus

Prometheus can be installed in Ubuntu ia the following command:

  sudo apt-get install prometheus
  

To ensure that the daemons are started at boot the following is required:

  sudo systemctl enable prometheus
  
  sudo service prometheus restart
  

The prometheus.yml needs to be updated to include the data provided by the metric.py script.

  scrape_configs:
   - job_name: 'laptop'
    static_configs:
      - targets: ['localhost:9100']
  - job_name: 'energy'
    static_configs:
      - targets: ['localhost:8000']
  
  

2.4 Grafana

Grafana can be installed via:

  sudo apt install grafana
  

The startup daemon needs to be started at boot.

  sudo systemctl enable prometheus
  sudo service prometheus restart
  

##3. Operations

Using metric.py the server is started which makes the power and temperature available.

./metric.py -h
usage: metric.py [-h] -t  (-c  | -j )

TP-Link Wi-Fi Smart Plug Client v0.2

optional arguments:
  -h, --help            show this help message and exit
  -t , --target 
                        Target hostname or IP address
  -c , --command 
                        Preset command to send. Choices are: reset, schedule,
                        antitheft, wlanscan, info, on, off, reboot, countdown,
                        time, cloudinfo, energy
  -j , --json 
                        Full JSON string of command to send

In Grafana the datasources should include prometheus data. The file metric_INA219.py has been developed for the Raspberry Pi monitoring.

DIsplay via Grafana

woensdag, 25. juli 2018 12:33

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages