Skip to content

WiFi 6 & Bluetooth

The ESP32-P4 does not have a built-in radio. Instead, the board pairs it with an ESP32-C6 co-processor that provides WiFi 6 and Bluetooth 5 connectivity over an SDIO bus. This architecture keeps the P4’s dual-core RISC-V fully available for application logic while the C6 handles all wireless protocol processing.

┌─────────────┐ SDIO Bus ┌─────────────┐
│ ESP32-P4 │───────────────│ ESP32-C6 │
│ (main CPU) │ │ (wireless) │
│ Application │ │ WiFi 6 + BT │
│ logic │ │ protocol │
└─────────────┘ └──────┬──────┘
Antenna
(onboard)
FeatureSpecification
WiFi standard802.11ax (WiFi 6)
WiFi band2.4 GHz only
BluetoothBluetooth 5 (BLE)
Host-to-radio linkSDIO
AntennaOnboard PCB antenna

WiFi functionality requires two Espressif components that bridge the P4’s application layer to the C6’s radio stack.

  1. Add the required components to your project:

    Terminal window
    idf.py add-dependency "espressif/esp_wifi_remote"
    idf.py add-dependency "espressif/esp_hosted"
  2. Run a full clean build after adding these components:

    Terminal window
    idf.py fullclean
    idf.py build

Connect to an existing WiFi access point:

#include "esp_wifi.h"
#include "esp_event.h"
#include "nvs_flash.h"
#define WIFI_SSID "your-network-name"
#define WIFI_PASS "your-network-password"
static void wifi_event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
esp_wifi_connect();
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
esp_wifi_connect(); // Auto-reconnect
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
printf("Connected! IP: " IPSTR "\n", IP2STR(&event->ip_info.ip));
}
}
void app_main(void)
{
nvs_flash_init();
esp_netif_init();
esp_event_loop_create_default();
esp_netif_create_default_wifi_sta();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_wifi_init(&cfg);
esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL);
esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL);
wifi_config_t wifi_config = {
.sta = {
.ssid = WIFI_SSID,
.password = WIFI_PASS,
},
};
esp_wifi_set_mode(WIFI_MODE_STA);
esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
esp_wifi_start();
}

Create a WiFi access point hosted by the board:

wifi_config_t ap_config = {
.ap = {
.ssid = "ESP32-P4-AP",
.ssid_len = 0,
.password = "esp32p4pass",
.channel = 1,
.max_connection = 4,
.authmode = WIFI_AUTH_WPA2_PSK,
},
};
esp_wifi_set_mode(WIFI_MODE_AP);
esp_wifi_set_config(WIFI_IF_AP, &ap_config);
esp_wifi_start();

The ESP32-C6 provides Bluetooth 5 (BLE) support. BLE is accessed through the standard ESP-IDF NimBLE or Bluedroid stacks.

#include "esp_bt.h"
#include "esp_gap_ble_api.h"
#include "esp_gattc_api.h"
// BLE initialization follows standard ESP-IDF patterns.
// The esp_hosted component transparently routes BLE
// traffic through the SDIO link to the C6.

WiFi 6 on the ESP32-C6 brings several improvements over previous ESP32 WiFi implementations:

  • OFDMA: Multiple devices can transmit simultaneously on different sub-carriers, reducing latency in crowded networks.
  • Target Wake Time (TWT): The C6 can negotiate sleep schedules with the access point, significantly reducing power consumption during idle periods.
  • BSS Coloring: Reduces interference from neighboring networks on the same channel.

Throughput will vary based on the access point capabilities and environment. Expect practical throughput in the range of 10—30 Mbps for TCP in typical conditions.

SymptomCauseFix
esp_wifi_init returns errorMissing esp_hosted componentAdd both required components and rebuild from clean
Compilation errors after adding WiFiBuild cache conflictRun idf.py fullclean, delete managed_components/, rebuild
Cannot find any access pointsSDIO communication failureCheck that the C6 module is properly soldered and powered
Low throughputCongested 2.4 GHz bandTry a different WiFi channel on your router; move closer to AP
BLE scan finds nothingBLE not initializedEnsure esp_bt_controller_init() is called after WiFi init