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. Help Needed: RS485 Communication With Hexing Meter

Help Needed: RS485 Communication with Hexing Meter

By Salamandra, 3 September, 2025
Forums
General discussion

Hi!

I'm working on a project with some Hexing meters. I was able to connect to the meter via the optical port using HDLCWithModeE at 300 baud, 7E1, with GURUX DLMS Director and Python, and publish the data via MQTT. However, I don’t know how to establish a connection through RS485. I’ve tried multiple baud rates, servers, and users using the baud rate scan in GURUX DLMS Director, but without success.

The final goal is to have an ESP32 connect to the meter via RS485 and publish the acquired data to my MQTT server.

So, long story short: the meter doesn’t respond over RS485.

Profile picture for user Kurumi

Kurumi

2 months ago

Hi, At first, check your…

Hi,

At first, check your cables. It's a common reason.

The best way is to ask the meter vendor or check if it's in the meter documentation.

If that is not possible, establish the connection with the optical probe. Read the device address from the IEC HDLC Setup and try with that.

https://gurux.fi/Gurux.DLMS.Objects.GXDLMSIecHdlcSetup

Because this is not defined in DLMS standards, meter manufacturers use different ways for meter address.

BR,
Mikko

Salamandra

2 months ago

Hi! Thank you for the quick…

Hi!

Thank you for the quick response. I was able to connect to the meter using GXDLMSDirector and Python. For anyone having issues with this manufacturer (which is quite notorious for the lack of support), these are the settings that worked for me:

Optical probe:

Interface: HDLCWithModeE

Authentication: High

Client Address: 1

Password: 00000000

ASCII: Disabled

Address Type: Default

Logical Server: 0

Physical Server: 1

Serial Port: YOUR PORT (Baud rate: 300, Data bits: 7, Parity: Even, Stop bits: 1, Flow control: None)

RS485:

Interface: HDLC

Authentication: High

Client Address: 1

Password: 00000000

ASCII: Disabled

Address Type: Default

Logical Server: 0

Physical Server: 1

Serial Port: YOUR PORT (Baud rate: 9600, Data bits: 8, Parity: None, Stop bits: 1, Flow control: None)

And here are the readings I obtained:

--------------------------------------------------
Siguiente desconexión en 13 lecturas.
--------------------------------------------------
Leyendo valor, lectura N° 28/500...
Tensión instantanea L1: 227.9 V
Corriente instantanea L1: 0.0 mA
Frecuencia de la red: 50.02 Hz
Factor de Potencia: 1.0
Energía Activa Total: 0.0 kWh
Potencia activa instantanea L1: 0 W
Tensión instantanea L2: 227.7 V
Tensión instantanea L3: 227.7 V
Corriente instantanea L2: 0.0 mA
Corriente instantanea L3: 0.0 mA

Now i have to convert my code to something i can program my ESP.

Again, thank you so much.

Profile picture for user Kurumi

Kurumi

2 months ago

Hi, I'm glad that you solved…

Hi,

I'm glad that you solved this. Unfortunately, support from the meter manufacturers is often quite poor.

Check this if you are using Arduino:
https://github.com/Gurux/GuruxDLMS.c/tree/master/Arduino_IDE/client

BR,
Mikko

Salamandra

2 months ago

Hi, I’m working with an…

Hi,

I’m working with an ESP32 and I’m having some trouble with the code. Specifically, I’m trying to figure out where I can define the OBIS codes I want to read. Could I get some guidance on this?

Salamandra

2 months ago

Hi, Sorry to bother again,…

Hi,

Sorry to bother again, but I'm not capable of stablish connection with the meter using ESP32 with HIGH authentication and the 00000000 password, in python i had no problem, using the password 0x00000000. If I use authentication NONE with no password and client 16 i can connect but not read anything.

Client.init(true, 1, 1,DLMS_AUTHENTICATION_HIGH, 0000000, DLMS_INTERFACE_TYPE_HDLC);

Profile picture for user Kurumi

Kurumi

2 months ago

Hi, You can read the…

Hi,

You can read the association view after you have established the connection to the meter. It will describe all available OBIS codes. If you are always read the same meters, you can read the association view with GXDLMSDirector and then rard code the objects you want to read. The association view can be huge and require a lot of memory.

I believe that your password is a string. Try this:

Client.init(true, 1, 1,DLMS_AUTHENTICATION_HIGH, "0000000", DLMS_INTERFACE_TYPE_HDLC);

BR,
Mikko

Salamandra

2 months ago

Hi, Thank you for your help…

Hi,

Thank you for your help and patience. I tried several variations using quotes, like "00000000" and 0x00000000, but had no luck. Do you have any other suggestions? I am stuck with this.

Profile picture for user Kurumi

Kurumi

2 months ago

Hi, Check that you are using…

Hi,

Check that you are using the same client and server address as in Python.

One of your settings differs from Python settings.

BR,
Mikko

Salamandra

2 months ago

Hi, I double-checked, and…

Hi,

I double-checked, and both the Client and Server settings are the same.

In Python I have:

main.py -S COM3:9600:8None1 -i HDLC -c 1 -s 1 -a High -P 0x00000000

and it works.

In Arduino I’m using:

Client.init(true, 1, 1, DLMS_AUTHENTICATION_HIGH, "00000000", DLMS_INTERFACE_TYPE_HDLC);

and nothing.

However, if I use:

Client.init(true, 16, 1, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);

I can connect to the meter. So I assume the issue is related to the password.

Since I’m using a MAX485 transceiver, I had to add custom read/write functions to handle the direction control pin (RS485_DIR). Otherwise, communication was impossible. Maybe this is also related to why it’s not working properly:

int rs485Write(const void* data, size_t len) {
// Cambiar a modo TX
digitalWrite(RS485_DIR, HIGH);
delay(1); // Pequeña pausa para estabilizar

// Enviar datos
int written = Serial.write((const uint8_t*)data, len);
Serial.flush(); // Esperar hasta que se envíen todos los datos

// Volver a modo RX
delay(1); // Pequeña pausa para asegurar transmisión completa
digitalWrite(RS485_DIR, LOW);

// Depuración
Serial1.print("TX: ");
for(int i=0; i<len; i++) {
Serial1.printf("%02X ", ((uint8_t*)data)[i]);
}
Serial1.println();

return written;
}

int rs485Read(uint8_t* buffer, size_t len, unsigned long timeout) {
size_t i = 0;
unsigned long start = millis();

while (i < len && (millis() - start) < timeout) {
if (Serial.available()) {
buffer[i++] = Serial.read();
start = millis(); // Resetear timeout con cada byte recibido
}
}

// Depuración
Serial1.print("RX: ");
for(int j=0; j<i; j++) {
Serial1.printf("%02X ", buffer[j]);
}
Serial1.println();

return i;
}

Profile picture for user Kurumi

Kurumi

2 months ago

Hi, The reason is that the…

Hi,

The reason is that the password contains non-ASCII characters. Get the latest version from the Arduino example. Then initialize it like this:

unsigned char password[] = {0, 0, 0, 0, 0, 0, 0, 0};
Client.init(true, 1, 1, DLMS_AUTHENTICATION_HIGH, password, sizeof(password), DLMS_INTERFACE_TYPE_HDLC);

BR,
Mikko

Salamandra

2 months ago

Hi, Thank you so much for…

Hi,

Thank you so much for your response. Yesterday, late in the day, I finally managed to authenticate using basically the same method you updated in the repository. Your help has been incredible, and I now have a functional prototype running on an ESP32.

If at any point you or someone need a hand or some collaboration, feel free to reach out.

Best regards!

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 10/29/2025 - 08:51
    gurux.dlms.c 9.0.2510.2901
  • Thu, 10/16/2025 - 09:59
    gurux.dlms.java 4.0.83
  • Wed, 10/08/2025 - 10:21
    gurux.dlms.c 9.0.2510.0801
  • Fri, 09/26/2025 - 10:02
    gurux.dlms.cpp 9.0.2509.2601
  • Fri, 09/26/2025 - 09:45
    gurux.dlms.c 9.0.2509.2601

New forum topics

  • Guidance on using the source codes
  • How to get/convert user readable format data from readRowsByRange
  • Insufficient memory to continue the execution of the program.
  • The client instance code failed to connect to the electricity meter for authentication
  • Unable to Release Request when closing connection with meter.
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin