Using Target Wake Time to Extend ESP32-C6 Battery Life
Power management for Wi-Fi devices usually involves a compromise between latency and energy consumption. Traditional Wi-Fi power-save modes rely on the station waking up at fixed intervals to check for buffered data from the access point. This process forces the radio to stay active while waiting for beacons, even when no data transfer occurs.
The ESP32-C6 introduces Wi-Fi 6 (802.11ax) capabilities to the Espressif ecosystem, including Target Wake Time (TWT). TWT changes the relationship between the device and the router. Instead of following the router’s beacon schedule, the ESP32-C6 negotiates specific, individual wake-up times. The radio remains in a deep-sleep state until the exact microsecond the scheduled window begins. This precision cuts idle power consumption and reduces airtime contention in crowded environments.
How TWT Reduces Power Consumption
In older Wi-Fi standards, devices use Legacy Power Save or Wireless Multimedia Power Save. These methods require the device to sync with the Delivery Traffic Indication Message (DTIM). If a router has a DTIM period of three, the device wakes every 300 milliseconds to listen for a map of buffered data. If the network is busy, the device waits with its radio powered on, consuming roughly 60–80 mA just to stay awake.
TWT removes the need to listen to every DTIM beacon. The ESP32-C6 and the Wi-Fi 6 router agree on a TWT session. This session defines a Wake Interval and a Wake Duration. For example, a soil moisture sensor might negotiate a 10-minute interval with a 50-millisecond duration. During those 10 minutes, the router buffers any incoming data and never expects a response from the device. The ESP32-C6 remains in a low-power state, drawing only microamps, without losing its network association.
Hardware Requirements
To follow this tutorial, you need a Wi-Fi 6 compatible Access Point. While the ESP32-C6 is backward compatible with Wi-Fi 4 (802.11n) and Wi-Fi 5 (802.11ac) routers, the TWT protocol requires a Wi-Fi 6 connection to function. If the router does not support 802.11ax, the ESP32-C6 falls back to standard power-save modes.
Configuring TWT in ESP-IDF
The ESP-IDF provides a dedicated API to manage TWT sessions. Luckily for us, it is enabled by default so you don’t need to change your default project menuconfig.
In your firmware, you can set up a TWT setup frame. The following code example demonstrates how to request an individual TWT session after the device connects to the Wi-Fi network.
#include "esp_wifi.h"
#include "esp_log.h"
static const char *TAG = "TWT_EXAMPLE";
void setup_twt_session() {
// Define TWT setup parameters
wifi_twt_setup_config_t twt_config = {
.setup_cmd = TWT_REQUEST,
.flow_id = 0, // Unique ID for this flow
.twt_id = 1, // ID assigned by the AP
.wake_invl_expn = 10, // Wake interval exponent
.wake_invl_mant = 1024, // Wake interval mantissa
.min_wake_dura = 255, // Minimum wake duration in 256us units
.trigger = 0, // 0 for non-trigger based TWT
};
// Calculate interval: mantissa * 2^exponent microseconds
// 1024 * 2^10 = 1,048,576 us (~1.05 seconds)
esp_err_t err = esp_wifi_sta_itwt_setup(&twt_config);
if (err == ESP_OK) {
ESP_LOGI(TAG, "TWT setup request sent successfully");
} else {
ESP_LOGE(TAG, "Failed to send TWT request: %s", esp_err_to_name(err));
}
}This configuration uses an exponent and a mantissa to define the sleep time. By adjusting these values, you can schedule wake windows ranging from milliseconds to hours. The router confirms the request and assigns a twt_id. From that point forward, the Wi-Fi stack handles the timing automatically.
Measuring the Results
To quantify the efficiency gains of TWT, we compare the ESP32-C6 current draw against the Baseline Power Save (Modem Sleep) mode. By analyzing the waveforms captured on the Nordic Power Profiler Kit II (PPK2), you can see how TWT fundamentally alters the radio’s duty cycle to extend battery life.
Baseline Power Save (Legacy DTIM)
In standard Wi-Fi 5 or Wi-Fi 4 Power Save mode, the ESP32-C6 uses a “heartbeat” rhythm. Even if no data is being sent, the station must wake up to listen for the DTIM (Delivery Traffic Indication Message) contained in the router’s beacon.
- Waveform Characteristics: You will see sharp, consistent current spikes approximately every 102.4ms (the standard DTIM interval).
- Current Floor: Between spikes, the current drops to the Modem Sleep floor (roughly 20–30 mA depending on your peripheral usage), but it never stays there for long.
- The Constraint: The device is “slaved” to the router’s schedule. If the router broadcasts a beacon every 100ms, the ESP32-C6 must wake up 10 times per second just to check if the router has a packet waiting.

Target Wake Time (Wi-Fi 6)
TWT moves away from the rigid heartbeat of the DTIM beacon. Instead of waking up for every beacon, the ESP32-C6 and your router negotiate a “contract.” The device tells the AP, “I am going to sleep for exactly 1.05 seconds; do not expect me to listen until then.”
- Waveform Characteristics: The frequent 102ms spikes disappear. They are replaced by a single, slightly wider wake event at your negotiated interval (e.g. 300ms).
- Current Floor: The “Sleep Valley” between spikes is now significantly wider. This allows the system to remain in its lowest power state for 10x longer than the baseline mode.
- The Gain: Because the radio is off for extended periods, the average current (the most important metric for battery math) drops dramatically.

Summary
| Feature | Baseline Power Save | Target Wake Time (TWT) |
|---|---|---|
| Wake Frequency | High (Every ~100ms) | Low (User-defined, e.g., 1s+) |
| Schedule Control | Dictated by Router (DTIM) | Negotiated between Device & AP |
| Impact of Network Traffic | Must wake for every beacon | Only wakes for its specific window |
| Power Consumption | High idling cost | Minimal idling cost |
Best Practices for TWT
TWT works best for sensors that follow a predictable communication pattern. If your device needs to receive “unsolicited” data from the cloud at any moment, TWT introduces latency. The router holds the data until the next scheduled wake window.
For high-reliability applications, combine TWT with the ESP32-C6 light sleep mode. In light sleep, the ESP32-C6 powers down the CPU and most peripherals while maintaining the Wi-Fi connection in RAM. TWT acts as the trigger to wake the system from light sleep. This combination provides the best possible energy efficiency for an internet-connected device.
Precise timing is the key to longevity in the field. When you move away from the reactive nature of legacy Wi-Fi and toward the scheduled windows of TWT, you turn the ESP32-C6 into a truly professional IoT endpoint. This protocol ensures the radio only runs when necessary, preserving battery capacity for years rather than weeks.
Ready to connect your devices anywhere on Earth? Get started with Hubble Network for free →