Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Serial Number Data Type

Serial Number Data Type

By technoshell, 5 June, 2025
Forums
Gurux.DLMS

Good Morning Sir,

I am using Arduino client code on ESP32 to read meter in MR mode with LLS. I am able to read the Manufacturer name and Active Energy successfully. But when I read Serial Number with obis code 0.0.96.1.0.255 I get the ASCII string on HPL meter but a Octet String on Secure Meter.
I use the code as under
cosem_init(BASE(ldn), DLMS_OBJECT_TYPE_DATA, "0.0.96.1.0.255"); // OBis for Serial No
com_read(BASE(ldn),2); // Read
obj_toString(BASE(ldn), &data);

How to identify what type of data is received octet string or normal string. ?Accordingly we can call for respective translation code.

Thank You and Best Regards
Technoshell

Profile picture for user Kurumi

Kurumi

10 months 1 week ago

Hi, You can check the…

Hi,

You can check the variant type like this:

if (ldn.value.vt == DLMS_DATA_TYPE_OCTET_STRING){
...
}
else if (ldn.value.vt == DLMS_DATA_TYPE_STRING){
...
}

BR,
Mikko

technoshell

10 months 1 week ago

I think it was Hex coded. It…

I think it was Hex coded. It showed up when I put in on Hex to ASCII converter. I will check sir. Thank you so much for your help.

technoshell

10 months 1 week ago

Sir , ldn.vt throws error…

Sir ,
ldn.vt throws error. Intellisense shows ldn has only two attributes one is base and other is value. Please advise.

Bet Regards

Profile picture for user Kurumi

Kurumi

10 months 1 week ago

Hi, My bad. The value is…

Hi,

My bad. The value is missing from the example code. I updated the code.

BR,
Mikko

technoshell

10 months 1 week ago

Thank You Sir. I wanted to…

Thank You Sir.
I wanted to read the serial number so I used the code

int com_readNamePlateSrno()
{
unsigned char i;
int ret;
char* data = NULL;
gxData ldn;
//Initialize connection.
ret = com_initializeConnection();
if (ret != DLMS_ERROR_CODE_OK)
{
GXTRACE_INT(PSTR("F"), ret);
return ret;
}

cosem_init(BASE(ldn), DLMS_OBJECT_TYPE_DATA, "0.0.96.1.0.255"); // OBis for Serial No
com_read(BASE(ldn),2); // Read

obj_toString(BASE(ldn), &data);

Serial2.print(data);

obj_clear(BASE(ldn));

free(data);

}

The result shows
Index: 2 Value: 54308521<CR><LF>

The Serial number is correctly read as 54308521
But soon after printing the above the program hangs and prints continues garbage.

Is there something wrong I am doing?

Thanks and Regards

Profile picture for user Kurumi

Kurumi

10 months 1 week ago

Hi, You need to close the…

Hi,

You need to close the connection after you have read the data. Now you leave it open and I believe that next com_initializeConnection is failing.

It's also important that you check that com_read is successful. The reading might sometimes fail.

BR,
Mikko

technoshell

10 months 1 week ago

Thank you sir. This worked…

Thank you sir. This worked well on the old version of Arduino code. I then downloaded the latest version to work with Encryption and facing some issues. But I will create a separate topic for this. Thanks once again

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 04/07/2026 - 17:17
    Gurux.DLMS.Python 1.0.197
  • Tue, 04/07/2026 - 15:03
    gurux.dlms.c 9.0.2604.0701
  • Tue, 04/07/2026 - 14:50
    gurux.dlms.java 4.0.91
  • Tue, 04/07/2026 - 14:00
    Gurux.DLMS.Net 9.0.2604.0701
  • Mon, 03/30/2026 - 15:39
    gurux.dlms.c 9.0.2603.3001

New forum topics

  • Issue when reading Itron Type620 meter
  • Handling Unexpected Disconnects
  • DLMS Communication Issue – No Response (L&T Meter via USB Probe)
  • Unable to cast object of type Gurux.DLMS.GXStructure to type Gurux.DLMS.GXArray
  • How to properly invoke KeyAgreement
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin