OpenEnergyMonitor Community

Newbie needs hand-holding

Hi all, thank you in advance for your forbearance.
First - am I right in thinking that all the processes in the ‘Main’ section of the dropdown are ‘log to feed’ style processes - so I only need on of them to initiate a feed?
Next - I am slowly finding my way around the graphing features (only been playing for a day), but can’t find how to generate a simple calculated value to display as text, eg kWh/week, /month, /year. Presumably via the feedvalue widget, which implies a separate feed for each value?
For context, this all needs to end up as an ‘Electricity bill’ broken down daily and monthly for a subset of my system, and I’m logging using ct clips.

Thanks again, I’m sure this is very simple and I’m missing something.


A bit more background of what you’re looking at and what you are trying to do will help to avoid assumptions at this end. Have a look at the first part of the FAQ page.

Hi Robert, and thank you.
I work in a hut at the bottom of my garden, and I have for some time needed a way of monitoring and (crucially) reporting to my accountant and HMRC how much electricity from my domestic supply I am using, so I can recover the cost from my company.
To this end, I’ve just bought and installed an emonpi kit with 2 ct clips, a pulse monitor (irrelevant for this enquiry), and an AC-AC convertor. One ct clip measures the total incoming current, and one measures the the current on the supply to the hut.
I’m getting lovely graphs, and can use straight feeds from the dropdown menu in the process list setup panel for live power and kWh/d, but need to aggregate for weekly, monthly, etc.
At the moment I’m just trying to get this to work on the total power consumption, once that’s done, it should be simple to reproduce it for hut consumption (effectively, simply the other ct clip). I hope this makes more sense.

ETA the x(-1) mod is there because I installed the ct clips upside down and can’t be bothered opening the consumer unit again…

Now everything makes sense. I’m not an emonCMS expert, so you’ll need someone who is to help you.

But I do wonder, given the fact that you are recovering your expenses, whether you would need a guaranteed accurate reading - and for that I’d have recommended a certified meter. There are many available, DIN-rail mounting so might fit inside your consumer unit if there’s space, that are not wildly expensive, and there would be no room for argument from your firm nor HMRC. Many have Modbus so could be read from your emonPi with the addition of a RS485 serial-USB converter. Have you seen this discussion: New build house: improving on clip on CTs

One suggestion that I can make: if you do have a pulse count from your meter, you might like to put both c.t’s on the meter tail (yes, I realise it means taking the C.U. apart again) and calibrate them against the pulses. Then you’ll know the accuracy of your c.t’s.

Robert, thank you! I had considered both having a separate supply installed to the hut, and having an extra meter installed just for the hut supply from the house, but assumed both would mean a load of hassle with the supply co. However, this suggestion makes far more sense. Another rabbit hole…

So, I have done as Robert.Wall suggested - I ordered and installed a SDM120M meter, and connected it via a RS485 serial-USB converter, and pasted the code found at ( into the config file at Setup>EmonHub>Edit Config.
The meter is working fine, but I’m not seeing data in emoncms. At the link above, it is stated that “The SDM120 readings will appear on the Emoncms Inputs page within a few seconds”. However, once I hit Save, and navigate to the Inputs page, the page is unavailable - as if the emonpi is rebooting? When it becomes available, there is no SDM120 entry on the inputs list, which is unsurprising as, upon checking the config file (as before), the SDM120 entry is no longer included.
I’ve been through this 3 times, and swapped the USB socket on the emonpi once.
The line ‘device = /dev/ttyUSB0’ - does it refer to a specific USB port? Or should I be able to use any?
The data setup on the SDM120 is default btw - port 001, 2400 baud, no parity.
Thank you for your help!

I can’t help with that part, sorry, it’s outside my area of expertise.

You probably need @pb66 or @TrystanLea to help you.

I would expect you to be able to use any port, but you must of course refer in the Interfacer set-up to the one you’re using.

Thank you Robert - I think I will make a new topic for this interfacing issue.

Is this an EmonSD/EmonPi install?

Did you restart emonhub after changing the settings?

Can you post some emonhub log from the point of restarting it please?

I note the example config uses device = /dev/ttyUSB0. Is that the right device for your item? It could be on a different USB port.

Hi Brian,
It’s an emonPi install.
I did a variety of things - including restarting emonhub after editing the config file.
I will happily repeat the process and post a chunk of the log, although it doesn’t differ from before the config edit - since the config edit is ‘undone’ by the restart.
I have done only and as closely as possible what is described in the Interfacers Guide.
Differences - my meter is an SDM120M, (although it’'s def RS485), and the RS485 - USB adaptor is a different model.
I do notice that the Interfacer Guide doesn’t specify a node definition. There are a number of node definitions in the config file, but they don’t properly match the nodes appearing on the Inputs page.
I don’t know if I should be providing a node definition for the SDM120M?
rpi can see the RS485 - USB converter - checked via lsusb in terminal(ssh).
device = /dev/ttyUSB0 is correct - verified via dmesg in terminal(ssh).

I haven’t checked RS485 signal is getting to/through the converter - don’t know how to do that…

Did you not save the change?


The log must be different as you should get some log messages about setting up that interfacer.

Well now I have to rewrite that post…

Yes, I had used the Save button, and the Restart button - but in attempting to recreate the issue for screenshots, it appears to have worked correctly.
The first times around, the Save button appeared outlined in red when activated, but the pop-up confirmation window didn’t appear, and I didn’t expect it, this being my first time out. Ho hum.
So, now the log shows
ERROR SDM120 Could not read from SDM120
which I guess is down to the lack of a node definition? (Since it doesn’t appear in the Inputs menu)
Thank you for your forbearance - it’s a steep learning curve for me…

Probably not.

Is log level set to DEBUG? if not do that, restart emonhub and post the initial debug messages.

When posting code or bash output, please put in 3 ‘backticks’ (found at the top left of the keyboard normally) on a line on their own, then the code, then 3 more backticks on a line following the code.


If it is something like php you can add a language identifier that after the first 3 backticks so ```php

Please post a link to the actual RS485/USB device you purchased.

I think this is the chunk you were wanting to see.

2021-01-20 22:05:25,788 INFO     MainThread Exiting hub...
2021-01-20 22:05:25,934 INFO     MainThread Exit completed
2021-01-20 22:05:28,685 INFO     MainThread EmonHub emonHub (emon-pi variant) v2.1.5
2021-01-20 22:05:28,687 INFO     MainThread Opening hub...
2021-01-20 22:05:28,687 INFO     MainThread Logging level set to DEBUG
2021-01-20 22:05:28,688 INFO     MainThread Creating EmonHubJeeInterfacer 'RFM2Pi'
2021-01-20 22:05:28,691 DEBUG    MainThread Opening serial port: /dev/ttyAMA0 @ 38400 bits/s
2021-01-20 22:05:30,704 INFO     MainThread RFM2Pi device firmware version: OK
2021-01-20 22:05:30,704 INFO     MainThread RFM2Pi device current settings:  5 158 253 233 255 135 253 181 92 0 0 0 0 0 0 0 0 0 0 0 0 81 46 0 0 (-0)
2021-01-20 22:05:30,706 INFO     MainThread Setting RFM2Pi baseid: 5 (5i)
2021-01-20 22:05:31,707 INFO     MainThread Setting RFM2Pi frequency: 433 (4b)
2021-01-20 22:05:32,710 INFO     MainThread Setting RFM2Pi group: 210 (210g)
2021-01-20 22:05:33,712 INFO     MainThread Setting RFM2Pi quiet: 1 (1q)
2021-01-20 22:05:34,714 INFO     MainThread Setting RFM2Pi calibration: 230V (1p)
2021-01-20 22:05:35,716 DEBUG    MainThread Setting RFM2Pi pubchannels: ['ToEmonCMS']
2021-01-20 22:05:35,717 DEBUG    MainThread Setting RFM2Pi subchannels: ['ToRFM12']
2021-01-20 22:05:35,719 INFO     MainThread Creating EmonHubMqttInterfacer 'MQTT'
2021-01-20 22:05:35,724 DEBUG    MainThread Setting MQTT pubchannels: ['ToRFM12']
2021-01-20 22:05:35,725 DEBUG    MainThread Setting MQTT subchannels: ['ToEmonCMS']
2021-01-20 22:05:35,726 INFO     MainThread Setting MQTT node_format_enable: 1
2021-01-20 22:05:35,727 INFO     MainThread Setting MQTT nodevar_format_enable: 1
2021-01-20 22:05:35,728 INFO     MainThread Setting MQTT nodevar_format_basetopic: emon/
2021-01-20 22:05:35,729 INFO     MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2021-01-20 22:05:35,731 DEBUG    MainThread Setting emoncmsorg pubchannels: ['ToRFM12']
2021-01-20 22:05:35,732 DEBUG    MainThread Setting emoncmsorg subchannels: ['ToEmonCMS']
2021-01-20 22:05:35,733 WARNING  MainThread Setting emoncmsorg apikey: obscured
2021-01-20 22:05:35,733 INFO     MainThread Setting emoncmsorg url:
2021-01-20 22:05:35,734 INFO     MainThread Setting emoncmsorg senddata: 1
2021-01-20 22:05:35,735 INFO     MainThread Setting emoncmsorg sendstatus: 1
2021-01-20 22:05:35,736 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-20 22:05:35,737 INFO     MainThread Creating EmonHubSDM120Interfacer 'SDM120'
2021-01-20 22:05:35,747 INFO     MainThread Connecting to SDM120 device=/dev/ttyUSB0 baud=2400
2021-01-20 22:05:35,749 INFO     MainThread Setting SDM120 read_interval: 10
2021-01-20 22:05:35,750 INFO     MainThread Setting SDM120 nodename: SDM120
2021-01-20 22:05:35,750 DEBUG    MainThread Setting SDM120 pubchannels: ['ToEmonCMS']
2021-01-20 22:05:35,839 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-20 22:05:35,941 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-20 22:05:36,043 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-20 22:05:36,147 DEBUG    RFM2Pi     1 NEW FRAME : OK 5 155 253 232 255 131 253 174 92 0 0 0 0 0 0 0 0 0 0 0 0 84 46 0 0 (-0)
2021-01-20 22:05:36,149 DEBUG    RFM2Pi     1 Timestamp : 1611180336.147532
2021-01-20 22:05:36,149 DEBUG    RFM2Pi     1 From Node : 5
2021-01-20 22:05:36,149 DEBUG    RFM2Pi     1    Values : [-613, -24, -637, 237.26, 0, 0, 0, 0, 0, 0, 11860]
2021-01-20 22:05:36,150 DEBUG    RFM2Pi     1 Sent to channel(start)' : ToEmonCMS
2021-01-20 22:05:36,150 DEBUG    RFM2Pi     1 Sent to channel(end)' : ToEmonCMS
2021-01-20 22:05:36,230 INFO     MQTT       Connecting to MQTT Server
2021-01-20 22:05:36,252 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-20 22:05:36,333 INFO     MQTT       connection status: Connection successful
2021-01-20 22:05:36,334 DEBUG    MQTT       CONACK => Return code: 0
2021-01-20 22:05:36,338 DEBUG    emoncmsorg Buffer size: 1
2021-01-20 22:05:36,435 INFO     MQTT       on_subscribe
2021-01-20 22:05:40,082 ERROR    SDM120     Could not read from SDM120
2021-01-20 22:05:40,282 DEBUG    RFM2Pi     3 NEW FRAME : OK 5 157 253 232 255 133 253 162 92 0 0 0 0 0 0 0 0 0 0 0 0 86 46 0 0 (-0)
2021-01-20 22:05:40,284 DEBUG    RFM2Pi     3 Timestamp : 1611180340.282116
2021-01-20 22:05:40,285 DEBUG    RFM2Pi     3 From Node : 5
2021-01-20 22:05:40,286 DEBUG    RFM2Pi     3    Values : [-611, -24, -635, 237.14000000000001, 0, 0, 0, 0, 0, 0, 11862]
2021-01-20 22:05:40,286 DEBUG    RFM2Pi     3 Sent to channel(start)' : ToEmonCMS
2021-01-20 22:05:40,287 DEBUG    RFM2Pi     3 Sent to channel(end)' : ToEmonCMS
2021-01-20 22:05:40,357 DEBUG    MQTT       Publishing: emon/emonpi/power1 -611
2021-01-20 22:05:40,359 DEBUG    MQTT       Publishing: emon/emonpi/power2 -24
2021-01-20 22:05:40,360 DEBUG    MQTT       Publishing: emon/emonpi/power1pluspower2 -635
2021-01-20 22:05:40,361 DEBUG    MQTT       Publishing: emon/emonpi/vrms 237.14000000000001
2021-01-20 22:05:40,364 DEBUG    MQTT       Publishing: emon/emonpi/t1 0
2021-01-20 22:05:40,365 DEBUG    MQTT       Publishing: emon/emonpi/t2 0

…and this is the RS485/USB

All looks good except it cannot read any data so I am at the limit of my help. I think @TrystanLea has one of these so he might chip in.

Check obvious things like cables connected correctly etc.

A very brief look at the code suggests that error message wording is a tad misleading.

That error is returned when if self._sdm and self._sdm.connected(): returns false, so the modbus is either not connected or wasn’t created ie “couldn’t connect to” rather than “couldn’t read” semantics maybe, but cannot read suggests some communication has taken place and not had the desired result, either no reply or a bad response for example.

Looking at the code prior to that point there seems to be a hardcoded device address /dev/modbus

which I would have expected it to use the address provided in the conf eg device = /dev/ttyUSB0, the baud seems to be hardcoded to 2400 too, but that is likely to be correct in this instance.

Looking at the logging line immediately before that line

I think that line (L47) was supposed to use the same variables ie

self._sdm = sdm_modbus.SDM120(device, baud)

Are you comfy using ssh and running shell commands? If so could you just try these 2 lines and post the output?

ls -la /dev/modbus
ls -la /dev/{tty{ACM,AMA,S,USB},serial}[0-9] 2>/dev/null

the fist line will tell us if the /dev/modbus address is valid on your setup and the second will show us what serial devices you do have in use, just to check /dev/ttyUSB0 is valid.

1 Like
[email protected]:~ $ ls -la /dev/modbus
ls: cannot access '/dev/modbus': No such file or directory
[email protected]:~ $ ls -la /dev/{tty{ACM,AMA,S,USB},serial}[0-9] 2>/dev/null
lrwxrwxrwx 1 root root          7 Jan 20 17:15  /dev/serial0 -> ttyAMA0
lrwxrwxrwx 1 root root          5 Jan 20 17:15  /dev/serial1 -> ttyS0
crw-rw---- 1 root dialout 204, 64 Jan 20 22:05  /dev/ttyAMA0
crw-rw---- 1 root dialout   4, 64 Jan 20 17:15  /dev/ttyS0
crw-rw---- 1 root dialout 188,  0 Jan 20 18:17  /dev/ttyUSB0

The baud is correct.

I found this spec sheet

One thing to note, it is the M and not the MB version @srt?

Looks like a cut and paste of the define. That has the ‘defaults’ but later should just be

as you say.

Ok good, that output is as I expected. The source code needs fixing, in the interim you could try a symlink as a workaround.

sudo ln -s /dev/ttyUSB0 /dev/modbus

Then restart emonhub as there are no changes to the conf to initiate a rebuild of the SDM120 interfacer.

sudo systemctl restart emonhub.service


1 Like