I bought an ESP32 C5 and I can't get it to connect to Wi-Fi using Arduino IDE. The sketch compiles and uploads successfully, but in the serial monitor I get:
"Connecting to Wi-FiE (2316) wifi:can not get wifi protocol under WiFi band mode WIFI_BAND_MODE_AUTO, please use esp_wifi_get_protocols instead"
I've attached the sketch below. Do you have an example sketch that works for C5?
Cheers,
Miti
#include <WiFi.h>
#include "esp_wifi.h"
// Replace with your network credentials
const char* ssid = "myssid";
const char* password = "mypassword";
// Built-in LED pin
const int ledPin = 13;
unsigned long previousMillis = 0;
const long interval = 500;
bool ledState = LOW;
void setup() {
Serial.begin(115200);
delay(1000);
// Set up LED pin
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Turn off initially
Serial.println();
Serial.print("Connecting to Wi-Fi");
WiFi.setBandMode(WIFI_BAND_MODE_5G_ONLY);
WiFi.begin(ssid, password);
WiFi.STA.begin();
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
unsigned long currentMillis = millis();
if (WiFi.status() == WL_CONNECTED) {
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
ledState = !ledState;
digitalWrite(ledPin, ledState);
}
} else {
digitalWrite(ledPin, LOW);
}
// No blocking delay here, so Wi-Fi stays responsive
}