Trying to read smart meter P1 data

Hi all,

I’m trying to read the info from the P1 port of a Landys&Gyr E360 smart meter. I want to use the power injection output to control some household appliances.

So far, I have tried several codes using both softSerial and altSoftSerial.

have tried the following codes:

Nothing seems to work: for some reason softSerial.available() remains zero, and softSerial.read() gives -1 (which is consistent with the available() remaining low.

The fact that none of the codes seems to works seems to point to my hardware.

I have the RX signal of the RJ11 connected to a pull-up resistor, and then I’m inverting it using a CD4069. The data request pin is also high, and according to the grid operator’ website, my port is opened.

Worse still: it has worked for some time with an UNO, but that gives different problems having just one serial port. now I’m using a mega, and no code seems to do anything. all help appreciated!

For completeness: latest code attempt:


#include <AltSoftSerial.h>
// AltSoftSerial always uses these pins:
//
// Board          Transmit  Receive   PWM Unusable
// -----          --------  -------   ------------
// Teensy 2.0         9        10       (none)
// Teensy++ 2.0      25         4       26, 27
// Arduino Uno        9         8         10
// Arduino Mega      46        48       44, 45
// Wiring-S           5         6          4
// Sanguino          13        14         12
 
AltSoftSerial altSerial;
char c;
 
void setup() {
    Serial.begin(115200);
    altSerial.begin(115200);
    Serial.println("we zijn vertrokken");
}
 
void loop() {
    if (altSerial.available()) 
        
    {
        Serial.println("in de loop");
        c = altSerial.read();
   
        // --- 7 bits instelling ---
        c &= ~(1 << 7);
        char inChar = (char)c;
 
    Serial.print(c);
    }
    else
    {Serial.println("altserial not available");
    delay(1000);
    }
    Serial.println(altSerial.read());
}

gives this output:

14:15:47.149 -> we zijn vertrokken

14:15:47.149 -> altserial not available

14:15:48.132 -> -1

14:15:48.132 -> altserial not available

14:15:49.172 -> -1

14:15:49.172 -> altserial not available

If you're using a Mega you have 3 spare serial ports. Why are you trying to use SoftwareSerial or AltSoftASerial?

I think that this is the only advice that I can give (if one can consider it advice).

1. Do you know the UART frame format used by your smart meter? If so, what is it?

2. I would suggest switching back to the UNO R3 and using a SoftwareSerial port at 9600 baud. Afterwards, carefully study the incoming data frames.

3. Please, givea link to your Smart Meter.

For communication with a PC I may hope :wink: The baudrate for the P1 interface is 115200, data format 7E1.

The SUART works well at 9600 and NOT at 115200. So, you use Serial1 or Serial2 of MEGA at 115200 Bd to communicate with your Smart Meter.

You can first check the functionality of Serial2 Port of MEGA by a loop back connection.

1. Short TX2 and RX2 of MEGA.
2. Upload the following sketch (untested) and check that whatever you enter from keyboard appears on the outputbox of Serial Monitor.

void setup()
{
  Serial.begin(115200);
  Serial2.begin(115200);  //charcater length 8-bit, no parity, 1-stopBit = default
}

void loop()
{
  byte y = Serial.available();
  if (y != 0)
  {
    char ch1 = Serial.read();
    Serial2.write(ch1);
  }

  byte z = Serial2.available();
  if (z != 0)
  {
    char ch2 = Serial2.read();
    Serial.print(ch2);
  }
}

You might have missed the 7E1 that I added later :wink:

I know it does not matter for a loopback.

Interesting.

I'm about to have something like this meter fitted when the RTS dual rate system has the plug pulled on it.

Is the P1 port an RJ45 type? From what I've read so far, is that the port has to be activated by the supplier. It would certainly be useful for getting usage and time of day data.

I have added 7E1 in my sketch of #5. Removed, see #9 given below:

from smart meter data:

“Data sent by the meter on the Data signal is transmitted as UART data with a baud rate fixed to 115200, 8 data bits, no parity bit and 1 stop bit. “

meter:

meter

thanks in advance

You may be on to something here.

Just did the test and the word “test” came back as follows:

15:53:03.325 -> �wu{w

“test1234” came back like this;

15:54:31.119 -> �wu{w����

So it looks like there is something going wrong there. Could that be local setting or something? some language thing?

I had studied your post carefully, and thanks for the elaborate work, I learned a lot. Did your code work in the end?

That means Serial2 is failing the loop back test. I will check it in my MEGA and report.

Check for Baud Rate (Bd) = 115200 in the Serial Monitor.

I don't have a meter. I wrote code for a friend and it uses 7E1.
Maybe he's using other meters but I have not had complaints that it did not work. Hence my 7E1.

I did check the DSMR specs (both V4 and V5) and they indeed specify 8N1 so your were correct. I could not find the 115200/8N1 in the link that you provided.

  • your electricity supplier may provide API’s to get the data you want direct from the web ( eg look at Octopus Energy site )
  • Your electricity meter may have a led on it that flasher ( eg once per 0.01 KWh) , that could be used .
  • You could use a clamp in ammeter to measure load

These all give you simpler alternatives that do not intrude into the meter ( your supplier may object to you using the coms for fear of hacking - you need to ask if it’s not your meter)

possible related info