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. Forums
  3. Code For Secure Energy Meter Using Nodemcu and Show All Reading On LCD

Code for Secure Energy meter using Nodemcu and Show all reading on LCD

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 ayushshriwastav, 1 November, 2022
Forums
Known problems

How can i make a code for display reading on lcd of energy meter by OBIS Code using Nodemcu. Can you suggest or link to me for making code for Secure meter?

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

The example reads the clock object. Find //Read clock.
It also prints date and time for the serial port using GXTRACE.

You need to add register objects in the same way as the clock object has been added.

The problem at the moment is that one of your settings is different than the meter expects.
Try to connect with GXDLMSDirector for your meter. It will help you to get a better idea of DLMS meters.

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks sir for reply. My question is not that use gxtrace or com_AllObject. My question is that what should i write read value in gxtrace or com_retAllObject and How should i write read value in gxtrace.?
for example, Can i write syntax in void loop() in Arduindo in given below-
ret = gxtrace("1.0.99.1.0.255") or not? please tell me syntax to read value of register and clock in void loop()?

Thanks Sir,

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

gxtrace is send to write a trace. You don't use it for the communication. You can think that gxtrace equals Console.WriteLine. It's used to print the value, not for the communication.

Check this. It will read the date and time from the clock object and then write the content of the clock object for the meter.

//Read clock
gxClock clock1;
cosem_init(BASE(clock1), DLMS_OBJECT_TYPE_CLOCK, "0.0.1.0.0.255");
com_read(BASE(clock1), 3);
com_read(BASE(clock1), 2);
obj_toString(BASE(clock1), &data);
GXTRACE(GET_STR_FROM_EEPROM("Clock"), data);
obj_clear(BASE(clock1));
free(data);

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks for replying sir, How can i read value of Register and Extended Register in void loop() function in Arduino? What is syntax of Register and Extended register in void loop() function?

Thanks sir

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

Add values that you want to read under the clock object. Something like this:

//Read register
gxRegister reg1;
cosem_init(BASE(reg1), DLMS_OBJECT_TYPE_REGISTER, "YOUR_OBIS_CODE");
com_read(BASE(reg1), 3);
com_read(BASE(reg1), 2);
obj_toString(BASE(reg1), &data);
GXTRACE(GET_STR_FROM_EEPROM("Register"), data);
obj_clear(BASE(reg1));
free(data);

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thank you so much for replying sir . How can i find InvocationCounter for Secure Meter?
Please tell me about InvocationCounter for Secure meter? How can I find it and What is role of Invocation Counter in DLMS Meter?

Thank you sir

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

When you connect to the meter there should be an Invocation Counter data object. It's used to improve security, but all meters don't use it.

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

I am very happy to hear for reply sir , thank you so much sir. If Some meter don't use Invocation Counter then What should i write in " ret = com_readAllObjects("0.0.43.1.0.255") " in the void loop()

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

Set it NULL if you don't want to use Invocation Counter.
com_readAllObjects(NULL);

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks for replying sir. I have found new error in NodeMCU Board in Arduino IDE when clock and register define in void loop() function in given below. How can I solve this sir?
Arduino: 1.8.18 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

You need to define data variable like this:
char* data = NULL;

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thank you so much sir. It is working perfectly and i did make it Global Variable char* data = NULL;
I have some question now that if i want to read more values of Register for example reg2, reg3, reg4 and reg5 etc. So what will syntax be written in void loop() function for reg2,reg3,reg4 etc??

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,
Check my answer:
https://www.gurux.fi/comment/25325#comment-25325

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks for reply sir. I am receiving this error again after convert object to string function obj_toString() in void loop() function in arduino ide in given below. Where am i going wrong ? Please tell me real solution.

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

It's a little hard to say from your pics, but you need to set data to NULL after free.

free(data);
data = NULL;

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks for replying sir. I am very happy that you are guiding well sir. I am attaching code of void loop() function of client.ino in given below - and please tell me this is Right or Wrong?

void loop()
{
int ret;
// Read the clock
gxClock clock1;
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_readAllObjects(1.0..43.1.0.255);

com_close();
}
}

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

It looks correct to me.

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks for replying sir. Very nice responsive talking. I have added more register whose name is reg2,reg3,reg4 in given below code. what is this correct code or not because i am taking register value in same time and declare global variable char* data = NULL; So please brief explain how is storing reg1,reg2,reg3 and reg4 in data in same time? And please tell sir this code is correct or not in given below-
client.ino

int ret;
// Read the clock
gxClock clock1;
//Read the Register
gxRegister reg1;
gxRegister reg2;
gxRegister reg3;
gxRegister reg4;
if (millis() - runTime > 5000)
{

}
}

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

This is the correct way to do it. You aren't reading the values with the same request. You can use readList to read multiple values with one request, but all the meters don't support it.

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Thanks for reply sir, Can you please suggest and give syntax me How can use readList to read multiple values in code?
And also brief tell sir if meter don't support it then what should be do for it?

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,
com_readScalerAndUnits do what you want to do.

https://github.com/Gurux/GuruxDLMS.c/blob/c65175efc8917f0ee3a7eb340ac4e…

If that is not supported then you need to read objects one by one as you do now.

BR,
Mikko

ayushshriwastav

3 years 1 month ago

Hi,

Hi,

Very thank you so much. Very nice talking and I am very happy that you are very helpful sir. Can you please tell how can read all value in com_readScalerAndUnits()? Please can you write a syntax to read all value in com_readScalerAndUnits().

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

I believe that you don't want to read all values. It's taking a long time, but this does it.

https://github.com/Gurux/GuruxDLMS.c/blob/c65175efc8917f0ee3a7eb340ac4e…

BR,
Mikko

Profile picture for user Kurumi

Kurumi

3 years 1 month ago

Hi,

Hi,

I believe that you don't want to read all values. It's taking a long time, but this does it.

https://github.com/Gurux/GuruxDLMS.c/blob/c65175efc8917f0ee3a7eb340ac4e…

BR,
Mikko

ayushshriwastav

2 years 12 months ago

In reply to Hi, by Kurumi

Hi, Thank you, But i am not…

Hi,

Thanks for helping but i didn,t get ouput. Sure, I will find.

Pagination

  • First page
  • Previous page
  • Page 1
  • Page 2
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 01/14/2026 - 14:29
    Gurux.DLMS.Python 1.0.196
  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5
  • Mon, 12/15/2025 - 08:11
    Gurux.DLMS.Net 4.0.87
  • Fri, 12/12/2025 - 08:38
    Gurux.DLMS.Python 1.0.195
  • Thu, 12/11/2025 - 13:22
    Gurux.DLMS.Python 1.0.194

New forum topics

  • 6-digit field values from meter not fully received (only 5 digits shown)
  • Gurux DLMS Android App
  • AMR support for bidirectional meters.
  • addition of new object in object list, meter not working
  • old meter take to much time(l&t)
More

Who's new

  • FRANCISCO
  • Supun Ellewela
  • Mario
  • brianmon
  • dejanm
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin