Skip to content

For Esp8266 (nodemcu) examples don't connect to network (and don't compile) #48

Open
@skichrome

Description

@skichrome

I am testing the library on an ESP8266 based board and samples don't work without codes modifications.

First, I must replace this code bloc with just #include <ESP8266WiFi.h> because otherwise I have a compile error on line where the WiFiClient client is declared.

#include <ArduinoMqttClient.h>
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_AVR_UNO_WIFI_REV2)
  #include <WiFiNINA.h>
#elif defined(ARDUINO_SAMD_MKR1000)
  #include <WiFi101.h>
#elif defined(ARDUINO_ESP8266_ESP12)
  #include <ESP8266WiFi.h>
#endif

Second, the code is locked in setup, in while loop that check the wifi status and forbid sketch start without wifi connexion.

To get the example working I replaced this :

  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    // failed, retry
    Serial.print(".");
    delay(5000);
  }

with this:

  WiFi.begin(WIFI_SSID, WIFI_PASSWD);
  while (WiFi.status() != WL_CONNECTED) {
    // failed, retry
    delay(5000);
  }

Infos:

  • Arduino 1.8.13
  • ArduinoMqttClient 0.1.5
  • Esp8266 boards 2.7.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions