Close

Bluetooth trouble resolved?

A project log for Tap to control

A small, ESP32-Pico based wearable for everyday DIY Smart Home control

xasinXasin 01/16/2019 at 21:100 Comments

Alright!

First things first, I'm really sorry for putting this project on pause. The Bluetooth code had been giving me trouble, and with Christmas approaching I had to 3D print some dragon heads and solder up their LEDs and ... Oh, right, I still need to document that project.

In any case, I recently got a push to get back onto the Bluetooth problem now that I am starting my Lasertag Rev.3 hardware, which would benefit greatly from a BT connection to a phone!
I had already gotten Bluetooth SPP to work, but there still was a huge downside: It kept the chip at almost 50-100mA current draw, even when idle, and ... That's just unacceptable. BLE would have to do!

After a bit of fiddling around, I decided to merge my data-transmission-concept of the SPP code with my BLE code, using a single Characteristic with notifications enabled as replacement for the SPP connection.
The current system uses two bytes of ID, followed by raw data. This way, the very power-saving BLE mode can be used, without loosing the flexibility of a custom protocol. PLUS, I can now add standard BLE Services like Battery or Connectivity services in parallel!

I've been running this new BLE code for a bit, and I've discovered another huge upside of having a permanent connection: It puts your app on a higher priority for Android, meaning it is much less likely to be killed in the background. 

Battery runtime is also just fine. With the ESP's APB Max Freq Lock taken the chip draws a steady 20mA, so I'm getting about ten hours with the 350mAh battery. But since Espressif want to enable Light Sleep with a running BLE connection, the current draw will definitely drop to <5mA.
Awesome!

It's not perfect, but much more usable now - I've already been able to control my lights with the morsecode, and am working on a smoother integration with my smart home right now.

Discussions