# Trying to read serial communication from smart meter with Arduino

First my compliments for this wonderful site. I'm hoping to find an answer to my problem. I've checked to find answers, however was not able to find it.

My background is somewhat technical, only with minor electrical knowledge.

My project goal is to read the serial signal which is supplied by the P1 port of a Smart Meter (ISKRA type MT382-D2A52-M2K0agnZ) with an Arduino MEGA 2560 @ 9600 Baud rate.

Many before me have succeeded, however I don't seem to manage.

Before the Arduino can 'read' the signal from the P1 port, the signal requires to be inverted. (General advice on the internet on this topic: Use 7404 hex inverters and transistors to invert the P1 signal)

I'm currently using the following components and schematic:

• Arduino Mega 2560
• NPN transistor 2N2369A
• 2x 1k resistor

The 2N2369A is doing something, because the serial output of the Arduino with the schematic of above is as follows:

0-0:96.then rubbish 0-0:96.then rubbish 0-0:96.then rubbish

The 0-0:96. part it spits out every 10 seconds looks somewhat like what it should read:

/ISk52ME382-1003
0-0:96.1.1(4B414C37303035313039)
1-0:1.8.1(00180.912*kWh)
1-0:1.8.2(00001.416*kWh)
1-0:2.8.1(00000.000*kWh)
1-0:2.8.2(00000.000*kWh)
0-0:96.14.0(0001)


etc..

When I connect the TX from the P1 (smart meter) directly onto the RX0 port of the Arduino, the following is produced:

(V
eÔR]d�“ZòövRÖå½Vû‹�“£�´ò«}—“IYÙ–ö–ö–V–Ö’’Ö™Ÿ™�™�™—f'ff+9½Rû‹�´dë^Ÿ“••“£(V
eÔR]d�“ZòövRÖå½Vû‹�“£�´ò«}—“IYÙ–ö–ö–V–Ö’’Ö™Ÿ™�™�™—f'ff+9½Rû‹�´dë^Ÿ“••“£(V
eÔR]d�“ZòövRÖå½Vû‹�“£�´ò«}—“IYÙ–ö–ö–V–Ö’’Ö™Ÿ™�™�™—f'ff+9½Rû‹�´dë^Ÿ“••“£¯ÉSë5\²MÔ3¸²-±00´�


which is absolute rubbish. Therefore I think I'm close with the NPN, however I can't make it to the last step.

Is someone willing to advise me what I'm doing wrong?

• wrong choice NPN? wrong resistors?

In advance my gratitude to anyone willing to help.

Kind regards,

Vernon

Following up on my question above, I have done a bit more testing.

I have tested a Sketch from internet using AltSoftSerial with Digital pin 48 on the Mega as a software RX solution, however with perfect results:

Result:

*0-0:96.1.1(5A424556303035313739303939343133)

1-0:1.8.1(06558.109*kWh)

1-0:1.8.2(05439.071*kWh)

1-0:2.8.1(00000.002*kWh)

1-0:2.8.2(00000.000*kWh)

0-0:96.14.0(0002)

1-0:1.7.0(0000.80*kW)

1-0:2.7.0(0000.00*kW)

0-0:17.0.0(0999.00*kW)

0-0:96.3.10(1)

0-0:96.13.1()

0-0:96.13.0()

!*

Arduino Sketch used: http://domoticx.com/p1-poort-slimme-meter-uitlezen-hardware/

Connecting the Smart Meter TX to pin D48 without NPN the output is rubish again: *+9=V{\$46{/#++9=V{

# 4r+}IYYvvVVV

f'ff+9=R{4dk^4rV+*

I'm very close, however I feel like an idiot not being able to get the normal RX0 serial port to spit out the same data as the AltSoftSerial option.

Anybody ideas? Many thanks in advance! Vernon

Looks like you might have your bits/parity set wrong.

Make sure your serial init looks like...

Serial1.begin( 9600, SERIAL_7E1 );

...since these seem to be the settings the meter uses.

• I'm impressed by such a fast reply. Many thanks. I have tried your suggestion, but same results. – Vernon Sep 30 '15 at 19:23

I think I just found a solution.

The issue with the Arduino Mega is that RX0 is also used for (USB) communication between computer.

I have found a sketch (see below) which I don't understand (yet) and require some further study. It uses RX1 (pin19) instead of RX0, probably for above explained reason.

In any case....

It works!

Working SKETCH

char x;

void setup() {

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

Serial1.begin(9600);

// defaults to 7-bit, even parity, 1 stop bit

//clear parity, stop bits, word length

UCSR1C = UCSR1C & B11000001;

UCSR1B = UCSR1B & B11111011;

//Set word length to 7 bits

UCSR1C = UCSR1C | B00000100;

UCSR1B = UCSR1B | B11111000;

//Even parity

UCSR1C = UCSR1C | B00100000;

//1 Stop bit

UCSR1C = UCSR1C | B00001000;

Serial1.flush();

}

void loop() {

if (Serial1.available() > 0) {

Serial.print(x);

}

}

Many thanks to all,

I'm able to continue my project now. If anybody has the time and can explain the sketch, please feel welcome as any advice is valuable.

Kind regards,

Vernon