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

9 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

9 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

9 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

9 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

9 months 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

9 months 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

9 months 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

  • Thu, 02/19/2026 - 11:51
    gurux.dlms.cpp 9.0.2602.1901
  • Sun, 02/01/2026 - 19:47
    gurux.dlms.cpp 9.0.2602.0101
  • Tue, 01/20/2026 - 10:38
    gurux.dlms.java 4.0.89
  • Wed, 01/14/2026 - 14:29
    Gurux.DLMS.Python 1.0.196
  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5

New forum topics

  • Gurux C library DLMS book edition support
  • Help with connection and read with landis+gyr e650 + CU-E22 using python
  • Preestablished connection
  • RJ11 to RS232 Pin out SECURE Premier 300
  • GENUS sugam 3 PH bidirectional
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin