BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Compile errors on PlatformIO when compiling example esp32_wifi

I’ve pasted the output from VSCode after I tried a build, I think all the info is in there.


Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (2.1.0) > Espressif ESP32 Dev Module
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)
PACKAGES: 
 - framework-arduinoespressif32 3.10004.201016 (1.0.4) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 75 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Blynk> 0.6.7
|   |-- <WiFi> 1.2.7
|   |   |-- <SPI> 1.0
|-- <WiFi> 1.2.7
|   |-- <SPI> 1.0
Building in release mode
Compiling .pio/build/esp32dev/src/main.cpp.o
Archiving .pio/build/esp32dev/libb27/libBlynk.a
Indexing .pio/build/esp32dev/libb27/libBlynk.a
In file included from src/main.cpp:8:0:
/home/graeme/Arduino/libraries/Blynk/src/BlynkSimpleEsp32.h: In member function 'void BlynkWifi::connectWiFi(const char*, const char*)':
/home/graeme/Arduino/libraries/Blynk/src/BlynkSimpleEsp32.h:37:14: error: 'class WiFiClass' has no member named 'mode'
         WiFi.mode(WIFI_STA);
              ^
/home/graeme/Arduino/libraries/Blynk/src/BlynkSimpleEsp32.h:37:19: error: 'WIFI_STA' was not declared in this scope
         WiFi.mode(WIFI_STA);
                   ^
/home/graeme/Arduino/libraries/Blynk/src/BlynkSimpleEsp32.h:39:34: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
             WiFi.begin(ssid, pass);
                                  ^
In file included from src/main.cpp:6:0:
/home/graeme/arduino-1.8.13/libraries/WiFi/src/WiFi.h:79:9: note:   initializing argument 1 of 'int WiFiClass::begin(char*, const char*)'
     int begin(char* ssid, const char *passphrase);
         ^
In file included from src/main.cpp:8:0:
/home/graeme/Arduino/libraries/Blynk/src/BlynkSimpleEsp32.h:41:28: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
             WiFi.begin(ssid);
                            ^
In file included from src/main.cpp:6:0:
/home/graeme/arduino-1.8.13/libraries/WiFi/src/WiFi.h:60:9: note:   initializing argument 1 of 'int WiFiClass::begin(char*)'
     int begin(char* ssid);
         ^
Compiling .pio/build/esp32dev/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Print.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/StreamString.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/WMath.cpp.o
*** [.pio/build/esp32dev/src/main.cpp.o] Error 1
============================================================================ [FAILED] Took 3.26 seconds ============================================================================
The terminal process "pio 'run', '--environment', 'esp32dev'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

The code I was compiling below,

#include <Arduino.h>
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

void setup() {
  // put your setup code here, to run once:
    // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
}

void loop() {
  // put your main code here, to run repeatedly:
   Blynk.run();
}

@murrgr please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code and your compiler output so that they display correctly.
Triple backticks look like this:
```

Pete.

Thanks, updated post

PIO is using the wrong WiFi library when it compiles your code. It’s probably using the ESP8266 or an AVR library instead.

It’s a long time since I dabbled with PIO and I can’t remember the process for including the ESP32 core and forcing the compiler to use it, so I’d suggest googling the error message and including Platform IO in your search.

Pete.

Thanks Pete, I have spent hours trying google on this problem, with no luck. Thanks for pointing me in the right direction. when I find the fix, I’ll post it.

There are lots of things I liked about PIO, especially the ability to do live monitoring of program execution using an inline debugger, but eventually I found myself drifting back to the Arduino IDE.

Pete.

As you said Pete it was the Arduino WiFi lib that PIO was using and of course that is not an esp32 lib.
PIO knew it was compiling for an esp32 board so why it used the Arduino WiFi, I’m not sure. Still digging into that one. The Arduino IDE knows which one to use. For my setup i’m using VS Code with the PlatformIO extension. I used the library manager to remove the Arduino WiFi lib v1.2.7 and all working, so up and running. The compiler is now using the espressif WiFi.h
Thanks for the help.

1 Like