Home Energy Monitor
I recently received my open energy monitor package. I unwrapped an EmonTX module, a base station module and the EmonTH plus some accessories.
After connecting everything and setting up the Raspberry Pi the system was running without any problems.
A big thank you to the guys at OpenEnergyMonitor for an easy to use and hackable product.
The only issue I had was that the Raspian was outdated. Raspbian Stretch (Debian 9) had been just recently released. I decided to give it a try and setup the energy monitor on a stock Raspian Stretch image. This also allowed me to re-configure the emon software to the parts that I actually needed.
The goal was to get to a clean setup with Raspian Stretch, node-red, influxdb and grafana.
Let’s get started
Raspian
Download and install the Lite version of Raspian to a micro SD card. I used an 8 GB card, but the bigger the better.
Use raspi-config to enable SSH and enable the serial hardware. Make sure the serial console is disabled.
Install influxdb
For the time series database we install the Debian version of influxdb, client and server packages.
Install NodeJS
We want to use the LTS version of nodejs. Install like this from nodesource:
|
|
We also install some other required packages such as the python library to controll the GPIO pins of the pi.
Node-red
Now that we have nodejs running we can use npm to install node-red:
|
|
The npm install of node-red does not come with service start and stop scripts. The corresponding scripts can be installed by fetching them from https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/. Run the follwing commands with sudo or as root.
|
|
grafana
There is no grafana package included in raspian yet. So we install an unofficial ARM package. Check out https://bintray.com/fg2it/deb/grafana-on-raspberry/v4.5.2 for details.
|
|
then run dpkg to install the downloaded .deb file.
In case the grafana service is not starting automatically at system boot, you can enable and launch the server with the following command sequence:
|
|
emonhub
Now to the most interesting part. To get the system process messages sent from the various probes we need to install emonhub. Emonhub interprets data from the 433 MHz receiver and publishes the sensor messages to MQTT queues.
|
|
It is recommended to turn off persistence in mosquitto. Edit the mosquitto.conf file and set “persistence” setting to false. Also define the location of the password file. Here is my complete mosquitto.conf
file.
|
|
We need to create a user and password for mosquitto. This account will be used by emonhub to connect to mosquitto.
|
|
Then, to install the emonhub we clone the package from git and run the installer blindly:
|
|
One important change I had to make was to configure the serial port correctly. This took some time to find out. The default port /dev/ttyAMA0
was not working. To change the port edit /home/pi/data/emonhub.conf
and change com_port = /dev/ttyAMA0
to com_port = /dev/ttyS0
. At the same time configure in the MQTT section the username and password used to connect to mosquitto.
|
|
I also made sure that emonhub is not publishing any data to emoncms.org.
|
|
After saving the config file restart the emonhub service.
Switch on your sensors and monitor the emonhub log file. You should see your sensor messages appear.
Time for Sauna
Once all was working I placed the temperature and humidity sensor in the sauna and fired up the sauna stove.
Outlook
We will take a look at how to get the data via MQTT - node-red to influxdb for visualisation in grafana in a future post. Also left behind is how to secure the different web interfaces using nginx as a frontend server.
Links
https://openenergymonitor.org/
https://github.com/openenergymonitor/emonhub.git
https://www.raspberrypi.org/downloads/raspbian/
https://grafana.com/