PlatformIO Community

WiFi on `heltec_wifi_kit_32` not compiling/found

IDE: Clion
PIO Core : 3.6.7

Cannot work out why I cant get the wifi examples to work properly.
I have managed to get basic things like the OLED to work but its struggling to find the correct WiFi.h header.
Source code has been trimmed to get wifi working, hence the other libraries.
using ArduinoIDE I have managed to get it to work, just not in CLion with platformio.

EDIT
Following some more investigation I am not sure that the toolchain is being installed correctly:

thanks in advance

platformio.ini

[common_env_data]
lib_deps_builtin =
    SPI
    Wire
lib_deps =
    421
    322
    83
    Time

;other env removed for clarity


[env:heltec_wifi_kit_32]
platform = espressif32
board = heltec_wifi_kit_32
board_build.mcu = esp32
architectures=esp32
framework = arduino
lib_deps =
    ${common_env_data.lib_deps_builtin}
    ${common_env_data.lib_deps}
    https://github.com/HelTecAutomation/Heltec_ESP32.git
    https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series.git
src_filter =
    +<main_esp.cpp>
upload_port=
    COM9

Compiler output

Processing heltec_wifi_kit_32 (framework: arduino; platform: espressif32; board: heltec_wifi_kit_32)

Detected non-PlatformIO `architectures` option in `[env:heltec_wifi_kit_32]` section
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/heltec_wifi_kit_32.html
PLATFORM: Espressif 32 > Heltec WiFi Kit 32
HARDWARE: ESP32 240MHz 320KB RAM (4MB Flash)
DEBUG: CURRENT(esp-prog) EXTERNAL(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)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 42 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SPI> 1.0
|-- <Wire> 1.0.1
|-- <DS1307RTC>
|   |-- <Time> 1.5
|   |-- <Wire> 1.0.1
|-- <SdFat> 1.1.0
|   |-- <SPI> 1.0
|-- <RTClib> 1.2.1
|   |-- <Wire> 1.0.1
|-- <Time> 1.5
|-- <Heltec_ESP32> 1.0.6 #9b5088b
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <WiFi_Kit_series> #c7bf261
Compiling .pioenvs\heltec_wifi_kit_32\src\main_esp.cpp.o
Archiving .pioenvs\heltec_wifi_kit_32\libfe0\libSPI.a
Archiving .pioenvs\heltec_wifi_kit_32\lib487\libWire.a
Indexing .pioenvs\heltec_wifi_kit_32\libfe0\libSPI.a
Archiving .pioenvs\heltec_wifi_kit_32\lib66a\libTime_ID44.a
Indexing .pioenvs\heltec_wifi_kit_32\lib487\libWire.a
Archiving .pioenvs\heltec_wifi_kit_32\libc15\libDS1307RTC_ID421.a
Indexing .pioenvs\heltec_wifi_kit_32\lib66a\libTime_ID44.a
Indexing .pioenvs\heltec_wifi_kit_32\libc15\libDS1307RTC_ID421.a
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\MinimumSerial.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SdCard\SdSpiCard.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SdCard\SdSpiCardEX.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SdCard\SdioCardEX.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SdCard\SdioTeensy.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SpiDriver\SdSpiESP8266.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SpiDriver\SdSpiParticle.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SpiDriver\SdSpiSAM3X.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SpiDriver\SdSpiSTM32.cpp.o
In file included from src\main_esp.cpp:154:0:
src\main_esp.h:15:18: fatal error: WiFi.h: No such file or directory

**************************************************************
* Looking for WiFi.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:WiFi.h"
* Web  > https://platformio.org/lib/search?query=header:WiFi.h
*
**************************************************************

compilation terminated.
Compiling .pioenvs\heltec_wifi_kit_32\liba6d\SdFat_ID322\SpiDriver\SdSpiTeensy3.cpp.o
Compiling .pioenvs\heltec_wifi_kit_32\lib330\RTClib_ID83\RTClib.cpp.o
*** [.pioenvs\heltec_wifi_kit_32\src\main_esp.cpp.o] Error 1
 [ERROR] Took 7.04 seconds 
mingw32-make.exe[3]: *** [CMakeFiles\PLATFORMIO_BUILD.dir\build.make:56: CMakeFiles/PLATFORMIO_BUILD] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:104: CMakeFiles/PLATFORMIO_BUILD.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:116: CMakeFiles/PLATFORMIO_BUILD.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:130: PLATFORMIO_BUILD] Error 2

main_esp.h

#ifndef CONDITION_MONITORING_ESP_H
#define CONDITION_MONITORING_ESP_H

#include "Arduino.h"
#include "heltec.h"
#include "images.h"
#include "board_pins.h"
#include "build_defs.h"
#include "staffa.h"
//#include "Ota.h"
#include "WiFi.h"

//#define  LED 25
extern Heltec_ESP32 Heltec;

extern WiFiClass WiFi;
//void WIFIScan(void);
#endif //CONDITION_MONITORING_ESP_H

main_esp.cpp

#include "main_esp.h"


// WiFi credentials.
const char* WIFI_SSID = "wifi-ssid";
const char* WIFI_PASS = "wifi-password";

void setup()
{
    Serial.begin(9600);
    // Giving it a little time because the serial monitor doesn't
    // immediately attach. Want the firmware that's running to
    // appear on each upload.
    delay(2000);

    Serial.println();
    Serial.println("Running Firmware.");

    // Connect to Wifi.
    Serial.println();
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(WIFI_SSID);

    // Set WiFi to station mode and disconnect from an AP if it was previously connected
//    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);

    WiFi.begin((char*) WIFI_SSID, WIFI_PASS);
    Serial.println("Connecting...");

    while (WiFi.status() != WL_CONNECTED) {
        // Check to see if connecting failed.
        // This is due to incorrect credentials
        if (WiFi.status() == WL_CONNECT_FAILED) {
            Serial.println("Failed to connect to WIFI. Please verify credentials: ");
            Serial.println();
            Serial.print("SSID: ");
            Serial.println(WIFI_SSID);
            Serial.print("Password: ");
            Serial.println(WIFI_PASS);
            Serial.println();
        }
        delay(5000);
    }

    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());

    Serial.println("Hello World, I'm connected to the internets!!");
}

void loop()
{
    delay(5000);
    Serial.println("Hello World");
}

Huh? (Warning! Ignore unknown configuration option 'architectures' in section)

No need to specficy that.

#include <Wifi.h> instead.

You see this is the problem. This isn’t a library you’re including there. This thing is an Arduino ESP32 & ESP8266 core. Why put it in lib_deps? The core seems to be a copy of the actual Espressif32-core with board additions?

I’m really not sure what you’re attempting to do. Do you need to compile for that core? Do you just want a library from there? Have you tried throwing this library out?

1 Like

@maxgerhardt thanks, it was just using the incorrect WiFi.h include.
I was trying to force it to use the libraries from the core by heltec, but now it works without.
Cheers.