Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

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

Breadcrumb

  1. Home
  2. Forums
  3. Errors In Compiling Arduino Server For ESP32

Errors in compiling Arduino server for ESP32

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 bhatiasidharth.89 , 14 August, 2021
Forums
General discussion

Hi Mikko,

I am trying to compile the Arduino server example for ESP32 but I am getting some errors. The code compiles and works fine for Arduino Mega. Following are the errors:
Arduino: 1.8.15 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

server:990:5: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER1_COMPA_vect) {

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino: In function 'int loadTargets(GXPushObjects*, gxTarget*, short unsigned int*)':

server:616:75: error: invalid conversion from 'short unsigned int' to 'DLMS_OBJECT_TYPE {aka tagDLMS_OBJECT_TYPE}' [-fpermissive]

if ((ret = oa_findByLN(Server.getObjects(), savedObjects->values[pos].objectType, savedObjects->values[pos].logicalName, &it)) != 0)

^

In file included from C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\included\dlmssettings.h:42:0,

from C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\included\serverevents.h:38,

from C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\GXDLMSServer.h:38,

from C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino:35:

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\included\objectarray.h:112:9: note: initializing argument 2 of 'int oa_findByLN(objectArray*, DLMS_OBJECT_TYPE, const unsigned char*, gxObject**)'

int oa_findByLN(

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino: In function 'void setTimer()':

server:973:3: error: 'TCCR1A' was not declared in this scope

TCCR1A = 0;

^

server:974:3: error: 'TCCR1B' was not declared in this scope

TCCR1B = 0;

^

server:976:3: error: 'TCNT1' was not declared in this scope

TCNT1 = 0;

^

server:978:3: error: 'OCR1A' was not declared in this scope

OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be < 65536)

^

server:980:19: error: 'WGM12' was not declared in this scope

TCCR1B |= (1 << WGM12);

^

server:982:19: error: 'CS12' was not declared in this scope

TCCR1B |= (1 << CS12) | (1 << CS10);

^

server:982:33: error: 'CS10' was not declared in this scope

TCCR1B |= (1 << CS12) | (1 << CS10);

^

server:984:3: error: 'TIMSK1' was not declared in this scope

TIMSK1 |= (1 << OCIE1A);

^

server:984:19: error: 'OCIE1A' was not declared in this scope

TIMSK1 |= (1 << OCIE1A);

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino: At global scope:

server:990:4: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER1_COMPA_vect) {

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino: In function 'void svr_postWrite(dlmsSettings*, gxValueEventCollection*)':

server:1789:67: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]

GXTRACE(PSTR("Low level password: "), associationLow.secret.data);

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino:279:6: note: initializing argument 2 of 'void GXTRACE(const char*, const char*)'

void GXTRACE(const char* str, const char* data)

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino: In function 'void svr_postAction(dlmsSettings*, gxValueEventCollection*)':

server:1817:69: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]

GXTRACE(PSTR("High level password: "), associationHigh.secret.data);

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino:279:6: note: initializing argument 2 of 'void GXTRACE(const char*, const char*)'

void GXTRACE(const char* str, const char* data)

^

server:1824:73: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]

GXTRACE(PSTR("High level password: "), associationHighGMac.secret.data);

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino:279:6: note: initializing argument 2 of 'void GXTRACE(const char*, const char*)'

void GXTRACE(const char* str, const char* data)

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino: In function 'DLMS_SOURCE_DIAGNOSTIC svr_validateAuthentication(dlmsServerSettings*, DLMS_AUTHENTICATION, gxByteBuffer*)':

server:1942:58: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]

GXTRACE(PSTR("Valid low level password."), password->data);

^

C:\Users\MKBHATIA\Documents\gurux_esp32_arduino\server\server.ino:279:6: note: initializing argument 2 of 'void GXTRACE(const char*, const char*)'

void GXTRACE(const char* str, const char* data)

^

exit status 1

expected constructor, destructor, or type conversion before '(' token

There were a few more errors but I could correct them by making the following changes to the server.ino file:
1. Changed EEPROM.update to EEPROM.write
2. Added a define for LED_BUILTIN

I am using the latest code from Github and latest Arduino IDE 1.18.15

Regards
Sidharth Bhatia

Profile picture for user Kurumi

Kurumi

4 years 10 months ago

Hi Sidharth,

Hi Sidharth,

What is your additional Board Manager Url? You can find that from the Arduino settings.

BR,
Mikko

bhatiasidharth.89

4 years 10 months ago

Hi Mikko,

Hi Mikko,

The additional Board Manager Url is:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/pack…

Profile picture for user Kurumi

Kurumi

4 years 10 months ago

Hi,

Hi,

Get the latest version from GitHub. Compiler errors for this board are fixed. Let me know if you have any problems.

BR,
Mikko

bhatiasidharth.89

4 years 9 months ago

Hi Mikko,

Hi Mikko,

Thanks for solving the compile errors. I tried with the latest version from GitHub and the code does compile fine. But the DLMS Director is not able to connect to the meter. The debug port shows the following log when the ESP32 starts:
:Communication speed 300..:Test mode Is OFF...:LLS password..:HLS password.

Regards

Profile picture for user Kurumi

Kurumi

4 years 9 months ago

Hi,

Hi,

I believe that invalid data is read from the flash. Find load() method and return zero. It will create all objects and use the default values. Something like this:

uint16_t load()
{
return 0;
}

BR,
Mikko

bhatiasidharth.89

4 years 9 months ago

Hi Mikko,

Hi Mikko,

Thanks, that worked. The DLMS director is able to connect to the meter now. But I don't get any logs on the second serial port which I get on the Arduino Mega apart from the log at the start of the sketch. Is it something to do with the change you have suggested above and would I need to keep this change permanently for ESP32? Also, the log at the startup shows EEPROM size to be 0.

Regards
Sidharth

Profile picture for user Kurumi

Kurumi

4 years 9 months ago

Hi Sidharth,

Hi Sidharth,

If EEPROM size is zero then it might be the reason for this. I believe that your app can't access the EEPROM for some reason or there is no EEPROM.

You should receive trace if testMode is set. Check your cables. Can you share information from your board? I'll order one so this can be tested with the same HW.

BR,
Mikko

bhatiasidharth.89

4 years 9 months ago

Hi Mikko,

Hi Mikko,

I am using the ESP32_Devkitc_V4 board. I did some research and found out that for ESP32, by default the EEPROM.length() function returns 0. We would need to use the following command to initialise the EEPROM first: EEPROM.begin(EEPROM_SIZE). Here the EEPROM_SIZE is a variable (or a macro definition) specifying the number of bytes we need for the EEPROM storage. I believe the maximum would be 512 bytes.
The EEPROM.length() function will still return zero but the EEPROM would be accessible. Instead we can get the EEPROM length by reading the value of EEPROM_SIZE variable.

Could you please tell me how much space would be needed in the EEPROM for the server Arduino sketch?

Regards

bhatiasidharth.89

4 years 9 months ago

Another option is given here:

Another option is given here: https://esp32.com/viewtopic.php?t=7012
But it seems this would require large number of changes to keep the compatibility with the AVR boards.

Profile picture for user Kurumi

Kurumi

4 years 9 months ago

Hi,

Hi,

SIze of the EEPROM depends on what you want to save. For example, what are the sizes of the profile generic buffers.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin