Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Arduino Code Not Running

Arduino code not running

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By juvinagrawal , 16 August, 2022
Forums
Gurux.Serial

i am interfacing Secure saral meter.
connections are correct as i am able to retrieve data from meter using DLMSdirector but when i am using code client.ino from GuruxDLMS.c-master.zip then it is not giving data.

When the code is uploaded, if i will remove tx rx pins (of meter) from arduino mega board still data is getting received at rx pin, and it is same string is receiving continously.
String received is:
7E A0 07 03 41 93 5A 64 7E

this is initialization code:
Client.init(true, 32, 1, DLMS_AUTHENTICATION_LOW, "ABCD0001", DLMS_INTERFACE_TYPE_HDLC);

this is loop function:
void loop() {
int ret;
if (millis() - runTime > 5000)
{
runTime = millis();
GXTRACE(GET_STR_FROM_EEPROM("Start reading"), NULL);
//TODO: Change logical name of the frame counter if it's used.
// ret= com_initializeConnection();
ret = com_readAllObjects("1.0.94.91.0.255");
delay(1000);
Serial1.println(ret);

com_close();
}
}

Kindly guide me to get correct data.

Thanks

Profile picture for user Kurumi

Kurumi

3 years 9 months ago

Hi,

Hi,

Check your client and server address from the GXDLMSDirector. If they are the 32 and 1 then check the serial port settings. I believe that your client address should be 0x32 and not 32.

BR,
Mikko

juvinagrawal

3 years 9 months ago

Hello! Kurumi,

Hello! Kurumi,
thanks for reply.

on GXDLMSDirector, i set client address as 0x20 -> it will be 32 in integer (same is shown on GXDLMSDirector)

working command line paramter:
-S COM7:9600:8NoneOne -c 32 -a Low -P ABCD0001 -w 1 -f 128 -t Verbose

juvinagrawal

3 years 9 months ago

What to check in Serial port

What to check in Serial port ?

juvinagrawal

3 years 9 months ago

7E A0 07 03 41 93 5A 64 7E

7E A0 07 03 41 93 5A 64 7E

this is i am receiving 4 times both with and without connections of meter to arduino

Profile picture for user Kurumi

Kurumi

3 years 9 months ago

Hi,

Hi,

The client re-establish the connection, because the meter doesn't reply. Check your serial port settings (baud rate) and serial port wires that those are correct.

BR,
Mikko

juvinagrawal

3 years 9 months ago

Thanks for your suggestion, i

Thanks for your suggestion, i have re-checked the serial connections and now it is working.

Please suggest me how can i translate the hex into understandable format.

like, this is the reply of date time read:
7E A0 1E 41 03 52 05 4F E6 E7 00 C4 01 81 00 09 0C 07 E6 08 10 FF 0F 21 1B FF 80 00 00 C7 1A 7E

i have used DLMSDirector -> DLMS translator function, it converts it into :
BlockCipher key: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Authentication Key:D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
1: 7E A0 1E 41 03 52 05 4F E6 E7 00 C4 01 81 00 09 0C 07 E6 08 10 FF 0F 21 1B FF 80 00 00 C7 1A 7E
<HDLC len="1D" >
<TargetAddress Value="20" />
<SourceAddress Value="1" />
<FrameType Value="52" />
<PDU>
<GetResponse>
<GetResponseNormal>
<!-- Priority: High, ServiceClass: UnConfirmed, Invoke ID: 1 -->
<InvokeIdAndPriority Value="81" />
<Result>
<Data>
<!-- 16-08-2022 15:33:27 -->
<OctetString Value="07E60810FF0F211BFF800000" />
</Data>
</Result>
</GetResponseNormal>
</GetResponse>
</PDU>
</HDLC>

but i want to write this date time translation in arduino code.
kindly give me idea so that i can take out date-time from above response and translate it into understandable value.

Profile picture for user Kurumi

Kurumi

3 years 9 months ago

Hi,

Hi,

DLMS is very complicated protocol and before you can read or write anything, you need to establish the connection for the meter. After that you can read the data. There is also a sequence number for each frame that makes this more difficult to just read the value.

The main problem at the moment is that your meter doesn't reply SNRM frame:
7E A0 07 03 41 93 5A 64 7E

Because you can connect from GXDLMSDirector and your client and server address are correct the only reason why the meter is not answering is that your serial port settings are wrong or the connection between Arduino and the meter is not working.

Check that baud rate is 9600 and then check your cable.

BR,
Mikko

juvinagrawal

3 years 9 months ago

In reply to Hi, by Kurumi

Hello Kurumi,

Hello Kurumi,
i am getting data now.

i got stuck with this last point, i just want to know how too convert DLMS hex data into XML format, so that i can convert received hex response into XML format like it is done by translator in DLMSirector.
i want to establish this code into arduino.

juvinagrawal

3 years 9 months ago

In reply to Hello Kurumi, by juvinagrawal

Thanks Kurumi,

Thanks Kurumi,
i got the way for translation.
thank you for your support

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin