Bangle.js to ESP32 via BLE

Posted on
  • Just got my Bangle.js from Adafruit yesterday, and was thinking about getting some data logging happening...

    This is very interesting, and would be a great place to start ...

    http://www.espruino.com/Bangle.js+Data+S­treaming

    But I could also imagine I might want to also communicate via BLE to a ESP32 "remote" bidirectionally. I see that there is some support for the nRF library, on ESP32, but don't see much in the way of documentation regarding how complete it is.

    Simple BLE advertisement ESP32 to the Bangle.js , could be step one.

    Any advice on where to begin understanding this?

    Thanks!

  • Mon 2021.05.24

    ' but don't see much in the way of documentation regarding how complete it is'

    Did the thirty or so functions within the NRF class not catch your eye?

    http://www.espruino.com/Reference#NRF
    https://banglejs.com/reference#NRF

  • I guess what I meant to say, is I'm not sure what directly applies to the ESP32, in this context.

    Is it fair to say that the generic NRF class is completely, implemented? I could use my other Espruino boards to prototype and test with, if that is/was the case.

    Thanks for the consideration your reply...

  • Implementation of BLE on ESP32 became incomplete.
    Know this because most of it was done by me.
    Espressif changed ESP-IDF and specially BLE a lot with each new (sub) version.
    Last not least there was no support by Espressif for Espruino over the years.
    Therefore my decision was to concentrate on other targets.

  • JumJum it's very interesting to look through your old posts, a lot of great work there.

    Thanks for posting.

  • Yes, @JumJum has done a bunch of work on this, but it's been a bit of a moving target both with Espressif's SDK and things changing inside Espruino itself, and unfortunately I haven't had any time to put into this either.

    For nRF52-based devices, support for the NRF.* API is complete, but on ESP32 it's very much 'try it and see'.

    I'd suggest if you really want to use ESP32 for Bluetooth, going with the Arduino IDE is probably your best bet right now.

    If you went with BLE advertising (http://www.espruino.com/BLE+Advertising) I think there's a good chance you could knock something up with ESP32 and the Arduino IDE relatively quickly.

  • Hi Gordon, thanks for your comments.

    Great minds run together, I ran some experiments this morning with the latest ESP32 dev module and the new Arduino IDE 2.o beta. The latest gen CHXXX USB serial interface does rip, and the serial programming performance is very good.

    My only motivation for using Espruino on the ESP32, was consistency with my other code examples. I am working on some education materials, and am looking at some gentle, progressive code snippets to get familiar with the "big ideas" in low power BLE.

    I'm getting a lot of inspiration from your recent YouTube videos on the subject.

    https://www.youtube.com/watch?v=lWjuMEIr­mY8

    I really like how you show the evolution of a generic BLE serial console, to a unique custom characteristic of your design, and then hit the Android Nordic nRF connect console to demonstrate manually stuffing a bit in the "register" to activate the servo. That seems like the learning trajectory best to follow.

  • Great, glad it helps!

    It's a shame about the lack of BLE support for ESP32 - but it's quite a hard, painful job making it reliable. It's definitely not something I think many people would want to take on as a fun thing to do in their free time!

  • but it's quite a hard, painful job making it reliable. It's definitely not something I think many people would want to take on as a fun thing to do in their free time!

    Unfortunately true for all other BLE platforms. Could be relatively easy to build Espruino for any random platform and get GPIO,uart,spi.i2c working but getting BLE stack working so that Espruino BLE API works is major effort. Maybe some port of the api to generic HCI protocol and then linking with HCI support from the manufacturer SDK could make it reusable (but probably more bloated)

  • Maybe some port of the api to generic HCI protocol

    This would actually be really cool if it could be implemented. I'm not thinking so much for MCUs, but for Linux devices (even OpenWRT-type stuff) it'd be really useful

  • I'm not sure if this is the right thread, but it's the only one I've found:
    I would like to establish a serial communication (SerialBT) between a Bangle.js 2 and an ESP32 - not necessarily with BLE.
    I've learned from the posts above that it's difficult with Espruino on an ESP32, has anyone tried it with the default ESP-IDF?
    Is there any chance for a serialBT connection between these two devices?

  • a serial communication (SerialBT) between a Bangle.js 2 and an ESP32 - not necessarily with BLE

    What you mean by "not necessarily with BLE", is using wires OK then? there is no other Bluetooth than LE in Bangle.js

  • Sorry for the confusion, but I thought there's also a non LE available.
    Using wires would be ok if you can show me how to route the serial port to the SWD pins ;-)

    Does this mean there is no possibility to connect a Bangle.js 2 with an ESP32 because the ESP32 doesn't support BLE?

    Should I create a new thread not mentioning BLE?

  • ESP32 does support BLE*. Maybe you are mixing up with ESP8266 which doesn't?
    You might be able to do what you want with MicroPython.

    • but I gather from this thread Espruino + ESP32 doesn't?
  • the best is to simply try :-) recently I tried BLE advertising and it worked fine in latest ESP32 build. Maybe opening connection (at least in one direction - from ESP32 to bangle? ) would work too?

  • Anyone fine a way to do a bidirectional connection between bangle.js and esp32?

  • Yes - if you use a recent Espruino build for ESP32 then this code should work fine: http://www.espruino.com/BLE+UART#receivi­ng-evaluating

    Or if you're programming it using some other language, it's pretty easy too - just implement the Nordic UART BLE endpoint a bit like is done at https://www.espruino.com/Interfacing#blu­etooth-le - if you google it, you'll likely find an implementation already

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Bangle.js to ESP32 via BLE

Posted by Avatar for RandallSY @RandallSY

Actions