From the Forum: Using Modbus RS485 to read a SDM630M 3-phase meter

JBecker writes :

I am using a modified OpenEnergyMonitor energy monitoring hardware since more than a year now, with one voltage sensor and three CTs for the current measurement of the three mains phases. This system logs via the RFM12 and a Jeelink USB dongle to Emoncms on a Windows Home Server. This setup is running very reliably with an accuracy of better than ~4% compared to my power meter. I think it would be possible to get better accuracy by using individual voltage sensors on all phases.

In Germany the majority of household have three phase supply. To be able to use three voltage sensors it would be necessary to have three outlets within the distribution (for non-invasive mounting). I have never seen that. This means that you have to ask a friendly electrician to install these outlets. But then the whole thing is not really 'non-invasive' any more (and the OEM solutions becomes quite complex with a lot of cabling). This is a dilemma which is hard to solve.

So I came to another solution which is quite simple and uses mostly ready-made components:

I am using Chinese 3-phase energy monitors since some time for professional purposes (PV-Systems with battery storage). A very nice unit of this type is the Eastron SDM630M. This device has integrated shunts for current measurement, a nice little display and an RS485 interface for data readout with Modbus protocol. A lot of measuring values can be read, including imported and exported energy, phase voltages, currents, frequency, reactive power and so on. Parameters for the RS485 can also be set via four small keys and the display.

For data storage and visualization I decided use the new Emoncms 'low-write' version on a Raspberry Pi. This was installed according to the installation instructions and worked 'out-of-the-box'. The only thing missing on the RasbPi for direct connection to the SDM630 is an RS485 interface.

To be able to use the already existing software for data collection on the RasPi (Emonhub), I simply made a 'clone' of the RFM12Pi module. This now has an RS485 driver onboard instead of the RFM12 RF transceiver. Software on the RS485Pi board is the Opti-bootloader (same as on RFM12Pi) for Arduino compatibility and a small sketch for data readout via modbus. As the only available hardware UART is already used for communication with the RasbPi I had to use a software serial for the RS485 interface. (The 'ModbusMasterSoft' library I use is a dirty hack of the existing ModbusMaster library and the AltSoftSerial library. I found no decent way to make these two work together, so I had to modify them)

So the whole installation now consists of:

- a Raspberry Pi with power supply and the RS485Pi interface board

- the SDM630 energy meter

(- and a cable in between :-))

See forum thread for schematic and code:

A right to build: An open approach to housing provision: self-provision
A right to build is a booklet written by Alaistair Parvin of (00 and Wikihouse), David Saxby, Cristina Cerulli and Tatjana Schneider that outlines a clear and comprehensive vision for how a self-provision approach to housing could be the best way to tackle the UK housing crisis while delivering higher quality, higher performance low energy housing.

Its a deeply inspiring vision of the potential power that empowering, distributive, open ways of doing things, that gives us all agency, to participate in solving problems like climate change can have.

'A right to build' starts by making an observation that we have become accustomed to an assumption that progress in production is the expansion of mass-produced goods, built by professionals and mass-consumed by citizens, a legacy of the industrial revolution, but far from progress the report provides a strong case that the large house builder model has actually resulted in a deterioration in the quality of housing when measured against modern examples of self-provision and self-build.

Driven by a combination of massive house price inflation over the last 40 years and the associated treatment of homes increasingly as financial assets, the incentives for higher quality housing has been sidelined with financial values being pursued over use value.

Who should build?

“The question is not ‘What homes do we need?, but rather ‘Who should build them?’ “ - A right to build.


Self provision of housing is a spectrum of models, the most common characteristic is that the first owners act as the client commissioning their own home. Beyond this there is a varying degree of involvement. From contracting out all of the work or doing a lot of the work yourself (self-build).

Advantages to self-provision:

Self provision fundamentally transforms the kind of houses and neighbourhoods that get built:
  • Designed for long term use-value, higher quality: affordability, generosity, sustainability, flexibility, community. Form of production that is structured around valuing those things.
  • Increased affordability. Overall cost often a third less and can be even less if you use your own 'sweat equity' (do a proportion of the building work yourself).
  • More innovative, more likely to explore more innovate architectural styles and newer and higher performing low energy building materials. More likely to create spaces that lead to further innovation: workshops, garages.
Self-provided housing is intrinsically more capable of delivering better outcomes because the developer is the user.

Removing barriers to participation

“The most challenging, but most crucial aspect of scaling the self-provided housing sector is not just increasing capacity for the current self-providing demographic, but coming up with innovative models which lower the economic threshold for participation.”

It mentions the Walter Segal system for self-build conceived in the 1960s and 1970s which is one historical example of an attempt to do this.
  1. Used an affordable, widely available and easy-to- work with material: timber.
  2. Lowered the skill-threshold for self-builders. With a bit of basic training and common sense, even those who didn’t have mainstream construction skills could put together a Walter Segal house.
Alaistair Parvin and 00's more recent project is wikihouse an open source low energy affordable home construction system that makes use of modern CNC manufacturing methods and self assembly on site. Wikihouse has a growing global community of people developing design's, sharing them openly online and prototyping these housing solutions. Like Walter Segal's system the aim is to lower the economic threshold for participation both by creating an open source self-build system and all the learning resources and collaboration, peer to peer support systems that can come from online open source projects.

Towards the end of the report a very good point is made about the mistaken attitude and opportunity lost that often classifies the professional-citizen relationship:

“Thirdly, by treating citizens only as passive users of a finished commodity provided by professionals, it can actually decrease the usefulness and quality of that commodity (as this booklet has argued in the case of housing) and decrease also the self-reliance and mutual support within communities. Citizens can be treated as passive, rather than active users, and their potential value can be overlooked. As the New Economics Foundation wrote in their 2008 pamphlet on the subject:

“The reason today’s problems seem so intractable is that public services, and technocratic management systems, have become blind to the most valuable resource they possess: their own clients and the neighbourhoods around them. When these assets are ignored or deliberately side-lined, then they atrophy.””

This is arguably one of the key principles of open source which is perhaps one of the clearest definitions of a system that enables this, a phrase commonly found in open source projects is that this project is open for everyone. Its open to everyone to make build, improve, modify, share, learn.

By treating fellow citizens as co-developers, fellow self-providers as equal contributors rather than passive consumers it unlocks this capacity that we all have.

Read the A Right to build here

Alaistair Parvin's TED talk:


Monitoring SolarPV, Heatpump and house electric, EmonTx v2 system upgrade example

Several years ago we did a community energy monitoring project in our local area, Penrhyndeudraeth, North Wales. It involved installing 20 openenergymonitor energy monitors in 20 households and carrying out energy assessment looking at electricity, heating and transport, there is a little more about it and some of the tools we developed here.

The houses that where most engaged in the monitoring part of the project still have those energy monitors installed and yesterday I went to upgrade one of these systems, I thought Id write a blog post on what I did (written half as a guide) as it might be useful for those using older hardware such as the emonTx V2 and its also quite an interesting example of what you can do with the monitoring system.

The upgrade essentially involved replacing a first generation nanode basestation with a RaspberryPI basestation running the latest image and also upgrading the emontx v2 that was in place with new firmware that both does the higher accuracy continuous sampling (developed by Robin Emley) and the watt hour calculation on board.

This particular system is measuring Solar PV generation, household electric consumption and the electrical consumption of a heatpump. It has an EmonGLCD Display running the SolarPV firmware, with the red/green glowing ambient light depending on whether more power is being used than generated or vice versa and the data is also posted to for graphing.

Here's a system diagram:


Upload to the EmonTxV2 the continuous sampling + watt hour firmware: 

The same thing can of course be achieved with an EmonTxV3 but with the added benefit of a fourth channel and only needing the one ACAC Power adapter. If you have the EmonTxV3 upload the continuous sampling + watt hour firmware found here:

Open the SolarPV example:

On lines 68 and 69 change the emontx radio packet defenition from:

    typedef struct { int power1, power2, power3, Vrms; } PayloadTX;
    PayloadTX emontx;


    typedef struct {
        unsigned long msgNumber;
        int heatpump; // heatpump
        int power1; // house power
        int power2; // solar power
        long wh_CT1;
        long wh_CT2;
        long wh_CT3;
    } PayloadTX;
    PayloadTX emontx;

I've named the second variable here heatpump instead of power1 and then powers 1 to 3 because power1 and power2 are used as house power and solar power lower down in the firmware.

RaspberryPI Basestation
I used the latest (28th of July emonSD image) that has EmonHub (thanks to Jerome and Paul Burnell) and emoncms ready to go but without the local emoncms installation enabled, the PI was just used as an EmonHub gateway forwarder to I used the nice pimoroni berryblack raspberrypi case so that the installation was tidy.

Download ready-to-go image: [link updated]

To configure EmonHub to post to, SSH into the raspberrypi and put the PI in read/write mode with:


and then open the emonhub configuration file:

    nano /boot/emonhub.conf

Set the dispatcher url to: and the apikey to your account write apikey.

In order to decode the emontx continuous + watt hour radio packet add a node decoder to the nodes section in the emonhub config file at the bottom:

        Datacodes = L,h,h,h,l,l,l

Secure the pi user by changing the password (the default password is raspberry)


Place the PI back in read only mode:


Emoncms configuration

With the emontx running and the raspberrypi configured as above the inputs will now appear in, but they will be un-named. For this particular installation I named them as in the picture below to correspond to the radio packet format and what I knew I was monitoring on each CT channel.

I then logged each of the power inputs to a fixed interval with averaging (PHPFiwa) feed and used the Wh Accumulator input processor to record the Watt hour totals. The Wh Accumulator checks if the watt hour total has reset and if it does it continues the accumulation from the last point. I used the fixed interval without averaging feed engine for the watt hour feeds.

To make use of the higher accuracy calculating of watt hours on the emontx and the recording of watt hour feeds, there is a slightly different procedure for creating dashboard kwh per day graphs:

Creating a daily electricity consumption graph in a dashboard using watt hour feeds (instead of the old power_to_kwhd method).  

Create a new dashboard and select visualisations > bargraph.

Click on the bargraph and click configure to bring up the configuration dialog. Select the watt hour feed that you want to display daily totals from, enter interval, units, dp, scale and delta=1 as below: (Note that you could change the interval here to any interval: hourly, half day, week etc)

Click save and continue to add any other text and widgets as required. A simple dashboard showing daily consumption and the current power could look like the screenshot below and could be repeated adding a graph for each channel, heatpump, solarpv and house consumption.

Pebble Smart Watch Emoncms Heating Control Demo

This post follows on my post a while back on Emoncms heating control, and links in with my previous post on using Tasker to display Emoncms notifications. For details of the hardware and overview of the heating control setup, see the Emoncms heating control post linked above.

The Pebble is a Bluetooth connected smart watch which works with Apple and android smartphones. Using an e-ink display the Pebble watches achieves a week of battery life. Very impressive from a hardware point of view. I've been using a Pebble with my android phone for the past couple of weeks and found the Pebble to be useful for keeping up with notifications while out out and about and especially for controlling music, navigation directions and activity tracking while out biking, running, driving and even swimming!

The thought occurred to me that the Pebble could potentially be a super convenient way to quickly control my heating. I've got working a simple demo to turn my heating on and off, the could easily be extended to allow setting a set point.

When the Pebble was first released my friend Ryan Brooks put together a demo to display feed data from Emoncms on the pebble. The code for this demo is up on GitHub, however since then things have moved on, Pebble have released SDK 2.0 and launched the pebble app store allowing many applications to be easily loaded onto the Pebble. One of the more powerful applications is Pebble Tasker, when linked with the main Tasker App on an android phone the possibles are endless. See my previous blog post on using Tasker to display Emoncms notification on an android phone. Taking inspiration from Nathan Chantrell's home automation setup using Pebble and Tasker I decided to have a go at directly controlling my heating from my Pebble, here is the result:

Here are the steps to replicate this system:

1. Install Emoncms on a Raspberry Pi and enable RF12 Packetgen Module 

I used the new pre-built SD card image for the low write version of emoncms, downloadable from the link below. This is soon to become our default Raspberry Pi pre-built image once testing is complete

Following the setup guide enable local logging and configure emonHub

The heating control setup requires the emoncms Packetgen module. Follow the steps to enable packetgen to work with emonHub. 
More info on packetgen module can be found:

2. Setup RFM12B receiver and control relay 

To perform the actual control of the boiler you will need to setup an RFM12B receiver node with a relay or similar. The actual hardware setup will depend on what you want to control, a JeeLink or partially populated emonTx V2 work well as a good base for the control hardware. See my previous post on heating control for more info regarding the hardware. The packetgen module will provide an example Arduino sketch to upload. 

3. Install and Configure Tasker on your android Phone

The emoncms API to set a packetgen variable is as follows:


ID is the id of the packetgen variable (they start at 0) and value is the value to be set, the example above will turn the heating on setting variable 4 which in my setup is a boolean control variable to '1'. You can test if this is working by calling the API in your browser.

I've created a Tasker template task which calls the above API which can be downloaded from Github and imported into Tasker, follow instructions on Github Readme. Variables should be self-explanatory.

If a successful response is received from the Emoncms server a 'success' notification is displayed, else a fail notification is activated. 

Home screen Tasker task shortcut widgets can be created on your android home screen to allow Tasker tasks to be easily activated, or profiles can be setup to turn the heating on as you arrive home / leave work or certain times per day. The possibles are endless! Just make sure your system has some hardware fail-safe so you don't get home to a house like a sauna or worse!

If you are setting up Tasker yourself from scratch setup GET requst as follows:

New Task > + new action > net > HTTP GET > enter HTTP API above into host and (optionally) write output to log file 

4. Install & configure Pebble Tasker on the Pebble Watch

To map Tasker tasks to allow easy control from a Pebble 

Other Pebble Tweaks I've found useful

While not directly relevant to heating control here are some further details of my Pebble smartwatch setup: 

  • Using PebbleBits firmware on the pebble to quickly launch pebble apps from the watch face
  • Using Tasker to Stop / Start Strava 
  • Modern Watchface is my favourite watch face (shown in demo above)
  • Music Boss is great for controlling music and starting podcasts while driving or biking
  • NavMe is great for directions on the Pebble while on the bike  
  • Tasker can be used to send commonly sent SMS's and call favourite contacts direct from the Pebble 

Android Tasker & Pebble Smartwatch - Emoncms Notifications

Tasker is a powerful android app which can be used to automate all sorts of things on your phone or tablet.

Using Tasker it's easy to create notifications using data from Emoncms to be triggered by certain events e.g. times of day, location, feed value etc. The possibilities are endless! Once you're done configuring Tasker it's possible to export your setup packaged as an android app to be easily installed on any device.

Using Pebble Notifier (which integrates with Tasker) the notification can be sent to a Pebble Smartwatch. Pebble Tasker can be used to activate the task to trigger the notification directly from the watch.

Here's the Tasker task I used to perform the notification show above, I have setup Tasker profile to activate this notification whenever I get home and at the end of the day at 11pm.  

I have uploaded a generic version of this Tasker task to GitHub, follow the instruction on the GitHub Readme to import into Tasker. 

How CT Sensors are Made...

Ever wondered how CT sensors are made? I've just been sent these photos of inside the YHDC factory, here we can see the CT windings being wound: 

Reducing emoncms write load and a minimal python version of emoncms

Over the last few weeks I have been investigating how to reduce the write load of emoncms to explore if it might be possible to achieve long term logging on SD cards.

A brief summary

Through a mix of buffered writing of feed data to disk, reduction of the number of meta and average data files written to and use of the FAT filesystem, my home raspberrypi now has a write load of 0.4kb_wrtn/s down from 197kb_wrtn/s.. almost 500x less and the writes are all append only (there's no regular writing of the same part of a file again and again). The question is could this mean years of SD card logging rather than months?

Write buffering

A single Emoncms PHPFina (PHP Fixed Interval No averaging) or PHPTimeSeries datapoint uses between 4 and 9 bytes. The write load on the disk however is a bit more complicated than that. Most filesystems and disk's have a minimum IO size that is much larger than 4-9 bytes, on a FAT filesystem the minimum IO size is 512 bytes this means that if you try and write 4 bytes the operation will actually cause 512 bytes of write load. But its not just the datafile that gets written to, every file has inode meta data which can also result in a further 512 bytes of write load. A single 4 byte write can therefore cause 1kb of write load.

By buffering writes for as long as we can in memory and then writing in larger blocks its possible to reduce the write load significantly. The full investigation with a lot of benchmarking of different configurations including differences between FAT and Ext4 can be found here:

A minimal version of emoncms in python

To make the investigation easier I simplified emoncms down to the core parts needed on a raspberrypi to get basic timeseries graphing: serial listener, node decoder, basic feed engine and a ui consisting of a nodelist and a single rawdata visualisation type and wrote the result in python making use of Jerome and Paul's (pb66) excellent work on the emonhub serial listener and node decoder.
Here's a diagram of the main components of the python app:

And some screenshots of what it looks like:

Node list:

Basic graphing:

The source code and an installation guide for this minimal python version of emoncms can be found here:

Further development questions (copied from the end of the write load investigation page)

Is the reduced write load and longer SD card lifespan that might result from using the FAT filesystem worth the increased chance of data corruption from power failure that Ext4 might prevent?

It would be interesting to compare the performance of the FAT filesystem + 5 min application based commit time with the EXT4 filesystem with Journaling turned off and filesystem delayed allocation set to 5 min instead of write buffering in the application.

I posted on the EmonHub issues list about this last friday and I've been having a bit of a discussion there with Paul

I've also posted this on the forum's here:

emonGLCD V2 SMT Development

For sometime now the emonGLCD has been lagging behind other OpenEnergyMonitor hardware units in terms of development, we're still selling it only in thru-hole DIY kit form.

We've been thinking about updating it to SMT pre-assembled for some time, however we've been dragged our heels somewhat since there has been thoughts that maybe a smartphone app could fill the same function. However I believe a physical LCD display unit fulfils a slightly different role to a smartphone app. I believe in certain circumstances there is certainly value to having an always-on low power LCD display located in a prominent location displaying current power consumption and or generation.

I have found the emonGLCD with the ambient indication tri-colour LED's to be a really useful easy-to-read indication of solar PV import / export at any given time.

Doing a quick Google search shows that there are lots of emonGLCD being used and customized for all sorts of purposes we could not even have though of! For example: heat pump monitor, temperature measurements, electric car charge rate etc.

With this in mind, we have decided to make an SMT version of the emonGLCD keeping the design largely the same (same LCD panel size and same controller chip ST7565). This will mean the current emonGLCD firmware sketches should run on the new unit with little or no modifications.

I would be interested to heard your thoughts on what you would like in a new version of the emonGLCD?

Over the past few weeks I've made a start to get a prototype, here is the main design criteria and features so far:
  • ST7565 128 x 64 LCD panel with integrated RGB backlight, specifically this Vatronix unit (to replace the LED's on the current version)
  • Single front facing rotary encoder with push-to-select (to replace the three push buttons the the current)
  • Option for lithium battery pack with USB battery charging circuit and battery voltage monitor
  • Arduino compatiable ATmega328 with RFM12B / RFM1269CW
  • Option for on-board DS18B20 and DHT22 temperature and humidity sensors 
Using SMT assembly and lower cost LCD unit and enclosure we should be able to reduce the price of the emonGLCD compared to the current version.

Yesterday I sent off for the first prototype PCB revision:

Testing the new LCD panel with built in RGB backlight
These images and more can be viewed in higher resolution in the emonGLCD V2 SMT Development album on G+, I will be periodically updating this album with development photos as things develop!


The enclosure is an important part of the emonGLCD design considerations. We plan to move to a 'proper' custom made enclosure for the new emonGLCD. These are the main options available:

1.) 3D printed (for small volumes and prototyping, not really possible for 500+ per production run)
2.) layered laser cut plywood or acrylic (like the Pimoroni Raspberry Pi cases)
3.) Injection molded plastic

I'm specifically interested in exploring if/how an enclosure could be made with lowest embodied energy and maximum recyclability.
We have not yet made much progress on case design nor have we got a designer or manufacturer in mind. If you would like to work with us please get in touch. Equally if you have some ideas on enclosure design I look forward to hearing.

Please use the the emonGLCD V2 SMT forum thread for comments and discussion: 

Emoncms time-series feed engine documentation

I've been working over the last few days on writing documentation on how the emoncms time-series feed engines work (phpfiwa, phpfina and phptimeseries). The documentation is an early draft at this stage and I would very much welcome comments.

    Emoncms time series database development history
    Variable interval time series
    Fixed interval time series
    Fixed interval with averaging time series

On a related note out of an interest in creating a version of emoncms that will run and log to SD cards without wearing them out so fast I've started to look at how the write load created by the emoncms feed engines can be reduced through in memory buffering and writing in larger blocks to disk, initial testing suggests that it could be reduced by potentially more than a 1000x on systems with 30+ feeds, maybe several 100x on systems with only a few feeds.

See forum post:

emonPi Raspberry Pi Energy Monitoring Shield - Prototype Dev Update

For a while now I have been working on developing a Raspberry Pi energy monitoring shield. Here is a preview of the first prototype design.

The emonPi is not designed to totally replace the emonTx V3, but rather to complement it. I see the emonPi fulfilling two applications:

1. As a low cost Raspberry Pi add-on shield to make all-in-one home energy monitoring unit based on the Raspberry Pi.  We will produce a version of the emonPi board on it's own (without enclosure, HDD and LCD), maybe even with just SMT components ready assembled (like the Arduino Lenoardo) to being the cost down further.

2. As a high quality, robust and nicely enclosed stand-alone energy monitoring unit and web-connected base station with LCD status display, built in hard-drive for local logging and backup. The emonPi has also been designed to be perfect for installers of heat-pump monitoring systems which require many temperature sensor wired up (see temperature sensing part of my forum post update) as well as power monitoring.

The emonPi has got an option for RFM12B / RFM69CW radio to enable it also to act as an emonBase, receiving date from other wireless nodes such as emonTH (room temperature and humidity node), emonTx V3 (energy monitoring node) and transmitting the current time to the emonGLCD LCD display.

Since the emonPi is an energy monitor sensing node and remote posting base station all-in-one and coupled with a status LCD this should make system setup, installation and debugging easier. The emonPi should also be great for remote administration since with the correct network config the Raspberry Pi can be accessed remotely, log files checked and even upload Arduino sketch firmware onto the emonPi's ATmega328.

Development has been documented in an ongoing open forum thread:

My latest update post can be viewed here:

emonPi - Raspberry Pi Energy Monitoring Shield Prototype 

emon Pi Features 

  • Two channel CT monitoring with AC sample input 
  • Ability to power the Raspberry Pi and an external HDD without the need for an additional USB hub, emonPi can also function without a HDD
  • RJ45 DS18B20 on-wire temperature bus to allow many temperature sensors to easily be added using a RJ45 breakout board for heatpump monitoring applications 
  • PWM and IRW I/O's on RJ45 
  • Status LCD
  • Compatible with RaspberryPi model A and model B 
  • Option for RFM12B / RFM69CW with SMA antenna to receive or transmit data from other sensor nodes
  • OOK (on-off keying) transmitter footprint for controlling remote plugs etc. 
  • ATmega328 with ability to remotely upload sketches vis Raspberry Pi Serial 
  • Open-source hardware, firmware and software 
  • High quality custom made, wall mountable enclosure

End-plate silkscreen draft:

See G+ album for more photos:

 LCD demo:

Please join in the emonPi's open-development forum thread if you have any ideas of thoughts to contribute:

The disadvantages of the emonPi compared to the current emonTx V3 are:

  • Only two CT channels, no (approximate) 3-phase
  • Due to higher power requirements of the Pi, the emonPi can't be powered from batteries, 5V DC USB mini-B is required. 
  • Again, due to higher power requirements of the Pi, the emonPi can't be powered from an AC-AC adapter, for real power a 5V DC and 9V AC adapter will both be required. 
  • Requires wifi connectivity or Ethernet to reach the location where the utility meter is located
  • Larger enclosure than the emonTx V3