Direct connection emonTx V3 > Raspberry Pi GPIO

Sometimes it's more convenient to connect the emonTx V3 directly to a Raspberry Pi base station rather than use RF. 
Both the Raspberry Pi and emonTx V3 run at 3.3V so the serial Rx and Tx serial lines can be directly connected. The raspberrypi's 5V supply can be used to power the emontx which is then stepped down to to 3.3V through the emonTx V3's voltage regulator. 5V is provided by the red wire. The ground connection is the black wire and the data going from the emontx to the raspberrypi is the green wire. I haven't connected a wire for serial data going the other way but this is a possible option if two-way serial is required.

emonTx V3 > Raspberry Pi Connection 

Here's a simple direct serial output sketch for the emontx v3 on GitHub here
On the raspberrypi if you just want to forward the emontx data to a remote emoncms this can be done with the oem_gateway developed by Jerome which is on the standard rock solid forwarder image
See our blog post about how to configure the oem_gateway for work over a serial link rather than RFM12B 

This info was taken from the emonTx wiki and written up after a forum thread

For the future we are working on developing an energy monitoring shield for the Pi to create an all-in-on Pi-energy-monitoring unit, see dev forum thread:

Pebble Smart Watch Emoncms Display & Heating Control - Dev

Smart watches seem to be all the rave at the moment. They could potentially be a convenient way to check your power and temperature feeds, be notified of events and control your heating.

Our friend Ryan Brooks (@spikeheap) has been working on getting Emoncms feeds to display on his Pebble Smart watch as well as making the fist steps towards controlling his RaspberryPi controlled heating from his wrist.

Take it away Ryan>

Ryan's code it all on GitHub if anyone fancies joining the fun. It would be great to get an Emoncms app in the in new Pebble app store. Even if it is just a simple as being able to display a single Emoncms feed this would be pretty cool.

OEM Gateway: Serial Port > Emoncms Link

In the past we have recommended our simple EmoncmsPythonLink to post data to emoncms which is received on a serial port (this could be an Arduino or USB device such a JeeLink plugged into a Raspberry Pi).

The OEM Gateway by Jerome that we use extensively on the Raspberrry Pi to post data received by the RFM12Pi to emoncms can also (easily) be used to post data received an a serial port to emoncms. Using the OEM Gateay to do this rather than the Emoncms Python Link is a much more robust solution with better error logging.

I have recently setup a Raspberry Pi with an Arduino connected to receive RF data from my honey bee hive temperature monitor and post to emoncms. I found using the OEM gateway in conjunction with ino to compile and upload code for the Arduino remotely over ssh directly on the Raspberry Pi to be invaluable for remote bug fixing.

Here's how to use the OEM Gateway to post data to a local or remote emoncms from data received on a serial port:

1. Fist setup the Arduino / JeeLink  to write to the serial port using Serial.print() in the following format 

NodeID val1 val2
NodeID val1 val2

Example for temperature and relative humidity fluctuating around 19°C and 60% posting as node 11

11 19.2 60.1
11 19.5 60.0
11 19.3 60.4
(No restriction on number size and decimal part.)

2. Follow the excellent instruction on Jerome's Github for how to setup the OEM gateway

3. Rename the oemgateway.conf file and edit it as follows adding in your USB port and API keys for local or remote emoncms or both.

# Gateway settings #
# loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
# see here :
loglevel = DEBUG

# Listeners #

# This listener manages the serail
    type = OemGatewaySerialListener
        com_port = /dev/ttyUSB0

# Buffers #

# The two following buffers instantiate the same class, 
# that formats the data for an emoncms instance.
# One sends the data to a local instance, the other one
# to a distant one.
# If active is set to False, the buffer neither records nor sends any data,
# but it holds unsent data until active becomes True.
    type = OemGatewayEmoncmsBuffer
        domain = localhost
        apikey =xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        protocol = http://
        active = False
        path = /emoncms

    type = OemGatewayEmoncmsBuffer
        domain =
        apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        protocol = http://
        active = True
        path = 

4. Start the gateway with instruction to use the config from the config file 

$ ./oemgateway --config-file oemgateway.conf

The instructions on Jerome's Github can be followed to set the oemgateway script to run as a deamon service automatically at startup if required.

emonTH Multiple DS18B20 Sensors

Thanks to Dave McCraw it's now possible to connect multiple DS18B20 digital temperature sensors to the emonTH on the one-wire bus.

Two External DS18B20 temperature sensor + internal DHT22 temp + humidity on emonTH

Multiple DS18B20 sensors can be (optionally) used alongside an internal DHT22 temperature and humidity sensor. Dave's sketch which is now up in the emonTH GitHub repo supports two DS18B20 sensors but can easily be extended to include more.

Dave's multiple sensor sketch requires the unique hardware addresses of the DS18B20 sensors hard-coded in the sketch, the 'emonTH temperature search' utility sketch can be used to discover the addresses.  Hardcoding the hardware addresses guarantees Emoncms inputs won't flip around if you replace or add sensors.

The multiple DS18B20 sketch includes all the low power saving tricks, the sensors are only switch on when required and the ATMega328 goes to sleep in-between readings switching off all unnecessary functions. Obviously running more than one sensor will consume more power but I would still expect battery life to be in the region of 12 months.

Using multiple DS18B20 external temperature sensors on the emonTH as lots of exciting possibilities, a few ideas include:

emonTH main getting started page:

We Won! Daily Post Business Award 2013 - Green Award Category

We have been lucky enough to be awarded winner of the Green Award category in the Daily Post Business Awards 2013. The Daily Post is a regional (North West Wales) newspaper, the Green Award was sponsored this year by Windpower Wales. The award was announced at the end of last year, I resisted posting about it until we got our hands on the video that was made about us.

Trystan being interviewed by Daily Post newspaper, read the article here

Winning the award was very unexpected for us, we feel very humbled. It goes without saying that it would not be possible for us to be doing what we do if it was not for the work of many others. As always with open-source it feels like we are standing on the shoulders of lots of other projects. A big thank you to everyone who has contributed to the project in some way and or bought items from the shop.

Given the nature of an online collaborative project such as OpenEnergyMonitor much of our day-to-day communications and business is conducted online; it's great that what we are doing is being recognised locally. Trystan and I are very proud to be able to live and work in Snowdonia, North Wales. We're both welsh speakers and were brought up locally. Our website has a couple of photos I've taken while out climbing and walking in the Snowdonia mountains as well as an overview of the OpenEnergyMonitor system.

Megni (which means 'monitoring energy' in Welsh) is the name of our business which runs the OpenEnergyMonitor shop. We're keen to make the distinction between Megni and OpenEnergyMonitor since we don't take claim for all OpenEnergyMonitor developments: the .org website, open-source hardware, software and documentation is all separate from the business. Megni is a partnership between Trystan Lea and myself (Glyn Hudson); we now have a couple of friends Ynyr Edwards and Gwil Noble working with us helping with shop fulfillment, support requests and ongoing development.

This award ended 2013 on a high for us, it's been a very exciting few months launching new pre-assembled hardware units and moving into a new office / lab space. Let's hope 2014 is just as awesome! We have lots of exciting plans for this year, high on the list is starting to move into the control of appliances and general polishing of the energy monitoring system.

Here's a short video which was made for the event, it's got some nice shots of the hardware and our new lab:

Tutorial on how to create an emoncms module

I've just created a tutorial that covers the basics of creating a simple custom display module for emoncms that shows a readout of current home power use and how many kwh's have been used today.

The tutorial is up on github here:

What should I expand on in the emoncms module building tutorial next?

Developing for Arduino remotely on a Raspberry Pi

I found myself tonight requiring the ability to develop for Arduino remotely on a Raspberry Pi. The use case is connecting an Arduino Uno to a Raspberry Pi to receive data from my Bee Hive Temperature Monitor setup. The Arduino posts data received from the Bee Monitor as a serial string onto ttyUSB0, EmoncmsPythonLink script is used to post the data to the emoncms server running locally on the Raspberry Pi with the file system on an external hard drive. The Pi also has an RFM12Pi fitted receiving data from an emonTx and a couple of emonTH's

I wanted to be able to access the Arduino, and upload a new sketch to fix bugs etc remotely since I will not always have local access to the system.

I came across a great Arduino command line build environment called inotool

$ sudo apt-get update 
$ sudo apt-get install arduino
$ sudo apt-get install python-dev&&python-setuptools
$ git clone git://
$ cd ino
$ sudo python install

if you want to use ino's built in serial terminal

$ sudo apt-get install picocom

to exit picocom serial [CTRL + A] followed by [CTRL + X]

$ ino init -t blink      # initiates a project using "blink" as a template, copy libraries into 
$ ino build               # compiles the sketch, creating .hex file (default Arduino uno -m atmega328 for duemilanove)
$ ino upload             # uploads the .hex file

The setup works well, opening the port on the router I can now ssh into the Pi and upload new sketches to the Arduino from anywhere on the web,

Emoncms control developments and demo's

First Happy Christmas everyone for yesterday!

One of the things I enjoy about the Christmas period is that you get some nice time to relax and with relaxation comes ideas and energy to try out some new things.

Glyn and I had been talking about control interfaces that could work well on a mobile or tablet and Id been working on a touch enabled dial earlier this month so I thought Id package it up as a emoncms module that sets the control variables in the packetgen module, I've also created a couple of simpler control interface examples using buttons and edit boxes. To try out the following demo's for yourself see the steps at the bottom of the post.

Example 1: Heating On/Off

A simple example using a bootstrap styled html button as our heating on/off button. Clicking the button toggles the state and updates the “packetgen” control packet with the new state.

button off

button on

Example 2: Heating On/Off plus set point

Very similar to the first example but now with a text input for setting the set point temperature for the room/building. The microcontroller on the control node checks the room temperature and turns on and off the heater depending on the setpoint setting it recieves from emoncms.


Example 3: Nest inspired dial

A nest inspired dial interface for setting the setpoint temperature. The set point can be adjusted by spinning the dial wheel with your finger:

heating dial

The dial and page resizes to fit different screen types from widescreen laptop's to mobile phones and tablets and touch can be used to spin the dial.

heating dial mobile

Solar PV Generation

Not really control but developing the idea of custom html/javascript canvas based graphics further.

I've always liked the standard “news & weather” app that came with my android phone. It's a good example of how clean an intuitive graphs can be and how touch can be used to browse temperature/humidity at different times of the day.
This example is a start on creating a graph that looks and behaves in much the same way implemented in canvas.


What you will need to run these examples

You will need your own installation of emoncms to try these out, such as an emoncms + raspberrypi + harddrive setup.

RaspberryPI with harddrive

You will also need the packetgen module (installed as default with the harddrive image):

and the 'development' repository

Copy the folder titled myheating from the development repository to your emoncms/Modules folder. (from development/Modules/control)

You should now be able to load the examples by clicking on the My Heating menu item.

The example does not yet allow for any gui based configuration and so assumes that the control packet structure looks like this:

packet structure

This packet will work with the Arduino electricradiator control node example that can be found here:

Arduino Examples / electricradiator

This sketch could be run on an emontx with jeeplug relay's attached or other rfm12b + arduino + relay type hardware builds.

Coding your own control interface

The code for the simple button example above which may be useful as a foundation for building something else can be found here:

The interface is all in html and javascript jquery and uses bootstrap style buttons it just sends the updated heating state to the packetgen module via ajax.

More posts on controlling things

Glyn's post on controlling his boiler:

The packet generator: