Hello folks, I’m new to ESP32 and PlatformIO, and know relatively little about programming in general. I hope I posted this in the right place .
I bought some Seeed Studio Xiao ESP32-c6 boards, and have installed the Arduino IDE v2.3.4 (CLI 1.1.1) on a Debian 12 Linux machine.
I also have installed VSCode, PlatformIO v6.1.16/3.4.4 and ESP-IDF v5.3.2. I modified the platformio.ini for my project according to the Seeed Studio wiki to support the Xiao c6 boards, and used arduino as the framework.
I compiled several example projects on both setups and they worked in both IDEs as expected. If I’m not mistaken, I had a simple webserver example project working and connecting to WiFi using PlaformIO as well as Arduino. But then when I tried a sample project (ESP32/ESP8266 Thermostat Web Server - Control Output Based on Temperature | Random Nerd Tutorials), and compiled in PlaformIO it failed to connect. Here’s the part of the setup() code that should do the connecting:
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed!");
return;
}
Serial.println();
Serial.print("ESP IP Address: http://");
Serial.println(WiFi.localIP());
I modified it a bunch of times, trying to figure out what was happening, and ended up with this (with my real network ssid and password):
const char *ssid = "xxxxxxx";
const char *password = "xxxxxxxx";
IPAddress local_IP(192, 168, 0, 8);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(192, 168, 0, 1); //optional
IPAddress secondaryDNS(192, 168, 0, 1); //optional
void setup(void) {
delay(3000);
Serial.begin(115200);
Serial.println("Connecting to WiFi");
Serial.println(ssid);
Serial.println(password);
WiFi.setHostname("test");
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
if (strlen(ssid) == 0) {
WiFi.begin();
} else {
WiFi.begin(ssid, password);
}
while (WiFi.status() != WL_CONNECTED) {
Serial.println(WiFi.status());
delay(500);
}
Serial.println();
Serial.print("ESP IP Address: http://");
Serial.println(WiFi.localIP());
The network status that it prints out is something like 6666666611111111111, and very occasionally it will give me a 3 and print out an assigned IP address. Even then the server that should be at that IP is unreachable. And even stranger, the chip will get so hot I can hardly touch it.
In Arduino IDE the same code will connect immediately and stay connected all night, and the example project functions as expected. Also, the chip doesn´t get hot.
My suspicion is that whatever is contained in wifi.h is not behaving the same in PlatformIO’s version. I don’t know where to look. Any advice will be greatly appreciated because I would prefer to use VSCode/PIO/ESP-IDF on my project if I can. Thanks!