i am working on electric meter. I upload Gurux.DLMS.c arduino code to NodeMCU(ESP8266) to read the meter throught Optical Port. The uploading is successfully done, but it cannot access the meter.
The output (also it is shown on the image attached):
---------------------------------
Start reading:
SnrmRequest
data length : 10
7EA0822121935D17E
AarqRequest
data length : 46
7EA02C2212110172AE6E60601DA19676085745811BE104E100065F1F4001E1DFFFFC5E47E
Data send failed. Try to resend. 1 :Data send failed. Try to resend. 2
---------------------------------
I Think the AarqRequest is correct but no response.
You are ahead. Still waiting for NodeMCU. I hope it will arrive soon. :-)
Can you read the meter with GXDLMSDirector? What client and server address you are using?
I tested this and it worked like expected. I changed this line:
Client.init(true, 16, 144, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
Generated first generated frame is this:
7E A0 08 02 21 21 93 05 D1 7E
Make sure that you have the latest version from the Github
// start serial port at 9600 bps:
mySerial.begin(9600);
while (!mySerial) {
; // wait for serial port to connect. Needed for native USB port only
}
-----------------------------------------
The output:
############################################
Start reading
SnrmRequest
7E A0 8 2 21 21 93 5 D1 7E
AarqRequest
7E A0 2C 2 21 21 10 17 2A E6 E6 0 60 1D A1 9 6 7 60 85 74 5 8 1 1 BE 10 4 E 1 0 0 0 6 5F 1F 4 0 0 1E 1D FF FF C5 E4 7E
:Data send failed. Try to resend. 1 :Data send failed. Try to resend. 2
#############################################
Also I tried it with Arduino Mega, but same error.
Hi,
There are numbers missing from the trace and I can't verify the messages. Try to change your trace baud rate from 9600 to 115200. Don't add the image. It's hard to get the bytes. Add plain text.
I know the reason for this. Your serial port is echoed the received packets. This causes the problem. We'll improve the Arduino example to handle echoed messages.
This is not fixed. Serial port sleep time changed from 100 ms to 50 ms. 100 ms was causing that serial port buffer was overwritten because it's size is only 64 bytes.
I used the updated Gurux.DLMS.c with Arduino Mega. I found that in AarqRequest it return code errors:
DLMS_ERROR_CODE_INVALID_CLIENT_ADDRESS
DLMS_ERROR_CODE_OUTOFMEMORY
I am sure that client address is correct.
Client.init(true, 16, 144, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
The output:
-------------------------------------------
Start readingSnrmRequest
7E A0 8 2 21 21 93 5 D1 7E
:Start readingSnrmRequest
This is strange. Data is correct, but I don't understand why where this reply is coming to AARQ message.
For some reason, the meter is replied to previous client messages. This is not happening with GXDLMSDirector. Have you modified the source code?
Yes, I used the update and that error is solved.
I tested it but in AarqRequest the function Client.ParseAAREResponse(&reply.data) returned 258 which is DLMS_ERROR_CODE_INVALID_PARAMETER
The output:
------------------------------------------------------
:Start reading
SnrmRequest
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
Hi,
Hi,
You are ahead. Still waiting for NodeMCU. I hope it will arrive soon. :-)
Can you read the meter with GXDLMSDirector? What client and server address you are using?
I believe that the problem here.
BR,
Mikko
Hi,
Hi,
Yes I used GXDLMSDirector software and I set the following addresses and it worked.
client address = 16
server address = 144
I set them on arduino code.
I think it can work with ESP6266.
Also I tested the meter with Gurux.DLMS Python and it worked.
Thanks,
Hi,
Hi,
I tested this and it worked like expected. I changed this line:
Client.init(true, 16, 144, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
Generated first generated frame is this:
7E A0 08 02 21 21 93 05 D1 7E
Make sure that you have the latest version from the Github
Let me know if you have any problems.
BR,
Mikko
Hi,
Hi,
Check your baud rates.
BR,
Mikko
Hi,
Hi,
Yes I used the last update. I set the correct baudrate 9600.
Serial -> for debugging
mySerial -> for Oprical Port
The code:
------------------------------------
bb_capacity(&frameData, 128);
Client.init(true, 16, 144, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
Serial.begin(115200);
// start serial port at 9600 bps:
mySerial.begin(9600);
while (!mySerial) {
; // wait for serial port to connect. Needed for native USB port only
}
-----------------------------------------
The output:
############################################
Start reading
SnrmRequest
7E A0 8 2 21 21 93 5 D1 7E
AarqRequest
7E A0 2C 2 21 21 10 17 2A E6 E6 0 60 1D A1 9 6 7 60 85 74 5 8 1 1 BE 10 4 E 1 0 0 0 6 5F 1F 4 0 0 1E 1D FF FF C5 E4 7E
:Data send failed. Try to resend. 1 :Data send failed. Try to resend. 2
#############################################
Also I tried it with Arduino Mega, but same error.
Thanks,
Hi,
Hi,
Check that you are using correct UART and your meter serial port settings are correct.
BR,
Mikko
Hi,
Hi,
I am sure that meter serial port settings are correct.
Hi,
Hi,
Is your UART correct? Join your Arduino to the PC and you can see if the bytes are coming from the serial port.
BR,
Mikko
Hi,
Hi,
Yes. Already the meter send the response and I checked that it is correct. But it cannot continue. It keeps sending SnrmRequest only.
see the output:
-------------------------------------------------------
:Start reading
7E A0 8 2 21 21 93 5 D1 7E
7E A0 8 2 21 21 93 5 D1 7E 7E A0 1F 21 2 21 73 56 F4 81 80 12 5 1 80 6 1 80 7 4 0 0 0 1 8 4 0 0 0 1 53 3B 7E
:Start reading
7E A0 8 2 21 21 93 5 D1 7E
7E A0 8 2 21 21 93 5 D1 7E 7E A0 1F 21 2 21 73 56 F4 81 80 12 5 1 80 6 1 80 7 4 0 0 0 1 8 4 0 0 0 1 53 3B 7E
-------------------------------------------------------
Thanks,
Hi,
Hi,
There are numbers missing from the trace and I can't verify the messages. Try to change your trace baud rate from 9600 to 115200. Don't add the image. It's hard to get the bytes. Add plain text.
BR,
Mikko
Hi,
Hi,
I tried to change the baud rate but I got the output from meter only at 9600.
The output is :
--------------------------------------
:Start reading
7E A0 8 2 21 21 93 5 D1 7E
7E A0 8 2 21 21 93 5 D1 7E 7E A0 1F 21 2 21 73 56 F4 81 80 12 5 1 80 6 1 80 7 4 0 0 0 1 8 4 0 0 0 1 53 3B 7E
-----------------------------------
I let the arduino to print byte by byte separated with SPACE . some bytes are displayed with removed MSB zeros. for example after A0 , 8 it is 08 .
The output after adding MSB zeros:
--------------------------------------
:Start reading
7E A0 08 02 21 21 93 05 D1 7E
7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
-----------------------------------
It is correct , but the meter didn't continue.
Thanks,
Hi,
Hi,
I know the reason for this. Your serial port is echoed the received packets. This causes the problem. We'll improve the Arduino example to handle echoed messages.
BR,
Mikko
Hi,
Hi,
This is not fixed. Serial port sleep time changed from 100 ms to 50 ms. 100 ms was causing that serial port buffer was overwritten because it's size is only 64 bytes.
BR,
Mikko
Hi,
Hi,
I used the updated Gurux.DLMS.c with Arduino Mega. I found that in AarqRequest it return code errors:
DLMS_ERROR_CODE_INVALID_CLIENT_ADDRESS
DLMS_ERROR_CODE_OUTOFMEMORY
I am sure that client address is correct.
Client.init(true, 16, 144, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
The output:
-------------------------------------------
Start readingSnrmRequest
7E A0 8 2 21 21 93 5 D1 7E
:Start readingSnrmRequest
7E A0 1F 21 2 21 73 56 F4 81 80 12 5 1 80 6 1 80 7 4 0 0 0 1 8 4 0 0 0 1 53 3B 7E
AarqRequest
7E A0 8 2 21 21 93 5 D1 7E 7E A0 2C 2 21 21 10 17 2A E6 E6 0 60 1D A1 9 6 7 60 85 74 5 8 1 1 BE 10 4 E 1 0 0 0 6 5F 1F 4 0 0 1E 1D FF
r1: 0
r2: 263
r3: 260
:Start readingSnrmRequest
FF C5 E4 7E 7E A0 8 2 21 21 93 5 D1 7E
:Start readingSnrmRequest
7E A0 1F 21 2 21 73 56 F4 81 80 12 5 1 80 6 1 80 7 4 0 0 0 1 8 4 0 0 0 1 53 3B 7E
AarqRequest
-----------------------------------------
Thanks,
Hi,
Hi,
Meter's reply to AARQ is not correct. I don't know the reason for this. Can you read the meter with GXDLMSDirector?
BR,
Mikko
Hi,
Hi,
Yes I tested it in GXDLMSDirector.
The output:
-------------------------------------------
12:14:24 Send SNRM request.
TX: 7E A0 08 02 21 21 93 05 D1 7E
12:14:24
RX: 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
12:14:24 Send AARQ request.
TX: 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
12:14:25
RX: 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E 7E A0 38 21 02 21 30 84 D4 E6 E7 00 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 00 12 19 04 C8 00 07 5C 76 7E
----------------------------------------------------
The meter settings is shown in the image below.
Thanks,
Hello,
Hello,
The hex string that you have added here is not correct. Can you use hex library that adds all zeroes?
Also check why the last bytes are wrong.
E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 02 14 FF FF
BR,
Mikko
Hi,
Hi,
I modified the print code to full format for hex.
The output:
-----------------------------------------------------------
:Start reading
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
TX : 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E
:Start reading
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
:Start reading
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
:Start reading
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
:Start reading
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
-----------------------------------------------------------
It shows that it sent SnrmRequest and AarqRequest only then it returned to repeat SnrmRequest continously.
I checked that the transimtted data bytes (SnrmRequest and AarqRequest) are correct.
Thanks,
Hi,
Hi,
This is strange. Data is correct, but I don't understand why where this reply is coming to AARQ message.
For some reason, the meter is replied to previous client messages. This is not happening with GXDLMSDirector. Have you modified the source code?
BR,
Mikko
Hi,
Hi,
No, I didn't modify the source code.
Hi,
Hi,
And you are using this example?
https://github.com/Gurux/GuruxDLMS.c/tree/master/Arduino_IDE/client
BR,
Mikko
Hi,
Hi,
I discovered that com_readDataBlock(&messages, &reply) function returned error (263) I think it is DLMS_ERROR_CODE_INVALID_CLIENT_ADDRESS
I set the correct addresses.
Client.init(true, 16, 144, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
Hi,
Hi,
I believe that reason is found for this. This is checked and a new version is released soon.
BR,
Mikko
Hi,
Hi,
I created an issue from this:
http://gurux.fi/node/16726
This is now fixed and a new version is released.
BR,
Mikko
Hi,
Hi,
Yes, I used the update and that error is solved.
I tested it but in AarqRequest the function Client.ParseAAREResponse(&reply.data) returned 258 which is DLMS_ERROR_CODE_INVALID_PARAMETER
The output:
------------------------------------------------------
:Start reading
SnrmRequest
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
AarqRequest
TX : 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
RX : 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E 7E A0 2E 21 02 21 30 5C 5B E6 E7 00 61 1F A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 01 A3 05 A1 03 02 01 01 BE 06 04 04 0E 01 06 04 EE 66 7E
TX : 7E A0 2C 02 21 21 32 07 28 E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
RX : 7E A0 2C 02 21 21 32 07 28 E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E 7E A0 2E 21 02 21 52 48 1B E6 E7 00 61 1F A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 01 A3 05 A1 03 02 01 01 BE 06 04 04 0E 01 06 04 EE 66 7E
:Start reading
SnrmRequest
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
TX : 7E A0 08 02 21 21 93 05 D1 7E
RX : 7E A0 08 02 21 21 93 05 D1 7E 7E A0 1F 21 02 21 73 56 F4 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
AarqRequest
TX : 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
RX : 7E A0 2C 02 21 21 10 17 2A E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E 7E A0 2E 21 02 21 30 5C 5B E6 E7 00 61 1F A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 01 A3 05 A1 03 02 01 01 BE 06 04 04 0E 01 06 04 EE 66 7E
TX : 7E A0 2C 02 21 21 32 07 28 E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
RX : 7E A0 2C 02 21 21 32 07 28 E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E 7E A0 2E 21 02 21 52 48 1B E6 E7 00 61 1F A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 01 A3 05 A1 03 02 01 01 BE 06 04 04 0E 01 06 04 EE 66 7E
---------------------------------------------------------
Hi,
Hi,
Try to connect with GXDLMSDirector and check are you getting the same error. If you do, try to reboot the meter.
BR,
Mikko
Hi,
Hi,
I tried with GXDLMSDirector and it connected without errors.
I tried to reboot the meter and connect again, but the error is still.
Hi,
Hi,
You are sending SnrmRequest twice. That is the only difference. Check why you are doing it.
BR,
Mikko