Hi there,
So sometimes WE overthink it…
That in mind, I looked into this a little closer here, And I’m able to reproduce the same issue I think you had originally.
Humor me and Load this Code and Tell me it runs It is more than blinking the LED and will test the C5 when you have USB connected and the WiFi see’s both 2.4 and 5Ghz. and it displays how many AP’s on both bands it see’s. it cycles and works? YES ?
Test_C5_sketch_oct21a.zip (1.8 KB)
You get these screens…
ONE
TWO
THREE
FOUR
YES/ NO ?
Now unplug the USB. does it stall and stop at main screen or when you reset it stalls, blinks , tries but nada..
YES ? True ?
Test_C5_sketch_oct21a.zip (1.8 KB)
// ==============================================================================
// PROJECT: XIAO ESP32-C5 Dual-Band Spectrum & Signal Analyzer
// AUTHOR: PJ (SmartIPTech) & Gemini AI Co-Pilot
// HARDWARE: Seeed Studio XIAO ESP32-C5 on XIAO Expansion Board (SSD1306 OLED)
// FEATURES: Simultaneous 2.4GHz + 5GHz Wi-Fi 6 Sniffing, Peak RSSI, & Live Waterfall
// NOTE: Runs untethered on battery
// If PJ Glasso , tells you the secret. :grin:
// ==============================================================================
#include <Arduino.h>
#include <Wire.h>
#include <U8g2lib.h>
#include "WiFi.h"
#include "esp_wifi.h"
// Hardware I2C for XIAO Expansion Board OLED (SSD1306 128x64)
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA);
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH); // Off initially
u8g2.begin();
// Intro Splash
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawRFrame(0, 0, 128, 64, 4);
u8g2.drawStr(14, 18, "XIAO ESP32-C5");
u8g2.setFont(u8g2_font_profont11_tr);
u8g2.drawStr(12, 34, "Dual-Band Wi-Fi 6");
u8g2.drawStr(22, 48, "2.4GHz + 5GHz");
u8g2.sendBuffer();
delay(2000);
// Set Wi-Fi to Station mode
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
}
void loop() {
// Activity LED blinks while scanning
digitalWrite(LED_BUILTIN, LOW);
// Status Screen during scan
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x10_tr);
u8g2.drawStr(10, 24, "Scanning Airwaves...");
u8g2.drawStr(10, 40, "[2.4 GHz & 5 GHz]");
u8g2.sendBuffer();
// Scan all available networks across both bands
int n = WiFi.scanNetworks();
digitalWrite(LED_BUILTIN, HIGH);
int count24 = 0;
int count50 = 0;
int maxRssi24 = -100;
int maxRssi50 = -100;
if (n > 0) {
for (int i = 0; i < n; ++i) {
int ch = WiFi.channel(i);
int rssi = WiFi.RSSI(i);
// Channels > 14 are 5 GHz
if (ch > 14) {
count50++;
if (rssi > maxRssi50) maxRssi50 = rssi;
} else {
count24++;
if (rssi > maxRssi24) maxRssi24 = rssi;
}
}
}
// --- FRAME 1: Dual-Band Signal & Channel Density Bars ---
u8g2.clearBuffer();
// Header bar
u8g2.drawBox(0, 0, 128, 11);
u8g2.setDrawColor(0);
u8g2.setFont(u8g2_font_5x7_tr);
u8g2.drawStr(2, 8, "C5 DUAL-BAND SPECTRUM");
u8g2.setDrawColor(1);
// 2.4 GHz Section
u8g2.setFont(u8g2_font_6x10_tr);
u8g2.drawStr(2, 22, "2.4G:");
char buf24[16];
snprintf(buf24, sizeof(buf24), "%d APs", count24);
u8g2.drawStr(34, 22, buf24);
// 2.4 GHz Peak Signal Bar (mapped -100 dBm to -30 dBm -> 0 to 48 px width)
int bar24 = (maxRssi24 <= -100) ? 0 : map(constrain(maxRssi24, -100, -30), -100, -30, 0, 48);
u8g2.drawFrame(76, 14, 50, 9);
if (bar24 > 0) u8g2.drawBox(77, 15, bar24, 7);
// 5.0 GHz Section
u8g2.drawStr(2, 36, "5.0G:");
char buf50[16];
snprintf(buf50, sizeof(buf50), "%d APs", count50);
u8g2.drawStr(34, 36, buf50);
// 5.0 GHz Peak Signal Bar
int bar50 = (maxRssi50 <= -100) ? 0 : map(constrain(maxRssi50, -100, -30), -100, -30, 0, 48);
u8g2.drawFrame(76, 28, 50, 9);
if (bar50 > 0) u8g2.drawBox(77, 29, bar50, 7);
// Hardware Divider Line
u8g2.drawHLine(0, 41, 128);
// Bottom Status / Memory Telemetry
u8g2.setFont(u8g2_font_5x7_tr);
char ramBuf[32];
snprintf(ramBuf, sizeof(ramBuf), "Free Heap: %u KB", (unsigned int)(ESP.getFreeHeap() / 1024));
u8g2.drawStr(2, 51, ramBuf);
char bandBuf[32];
snprintf(bandBuf, sizeof(bandBuf), "Total Airwaves: %d BSSIDs", n);
u8g2.drawStr(2, 61, bandBuf);
u8g2.sendBuffer();
delay(3500);
// --- FRAME 2: Live Mini Channel Distribution Waterfall / Histogram ---
if (n > 0) {
u8g2.clearBuffer();
u8g2.drawBox(0, 0, 128, 10);
u8g2.setDrawColor(0);
u8g2.setFont(u8g2_font_5x7_tr);
u8g2.drawStr(2, 8, "SPECTRUM WATERFALL (CH)");
u8g2.setDrawColor(1);
// Plot up to 14 channels on 2.4G and high buckets for 5G
for (int i = 0; i < min(n, 20); i++) {
int ch = WiFi.channel(i);
int rssi = WiFi.RSSI(i);
int h = map(constrain(rssi, -95, -30), -95, -30, 2, 44);
int x;
if (ch <= 14) {
x = map(ch, 1, 14, 4, 56);
} else {
x = map(ch, 36, 165, 68, 122);
}
u8g2.drawVLine(x, 62 - h, h);
u8g2.drawPixel(x - 1, 62 - h);
u8g2.drawPixel(x + 1, 62 - h);
}
// Band Markers
u8g2.drawVLine(63, 12, 52); // separator
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(12, 63, "2.4G (Ch 1-14)");
u8g2.drawStr(74, 63, "5G (Ch 36-165)");
u8g2.sendBuffer();
delay(3500);
}
WiFi.scanDelete();
}
Tell , me and I’ll give you the fix, You won’t believe it…

HTH
GL
PJ 
BTW , forget all the diode buisness

Hint: it is specific to the C5 and some like it.