The old #include <ESP8266WiFi.h> not found

I am trying to compile this project: GitHub - absalom-muc/MHI-AC-Ctrl: Reads and writes data (e.g. power, mode, fan status etc.) from/to a Mitsubishi Heavy Industries (MHI) air conditioner (AC) via SPI controlled by MQTT
… which many before seem to have successfully done. However, I get a compile error.

In file included from src/main.cpp:7:
src/support.h:58:10: fatal error: ESP8266WiFi.h: No such file or directory

line 58 in support.h

#include <ESP8266WiFi.h>        // https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi
#include <PubSubClient.h>       // https://github.com/knolleary/pubsubclient
#include <ArduinoOTA.h>         // https://github.com/esp8266/Arduino/tree/master/libraries/ArduinoOTA

As per compile result, I tried this:

platformio lib search "header:ESP8266WiFi.h"

WARNING: This command is deprecated and will be removed in the next releases. 
Please use `pio pkg search` instead.

Nothing has been found by your request
Try a less-specific search or use truncation (or wildcard) operator *

The board is a Wemos D1 mini.

platformio.ini looks like this:

[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
lib_deps =
	jandrassy/ArduinoOTA@^1.1.0
	knolleary/PubSubClient@2.7

What am I doing wrong?
Any hints appreciated.

(There is a similar post for this project: Stuck! Fatal error: ESP8266WiFi.h: No such file or directory when compiling
… but he used a different ESP board.)

You are using Espressif32 framework and an esp32 based board.

You have to #include <WiFi.h>.
ESP8266WiFi.h is for ESP8266!

Isn’t the Wemos D1 mini an ESP8266?
(I usually do not work with ESPs, hence, always puzzled about the many boards.)

I let platformio create the project, and thus the .ini… selecting the Wemos D1 mini.
What do I need to change? Or was selecting the Arduino framework the wrong thing?

I actually tried <WiFi.h> and got lots of errors.

src/main.cpp: In function 'void setup()':
src/main.cpp:536:52: error: 'class EspClass' has no member named 'getCoreVersion'; did you mean 'getSdkVersion'?
     Serial.printf("ESP.getCoreVersion()=%s\n", ESP.getCoreVersion().c_str());
                                                    ^~~~~~~~~~~~~~
                                                    getSdkVersion
src/main.cpp:538:51: error: 'class EspClass' has no member named 'checkFlashCRC'
     Serial.printf("ESP.checkFlashCRC()=%i\n", ESP.checkFlashCRC());
                                                   ^~~~~~~~~~~~~
src/support.cpp: In function 'void handleWiFiScanResult(int)':
src/support.cpp:106:170: error: 'ENC_TYPE_NONE' was not declared in this scope
         Serial.printf("%2d %25s %2d %ddBm %s %s %02x\n", i + 1, WiFi.SSID(i).c_str(), WiFi.channel(i), WiFi.RSSI(i), WiFi.BSSIDstr(i).c_str(), WiFi.encryptionType(i) == ENC_TYPE_NONE ? "open" : "secured", (uint)WiFi.encryptionType(i));
                                                                                                                                                                          ^~~~~~~~~~~~~
Compiling .pio/build/wemos_d1_mini32/lib69c/WiFi/WiFiUdp.cpp.o
src/support.cpp:106:170: note: suggested alternative: 'ESP_LOG_NONE'
         Serial.printf("%2d %25s %2d %ddBm %s %s %02x\n", i + 1, WiFi.SSID(i).c_str(), WiFi.channel(i), WiFi.RSSI(i), WiFi.BSSIDstr(i).c_str(), WiFi.encryptionType(i) == ENC_TYPE_NONE ? "open" : "secured", (uint)WiFi.encryptionType(i));
                                                                                                                                                                          ^~~~~~~~~~~~~
                                                                                                                                                                          ESP_LOG_NONE
src/support.cpp: In function 'void setupWiFi(int&)':
src/support.cpp:150:18: error: 'class WiFiClass' has no member named 'scanNetworksAsync'; did you mean 'scanNetworks'?
             WiFi.scanNetworksAsync(handleWiFiScanResult);
                  ^~~~~~~~~~~~~~~~~
                  scanNetworks
src/support.cpp: In function 'void setupOTA()':
src/support.cpp:359:16: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setHostname'
     ArduinoOTA.setHostname(OTA_HOSTNAME);
                ^~~~~~~~~~~
src/support.cpp:362:20: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setPassword'
         ArduinoOTA.setPassword(OTA_PASSWORD);
                    ^~~~~~~~~~~
src/support.cpp: In lambda function:
src/support.cpp:368:24: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'getCommand'
         if (ArduinoOTA.getCommand() == U_FLASH)
                        ^~~~~~~~~~
src/support.cpp:368:40: error: 'U_FLASH' was not declared in this scope
         if (ArduinoOTA.getCommand() == U_FLASH)
                                        ^~~~~~~
src/support.cpp: In function 'void setupOTA()':
src/support.cpp:377:16: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onEnd'
     ArduinoOTA.onEnd([]()
                ^~~~~
src/support.cpp:382:16: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onProgress'
     ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
                ^~~~~~~~~~
src/support.cpp:387:27: error: 'ota_error_t' has not been declared
     ArduinoOTA.onError([](ota_error_t error)
                           ^~~~~~~~~~~
src/support.cpp: In lambda function:
src/support.cpp:391:22: error: 'OTA_AUTH_ERROR' was not declared in this scope
         if (error == OTA_AUTH_ERROR)
                      ^~~~~~~~~~~~~~
src/support.cpp:391:22: note: suggested alternative: 'UART_NO_ERROR'
         if (error == OTA_AUTH_ERROR)
                      ^~~~~~~~~~~~~~
                      UART_NO_ERROR
src/support.cpp:393:27: error: 'OTA_BEGIN_ERROR' was not declared in this scope
         else if (error == OTA_BEGIN_ERROR)
                           ^~~~~~~~~~~~~~~
src/support.cpp:393:27: note: suggested alternative: 'ESP_LOG_ERROR'
         else if (error == OTA_BEGIN_ERROR)
                           ^~~~~~~~~~~~~~~
                           ESP_LOG_ERROR
src/support.cpp:395:27: error: 'OTA_CONNECT_ERROR' was not declared in this scope
         else if (error == OTA_CONNECT_ERROR)
                           ^~~~~~~~~~~~~~~~~
src/support.cpp:395:27: note: suggested alternative: 'STA_CONNECTED_BIT'
         else if (error == OTA_CONNECT_ERROR)
                           ^~~~~~~~~~~~~~~~~
                           STA_CONNECTED_BIT
src/support.cpp:397:27: error: 'OTA_RECEIVE_ERROR' was not declared in this scope
         else if (error == OTA_RECEIVE_ERROR)
                           ^~~~~~~~~~~~~~~~~
src/support.cpp:399:27: error: 'OTA_END_ERROR' was not declared in this scope
         else if (error == OTA_END_ERROR)
                           ^~~~~~~~~~~~~
src/support.cpp:399:27: note: suggested alternative: 'UART_NO_ERROR'
         else if (error == OTA_END_ERROR)
                           ^~~~~~~~~~~~~
                           UART_NO_ERROR
src/support.cpp: In function 'void setupOTA()':
src/support.cpp:401:6: error: invalid user-defined conversion from 'setupOTA()::<lambda(int)>' to 'void (*)(int, const char*)' [-fpermissive]
     });
      ^
src/support.cpp:387:44: note: candidate is: 'setupOTA()::<lambda(int)>::operator void (*)(int)() const' <near match>
     ArduinoOTA.onError([](ota_error_t error)
                                            ^
src/support.cpp:387:44: note:   no known conversion from 'void (*)(int)' to 'void (*)(int, const char*)'
In file included from .pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/ArduinoOTA.h:22,
                 from src/support.h:60,
                 from src/support.cpp:1:
.pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/WiFiOTA.h:49:8: note:   initializing argument 1 of 'void WiFiOTAClass::onError(void (*)(int, const char*))'
   void onError(void (*fn)(int code, const char* msg)) {
        ^~~~~~~
src/support.cpp:403:22: error: no matching function for call to 'ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>::begin()'
     ArduinoOTA.begin();
                      ^
In file included from src/support.h:60,
                 from src/support.cpp:1:
.pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/ArduinoOTA.h:94:8: note: candidate: 'void ArduinoOTAMdnsClass<NetServer, NetClient, NetUDP>::begin(IPAddress, const char*, const char*, OTAStorage&) [with NetServer = WiFiServer; NetClient = WiFiClient; NetUDP = WiFiUDP]'
   void begin(IPAddress localIP, const char* name, const char* password, OTAStorage& storage) {
        ^~~~~
.pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/ArduinoOTA.h:94:8: note:   candidate expects 4 arguments, 0 provided
Compiling .pio/build/wemos_d1_mini32/lib793/FS/FS.cpp.o
*** [.pio/build/wemos_d1_mini32/src/main.cpp.o] Error 1
*** [.pio/build/wemos_d1_mini32/src/support.cpp.o] Error 1

Afaik there are two D1 mini. ESP32 and ESP8266.
Which one do you have?

It says: ESP8266MOD.

… which is the same as in the project:

I do not have the board connected. This is merely compiling the original (provided) project files w/o any modifications.

Then you must use framework=espressif8266 and board=d1_mini

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wemos_d1_mini32.html
PLATFORM: Espressif 32 (6.3.1) > WEMOS D1 MINI ESP32
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- tool-esptoolpy @ 1.40501.0 (4.5.1)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Error: This board doesn't support espressif8266 and board = d1_mini framework!
========================== [FAILED] Took 0.26 seconds ==========================
[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = espressif8266 and board = d1_mini
#framework = arduino
lib_deps =
	jandrassy/ArduinoOTA@^1.1.0
	knolleary/PubSubClient@2.7

Maybe the board name is wrong too?!

my bad. i meant platform=espressif8266 not framework.

platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
	jandrassy/ArduinoOTA@^1.1.0
	knolleary/PubSubClient@2.7

Thanks for hanging in there…

Dependency Graph
|-- ArduinoOTA @ 1.1.0
|-- PubSubClient @ 2.7.0
|-- ESP8266WiFi @ 1.0
Building in release mode

At least the ESP8266WiFi.h error is gone…

Have a bunch of yellow warnings…
… but also red ones:

src/support.cpp: In function 'void setupOTA()':
src/support.cpp:359:16: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setHostname'
  359 |     ArduinoOTA.setHostname(OTA_HOSTNAME);
      |                ^~~~~~~~~~~
src/support.cpp:362:20: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'setPassword'
  362 |         ArduinoOTA.setPassword(OTA_PASSWORD);
      |                    ^~~~~~~~~~~
src/support.cpp: In lambda function:
src/support.cpp:368:24: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'getCommand'
  368 |         if (ArduinoOTA.getCommand() == U_FLASH)
      |                        ^~~~~~~~~~
src/support.cpp: In function 'void setupOTA()':
src/support.cpp:377:16: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onEnd'
  377 |     ArduinoOTA.onEnd([]()
      |                ^~~~~
src/support.cpp:382:16: error: 'class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>' has no member named 'onProgress'
  382 |     ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
      |                ^~~~~~~~~~
src/support.cpp:387:27: error: 'ota_error_t' has not been declared
  387 |     ArduinoOTA.onError([](ota_error_t error)
      |                           ^~~~~~~~~~~
src/support.cpp: In lambda function:
src/support.cpp:391:22: error: 'OTA_AUTH_ERROR' was not declared in this scope
  391 |         if (error == OTA_AUTH_ERROR)
      |                      ^~~~~~~~~~~~~~
src/support.cpp:393:27: error: 'OTA_BEGIN_ERROR' was not declared in this scope
  393 |         else if (error == OTA_BEGIN_ERROR)
      |                           ^~~~~~~~~~~~~~~
src/support.cpp:395:27: error: 'OTA_CONNECT_ERROR' was not declared in this scope
  395 |         else if (error == OTA_CONNECT_ERROR)
      |                           ^~~~~~~~~~~~~~~~~
src/support.cpp:397:27: error: 'OTA_RECEIVE_ERROR' was not declared in this scope
  397 |         else if (error == OTA_RECEIVE_ERROR)
      |                           ^~~~~~~~~~~~~~~~~
src/support.cpp:399:27: error: 'OTA_END_ERROR' was not declared in this scope
  399 |         else if (error == OTA_END_ERROR)
      |                           ^~~~~~~~~~~~~
src/support.cpp: In function 'void setupOTA()':
src/support.cpp:401:6: error: invalid user-defined conversion from 'setupOTA()::<lambda(int)>' to 'void (*)(int, const char*)' [-fpermissive]
  401 |     });
      |      ^
src/support.cpp:387:24: note: candidate is: 'constexpr setupOTA()::<lambda(int)>::operator void (*)(int)() const' (near match)
  387 |     ArduinoOTA.onError([](ota_error_t error)
      |                        ^
src/support.cpp:387:24: note:   no known conversion from 'void (*)(int)' to 'void (*)(int, const char*)'
In file included from .pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/ArduinoOTA.h:22,
                 from src/support.h:60,
                 from src/support.cpp:1:
.pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/WiFiOTA.h:49:23: note:   initializing argument 1 of 'void WiFiOTAClass::onError(void (*)(int, const char*))'
   49 |   void onError(void (*fn)(int code, const char* msg)) {
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/support.cpp:403:22: error: no matching function for call to 'ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>::begin()'
  403 |     ArduinoOTA.begin();
      |                      ^
In file included from src/support.h:60,
                 from src/support.cpp:1:
.pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/ArduinoOTA.h:94:8: note: candidate: 'void ArduinoOTAMdnsClass<NetServer, NetClient, NetUDP>::begin(IPAddress, const char*, const char*, OTAStorage&) [with NetServer = WiFiServer; NetClient = WiFiClient; NetUDP = WiFiUDP]'
   94 |   void begin(IPAddress localIP, const char* name, const char* password, OTAStorage& storage) {
      |        ^~~~~
.pio/libdeps/wemos_d1_mini32/ArduinoOTA/src/ArduinoOTA.h:94:8: note:   candidate expects 4 arguments, 0 provided
Compiling .pio/build/wemos_d1_mini32/libb89/ESP8266SdFat/ExFatLib/ExFatFilePrint.cpp.o
Compiling .pio/build/wemos_d1_mini32/libb89/ESP8266SdFat/ExFatLib/ExFatFormatter.cpp.o
Compiling .pio/build/wemos_d1_mini32/libb89/ESP8266SdFat/ExFatLib/ExFatFileWrite.cpp.o
*** [.pio/build/wemos_d1_mini32/src/support.cpp.o] Error 1

… which I need to look at; weird.

Thats strange.
Usually ArduinoOTA is available for ESP8266.
Im not on my PC right now.

Please check for updates of the ESP8266 platform.

It seems to be present…

PlatformIO, libraries, boards, etc. all up-to-date.

Line 76 in ArduinoOTA.h shows orange:

    NetClient client = server.available();

‘WiFiClient WiFiServer::available(uint8_t*)’ is deprecated: Renamed to accept(). [-Wdeprecated-declarations]

NetServer::available

and I changed it to:

    NetClient client = server.accept();

… but that does not resolve the errors.

I may use the Arduino IDE to check if there is a difference…

[edit]
While I usually don’t use the Arduino IDE, it shows:

. Variables and constants in RAM (global, static), used 30308 / 80192 bytes (37%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ DATA     1560     initialized variables
╠══ RODATA   2060     constants       
╚══ BSS      26688    zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 61359 / 65536 bytes (93%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ ICACHE   32768    reserved space for flash instruction cache
╚══ IRAM     28591    code in IRAM    
. Code in flash (default, ICACHE_FLASH_ATTR), used 301744 / 1048576 bytes (28%)
║   SEGMENT  BYTES    DESCRIPTION
╚══ IROM     301744   code in flash  

… it seems it compiles the code.

… could write it too:

esptool.py v3.0
Serial port /dev/ttyUSB1
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 08:f9:e0:73:e6:76
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 338112 bytes to 243874...
Writing at 0x00000000... (6 %)
Writing at 0x00004000... (13 %)
Writing at 0x00008000... (20 %)
Writing at 0x0000c000... (26 %)
Writing at 0x00010000... (33 %)
Writing at 0x00014000... (40 %)
Writing at 0x00018000... (46 %)
Writing at 0x0001c000... (53 %)
Writing at 0x00020000... (60 %)
Writing at 0x00024000... (66 %)
Writing at 0x00028000... (73 %)
Writing at 0x0002c000... (80 %)
Writing at 0x00030000... (86 %)
Writing at 0x00034000... (93 %)
Writing at 0x00038000... (100 %)
Wrote 338112 bytes (243874 compressed) at 0x00000000 in 21.3 seconds (effective 127.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Hmmm… seems to be a PlatformIO issue…?!

The project seems to be based on an older Arduino core. I guess 2.x.x.
Try platform=espressif8266@^2.6.3
That’s the last 2.x version. To be exact: 2.7.4

I’m back at the PC and was able to solve the problem.

  1. rename “MHI-AC-Ctrl.ino” to “MHI-AC-Ctrl.cpp
  2. use the following platformio.ini:
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
	knolleary/PubSubClient@2.7

The last issue was with lib_deps = jandrassy/ArduinoOTA@^1.1.0
ArduinoOTA is part of ESP8266 Arduino core and jandrassy/ArduinoOTA@^1.1.0 is superfluousis and also incompatible

1 Like

You’re a genius! Thank you so much… it’s working now. Awesome!

Retrieving maximum program size .pio/build/d1_mini/firmware.elf
Checking size .pio/build/d1_mini/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  37.1% (used 30432 bytes from 81920 bytes)
Flash: [===       ]  32.0% (used 333760 bytes from 1044464 bytes)
Building .pio/build/d1_mini/firmware.bin
Creating BIN file ".pio/build/d1_mini/firmware.bin" using "/home/maxg/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and ".pio/build/d1_mini/firmware.elf"
============================================================= [SUCCESS] Took 7.92 seconds =============================================================

The first thing I did when starting with this project was renaming the ‘.ino’ to ‘main.cpp’.
The key things seem to be the platformio.ini and ArduinoOTA.h.

I most likely would not have figured out the ArduinoOTA.h issue, considered I added this library to the Arduino IDE and had no issue there.

Not getting this to work would have been a disappointment, as I already received the circuit boards I ordered for this project. Again, thank you.

1 Like