Setting up DSMR Meter Readings via a Raspberry Pi


The internet is probably full of tutorials on how to do this right, but I had to struggle a bit to figure it out for myself. My Pi randomly crashed, the other day, and I’m having to do some of the setup again and having done this for the first time months ago (and having now mostly forgotten what I did), I decided I should blog about it as I retread my steps and recreate my setup.

Aside: The internet tells me that the C shell was the first to introduce the history command. It would not be hyperbolic to say that without history my task of recreating my setup would be significantly more difficult. I used it extensively to figure out what I ran when I needed to do this all those months ago. I should probably containerise or chefise or ansibilise or something.

I live in a country that uses DSMR meters and have one in my home. My girlfriend wanted a closer look at our electricity consumption, so I decided to hook up a raspberry Pi to the meter’s P1 port and send those readings to my home lab server using the Pi as a relay.

I bought a RJ12 –> USB cable off of Amazon and tried to read from my Pi’s USB port by using first cu and then pyserial (which is a much friendlier interface).

# Using cu
cu -l /dev/ttyUSB0 -s 115200 --parity=none

# Using pyserial
python3 -m /dev/ttyUSB0 115200 --xonxoff

Initially neither tool gave me any readings and I nearly tore my luscious hair out before finally realising that it was a bad cable I was using. I returned it and bought a more respectable cable from

And that gave me results!


I had a few different ways of turning the meter readings into useful insights:

  1. Run HomeAssistant on my Pi with direct access to the port: Not an option since my HA instance was already running on my home lab server. The Pi was meant to be a relay only.
  2. DSMR to MQTT: I could run something that would read the DSMR telegrams and send them to an MQTT broker to which I could subscribe my HA integration. Definitely an option.
  3. Serial to Network Proxy: The option I ended up going with since it felt the simplest to me. I would run a program that would expose the DSMR telegrams over a TCP connection.

The program I landed on for doing this is ser2net With a little help from ChatGPT I figured out this ser2net config. Comments describe what the various fields do.

# defines an alias confver, I'm not entirely sure if this does anything
define: &confver 1.0

# begins a new connection definition and assigns it an alias `con00`.
connection: &con00
  # specifies how incoming network connections will be accepted, in this case the Telnet protocol with RFC 2217 support (I no clue what that means), and the connection will be over TCP and listen on port 2013c (this part I understand)
  accepter: telnet(rfc2217),tcp,2013
  # specifies how the serial device will be connected, includes path to the serial device file and port settings, and it is to be configured in local mode (not sure what local mode means)
  connector: serialdev,/dev/ttyUSB0,115200n81,local

I paired this with HA’s DSMR Slimme Meter integration with it set to listen on the network, pointed at my Pi on port 2013.

And we have lift-off!


Note: Solar readings are coming in via a different integrations and configured together with the DSMR readings using HomeAssistant’s Energy Dashboard.

More posts like this

Is it Dry Yet?

2024-04-08 | #home-assistant #home-automation #smart-plugs

Clarification: This is literally about my laundry. I am not being metaphorical. I am not talking about my feelings or my secrets. I am talking about my clothes. Intro Our washing machine is a Samsung something-something that sends me a notification on the SmartThings app when it completes a wash cycle. This is useful since we almost always need to follow up a washing cycle with a drying one and maybe even another load of laundry.

Continue reading 

Alerting on Process Completion

2024-04-04 | #home-assistant #shell-scripting #webhooks

Most of my technical endeavours have something to do with enabling me to work as little as possible for as much reward as possible. And yet, paradoxically, in a pursuit of doing less I often end up doing more. I have this idea that in the long term this will eventually lead me to doing much less. I’m not sure if that’s true, but it’s a nice thought and keeps me going.

Continue reading 