ESP32-C5 Dual-Band Wi-Fi Tutorial: Connect to 2.4GHz and 5GHz with Arduino IDE (2026 Guide)

 

ESP32-C5 Dual-Band Wi-Fi Tutorial: Connect to 2.4GHz and 5GHz with Arduino IDE (2026 Guide)

I'll be honest — when the ESP32-C5 boards first showed up on my bench, I almost filed them under "same chip, new number" and moved on. I was wrong. This is the first ESP32 that can actually see and join a 5GHz network, and after two weeks of flashing, band-hopping, and killing one breadboard connection with a badly stripped wire, I think it quietly fixes one of the most annoying limitations in the entire ESP32 lineup.

If you've ever tried to connect an ESP32 to a router broadcasting only on 5GHz — a lot of mesh systems and newer ISP routers do this by default now — you already know the fix used to be "log into your router and create a separate 2.4GHz-only network." That workaround still exists, but with the C5, it's no longer necessary. This guide walks through exactly how to get the ESP32-C5 running in Arduino IDE, how to connect to both bands, and how to decide which band to use for which kind of project.

Why the ESP32-C5 Actually Matters

Every ESP32 variant before this one — the original ESP32, S3, C3, C6 — is 2.4GHz only. That's fine for most home automation, but it creates two real problems:

  1. Band congestion. 2.4GHz has only 3 non-overlapping channels. In an apartment building with forty neighboring routers, that band is a traffic jam.
  2. Router compatibility. More routers and mesh systems now favor 5GHz for primary devices and either hide the 2.4GHz SSID or push IoT gear onto a slower guest band.

The ESP32-C5 is Espressif's first RISC-V MCU with native 2.4GHz and 5GHz Wi-Fi 6 support, alongside Bluetooth 5 (LE) and 802.15.4 for Zigbee/Thread. It runs a single RISC-V core up to 240MHz, with 384KB of SRAM and support for external PSRAM. For a sensor node, camera bridge, or gateway device that needs a cleaner, faster, lower-interference connection, this is the first ESP32 that can genuinely deliver it.

What You'll Need

  • An ESP32-C5 development board (I used a DevKitC-1 style board; XIAO ESP32-C5 works identically for this code)
  • USB-C cable
  • Arduino IDE 2.x
  • Access to a router or hotspot broadcasting on 5GHz (most dual-band routers already do this — check your router's admin panel if you're not sure)

Step 1: Set Up Arduino IDE for the ESP32-C5

The C5 needs a recent version of the ESP32 Arduino core — anything older than 3.3.x will not show the board in the list.

  1. Open Arduino IDE, go to File → Preferences, and add this to Additional Boards Manager URLs:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  1. Go to Tools → Board → Boards Manager, search "esp32," and install version 3.3.x or later.
  2. Plug in your board, then select Tools → Board → ESP32C5 Dev Module.
  3. Set the correct COM port under Tools → Port.

If the board doesn't show up under a valid port, hold the BOOT button while plugging in the USB cable — some C5 boards need to be manually put into download mode the first time.

Step 2: Scan Both Bands First

Before connecting to anything, it's worth confirming the board can actually see both bands in your environment. This sketch scans and prints every network it finds, sorted by frequency:

cpp
#include <WiFi.h>

void setup() {
  Serial.begin(115200);
  delay(1000);
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(200);

  Serial.println("Scanning for networks...");
  int n = WiFi.scanNetworks();

  if (n == 0) {
    Serial.println("No networks found.");
  } else {
    Serial.printf("%d networks found:\n", n);
    for (int i = 0; i < n; i++) {
      int channel = WiFi.channel(i);
      String band = (channel <= 14) ? "2.4GHz" : "5GHz";
      Serial.printf("%2d | %-32s | %s | Ch %2d | %d dBm\n",
        i + 1, WiFi.SSID(i).c_str(), band.c_str(), channel, WiFi.RSSI(i));
    }
  }
}

void loop() {}

Upload this and open the Serial Monitor at 115200 baud. You should see entries with channel numbers above 14 — those are your 5GHz networks. If you only see 2.4GHz entries, double-check your router actually broadcasts a visible 5GHz SSID (some routers hide it or use band-steering to merge both under one name).

Step 3: Connect to a 5GHz Network

Connecting is almost identical to a normal ESP32 sketch — the difference is entirely handled by the chip's radio, not your code:

cpp
#include <WiFi.h>

const char* ssid = "YOUR_5GHZ_SSID";
const char* password = "YOUR_PASSWORD";

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("\nConnected!");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("Band: ");
  Serial.println(WiFi.channel() <= 14 ? "2.4GHz" : "5GHz");
}

void loop() {}

There's no special API call to "force" 5GHz — the C5 automatically negotiates whichever band the target SSID is broadcasting on. If your router uses band-steering (one SSID name covering both bands), the chip will connect to whichever one has the better signal at boot, which is usually 5GHz if you're close to the router.

Step 4: Build Automatic Band Fallback

For real projects — especially battery sensors that might move between rooms — you want fallback logic: try 5GHz first for speed, and drop to 2.4GHz automatically if the connection is weak or fails. Here's a pattern that works well:

cpp
#include <WiFi.h>

struct WifiNetwork {
  const char* ssid;
  const char* password;
};

WifiNetwork networks[] = {
  {"HomeNetwork-5G", "your_password"},
  {"HomeNetwork-2G", "your_password"}
};

bool connectWithFallback() {
  for (int i = 0; i < 2; i++) {
    Serial.printf("Trying %s...\n", networks[i].ssid);
    WiFi.begin(networks[i].ssid, networks[i].password);

    unsigned long start = millis();
    while (WiFi.status() != WL_CONNECTED && millis() - start < 8000) {
      delay(300);
    }

    if (WiFi.status() == WL_CONNECTED) {
      Serial.printf("Connected to %s (%s)\n", networks[i].ssid,
        WiFi.channel() <= 14 ? "2.4GHz" : "5GHz");
      return true;
    }
    WiFi.disconnect();
  }
  return false;
}

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  if (!connectWithFallback()) {
    Serial.println("Both networks failed. Check credentials.");
  }
}

void loop() {}

This is the pattern I'd actually ship in a product: try the fast, clean 5GHz link first, and quietly fall back to 2.4GHz's better range if the device wanders farther from the router.

2.4GHz vs 5GHz on the ESP32-C5: Which Should You Use?

Factor2.4GHz5GHz
RangeBetter — penetrates walls furtherShorter — signal drops faster through walls
InterferenceHigh (Bluetooth, microwaves, neighbors)Low — much cleaner spectrum
SpeedLowerHigher, more consistent
Best forOutdoor sensors, garage/shed nodes, long-rangeCameras, indoor gateways, high-throughput telemetry
Battery impactSlightly lower power drawSlightly higher, but shorter transmit windows can offset it

Rule of thumb from testing: if the device is more than one interior wall away from your router, stick with 2.4GHz. If it's in the same room or open-plan area and you're pushing more data (a camera feed, frequent MQTT bursts, OTA updates), 5GHz is noticeably more stable.

Where the C5 Fits Next to the C6 and S3

If you've already read through the C6 or S3 guides on this site, here's the honest comparison:

  • ESP32-C6 — your pick for Matter, Thread, and Zigbee smart-home work. Still 2.4GHz only.
  • ESP32-S3 — your pick for camera and edge-AI work with vector instructions for TinyML.
  • ESP32-C5 — your pick when Wi-Fi congestion or router band-steering is the actual problem you're solving, not connectivity protocol variety.

They're not competitors — they're tools for different bottlenecks. A lot of production designs I've seen recently pair a C5 or C6 as the connectivity layer with an S3 or P4 handling compute, rather than trying to make one chip do everything.

Common Issues and Fixes

Board not detected in Arduino IDE — Update the ESP32 board package to 3.3.x+. Older cores don't list the C5 at all.

Can see 5GHz networks in scan but can't connect — Some 5GHz channels (particularly DFS channels used by radar-avoidance) aren't supported by every regional firmware build. Try switching your router to a fixed non-DFS channel like 36, 40, 44, or 48.

Weaker range than expected on 5GHz — This is physics, not a bug. 5GHz doesn't travel through walls as well as 2.4GHz. If you need whole-house coverage from one node, use 2.4GHz or the fallback pattern above.

Random disconnects under load — Add a stable power source. Wi-Fi radio transmission spikes current draw briefly, and undersized USB cables or weak power banks can cause brownout resets that look like Wi-Fi bugs but aren't.

Final Thoughts

The ESP32-C5 isn't a flashy upgrade — it's a plumbing fix. It solves the quiet, recurring annoyance of ESP32 devices getting stuck on a congested or unsupported band, without changing how you write code. If you're building anything that needs to survive a modern dual-band home network without a router workaround, this is the chip to reach for in 2026.

If you build something with it, I'd genuinely like to see it — drop a comment or reach out through the About page.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.