Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By naish
#24918 I'm unable to make it work.
I think I have a problem with the PubSubClient.h library. I've found 3 different versions, none of them work.

The most interesting error:

In file included from esp8266_pubsubclient.ino:1:0:
C:\Users\George\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\pubsubclient-master\src/PubSubClient.h:72:46: error: section attribute not allowed for '<anonymous>'
boolean publish_P(char *, uint8_t PROGMEM *, unsigned int, boolean);

Apart from other warnings, that will compile:
esp8266_pubsubclient.ino:7:15: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Any thoughts?
User avatar
By Nearly
#25203
naish wrote:I'm unable to make it work.
I think I have a problem with the PubSubClient.h library. I've found 3 different versions, none of them work.

The most interesting error:

In file included from esp8266_pubsubclient.ino:1:0:
C:\Users\George\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\pubsubclient-master\src/PubSubClient.h:72:46: error: section attribute not allowed for '<anonymous>'
boolean publish_P(char *, uint8_t PROGMEM *, unsigned int, boolean);

Apart from other warnings, that will compile:
esp8266_pubsubclient.ino:7:15: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Any thoughts?


I had the exact same issue as you. Took a few days to work that one out...

The following is a very dirty solution, much more elegant ones must exist out there :
1) Got the original Nicholas O'Leary's PubSubClient https://github.com/knolleary/pubsubclient
2) Installed it manually in the arduino library folder. Renamed the folder PubSubClient2 as well as all instances "PubSubClient" As "PubSubClient2" in all files within. (This is so it does not conflict with newer PubSubClient versions installed on your system and used by your other sketches).
3) Deleted PROGMEM references in both PubSubClient2.h and PubSubClient2.cpp. See https://github.com/knolleary/pubsubclient/issues/46
4) Renamed PubSubClient.h as PubSubClient2.h in the original sketch.
5) Blessfully ignored warning messages that did not prevent the sketch to compile.

Hope that helps.
EDIT : Code is now tested and works (Beware IoT, I'm coming for you).

I take this opportunity to thank this amazing community for the work done : what has been achieved is truly amazing.

Chris
User avatar
By ian
#25304 I've also found 3 MQTT libraries & they've all worked for me.
Unfortunately they all share the same name but behave differently :(
It's a bit tricky trying to work with the subtle differences, particularly as the Arduino library manager no longer allows us to temporarily rename the library folders.
My feeling is that the original 'knolleary' library is the most flexible but not the easiest to use.