Author Topic: Compile warning when using ESP8266WiFi library, Arduino IDE  (Read 6328 times)

Pegman

  • Newbie
  • *
  • Posts: 13
Compile warning when using ESP8266WiFi library, Arduino IDE
« on: April 10, 2016, 01:39:46 am »
I have written a working sketch that reads data from a device and publishes it to my home domotica system over MQTT.

My code uses:

Code: [Select]
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

When compiling I get the following warning, but the code runs fine:
Quote
WARNING: library ESP8266WiFi claims to run on [esp8266] architecture(s) and may be incompatible with your current board which runs on [oak] architecture(s).

Using Arduino IDE 1.6.8 and Oak firmware 1.0.0.

Is this caused by using an incorrect library version (or a library that has not been made explicitly compatible with Oak) or perhaps some IDE or compiler setting?

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Compile warning when using ESP8266WiFi library, Arduino IDE
« Reply #1 on: April 10, 2016, 05:20:29 am »
Hi Pegman,

You can safely ignore that warning. It is only coming up due to the architecture flag in the library.properties file for that library indicating esp8266 as the compatible architecture, whereas the board manager core is reporting itself as being the 'oak' architecture. Erik could have fixed this by changing this flag in the libraries distributed with the Oak, but I suppose that would be yet another change from the official ESP8266 libraries / core, and they are currently looking at how best to merge the two!

Pete

Pegman

  • Newbie
  • *
  • Posts: 13
Re: Compile warning when using ESP8266WiFi library, Arduino IDE
« Reply #2 on: April 10, 2016, 05:53:30 am »
Hi Pete,

Thanks for your reply. It confirms my suspicions :)

I am glad that there's active work being done on the incorporation of ESP8266. It seems to me that the version included in Oak 1.0.1 is somewhat outdated, missing for example the functionality to make WiFi go to sleep. I would be very interested in having that available!

defragster

  • Sr. Member
  • ****
  • Posts: 467
Re: Compile warning when using ESP8266WiFi library, Arduino IDE
« Reply #3 on: April 12, 2016, 04:18:01 pm »
Pegman - can you post a working sample of MQTT code?

I keep seeing cool Connectivity methods in various threads.  Starting one thread to track them might work but could get polluted quickly - it could become a WIKI section.  It occurred to me putting a unique string once per Thread where stuff works could at least allow a forum Search to work.
MQTT::OAK_CONNECT

Pegman

  • Newbie
  • *
  • Posts: 13
Re: Compile warning when using ESP8266WiFi library, Arduino IDE
« Reply #4 on: April 17, 2016, 12:37:03 am »
defragster,

Apologies for the late reply :(

I wrote a sketch that reads data from a temp/humidity/co2 sensor and publishes it to MQTT. The MQTT part goes like this:

Code: [Select]
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

/* MQTT variables */
const char* mqtt_server = "192.168.178.xxx";
const unsigned int mqtt_port = 11883;
const char* connection_id = "ESP8266Client";
const char* client_name = "digistumpoak";
const char* client_password = "xxxxx";
const char* outTopic = "domoticz/in";           // MQTT topic for Domoticz
const char* statusTopic = "outTopic";           // General (debug/status) topic

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  client.setServer(mqtt_server, mqtt_port);

  // Connect here, in case we want to have some publishing capabilities outside
  // the publishToMQTT function.
  reconnect();
}


void loop() {
  client.loop();    // MQTT, maintain server connection

  /* do interesting stuff */

  publishToMQTT(msg);

} // loop


/*
  publish a formatted message to MQTT
*/
void publishToMQTT(char* msg) {

  // Reconnect, if necessary.
  if (!client.connected()) {
    reconnect();
  }

  client.publish(outTopic, msg);

} // publishToMQTT


/*
   Reconnect to MQTT
*/
void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    // Attempt to connect
    if (client.connect(connection_id, client_name, client_password)) {
      client.publish(statusTopic, "Oak has (re)connected");
    } else {
      // Wait before retrying
      delay(5000); // msec
    }
  }
} // reconnect



You can find the entire sketch  here.

defragster

  • Sr. Member
  • ****
  • Posts: 467
Re: Compile warning when using ESP8266WiFi library, Arduino IDE
« Reply #5 on: April 18, 2016, 12:43:32 am »
Thanks @Pegman - nice to have another reference - for general FORUM info - and myself since I want to try MQTT