Read data from the Belgian digital meter through the P1 port

Like some other Belgians, unfortunately, my analog electricity meter was replaced by a digital one since a few months. Initially, I was quite happy with the change as it allows a much easier look into your consumption and solar panel injection to the net. But exactly that last turned out to be a bummer as the government decided to not keep their word regarding reversing consumption with solar panel injection. Nevertheless, I have the thing so I might as well take advantage of it. This post describes how to connect to and use the data from the P1 port on a digital electricity meter in Belgium.

YouTube Video

If you are interested, I also created a YouTube video from this blogpost. If you prefer classic text, you can just follow the rest of this article:

Introduction

Digital electricity meters are used in a variety of countries. While exploring this, I noticed that each country/region and even device model works in a slightly different way and standard (more about this further in the post). As this post mainly would be interesting for people living in Belgium, for the first time, I decided to also create a Dutch version. You can find this one over here: https://jensd.be/1205/linux/data-lezen-van-de-belgische-digitale-meter-met-de-p1-poort

The electricity meter is communicating back it’s reading, additional data and natural gas meter’s readings back to the distributor, using cellular, on regular times. This allows you to check that data on the site of the distributor itself:

So if your goal is just to see the consumption in a nice graph there is no need to make use of the data coming from the P1 port. If you want to do something with the data on the other hand, like triggering automation or have the ability to use the near real-time information, you are at the right place.

The digital meter

In Belgium, distributor Fluvius has started distribution and installation of the digital meters. They are currently using only three types of digital meters for consumers. One for single phase installations, another for three-phase and a natural gas meter that uses the digital electricity meter to send it’s data as well to the distributor:

  • Sagecom S211: Single phase
  • Sagecom T211-D : Three-phase
  • Flonidan – G4SRTV: Natural gas

The P1 and S1 ports

The electricity meters mentioned above, are having two serial ports on the front of the device, behind the yellow cover. Both these ports can be used to read data from. S1 is sending raw data around 2600-4000 times/second. P1 on the other hand is a bit calmer and provides information around once/second in a more formatted form.

The P1 port, which I will use through the rest of the article, is the most interesting for most users and automation integration.

Physical port

Both the P1 and S1 ports are following the serial RS422 standard and are using a RJ12 connector. (RJ11 works as well with the correct pinout). Important to know is that these ports are disabled by default. Fortunately, they can easily be enabled using the Fluvius webinterface through https://mijn.fluvius.be/poortbeheer/.

To connect to the ports, you can create a cable yourself with the following pinout:

PinSignalDescription
1+5VPower supply for reading equipment (optional)
2RTSInput
3GNDData ground
4
6RXOutput
6Power GNDPower supply for reading equipment (optional)

Another option, if you can’t make a cable or are lazy as me, is to buy one of the readily available cables with a serial to usb convertor integrated, like the following:

Data format

The data format of the P1 port, as well as the above discussed physical format, is using the DSMR 5.0.2 P1 standard. DSMR stands for Dutch Smart Meter Requirements. And as the name suggests, this was developed and is maintained by our northern neighbors. Unfortunately, while looking up information and seeing the various scripts that are available, I noticed that each model of meter seems to use the standard in slightly different ways. So most of what I will discuss in this post applies to other countries that use DSMR but it might needs some tweaks here and there.

You can find all details of the standard over here: https://www.netbeheernederland.nl/_upload/Files/Slimme_meter_15_a727fce1f1.pdf

To not go to deep but still make things understandable, I’ll try to go through the things you need to know from this in order to start using the data.

The whole message (called telegram or COSEM object), coming from the P1 port in DSMR like the following:

And the data itself, inside the telegram, looks like the following:

This gives us the following info:

  • Each block of info (telegram) starts with a /
  • After the start, there is a fixed, model specific identification, followed with a fixed device-unique identification
  • The data lines start with an OBIS code, including identification from which meter (electricity or natural gas) the data comes and which type of info is next
  • The values are inside parentheses and if a unit is preset, it’s separated by a *
  • The block of info (telegram) ends with a !
  • The CRC field contains a CRC16 calculated value of the rest of the block

In practice: reading and interpreting the data

So far I’ve only covered things from a theoretical angle. Next, let me explain how you can read the data and parse it to do something useful with it.

For this, I’ll start with a minimal install of Debian but another Linux distribution, like Ubuntu, CentOS, or even Windows/OS X should work in the same way.

First, I’ll install pyserial and crcmod using the package manager as I will use Python to parse the data coming from the P1 port.

jensd@deb10:~$ sudo apt install python3-serial python3-crcmod python3-tabulate
Reading package lists… Done
Building dependency tree
...
Setting up python3-serial (3.4-4) ...

Next, just to get started, we can try and read out the serial port. In my case, as I mentioned above, I use the P1 cable with integrated serial to USB convertor so my serial port is /dev/ttyUSB0. Port settings for P1 are 115200 baud, 8N1, Xon/Xoff.

In order for a non-root user to access the serial port, we need to set the right permissions:

jensd@deb10:~$ sudo chmod o+rw /dev/ttyUSB0

And to, finally, test the data coming in:

jensd@deb10:~$ python3 -m serial.tools.miniterm /dev/ttyUSB0 115200 --xonxoff
--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
925*m3)
!CE4E
/FLU5\253xxxxxx_A

0-0:96.1.4(xxxxx)
0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-0:1.0.0(210204163628W)
1-0:1.8.1(000439.094kWh)
1-0:1.8.2(000435.292kWh)
1-0:2.8.1(000035.805kWh)
1-0:2.8.2(000012.156kWh)
0-0:96.14.0(0001)
1-0:1.7.0(00.233kW)
1-0:2.7.0(00.000kW)
1-0:21.7.0(00.233kW)
1-0:22.7.0(00.000kW)
1-0:32.7.0(236.2V)
1-0:31.7.0(002.04A)
0-0:96.3.10(1)
0-0:17.0.0(999.9kW)
1-0:31.4.0(999A)
0-0:96.13.0()
0-1:24.1.0(003)
0-1:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-1:24.4.0(1)
0-1:24.2.3(210204163500W)(00343.925*m3)
!1374
/FLU5\253xxxxxx_A

0-0:96.1.4(xxxxx)
0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-0:1.0.0(210204163629W)
1-0:1.8.1(000439.094kWh)
1-0:1.8.2(000435.292kWh)
1-0:2.8.1(000035.805kWh)
1-0:2.8.2(000012.156kWh)
0-0:96.14.0(0001)
1-0:1.7.0(00.228kW)
1-0:2.7.0(00.000kW)
1-0:21.7.0(00.228kW)
1-0:22.7.0(00.000kW)
1-0:32.7.0(236.3V)
1-0:31.7.0(002.01A)
0-0:96.3.10(1)
0-0:17.0.0(999.9kW)
1-0:31.4.0(999A)
0-0:96.13.0()
0-1:24.1.0(003)
0-1:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-1:24.4.0(1)
0-1:24.2.3(210204163500W)(00343.925*m3)
!4BE6

 --- exit ---

As you can see, this matches with the message format for DSMR that I described above. Looking in the documentation, we can find the meaning of these values. This is not always easy as the codes are not an exact match and can contain channel or meter ID. For the examples above, the following applies. I added some other useful ones as well for completeness. More info, specifically for the Belgian meters can be found here as well: https://www.fluvius.be/sites/fluvius/files/2020-02/technische-info-displays-digitale-elektriciteitsmeter.pdf

OBIS codeMeaning
0-0:96.1.4ID
0-0:96.1.1Serial number of electricity meter (in ASCII hex)
0-0:1.0.0Timestamp of the telegram
1-0:1.8.1Rate 1 (day) – total consumption
1-0:1.8.2Rate 2 (night) – total consumption
1-0:2.8.1Rate 1 (day) – total production
1-0:2.8.2Rate 2 (night) – total production
0-0:96.14.0Current rate (1=day,2=night)
1-0:1.7.0All phases consumption
1-0:2.7.0All phases production
1-0:21.7.0L1 consumption
1-0:41.7.0L2 consumption
1-0:61.7.0L3 consumption
1-0:22.7.0L1 production
1-0:42.7.0L2 production
1-0:62.7.0L3 production
1-0:32.7.0L1 voltage
1-0:52.7.0L2 voltage
1-0:72.7.0L3 voltage
1-0:31.7.0L1 current
1-0:51.7.0L2 current
1-0:71.7.0L3 current
0-0:96.3.10Switch position electricity
0-0:17.0.0Max. allowed power/phase
1-0:31.4.0Max. allowed current/plase
0-0:96.13.0Message
0-1:24.1.0Other devices on bus
0-1:96.1.1Serial number of natural gas meter (in ASCII hex)
0-1:24.4.0Switch position natural gas
0-1:24.2.3Reading from natural gas meter (timestamp) (value)

Ptyhon script

Running this through a Python script to parse the data, results in the following:

jensd@deb10:~$ python3 test.py
 
 Description                         Value           Unit
 ----------------------------------  --------------  ------
 Meter serial electricity            XXXXXXXXXXXXXX
 Timestamp                           210204172711.0
 Rate 1 (day) - total consumption    439.33          kWh
 Rate 2 (night) - total consumption  435.292         kWh
 Rate 1 (day) - total production     35.805          kWh
 Rate 2 (night) - total production   12.156          kWh
 Current rate (1=day,2=night)        1.0
 All phases consumption              0.329           kW
 All phases production               0.0             kW
 L1 consumption                      0.329           kW
 L1 production                       0.0             kW
 L1 voltage                          238.3           V
 L1 current                          2.18            A
 Switch electricity                  1.0
 Meter serial gas                    XXXXXXXXXXXXXX
 Switch gas                          1.0
 Gas consumption                     343.925         m3
...
 

In case you are interested in this script, I uploaded it to GitHub: https://github.com/jensdepuydt/belgian_digitalmeter_p1

The script definitely needs more attention but I guess it can serve well as a source for someone that wants to set up his/her small project by using the data coming from the P1 port.

Let me know your thoughts in the comment section!

15 thoughts on “Read data from the Belgian digital meter through the P1 port

  1. Pingback: Data lezen van de Belgische digitale meter met de P1 poort | Jensd's I/O buffer

  2. Hi Jens,

    I followed your tutorial but i’m not receiving any readable data. I only get question marks.

  3. Hi, thanks for this article. From where did you buy the cable? I see all different kinds of pin out cables (mostly for the dutch meters) available and not sure which one would work. Thanks!

    • Mine came from bol.com. The cables for the Dutch meters should work in Belgium without issues as well as they (in theory) follow the same DSMR standards.

  4. Hi Jens,

    Thanks for the work you have done, tried your python script but failed with errors.
    python read_p1.py
    File “read_p1.py”, line 62
    print(f”Given checksum: {givencrc}, Calculated checksum: {calccrc}”)
    ^
    SyntaxError: invalid syntax

    using raspberry pi os with python Python 2.7.16

    Hope you know what is failing, Thanks in Advance.

    • Python 3.7.3 en print (f schijnt in versie 3.6 veranderd te zijn, moest ook de modules met pip3 installeren en met python3 opstarten. Lijkt nu goed te werken.

  5. Hi Jens! Thanks a lot for this article. It was super easy with your guideline to get the data out of the smart meter and saved me a lot of time. Also a big thanks for having it done in English.

    Unfortunately my IT knowledge is limited I’ve nothing to contribute except that I can say that Sibelga (grid operator in Brussels?) has the P1 open/active by default (understood it’s different to Fluvius).

  6. Hi Jens,

    Are you sure about the cable pinout?
    I am using a Generic FTDI chip with 5V logic.
    But when I use the pinout and software settings from your video I only receive “square” symbols every so often.
    Or maybe I will need to wait even longer before the port is actually activated?
    thanks\
    Steven

    • Hello,

      My FTDI USB to serial cable did not have RS422 capability.
      Problem solved :)
      New cable has same chip however.. FT232RL

      br
      Steven

  7. Hello,
    Having ordered a smart meter from Ores, I now discover your site.
    Very interesting !

    The installation of the new meter is scheduled for Tuesday, September 14, and I am preparing to collect and process the data provided on port P1.

    I would like to point out a typo in the “Physical port” section, where it should probably read:
    5 RX Output
    and not ‘6’

    Good continuation.

  8. hello jens,
    im trying to work in similar thing on C#, i can understand how u read , but my questions how can i send specific command to the meter ?? for example if i want to read energy for a specific timestamp

    • You cannot send any commands to the meter. There is no querying. It simply spits the data out and you can capture it…

      • So the meter send all the data that that is available in the registers ? i mean if want to read energy for specific a time for example (01/10/2021 00H00)

Leave a Reply

Your email address will not be published. Required fields are marked *