Decoding DSMR protocol (Smart meters)

This topic is to share my search about “how to connect a B&R PLC to a Power metering system using DSMR protocol”
The meter use the DSMR protocol version 5.0.2
Description of the interface spec and protocol can be found here : DSMR 5.0.2 P1 Companion Standard | Netbeheer Nederland

The interface of the meter is based on a optocoupler.
I used a simple electronic interface to be able to get inverted TTL level signal.
Then, I used small signal converter from TTL to RS232 level. (see pic)
https://fr.aliexpress.com/item/1005006746959263.html?spm=a2g0o.order_list.order_list_main.64.3f945e5bHoxOwg&gatewayAdapt=glo2fra
RS232 RX (only) signal is connected to a B&R X20CS1020 serial board

A used DV-Frame lib from B&R to OPEN the channel and Receive the RS232 frame
Code is written in ST
In the INIT part, I initiate the settings of the board and I open the communication
In the CYCLIC part, I receive the frame and if the receive and size is ok, I start decoding
The decoding is very simple as each meter values are preceded by an unique index style: “1-0:1.8.1” (see the protocol PDF for the index description)
I use FIND instruction to find the index, then I extract the value (string), then I convert this string to real.

I will attach the variable declaration, type and ST code…
DSMR_Meter.zip (416.5 KB)


3 Likes