[SOLVED] ESP8266 MQTT API compile errors

  • Device & model you are using : NodeMCU 1.0

  • What dashboard are you using? Web

Hello community !

I’m working on updating my code for my nodemcu ESP8266 to match the MQTT API.
So, first step would be to make my board to connect with cayenne before even dreaming of modifying my code but i’m just stuck …

Added the new library, opened the exemple Connection/ESP8266Shield. It askes me to install the library ESP8266SerialLibrary.zip, which I do.

Then after adding my credentials given by the cayenne dashboard while creating a new device, I try to compile and i have this error :

/Documents/Arduino/libraries/ESP8266SerialLibrary/ESP8266.cpp:22:26: fatal error: avr/pgmspace.h: No such file or directory
#include <avr/pgmspace.h>
^
compilation terminated.
exit status 1
Erreur de compilation pour la carte Generic ESP8266 Module

(sorry, last line in french ! but you get the idea of the problem…)

Alright, so pgmspace.h is missing … after looking a bit I understand the pgmspace.h file isn’t in the avr/ folder in the board files, so i change the code to remove that bit and hit compile :

In file included from xxxx/Documents/Arduino/CayenneMQTTESP8266/CayenneMQTTESP8266.ino:21:0:
xxxx/Documents/Arduino/libraries/CayenneMQTT/src/CayenneMQTTESP8266Shield.h:36:2: error: #error This code is not intended to run on the ESP8266 platform! Please check your Tools->Board setting.
#error This code is not intended to run on the ESP8266 platform! Please check your Tools->Board setting.
^
exit status 1
Erreur de compilation pour la carte NodeMCU 1.0 (ESP-12E Module)

Imagine my surprise when I read a error message from a file called ESP8266 stating that the code isn’t intended to run on a ESP8266 platform !
Even when I delete this line in the said file I get this :

command-line>:0:9: error: expected identifier before numeric constant
/Users/CharlesSicard/Documents/Arduino/libraries/ESP8266SerialLibrary/ESP8266SerialLibrary.h:39:7: note: in expansion of macro ‘ESP8266’
class ESP8266 {
^
:0:9: error: expected unqualified-id before numeric constant
/Users/CharlesSicard/Documents/Arduino/libraries/ESP8266SerialLibrary/ESP8266SerialLibrary.h:39:7: note: in expansion of macro ‘ESP8266’
class ESP8266 {
^
exit status 1
Erreur de compilation pour la carte NodeMCU 1.0 (ESP-12E Module)

And now I’m stuck … I’m obviously doing something wrong, I can’t be the only one with those issues ! I re-installed all the libraries, updated Arduino IDA (I’m running it on a mac)

Is this a known issue ? Am I just dumb ?

I can still compile my old script with no problem …

If anyone has an idea, I’ll take it !

Thanks folks

Hi @charles.sicard,

Hmmm. Did you download the ESP specific cayenne library from Arduino IDE?

Told you I’m dumb

I downloaded it manually as it doesnt show up in the repo (as stated in the doc …) I just didnt follow the link in the device creation, I went to the docs section on top

You can delete my post if you want …

Thanl you!

1 Like

Haha no worries @charles.sicard! I’m just glad you figured things out. That’s part of the fun :slight_smile:

~Benny

Well, usually I’m a bit better than this … thanls for the help !

Hi,
Same problem.
I’m using Wemos D1. In the ESP8266.cpp file I changed the #include <avr/pgmspace.h> row to this:

#if (defined(AVR))
#include <avr\pgmspace.h>
#else
#include <pgmspace.h>
#endif

I get the error message:
Documents/Arduino/libraries/CayenneMQTT/src/CayenneMQTTESP8266Shield.h:36:2: error: #error This code is not intended to run on the ESP8266 platform! Please check your Tools->Board setting.
#error This code is not intended to run on the ESP8266 platform! Please check your Tools->Board setting.
^
I installed all of the necessary libraries.
Any idea?

you are using wrong library. Have a look at this tutorial Adding a New Device using MQTT

Thanks. It is working.

1 Like