Reading from a SDM120 meter using EmonHub

Ah, that’s better, thank you.
A little bit further forward…

2021-01-22 18:45:01,562 INFO     MainThread Exiting hub...
2021-01-22 18:45:07,412 DEBUG    SDM120     []
2021-01-22 18:45:07,513 INFO     MainThread Exit completed
2021-01-22 18:45:09,029 INFO     MainThread EmonHub emonHub (emon-pi variant) v2.1.5
2021-01-22 18:45:09,030 INFO     MainThread Opening hub...
2021-01-22 18:45:09,030 INFO     MainThread Logging level set to DEBUG
2021-01-22 18:45:09,031 INFO     MainThread Creating EmonHubJeeInterfacer 'RFM2Pi'
2021-01-22 18:45:09,032 DEBUG    MainThread Opening serial port: /dev/ttyAMA0 @ 38400 bits/s
2021-01-22 18:45:11,045 INFO     MainThread RFM2Pi device firmware version: OK
2021-01-22 18:45:11,046 INFO     MainThread RFM2Pi device current settings:  5 232 245 155 255 131 245 182 90 0 0 0 0 0 0 0 0 0 0 0 0 42 1 2 0 (-0)
2021-01-22 18:45:11,047 INFO     MainThread Setting RFM2Pi baseid: 5 (5i)
2021-01-22 18:45:12,049 INFO     MainThread Setting RFM2Pi frequency: 433 (4b)
2021-01-22 18:45:13,051 INFO     MainThread Setting RFM2Pi group: 210 (210g)
2021-01-22 18:45:14,054 INFO     MainThread Setting RFM2Pi quiet: 1 (1q)
2021-01-22 18:45:15,056 INFO     MainThread Setting RFM2Pi calibration: 230V (1p)
2021-01-22 18:45:16,058 DEBUG    MainThread Setting RFM2Pi pubchannels: ['ToEmonCMS']
2021-01-22 18:45:16,059 DEBUG    MainThread Setting RFM2Pi subchannels: ['ToRFM12']
2021-01-22 18:45:16,061 INFO     MainThread Creating EmonHubMqttInterfacer 'MQTT'
2021-01-22 18:45:16,065 DEBUG    MainThread Setting MQTT pubchannels: ['ToRFM12']
2021-01-22 18:45:16,067 DEBUG    MainThread Setting MQTT subchannels: ['ToEmonCMS']
2021-01-22 18:45:16,068 INFO     MainThread Setting MQTT node_format_enable: 1
2021-01-22 18:45:16,069 INFO     MainThread Setting MQTT nodevar_format_enable: 1
2021-01-22 18:45:16,070 INFO     MainThread Setting MQTT nodevar_format_basetopic: emon/
2021-01-22 18:45:16,073 INFO     MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2021-01-22 18:45:16,081 DEBUG    MainThread Setting emoncmsorg pubchannels: ['ToRFM12']
2021-01-22 18:45:16,082 DEBUG    MainThread Setting emoncmsorg subchannels: ['ToEmonCMS']
2021-01-22 18:45:16,083 WARNING  MainThread Setting emoncmsorg apikey: obscured
2021-01-22 18:45:16,083 INFO     MainThread Setting emoncmsorg url: https://emoncms.org
2021-01-22 18:45:16,084 INFO     MainThread Setting emoncmsorg senddata: 1
2021-01-22 18:45:16,085 INFO     MainThread Setting emoncmsorg sendstatus: 1
2021-01-22 18:45:16,079 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-22 18:45:16,088 INFO     MainThread Creating EmonHubSDM120Interfacer 'SDM120'
2021-01-22 18:45:16,097 INFO     MainThread Connecting to SDM120 device=/dev/ttyUSB0 baud=2400
2021-01-22 18:45:16,099 INFO     MainThread Setting SDM120 read_interval: 10
2021-01-22 18:45:16,099 INFO     MainThread Setting SDM120 nodename: sdm120
2021-01-22 18:45:16,100 INFO     MainThread Setting SDM120 prefix: 
2021-01-22 18:45:16,100 INFO     MainThread Setting SDM120 datafields: total_demand_current,maximum_total_demand_current,total_energy_active,total_energy_reactive
2021-01-22 18:45:16,101 INFO     MainThread Setting SDM120 names: total_demand_current,maximum_total_demand_current,total_energy_active,total_energy_reactive
2021-01-22 18:45:16,101 INFO     MainThread Setting SDM120 precision: 3,3,3,3
2021-01-22 18:45:16,101 DEBUG    MainThread Setting SDM120 pubchannels: ['ToEmonCMS']
2021-01-22 18:45:16,190 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-22 18:45:16,293 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-22 18:45:16,397 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-22 18:45:16,505 DEBUG    RFM2Pi     1 NEW FRAME : OK 5 209 245 155 255 108 245 172 90 0 0 0 0 0 0 0 0 0 0 0 0 53 1 2 0 (-0)
2021-01-22 18:45:16,508 DEBUG    RFM2Pi     1 Timestamp : 1611341116.505266
2021-01-22 18:45:16,509 DEBUG    RFM2Pi     1 From Node : 5
2021-01-22 18:45:16,509 DEBUG    RFM2Pi     1    Values : [-2607, -101, -2708, 232.12, 0, 0, 0, 0, 0, 0, 131381]
2021-01-22 18:45:16,510 DEBUG    RFM2Pi     1 Sent to channel(start)' : ToEmonCMS
2021-01-22 18:45:16,510 DEBUG    RFM2Pi     1 Sent to channel(end)' : ToEmonCMS
2021-01-22 18:45:16,574 INFO     MQTT       Connecting to MQTT Server
2021-01-22 18:45:16,614 DEBUG    RFM2Pi     device settings updated: E i5 g210 @ 433 MHz q1 USA 0
2021-01-22 18:45:16,679 INFO     MQTT       connection status: Connection successful
2021-01-22 18:45:16,680 DEBUG    MQTT       CONACK => Return code: 0
2021-01-22 18:45:16,688 DEBUG    emoncmsorg Buffer size: 1
2021-01-22 18:45:16,783 INFO     MQTT       on_subscribe
2021-01-22 18:45:20,544 DEBUG    RFM2Pi     3 NEW FRAME : OK 5 216 245 155 255 115 245 179 90 0 0 0 0 0 0 0 0 0 0 0 0 65 1 2 0 (-0)
2021-01-22 18:45:20,547 DEBUG    RFM2Pi     3 Timestamp : 1611341120.544605
2021-01-22 18:45:20,548 DEBUG    RFM2Pi     3 From Node : 5
2021-01-22 18:45:20,548 DEBUG    RFM2Pi     3    Values : [-2600, -101, -2701, 232.19, 0, 0, 0, 0, 0, 0, 131393]
2021-01-22 18:45:20,549 DEBUG    RFM2Pi     3 Sent to channel(start)' : ToEmonCMS
2021-01-22 18:45:20,550 DEBUG    RFM2Pi     3 Sent to channel(end)' : ToEmonCMS
2021-01-22 18:45:20,706 DEBUG    MQTT       Publishing: emon/emonpi/power1 -2600
2021-01-22 18:45:20,708 DEBUG    MQTT       Publishing: emon/emonpi/power2 -101
2021-01-22 18:45:20,709 DEBUG    MQTT       Publishing: emon/emonpi/power1pluspower2 -2701
2021-01-22 18:45:20,711 DEBUG    MQTT       Publishing: emon/emonpi/vrms 232.19
2021-01-22 18:45:20,712 DEBUG    MQTT       Publishing: emon/emonpi/t1 0
2021-01-22 18:45:20,714 DEBUG    MQTT       Publishing: emon/emonpi/t2 0
2021-01-22 18:45:20,716 DEBUG    MQTT       Publishing: emon/emonpi/t3 0
2021-01-22 18:45:20,717 DEBUG    MQTT       Publishing: emon/emonpi/t4 0
2021-01-22 18:45:20,719 DEBUG    MQTT       Publishing: emon/emonpi/t5 0
2021-01-22 18:45:20,721 DEBUG    MQTT       Publishing: emon/emonpi/t6 0
2021-01-22 18:45:20,722 DEBUG    MQTT       Publishing: emon/emonpi/pulsecount 131393
2021-01-22 18:45:20,724 INFO     MQTT       Publishing 'node' formatted msg
2021-01-22 18:45:20,725 DEBUG    MQTT       Publishing: emonhub/rx/5/values -2600,-101,-2701,232.19,0,0,0,0,0,0,131393
2021-01-22 18:45:25,577 DEBUG    RFM2Pi     4 NEW FRAME : OK 5 208 245 155 255 107 245 165 90 0 0 0 0 0 0 0 0 0 0 0 0 76 1 2 0 (-0)
2021-01-22 18:45:25,579 DEBUG    RFM2Pi     4 Timestamp : 1611341125.577614
2021-01-22 18:45:25,580 DEBUG    RFM2Pi     4 From Node : 5
2021-01-22 18:45:25,580 DEBUG    RFM2Pi     4    Values : [-2608, -101, -2709, 232.05, 0, 0, 0, 0, 0, 0, 131404]
2021-01-22 18:45:25,581 DEBUG    RFM2Pi     4 Sent to channel(start)' : ToEmonCMS
2021-01-22 18:45:25,581 DEBUG    RFM2Pi     4 Sent to channel(end)' : ToEmonCMS
2021-01-22 18:45:25,673 DEBUG    MQTT       Publishing: emon/emonpi/power1 -2608
2021-01-22 18:45:25,674 DEBUG    MQTT       Publishing: emon/emonpi/power2 -101
2021-01-22 18:45:25,676 DEBUG    MQTT       Publishing: emon/emonpi/power1pluspower2 -2709
2021-01-22 18:45:25,677 DEBUG    MQTT       Publishing: emon/emonpi/vrms 232.05
2021-01-22 18:45:25,679 DEBUG    MQTT       Publishing: emon/emonpi/t1 0
2021-01-22 18:45:25,680 DEBUG    MQTT       Publishing: emon/emonpi/t2 0
2021-01-22 18:45:25,681 DEBUG    MQTT       Publishing: emon/emonpi/t3 0
2021-01-22 18:45:25,683 DEBUG    MQTT       Publishing: emon/emonpi/t4 0
2021-01-22 18:45:25,684 DEBUG    MQTT       Publishing: emon/emonpi/t5 0
2021-01-22 18:45:25,686 DEBUG    MQTT       Publishing: emon/emonpi/t6 0
2021-01-22 18:45:25,687 DEBUG    MQTT       Publishing: emon/emonpi/pulsecount 131404
2021-01-22 18:45:25,688 INFO     MQTT       Publishing 'node' formatted msg
2021-01-22 18:45:25,689 DEBUG    MQTT       Publishing: emonhub/rx/5/values -2608,-101,-2709,232.05,0,0,0,0,0,0,131404
2021-01-22 18:45:27,394 ERROR    SDM120     Error parsing data: 'str' object cannot be interpreted as an integer
2021-01-22 18:45:30,520 DEBUG    RFM2Pi     6 NEW FRAME : OK 5 206 245 156 255 106 245 219 90 0 0 0 0 0 0 0 0 0 0 0 0 88 1 2 0 (-0)
2021-01-22 18:45:30,523 DEBUG    RFM2Pi     6 Timestamp : 1611341130.520433
2021-01-22 18:45:30,524 DEBUG    RFM2Pi     6 From Node : 5
2021-01-22 18:45:30,524 DEBUG    RFM2Pi     6    Values : [-2610, -100, -2710, 232.59, 0, 0, 0, 0, 0, 0, 131416]
2021-01-22 18:45:30,525 DEBUG    RFM2Pi     6 Sent to channel(start)' : ToEmonCMS
2021-01-22 18:45:30,526 DEBUG    RFM2Pi     6 Sent to channel(end)' : ToEmonCMS
2021-01-22 18:45:30,751 DEBUG    MQTT     

thanks @srt, could you try updating again, i’ve made a couple of minor changes.

git pull origin sdm120_datafield_config

That seems to have done the trick.
Under ‘Inputs’ we now have a menu named sdm120, with 4 inputs, total_demand_current, maximum_total_demand_current, total_energy_active, & total_energy_reactive.
They all have data. I’m assuming all will be straightforward from here - thank you both very much for all your help with this.

1 Like

Personally I think rs485 is pretty robust, I always tend to use Cat5e cable and have not had any troubles, even on very long runs with multiple devices, so I doubt a 0.5m run of 2-core will be an issue and I do not connect ground wires either. There are competing beliefs on this point, for and against, some of my devices don’t even have a 3rd “ground” terminal.

Although the diagram does only show 2 (albeit screened) cores it does show not only one but 2 termination resistors, however, many rs485 adapters (but not all) do have one inbuilt, sometimes with a switch or link. All my adapters do have one inbuilt termination resister but I have never noticed a benefit when introducing a second one, so even this requirement I take with a pinch of salt.

But, although I believe the rs485 networks to be pretty forgiving, flexible and robust, I am aware that I may be just sitting pretty, in the safe zones and may need to implement changes one day under some circumstance. So when debugging I do tend to try these things, if for no other reason than to confirm my interpretation of the “rules” isn’t the issue.

I think you still have a little way to go if you are unable to get basic values such as “voltage” and “current” etc, I have yet to find a modbus energy meter that doesn’t report those values, let alone a sdm120, I have 2 and Trystan has one, all three do “voltage” and all the manuals and guide I can find for the sdm120, all show “voltage” is reported regardless of any other differences.

Now you have some values, try adding “voltage” to the datafields entry in emonhub.conf to see if that works now.

I’m bordering on thinking this is a library issue, if for no other reason than it seems incomplete. It should return something under all circumstances, if there’s an error it should say so, when something is done there should be a positive indication eg data, or at least a message. Modbus is 2way comms, there is no scenario where the device will not respond (to the master ie the sdm_modbud code), if it timesout or doesn’t respond that is an issue that sdm_modbus must relay to the user.

Great, out of interest, where did you buy the SDM120? Is it an Eastron original? Seems a shame not to have the real time power, power factor etc that mine reads…

It might require what @pb66 suggests to get at the other reads, Id be interested to hear if you get any more results if you did decided to investigate that further.

Can you expand?

Are you saying they are for different spec’d sdm120’s? What are the differences you’ve spotted? Would seeing pic’s of Sean and Trystan’s meters reveal anything or perhaps the serial numbers etc?

That way we can compare to mine.

I noticed this in the Spec

image

As long as it is the M then it is probably the same - just exploring all possibilities.

It is likely something subtle has changed inside the device. Can the FW be updated?

ok, so I edited the config thus:

        datafields = total_demand_current,maximum_total_demand_current,total_energy_active,total_energy_reactive,voltage
        names = total_demand_current,maximum_total_demand_current,total_energy_active,total_energy_reactive,voltage
        precision = 3,3,3,3,3

and restarted emonhub. It’s still only reading and reporting 4 values:

2021-01-23 11:27:17,394 DEBUG    SDM120     3 From Node : sdm120
2021-01-23 11:27:17,394 DEBUG    SDM120     3    Values : [0.379, 12.039, 6.238, 6.366]
2021-01-23 11:27:17,395 DEBUG    SDM120     3 Sent to channel(start)' : ToEmonCMS
2021-01-23 11:27:17,396 DEBUG    SDM120     3 Sent to channel(end)' : ToEmonCMS
2021-01-23 11:27:17,616 DEBUG    MQTT       Publishing: emon/sdm120/total_demand_current 0.379
2021-01-23 11:27:17,618 DEBUG    MQTT       Publishing: emon/sdm120/maximum_total_demand_current 12.039
2021-01-23 11:27:17,619 DEBUG    MQTT       Publishing: emon/sdm120/total_energy_active 6.238
2021-01-23 11:27:17,621 DEBUG    MQTT       Publishing: emon/sdm120/total_energy_reactive 6.366
2021-01-23 11:27:17,622 INFO     MQTT       Publishing 'node' formatted msg
2021-01-23 11:27:17,623 DEBUG    MQTT       Publishing: emonhub/rx/sdm120/values 0.379,12.039,6.238,6.366

I’m very happy to investigate further - it’ll no doubt be of use to someone else at some point.
The SDM120M is an Eastron original as far as I can ascertain - properly boxed in a sealed, branded box, with paperwork inside, as well as terminal caps. Although I did buy it off ebay…

Ok, thanks for testing. I perceive that as an issue, at least until I know that your device is not supposed to report anything other than the 4 values you see.

Does your paperwork confirm voltage? Do you have “Camscanner” app? Could you attach copies of your included paperwork (photo’s if you cannot scan to pdf but they are harder to read) and maybe a photo of the device perhaps?

That’s great, I hope Trystan will take you up on that as an sdm120 interfacer should really read all data from all sdm120 meters.

I will try to put together a minimalmodbus script to read an sdm120 and test it on mine when I can. As much as I would love to get stuck in right now, I have so many things to do and I’m just about to do a full service on the car, then I have a storm damaged roof to replace on a huge temporary chicken run (due to current uk avian flu restrictions) over the weekend before the weather changes again.

1 Like

The manual is the one linked earlier in this thread:

only mine is v1.3 2020 - there are very slight differences on first sight, but I’ll scan what I have shortly.

I wont get a change to do a rewrite using minimalmodbus just yet but I’m happy if others want to investigate.

In the manual v1.3 2017 it has this

image

I have tried this with my sdm120’s and they return that same version “0201.05”. Could you guys try yours please.

Also if you look at the side of the meter what details do you have there?

This is from the eastroneurope website

mine is notable different despite coming in a eastron box with eastron paperwork it says it’s “smartprocess” on the side and whilst the details are similarly laid out with the same diagram and most details are the same, there is no version like the picture above says “SW V2.4”.

I suspect my meters to perhaps be earlier models with only 14 input registers and Sean’s to be a later model with 20 input registers as he is able to read the registers I do not have, I have just tried to use the extended register map (extra 32 bytes) but I cannot read the latter 16bytes and the first 16bytes can be read but are all zero. Trystan’s could be either, either way neither of you are getting all the data (unless Trystan is getting 14 values from an early meter and just not referencing them in emonhub).

Disclaimer - I’m a total novice on this too. I’m trying to connect my SDM120 up having followed the guides.

I’m also getting the ‘error could not read from SDM120’ message.

I’m using this interfacer as the one linked in the guide seems to be discontinued. Having poked at the SDM120 just now mine shows software version 202.04…?

The interfacer has two LEDS for TX and RX but neither of them ever light…

1 Like

Could you share your emonhub.conf interfacer configuration for the SDM120 as well @richardsmith99?

Im just selecting the readings Im interested in, there where a lot more when I read them all.

[[SDM120]]
Type = EmonHubSDM120Interfacer
[[[init_settings]]]
device = /dev/ttyUSB0
baud = 2400
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
read_interval = 10
nodename = SDM120

Do you recall how many? It would be useful to know what model/vintage/version you have and what data is available via emonhub. Do you now if you gat all 14 or all 20 for sure?

Perhaps you could add a temp line to print the whole reply from read_all() to the log file and post it here so we can see if all the values are (consistently?) there.

My meters don’t do the 8 extra values so it will never output the full 20 that I’m expecting Sean’s to output.

Thanks that fits with being later than mine.

It might be wise to call that an adapter rather than an interfacer, especially whilst we are discussing the sdm120 “interfacer” in emonhub. Interfacer was a word I coined as it wasn’t really used anywhere else so it would be clear when talking about emonhub interfacers so it wouldn’t be confused with other tech jargon.

That adapter is based on the FTDI ft232rl which is a respected chip for serial devices, however I dis notice that despite not showing any termination resisters in their wiring diagrams, there was this note!

So maybe a resister would help, do you have access to a 120 ohm resister by any chance? Don’t worry if you don’t we can revisit this if we don’t get anywhere, like I said previously, I tend to try these things just to rule them out, but I do have the resister kicking around so it’s a very quick test for me.

I have no experience with that adapter, the comms may be very brief and the leds are not even reaching a brightness level you can see before extinguishing, try lowering the ambient light whilst you know it’s working. AFAICT the library grabs all the values one by one, so that’s alot of very brief comms. I tend to grab all the data in much larger chunks at a faster baud (9800) so that all the values are relative at a single point in time rather than getting values from marginally different times.

Mine returns version 0202.04. It’s wired into a CU and I’d have to dismantle it to see the diag on the side, but from memory, it’s broadly the same as the image you show. Scans of the leaflet:

Apologies Richard, I had seen your post on my mobile earlier in the day, but when I sat down at the PC briefly in the evening to reply to Trystan, I tagged on a couple of comments, thinking I was replying to Sean at the time.

So it seems you have the same FW as Sean has (he’s just confirmed his version in the post above). Have you read all the earlier posts in this thread? Have you confirmed the device address using the ls command I provided earlier?

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

Have you updated the emonsd or emonhub and switched emonhub branch to master? (see Post 32)

Have you tried the second independent test script in Post 51? Trystan explains how in Post 46.

If all else fails, have you tried reversing the A & B wires? Once you get one or more values, that confirms the polarity is correct, as well as the address and baud etc.

The 120 ohm resister is also something to try if you can easily lay your hands on one (it was the adapter you linked that said it had no resister fitted), I’m not sure it would make a difference at this point, but if you had one laying around, it’s worth a stab.

Hopefully a daft question, but can we assume the sdm120 is fitted to a live circuit? The modbus part of the device is actually powered via the mains, so won’t work with just the 2 A + B wires.