[SOLVED] Bluetooth BLE support for Adafruit Feather Bluefruit LE

I was ravenously excited to find you added BLE support and was about to give Blynk lots of money - only to discover that it doesn’t seem to work for my Feather BLE board. The reason is that Adafruit use some not-quite-standard BLE firmware that the BLEPerhipheral library doesn’t support. Gory details can be found here: https://github.com/sandeepmistry/arduino-BLEPeripheral/issues/34

The good news is that not all is lost. I think Blynk is using UART over BLE for comms, which adafruit supports via their own library. Hopefully all I need to do is create a wrapper over adafruit’s library that supports the Arduino Stream interface, then everything should just work.

Does anyone know if this will work? Has anyone done this? If I get the chance I may have a go myself - in which case I’ll be sure to contribute it back.

2 Likes

We will add devices over time. It was stated that it’s beta.

Secondly, Adafruit is not replying to our emails. So maybe you, as a customer can ping them back.

I was also hoping to have a lightweight arduino+BLE board and found out that Adafruit feather is not supported yet, and also Blueduino isn’t supported yet.

I am already for some time looking for an app that simply can be downloaded on Android+iPhone for controlling selfmade robots and flying objects. On Android there are some options, but only Blynk seems a solution on iOS.

I will try HM-10 to start.

Ok the great news is that since the adafruit wrapper implements Print and Stream it all “Just Works”! Here is my minimal code:

#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include <BlynkSimpleSerialBLE.h>

//pins for feather BLE, see adafruit web for details
#define BLUEFRUIT_SPI_CS               8
#define BLUEFRUIT_SPI_IRQ              7
#define BLUEFRUIT_SPI_RST              4 

char auth[] = "..."; //Had to reverse engineer this.

Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

void setup() {
  Serial.begin(9600);

  Blynk.begin(auth, ble);
  ble.begin(true); //true => debug on, you can see bluetooth in the serial monitor.
  ble.factoryReset(); //Optional
  ble.setMode(BLUEFRUIT_MODE_DATA);  
}
  
void loop() {          
      Blynk.run();
}

I’m very pleased :slight_smile:

The odd thing is that the auth code doesn’t reflect that in my project. I had to reverse-engineer the correct auth code by using the debug connection. Also the auth code doesn’t appear to change with the project I’m using, or when I generate a new token!

Overall impressed so far though!

3 Likes

@Gaff thanks for pull request!

Could be a bug. Thank you for reporting!

After next app update, use your auth token as usual…

Yes,

It can connect to feather now after updating the app.

1 Like

I am trying to get the same board working feather M0 bluefruit.
i uploaded the code shown above and adapted the key.
however
./blynk-ser.sh
get into this loop:
Connecting: GOPEN:/dev/cu.usbmodem1411,raw,echo=0,clocal=1,cs8,nonblock=1,ixoff=0,ixon=0,ispeed=9600,ospeed=9600,crtscts=0 <-> openssl-connect:blynk-cloud.com:8441,cafile=/Users/raminsoleymani/Documents/workspaces/Arduino/libraries/Blynk/scripts/certs/server.crt,nodelay 2016/12/06 18:10:23 socat[15319] N opening character device "/dev/cu.usbmodem1411" for reading and writing 2016/12/06 18:10:23 socat[15319] N opening connection to LEN=16 AF=2 46.101.143.225:8441 2016/12/06 18:10:23 socat[15319] N successfully connected from local address LEN=16 AF=2 192.168.2.202:58408 2016/12/06 18:10:23 socat[15319] N trusting certificate, commonName matches 2016/12/06 18:10:23 socat[15319] N SSL connection using ECDHE-RSA-AES128-GCM-SHA256 2016/12/06 18:10:23 socat[15319] N SSL connection compression "none" 2016/12/06 18:10:23 socat[15319] N SSL connection expansion "none" 2016/12/06 18:10:23 socat[15319] N starting data transfer loop with FDs [5,5] and [6,6] 2016/12/06 18:10:38 socat[15319] N socket 2 (fd 6) is at EOF 2016/12/06 18:10:39 socat[15319] N exiting with status 0 Reconnecting in 3s...
and it doesnt react to any input

Maybe just try direct connection, with BLE Blynk widget?

1 Like

magically working right now.
no serial outputs tho…

I’m struggling to get my feather MO to work with blynk. I found this question and I saw a glimmer of hope. I started this effort by trying to run the sketch provided by blynk for the Adafruit Bluefruit LE. I keep getting a compile error that the BLEPeripheral.h can’t be found. I looked on the blynk site and didn’t see where I could my hands on it. I found something on git https://github.com/sandeepmistry/arduino-BLEPeripheral/blob/master/src/BLEPeripheral.h added that to the library and more rabbits popped out of the holes.

I found this article and took the sketch, put in the auth code. Ran it… compiles. Loads to the feather MO. Nothing in the serial monitor

I create a project in the blynk mobile app and no matter my selection it tells me that the device is not connected. 1) does the app automatically connect to the BLE device? 2) what hardware should I select for a feather MO with a BLE Friend SPI?

What am I missing? The intended simplicity of the project being offered is making it hard for me to understand what’s not working.

1 Like

Also - what hardware are you selecting when setting up the project in the iphone app>

regarding this, in project settings you have to select on “connection type”: “BLE” and also add the BLE widget in the app. after adding the ble widget, before starting the app you have to click the ble widget and search for / connect your ble module. after the module is connected, click on play button, and if you are luckier than me, you will have a usable ble connection.

1 Like

Ok I’ve blown the dust off my project and discovered the following things:

  • If you connect using Adafruit’s Bluefruit LE Connect App to Adafruit’s example code it will offer to update the BLE firmware on your feather board. Not sure if this is important or not, release notes can be found here..

  • Something has changed in the BLE / Blynk world that means you can’t initialise Blynk until you have fininshed initialising BLE. This means the code in my previous post no longer works, specifically you need to reorder these lines:

    ble.begin(true); //true => debug on, you can see bluetooth in the serial monitor.
    ble.factoryReset(); //Optional
    ble.setMode(BLUEFRUIT_MODE_DATA);
    Blynk.begin(auth, ble);

The bad news is that I’m still seeing odd connection issues - I’m able to send commands from the blynk app to the feather board, but I’m unable to transmit in the other direction :cry:. The app logs messages being sent from the device to the app, but the app doesn’t update. Worse, the board see heartbeat timeouts (though even though the app believes the remote end is disconnected it still receives commands!). I’ll continue my educated guesswork and see what I can find…

Just want to chime in that I, too, have great hopes of getting Blynk working with a BLE device, and will be anxious to hear how the adafruit feather goes. I’ve had no luck with the punch through Bean, or adafruits NRF8001 BOB.

1 Like

i can confirm this. i have very similar experience with various ble / bluetoooth boards (bluefruit, hm5, hc8, hm10). tested on different android phones.

1 Like

@Pavel / @vshymanskyy Don’t suppose you guys had a chance to look at these boards?

Actually some sort of debug option in the android app where you could show every byte sent / received from the device might be helpful for pinpointing issues here? Could we get that? Even if it’s one of those manual-install APKs or something?

we already did lots of debugging in the last 2 months with debug version of the app, but could not identify the problem. i have tested on 3-4 different android phones, all kind of ble / bluetooth modules, and sent lots of log file to developers.

some issues were identified and patched, but all in all, in my tests the app seldom had a stable connection. last month developers also tested ble with their setup, and they said everything worked ok.

so, up to now, it is a mistery to me why ble/bluetooth not working for me as expected. it is true, that all the phones i used for testing are older android devices (< 5.0), and i read on xda developers that these older versions do not behave very nicely with ble. maybe with some newer phones it works better…

it would be useful to know, what setup (board + ble module + phone + os version) did @vshymanskyy used during the successful tests. maybe than i could try something similar.

I am having similar woes trying to get a simple Adafruit Bluefruit (nRF8001 based) breakout board to work with no love. I’ve spent an awful lot of time scouring these forums and it seems nobody else is having much luck either. I was going to use this for a STEM project I’m working on but I think I’m going to forget Blynk and see what other Bluetooth app options are out there.

@SDC You already have a topic created for your issue, please keep to that topic. Thanks.