I am Currently working on a project to develop an iiot gateway like device. And I am planning to add DLMS interface in it. The device will run on ESP8266 and another model on ESP32.
So help me get started with the physical level interfacing required to connect a DLMS meter to Arduino.
I believe Optical interface and RS232 Serial interfaces are available. right?
But if I intend to use optical interface to Read data, then what is required on the ESP8266 Side?
Optical to serial converters ? fibre cables ? which Mode of fibre?
I hope I can get a detailed guidance here.
Yes, you should be able to use this TTL converter to connect your gateway to a meter. You need an optical head that you can connect to the serial port. There are lots of different optical heads so make sure that head is supporting IEC 62056-21 or it doesn't work.
Now will this work with RS485?
Say if I use TTL to RS485 converter, DLMS will work on that too?
And in the code Client.ino can I use software serial instead of serial1?
And what are the fields or values that I should change in the code so as to read from a meter? I mean each meters are different so settings will differ. right?
I appreciate your help and I desperately need your guidance here.
Serial and Serial1 are default serial interfaces of the hardware and there are dedicated pins for that.
But SoftwareSerial is a Library used to allow Serial communication on user defined GPIO pins. Software serial is very dependable and have worked on all kinds of projects with serial comm.
Its working perfectly fine with Modbus-RTU in esp8266.
how are the serial ports used in client.ino?
Serial1 to communicate with DLMS meter and default serial to print the output to Serial monitor in PC. am I right?
Happy to inform you that the code compiled and uploaded to ESP8266. Now I am working on the connection interfaces. Looks like I got it wrong.
The meter I am using is Genus Single phase DLMS Meter with RJ11 Port for RS232
So can you help me with RJ11 to DB9 pin diagram? Any reference doc available regarding this?
Also The BAUD Rate = 9600 , And a Low Level Password of 8 characters
So What all settings should I do in the code for this specific Meter?
Thank you, it worked
After some tweaking I got the meter to communicate with both PC and Nodemcu.
Now I faced a slight issue while reading attributes from Register Object.
I used exception decoder to see the problem here is what i got
Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
PC: 0x4000df1b
EXCVADDR: 0x402518c0
Decoding stack results
0x40202973: bb_set at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\bytebuffer.c line 528
0x40202a2c: bb_addString at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\bytebuffer.c line 589
0x40204d7c: obj_RegisterToString at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\converters.c line 732
0x40207d0d: obj_toString at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\converters.c line 3083
0x402162fd: com_readAllObjects(char const*) at E:\AMAL\micredge\iiotnext-edge\Trials\DLMS-test\DLMS-client/DLMS-client.ino line 958
0x40216370: loop() at E:\AMAL\micredge\iiotnext-edge\Trials\DLMS-test\DLMS-client/DLMS-client.ino line 1019
0x4021795c: loop_wrapper() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197
I can't find any reason for this in your code. Check com_read return value. Is that zero?
Can you read 1.0.12.7.0.255 with GXDLMSDirector and add a hex trace from the read and reply messages so I can try to figure out what might cause this?
Hi Amal,
Hi Amal,
Yes, you should be able to use this TTL converter to connect your gateway to a meter. You need an optical head that you can connect to the serial port. There are lots of different optical heads so make sure that head is supporting IEC 62056-21 or it doesn't work.
BR,
Mikko
Got it sir, Thank you
Got it sir, Thank you
Now will this work with RS485?
Say if I use TTL to RS485 converter, DLMS will work on that too?
And in the code Client.ino can I use software serial instead of serial1?
And what are the fields or values that I should change in the code so as to read from a meter? I mean each meters are different so settings will differ. right?
I appreciate your help and I desperately need your guidance here.
Hi,
Hi,
Yes, that should work. I'm sorry, but I don't understand what you mean by software serial?
You need to change the correct serial port settings and set correct parameters in Client.init method.
https://github.com/Gurux/GuruxDLMS.c/blob/220b212f800e37e420e511ff376ef…
BR,
Mikko
Hi,
Hi,
Serial and Serial1 are default serial interfaces of the hardware and there are dedicated pins for that.
But SoftwareSerial is a Library used to allow Serial communication on user defined GPIO pins. Software serial is very dependable and have worked on all kinds of projects with serial comm.
Its working perfectly fine with Modbus-RTU in esp8266.
Hi,
Hi,
I don't see any reason why the software serial doesn't work, but the only way to make sure is to try.
BR,
Mikko
Hi
Hi
how are the serial ports used in client.ino?
Serial1 to communicate with DLMS meter and default serial to print the output to Serial monitor in PC. am I right?
Hi,
Hi,
The example program prints output to Serial1 and Serial is used to communicate with the meter.
BR,
Mikko
Hi,
Hi,
Happy to inform you that the code compiled and uploaded to ESP8266. Now I am working on the connection interfaces. Looks like I got it wrong.
The meter I am using is Genus Single phase DLMS Meter with RJ11 Port for RS232
So can you help me with RJ11 to DB9 pin diagram? Any reference doc available regarding this?
Also The BAUD Rate = 9600 , And a Low Level Password of 8 characters
So What all settings should I do in the code for this specific Meter?
Hi,
Hi,
I have to say that buy the cable ready if possible. It will save lots of problems.
Your settings will be something like this:
Client.init(true, 32, 1, DLMS_AUTHENTICATION_LOW, YOUR_PASSWORD, DLMS_INTERFACE_TYPE_HDLC);
BR,
Mikko
Hi
Hi
Thank you, it worked
After some tweaking I got the meter to communicate with both PC and Nodemcu.
Now I faced a slight issue while reading attributes from Register Object.
To get voltage value from meter I added this code
//Read Voltage
gxRegister voltage;
cosem_init(BASE(voltage), DLMS_OBJECT_TYPE_REGISTER, "1.0.12.7.0.255");
com_read(BASE(voltage), 3);
com_read(BASE(voltage), 2);
obj_toString(BASE(voltage), &data);
GXTRACE(GET_STR_FROM_EEPROM("voltage"), data);
obj_clear(BASE(voltage));
free(data);
But NodeMCU crashes on this code
Exception (3):
epc1=0x4000df1b epc2=0x00000000 epc3=0x00000000 excvaddr=0x402518c0 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffce0 end: 3fffffc0 offset: 0190
3ffffe70: 3fffdad0 00000008 3ffffec0 40202973
3ffffe80: 31302e30 30303030 3ffe0000 3ffef7dc
3ffffe90: 3fffdad0 3fffff88 3ffffec0 40202a2c
3ffffea0: 402518c0 00000000 00000000 3ffef7dc
3ffffeb0: 3fffdad0 3fffff88 3fffff40 40204d7c
3ffffec0: 3fff141c 0027004b 00000000 40200000
3ffffed0: 070c0001 00000000 00000000 40207d0d
3ffffee0: 3fffdad0 00000000 00000000 402162fd
3ffffef0: 00000008 00000000 ff000001 00000000
3fffff00: 00000000 00000000 00000000 00000000
3fffff10: 00000000 00000000 00000000 00000000
3fffff20: 0000014a 638def7e 0080014a 00000000
3fffff30: 00000000 00000000 00000000 00000000
3fffff40: 00000003 00010000 ff00070c 00000000
3fffff50: 00000012 00000000 000059b0 00000000
3fffff60: 000123fe 00000000 00000001 00000000
3fffff70: ff00002a 00000000 00000000 00000000
3fffff80: 00000000 00000000 3fff141c 3ffef7dc
3fffff90: 3fffdad0 00000000 3ffef480 40216370
3fffffa0: 3fffdad0 00000000 3ffef79c 4021795c
3fffffb0: feefeffe feefeffe 3ffe84e8 40101289
<<<stack<<<
I used exception decoder to
I used exception decoder to see the problem here is what i got
Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
PC: 0x4000df1b
EXCVADDR: 0x402518c0
Decoding stack results
0x40202973: bb_set at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\bytebuffer.c line 528
0x40202a2c: bb_addString at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\bytebuffer.c line 589
0x40204d7c: obj_RegisterToString at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\converters.c line 732
0x40207d0d: obj_toString at C:\Users\DELL\AppData\Local\Temp\arduino_build_109995\sketch\src\converters.c line 3083
0x402162fd: com_readAllObjects(char const*) at E:\AMAL\micredge\iiotnext-edge\Trials\DLMS-test\DLMS-client/DLMS-client.ino line 958
0x40216370: loop() at E:\AMAL\micredge\iiotnext-edge\Trials\DLMS-test\DLMS-client/DLMS-client.ino line 1019
0x4021795c: loop_wrapper() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197
Hi,
Hi,
I can't find any reason for this in your code. Check com_read return value. Is that zero?
Can you read 1.0.12.7.0.255 with GXDLMSDirector and add a hex trace from the read and reply messages so I can try to figure out what might cause this?
BR,
Mikko