BLE sometimes inits slowly

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Holzklotz
Posts: 1
Joined: Sun Dec 29, 2019 11:37 pm

BLE sometimes inits slowly

Post by Holzklotz » Mon Dec 30, 2019 12:10 am

Running the minimal bluetooth initialisation on my esp32 board, often needs about 200ms. But every 10-th or 20-th start it takes nearly 10 seconds. Without changing the code. Is there anything to make the initiation more consistent?

My application is some sort of battery powered light switch. A key press wakes the esp32 from deepsleep, connects to bluetooth, send some bytes and gets back to sleep. A initiation phase of 10 seconds is not meaningful for this context.

Minimal code

Code: Select all

import time
import machine
import bluetooth

print('starting')
t = time.ticks_us()

# init BLE
ble = bluetooth.BLE()
ble.active(True)

delta = time.ticks_diff(time.ticks_us(), t)
print('elapsed time = {:6.3f}ms'.format(delta/1000))

time.sleep_ms(1000)
machine.deepsleep(5000)
And my serial log for a case of a slow start.

Code: Select all

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4988
load:0x40078000,len:10404
load:0x40080400,len:5680
entry 0x400806bc
I (518) cpu_start: Pro cpu up.
I (518) cpu_start: Application information:
I (519) cpu_start: Compile time:     Dec 20 2019 07:56:38
I (522) cpu_start: ELF file SHA256:  0000000000000000...
I (528) cpu_start: ESP-IDF:          v4.0-beta1
I (533) cpu_start: Starting app cpu, entry point is 0x40083014
I (0) cpu_start: App cpu up.
I (544) heap_init: Initializing. RAM available for dynamic allocation:
I (550) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (556) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (562) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (569) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
I (575) heap_init: At 3FFCC8A0 len 00013760 (77 KiB): DRAM
I (581) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (587) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (594) heap_init: At 40099FB8 len 00006048 (24 KiB): IRAM
I (600) cpu_start: Pro cpu start user code
I (618) spi_flash: detected chip: generic
I (619) spi_flash: flash io: dio
I (619) cpu_start: Chip Revision: 1
W (620) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.
I (631) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
starting
I (593) phy: phy_version: 4102, 2fa7a43, Jul 15 2019, 13:06:06, 0, 1
GAP procedure initiated: stop advertising.
elapsed time = 10181.320ms
Background information
  • board: JOY-IT, ESP32 Node MCU Modul
  • micropython version: MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
    esp32-idf4-20191220-v1.12.bin

Post Reply