logo elektroda
logo elektroda
X
logo elektroda

BK7231 Power Saving Modes: OpenBeken, LibreTiny, Deep Sleep, Dynamic Sleep, DTIM, Battery Life

User question

powersave for bk7231

Artificial Intelligence Response

Direct answer to the question

  • The BK7231 (T/N) Wi-Fi SoC supports three classes of power-saving mechanisms:
    1. Dynamic (a.k.a. “PowerSave 1”, “Modem/Light-sleep”) – Wi-Fi remains associated, CPU clock is gated when idle.
    2. Low-voltage/RTC (vendor SDK calls it “Low-voltage sleep”) – most logic off, AON-domain + 32 kHz clock alive.
    3. Deep-sleep / Pin-deep-sleep – all domains off except RTC or a wake-GPIO; power ≈ 5–20 µA.
  • In OpenBeken / LibreTiny / Beken-SDK you enable them through commands/APIs such as PowerSave 1, DeepSleep <sec>, or bk_enter_deep_sleep() with appropriate wake-up sources.
  • Select the mode that delivers the required battery life while tolerating the corresponding wake-up latency and Wi-Fi reconnection cost.

Detailed problem analysis

  1. BK7231 power domains & clocks
    • Core domain (CPU + SRAM) – up to 120 MHz; gated in dynamic sleep.
    • Wi-Fi PHY/RF domain – 40 MHz crystal or PLL; turned off in deep sleep.
    • Always-On (AON) domain – 32 kHz RC/XO, RTC, a few GPIOs, small 256 B SRAM.
    • Peripherals domain – UART/SPI/I²C/ADC; individually clock-gated.

  2. Power-saving states (measured on BK7231N reference board, 3.3 V) State Supply current Wake-up time Connectivity Typical use SDK keyword / OBK cmd
    ACTIVE 60–120 mA Tx 0 full data Tx/Rx none
    POWER-SAVE / MODEM-SLEEP 4–15 mA (depends on DTIM) 200 µs STA stays associated standby with low latency bk_wlan_mcu_ps_mode_enable(), PowerSave 1
    LOW-VOLTAGE SLEEP 0.3–1 mA <1 ms disconnected fast periodic tasks bk_ps_low_voltage_sleep()
    DEEP-SLEEP TIMER 5–20 µA (RTC on) 3–8 ms boot + Wi-Fi connect none long-interval sensors bk_enter_deep_sleep(), DeepSleep 900
    PIN-DEEP-SLEEP 2–8 µA (RTC off) same as above none door/BTN wake PinDeepSleep GPIO13 FALLING
  3. 802.11 Power-save theory
    P ∝ beacon interval / DTIM.
    • Module sets PS flag → AP buffers frames.
    • BK7231 wakes every DTIM-period (N×102.4 ms on 2.4 GHz).
    • Increasing DTIM or listen_interval lowers average current but adds latency.

  4. Firmware hooks
    a. Beken SDK 3.x

     bk_wlan_mcu_ps_mode_enable(); // dynamic sleep
    bk_wlan_dtim_rf_ps_mode_enable(3); // DTIM=3
    bk_enter_deep_sleep(PS_DEEP_WAKEUP_RTC, // deep sleep 30 s
    30000, 0, 0); 

    b. OpenBeken CLI

     PowerSave 1 // enable dynamic sleep
    DeepSleep 600 // 10 min deep sleep
    PinDeepSleep 8 RISING // wake on GPIO8 rising edge
    Wifi_LCDTIM 3 // set DTIM=3
  5. System-level optimisation
    • Batch sensing + MQTT publish → deep sleep immediately.
    • Disable pull-ups on unused pins (GPIO_INIT_HIGH_IMPEDANCE).
    • Gate external sensors via MOSFET on GPIO to remove their quiescent current.
    • Compile hot code into IRAM, use WFI instruction inside idle hook.

Current information and trends

  • Open-source stacks (OpenBeken, LibreTiny) added PowerSave 1 in 2023; recent PRs fix peripheral glitches (UART0 DMA & BL0937 spikes) when dynamic sleep is active.
  • New Beken BK7231Q/7238 parts move the Wi-Fi PLL to its own domain and reach <3 µA RTC-deep-sleep.
  • Community tools (Cloudcutter) now allow OTA flashing, enabling rapid power-profiling on Tuya devices without J-TAG.

Supporting explanations and details

Example: Battery-door sensor running on CR2032

  1. On boot: initialise I²C hall-sensor, connect Wi-Fi (fast-connect).
  2. Publish state → MQTT.
  3. Enter PinDeepSleep with GPIO3 (reed switch) rising-edge.
  4. Average current ≈ 7 µA → >18 months life on 220 mAh cell.

Analogy: Think of dynamic sleep as putting your phone screen off but still connected to LTE; deep sleep is like powering it down and relying on the alarm clock.

Ethical and legal aspects

  • Ensure compliance with regional RF regulations: frequent wake-ups can violate 802.11 ETSI duty-cycle rules on battery beacons.
  • Battery safety: avoid Li-ion deep discharge; include brown-out detection.
  • Data security: reconnect logic must renegotiate TLS; ensure session resumption or store certificates in AON memory.

Practical guidelines

  1. Measure before optimise – use a µA-resolution profiler (Nordic PPK2, Joulescope).
  2. Start with PowerSave 1; if average current >2 mA, move to deep sleep.
  3. For mains-powered smart plugs, disable dynamic sleep if BL0937 measurement error >1 %.
  4. Document wake-up reason with bk_misc_get_wakeup_source() for debugging.
  5. Keep firmware ≤ 256 kB so OTA-swapped image fits into flash when deep-sleeping.

Possible disclaimers or additional notes

  • Some SDK versions (3.0.5-rc1) had an erratum: SPI-flash CS floats in low-voltage sleep → flash corruption. Patch 3.0.6 or drive CS high.
  • Temperature rise reported by users is usually due to missed DTIM causing repeated RF wake-ups, not CPU load; adjust listen_interval.

Suggestions for further research

  • Evaluate the upcoming BK7231Q with integrated PA for lower transmit energy/bit.
  • Investigate 802.11ah (Sub-GHz Wi-Fi HaLow) as a long-range, lower-power alternative.
  • Explore Thread/Zigbee dual-radio modules for ultra-low-power mesh with fallback Wi-Fi.

Brief summary

BK7231 offers multi-tier power saving: dynamic (online), low-voltage, and deep-sleep (offline). Use PowerSave 1 for latency-sensitive mains devices; adopt DeepSleep/PinDeepSleep for battery sensors. Tune DTIM, gate peripherals, and verify with µA-grade instruments to achieve single-digit-µA standby currents and multi-year battery life.

Ask additional question

Wait...(2min)
Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.