ArduinoBLE icon indicating copy to clipboard operation
ArduinoBLE copied to clipboard

BLE Serial Example

Open hongkai0818 opened this issue 6 years ago • 10 comments

Hi Possible to add an example on ble serial similar to https://github.com/sandeepmistry/arduino-BLEPeripheral/tree/master/examples/serial

Thanks

hongkai0818 avatar Sep 01 '19 13:09 hongkai0818

@tigoe any opinions on this?

sandeepmistry avatar Sep 03 '19 17:09 sandeepmistry

I don't love the idea, since BLE isn't serial, and it's confusing to users who think it should show up on their laptop/desktop machines as a serial port. Unless you have an app to pair it with that'll provide a "serial" connection, I think it'll only be confusing.

OTOH, if BLE 4 and 5 now supports real serial, and it can actually show up as a COM port on MacOS and Windows and Linux without having to modify the central device's OS, I am all for it.

tigoe avatar Sep 03 '19 17:09 tigoe

Hi, thanks for your reply. The reason I was asking that is because I have previously explored NRF52DK and Bluefruit NRF52. Both SDK provides examples on both BLE central and peripheral that are exposing to BLEUART (NUS). Current examples in the arduinoBLE do not have the BLEUART example using NUS. That might be good to add BLEUART examples in the future release of the library.

hongkai0818 avatar Sep 04 '19 01:09 hongkai0818

Is it even possible to create a serial connection via regular BT 5 on the nano 33 ble sense?

I'm currently searching for a way to Transfer bulk data and had no luck so far :(

Just asking, because if BLE is the only (recommended) way, a tutorial would be nice..

ChrisKretschmer avatar Sep 19 '19 19:09 ChrisKretschmer

How big is "bulk"? If I remember correctly, BLE transfers data in something like 20-byte packets, so for something like a file transfer, you'd need to break it up into those chunks. If you were making a file transfer API, you'd make it break the file up and packetize it. OTOH, if you're talking about transfer of sensor data where each reading or group of readings is less than 20 bytes total, it's no problem. The BLE spec would have you make a characteristic for each sensor reading, and that's what's easiest in the API, but you could presumably make a string or array with a bunch of numbers in it. That's how BLE MIDI works, for example.

On Thu, Sep 19, 2019 at 3:45 PM Christoph Kretschmer < [email protected]> wrote:

Is it even possible to create a serial connection via regular BT 5 on the nano 33 ble sense?

I'm currently searching for a way to Transfer bulk data and had no luck so far :(

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/ArduinoBLE/issues/19?email_source=notifications&email_token=AAC45HY2KQZT56ACKJFPELTQKPJFRA5CNFSM4ISWZMG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7ETOHI#issuecomment-533280541, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC45HYJSV5HZHHXUZYXIKLQKPJFRANCNFSM4ISWZMGQ .

tigoe avatar Sep 19 '19 20:09 tigoe

Well... I'm building a data logger for model rockets... The Arduino nano 33 Sense had the perfect fit for me, but i thought that BLE might be the best idea to get the data from the Arduino after recovery...

so we're talking about not more than a few KB if done correctly i think.

I'm currently experimenting with the notification feature to push the values through, but it feels like im abusing it...

ChrisKretschmer avatar Sep 20 '19 21:09 ChrisKretschmer

That's pretty much what notification feature is for, so don't worry about it.

T

On Fri, Sep 20, 2019, 5:14 PM Christoph Kretschmer [email protected] wrote:

Well... I'm building a data logger for model rockets... The Arduino nano 33 Sense had the perfect fit for me, but i thought that BLE might be the best idea to get the data from the Arduino after recovery...

so we're talking about not more than a few KB if done correctly i think.

I'm currently experimenting with the notification feature to push the values through, but it feels like im abusing it...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/ArduinoBLE/issues/19?email_source=notifications&email_token=AAC45H3NPSVHL2UOQN7RQ73QKU4MLA5CNFSM4ISWZMG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7H4R7A#issuecomment-533711100, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC45H6GZ2K5OVBHFLSMRJTQKU4MLANCNFSM4ISWZMGQ .

tigoe avatar Sep 20 '19 21:09 tigoe

one last question (and i know i'm abusing this topic right now :D)

I have a struct for my logging data points - BLECharacteristic are typed... the largest thing i can get is BLELongCharacteristic or something like that, but I want to transfer my struct as a byte array...

how would I manage that? I think, there will be others with this problem...

ChrisKretschmer avatar Sep 20 '19 22:09 ChrisKretschmer

Check out the ble midi examples in @sandeepmistry, @don, and @alasdairallan's book "make: Bluetooth". They use byte arrays. Here's an example derived from them: https://github.com/tigoe/SoundExamples/blob/master/MIDI_examples/ArduinoBLEMIDI/ArduinoBLEMIDI.ino

On Fri, Sep 20, 2019, 6:04 PM Christoph Kretschmer [email protected] wrote:

one last question (and i know i'm abusing this topic right now :D)

I have a struct for my logging data points - BLECharacteristic are typed... the largest thing i can get is BLELongCharacteristic or something like that, but I want to transfer my struct as a byte array...

how would I manage that? I think, there will be others with this problem...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/ArduinoBLE/issues/19?email_source=notifications&email_token=AAC45H5TKPHMY4QQJURO4YLQKVCH7A5CNFSM4ISWZMG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7IABIA#issuecomment-533725344, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC45H6SBGJQGYGPJEA7XY3QKVCH7ANCNFSM4ISWZMGQ .

tigoe avatar Sep 21 '19 01:09 tigoe

Thank you all for your help - got it all working.

For anyone who is interested - my code is in https://github.com/adastra-rocketry/adastra-telemetry/tree/master/ArduinoNano33BLESense/Telemetry

ChrisKretschmer avatar Sep 22 '19 16:09 ChrisKretschmer