"Streaming" data via bluetooth - now with example code! #3145
Replies: 11 comments
-
|
Posted at 2019-08-05 by @gfwilliams
Not really - you can create your own characteristics, but because the UART is handled natively by Espruino it will probably be slightly faster.
Raw binary :) I think just Bluetooth LE packets are normally 20 bytes max, so if you can send in chunks that are multiples of 20 you're likely to get slightly better bandwidth. Also do
Absolutely yes :) |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-05 by AkosLukacs Oh, best serialization is no serialization at all :) Current progress: pretty happily pushing 128 * 16 bit values at 100ms intervals, and that is more than enough for this project. For the record, going below 100ms interval, the busy LED becomes almost always on, and the actual throughput doesn't increase (measured in the browser by the number of received "packets"). Edit: doing some math :) |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-05 by @gfwilliams That sounds about right, yes :) At some point I believe we could enable a larger MTU (eg >20 byte chunks) which would really improve matters, but it's not guaranteed it won't just fall back to 20... So you could create something that'd work on one computer but bomb on another - and that sounded like a support nightmare :) |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-09-23 by AkosLukacs Sneak peek: Power consumption of a Pixl.JS streamed real time via web-bluetooth :) UI needs more work. Plotly doesn't really like redrawing thousands of data points in real time. :(
|
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-09-24 by @gfwilliams Nice - how did you work out the power consumption? |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-09-24 by AkosLukacs Just data from the INA226 :) |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-10-12 by AkosLukacs Just tried creating my own characteristic + using notify: Edit: and on the browser side just receiving data at 100Hz doesn't create any extraordinary CPU usage. Actually I have dozens of tabs open in Vivaldi, and a couple in Chrome, and my laptop CPU clocks down to <1GHz and <10% CPU usage by Chrome :) |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-02 by AkosLukacs Created an example project with the Puck + Web Bluetooth pushing the magnetometer data at up to 80 Hz. It's really kind-of-surprisingly smooth. Code up at my Github |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-02 by @MaBecker Wow, this is so cool, thanks for sharing! |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-02 by AkosLukacs Thanks! A quick update (as I'm exploring these things): you can connect to, and receive notifications from multiple services. demonstration with battery level service. I have a more practical use: measuring energy consumption with an INA226: BLEnergyGraphs Right now uses the NUS for communication, but plan to "upgrade" it using custom characteristic & improve usability. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-04 by @gfwilliams Nice - thanks! |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-08-04 by AkosLukacs
I want to stream ADC data from the MDBT42 module via web bluetooth. The sampling & DMA part works nicely (thanks for the low-level library Gordon!). With 256x oversampling, I have a theoretical 781 effective sample / second. Each sample is an Uint16 value.
I have seen the Web bluetooth and Web Bluetooth Dashboard tutorials, and looks like that can work.
Need to fiddle with serialization, because JSON feels inefficient - 6 characters (worst case) to transfer 2 bytes of data. And the communication wasn't really happy at 160ms intervals :/
My questions:
Beta Was this translation helpful? Give feedback.
All reactions