emonPi is an open-hardware energy monitoring solution based on the Raspberry Pi. It was originally launched as a Kickstarter around April last year and raised almost £25,000 with a £15,000 goal. It comes in different flavours, from board only to fully assembled device with custom aluminium enclosure. I have the board only, and will be using it in a combination with a Raspberry Pi Zero rather than the suggested Raspberry Pi 3. The less energy the monitor consumes, the better, right?


If you want to know more about the emonPi solution, have a look at their Kickstarter video:



Let's set it up and start measuring the power consumption!




For initial testing, I set up the bare board on top of the electricity meters, allowing measurements where the wires enter the fuse box. I'll be moving house in July, so I'll foresee a nicer setup then



Before investigating where, how and actually connecting the clamp, turn OFF the power! Do not work while the conductors are LIVE! If you don't know what you're doing, ASK someone who does!


To retain double insulation, make sure anything leaving the fuse box is sleeved!



On the picture on the left, is the emonPi board controlled by a Raspberry Pi Zero which is mounted under it! The whole things is powered by a mini USB cable providing 5V. Remote connectivity is achieved using a wifi dongle connected to the Pi Zero's USB OTG port.


On the second picture, in the middle, is the clamp used to measure the power consumption. A so-called "CT current sensor". The sensor acts as an inductor and responds to the magnetic field of the conductor it is clamped to, making it possible to calculate how much current is passing through that conductor.


On the third picture, on the right, the protection panel of the fuse box has been restored while foreseeing an exit for the sensor's connection to emonPi. In the final setup, emonPi will be mounted on the wall next to the fuse box (in the new house).




The software side of thing is rather straightforward, as a Raspbian Jessie Lite image with all the emonPi software included is available for download.




The image offers a lot of software preconfigured and activated. Perhaps a little bit too much. That's why I disabled a number of software components and kept a minimum in order to still be able to fetch the actual power measurements, while not unnecessarily exposing unused interfaces.


By default, the filesystem is set to read-only. This is explained by a message when connecting via SSH:


The file system is in Read Only (RO) mode. If you need to make changes,
use the command 'rpi-rw' to put the file system in Read Write (RW) mode.
Use 'rpi-ro' to return to RO mode. The /home/pi/data directory is always in RW mode.


To make changes, such as disabling certain services, the system needs to be set to "read-write".


pi@emonpi:~ $ rpi-rw

Filesystem is unlocked - Write access
type ' rpi-ro ' to lock


The different, undesired services can be disabled. What it boils down to, is that I'd like to keep the MQTT broker to be able to subscribe to the measurement data, and the emonHub which is doing the actual decoding of the data. The rest is useful when using emonPi as a standalone device, but less so in my case, where all data is gathered to a central point.


pi@emonpi:~ $ sudo systemctl disable openhab.service
pi@emonpi:~ $ sudo systemctl disable nodered.service
pi@emonpi:~ $ sudo systemctl disable emonPiLCD.service
pi@emonpi:~ $ sudo systemctl disable apache2.service


Once finished, set the filesystem back to "read-only".


pi@emonpi:~ $ rpi-ro

Filesystem is locked - Read Only access
type ' rpi-rw ' to unloc





The measurement data from emonPi is exposed via MQTT, by default, the following settings apply:


  • URL: tcp://<emonpi>:1883
  • User: emonpi
  • Password: emonpimqtt2016
  • QoS: 2
  • Retain: false


I'd recommend you change the default credentials to more secure ones, using:


pi@emonpi:~ $ mosquitto_passwd

mosquitto_passwd is a tool for managing password files for mosquitto.

Usage: mosquitto_passwd [-c | -D] passwordfile username
       mosquitto_passwd -b passwordfile username password
       mosquitto_passwd -U passwordfile
 -b : run in batch mode to allow passing passwords on the command line.
 -c : create a new password file. This will overwrite existing files.
 -D : delete the username rather than adding/updating its password.
 -U : update a plain text password file to use hashed passwords.

See http://mosquitto.org/ for more information.



The MQTT setup for my project looks like this:

Screen Shot 2016-06-18 at 20.54.43.png


By configuring the MQTT settings from earlier in OpenHAB and subscribing to the correct topics, the measurements are available on the central control unit.


# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.

# Optional. User id to authenticate with the broker.

# Optional. Password to authenticate with the broker.

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.


The items are defined to use OpenHAB's MQTT binding, which connects to the configured broker and receives the data from the subscribed topics.


Number  emonpi_ct1      "Power 1 [%d W]" <energy>    { mqtt="<[emonpi:emon/emonpi/power1:state:default]" }
Number  emonpi_ct2      "Power 2 [%d W]" <energy>    { mqtt="<[emonpi:emon/emonpi/power2:state:default]" }


The result is power data from up to two current clamps available on the central interface.



Once persistence will be added, and the data graphed over time, patterns in power consumption will emerge.


This data will be useful for different things, such as:

  • Knowing how much power is consumed at what time. Over time, consumption could be improved!
  • Trigger alarms/notification should consumption exceed threshold while away (on holiday).




Navigate to the next or previous post using the arrows.