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.
Wireless architecture
Section titled “Wireless architecture” ┌─────────────┐ SDIO Bus ┌─────────────┐ │ ESP32-P4 │───────────────│ ESP32-C6 │ │ (main CPU) │ │ (wireless) │ │ Application │ │ WiFi 6 + BT │ │ logic │ │ protocol │ └─────────────┘ └──────┬──────┘ │ Antenna (onboard)| Feature | Specification |
|---|---|
| WiFi standard | 802.11ax (WiFi 6) |
| WiFi band | 2.4 GHz only |
| Bluetooth | Bluetooth 5 (BLE) |
| Host-to-radio link | SDIO |
| Antenna | Onboard PCB antenna |
Required ESP-IDF components
Section titled “Required ESP-IDF components”WiFi functionality requires two Espressif components that bridge the P4’s application layer to the C6’s radio stack.
-
Add the required components to your project:
Terminal window idf.py add-dependency "espressif/esp_wifi_remote"idf.py add-dependency "espressif/esp_hosted" -
Run a full clean build after adding these components:
Terminal window idf.py fullcleanidf.py build
WiFi station (STA) example
Section titled “WiFi station (STA) example”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();}WiFi soft AP example
Section titled “WiFi soft AP example”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();Bluetooth Low Energy (BLE)
Section titled “Bluetooth Low Energy (BLE)”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.Performance notes
Section titled “Performance notes”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.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
esp_wifi_init returns error | Missing esp_hosted component | Add both required components and rebuild from clean |
| Compilation errors after adding WiFi | Build cache conflict | Run idf.py fullclean, delete managed_components/, rebuild |
| Cannot find any access points | SDIO communication failure | Check that the C6 module is properly soldered and powered |
| Low throughput | Congested 2.4 GHz band | Try a different WiFi channel on your router; move closer to AP |
| BLE scan finds nothing | BLE not initialized | Ensure esp_bt_controller_init() is called after WiFi init |
Further reading
Section titled “Further reading”- ESP-IDF WiFi driver documentation
- esp_hosted component — source and documentation for the host-radio bridge
- ESP-IDF BLE documentation
- Waveshare wiki FAQ — WiFi-specific troubleshooting