Adafruit Bluefruit LE SPI Friend stops transmitting

Hey guys,

it’s the first time I’m using a Bluetooth shield with an Arduino Uno, it’s the Adafruit Bluefruit LE SPI Friend.

I’ve hooked up everything exactly as described in the documentation (@Adafruit – that’s SCK=13, MISO=12, MOSI=11, CS=8, IRQ=7, RST=4).

The setup is very basic: following a push on a button, the module (running as HID) should send any keyboard letter (in this case “A”) to an iPad, unlocking the device.

Following the red LED (blinking three times followed by a three second delay) I should be in Command Mode and everything should basically work. Well it does – at least for a few hours. After some time of not sending/receiving anything, the module just stops transmitting data and I just can’t figure out why. :o

I’ve tested the code on various devices and platforms and the problem always stays the same (assuming it’s related to the shield/code). Currently the shield is connected to an iPad Mini 1st Gen, running iOS 9.3.5.

The code works fine for some time…after a few hours of not pushing the button, the shield refuses to send anything. It’s still shown as paired on the iPad and blinks like before. EDIT: I just noticed that when the issue occurs, the shield is still paired, but shown with it’s default name (Bluefruit LE) and not with the name designated in the setup! This is getting really strange…

Here’s the very basic code (it’s basically one of the example codes that come with the shield, stripped of some serial monitor functions+the button added; the problem exists with the original example code as well):

#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"
#include "BluefruitConfig.h"

#if SOFTWARE_SERIAL_AVAILABLE
#include <SoftwareSerial.h>
#endif

const byte BUTTON = 5;

#define FACTORYRESET_ENABLE         0
#define MINIMUM_FIRMWARE_VERSION    "0.6.6"

Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

void error(const __FlashStringHelper*err) {
  Serial.println(err);
  while (1);
}

void setup() {

  Serial.begin(115200);
  if ( !ble.begin(VERBOSE_MODE) )
  {
    error(F("Error board"));
  }
  Serial.println( F("OK!") );

  if ( FACTORYRESET_ENABLE )
  {
    if ( ! ble.factoryReset() ) {
      error(F("Error factory reset"));
    }
  }

  ble.echo(false);
  ble.info();

  if (! ble.sendCommandCheckOK(F( "AT+GAPDEVNAME=Keyboard" )) ) {
    error(F("Error name"));
  }

  if ( ble.isVersionAtLeast(MINIMUM_FIRMWARE_VERSION) )
  {
    if ( !ble.sendCommandCheckOK(F( "AT+BleHIDEn=On" ))) {
      error(F("Error Keyboard"));
    }
  } else
  {
    if (! ble.sendCommandCheckOK(F( "AT+BleKeyboardEn=On"  ))) {
      error(F("Error Keyboard"));
    }
  }

  if (! ble.reset() ) {
    error(F("Error reset"));
  }

  pinMode(BUTTON, INPUT_PULLUP);
}

void loop() {

  if (digitalRead(BUTTON) == LOW) {
    ble.println("AT+BleKeyboard=A");
    delay(100);
  }
  
}

And here’s the configuration:

// COMMON SETTINGS
// ----------------------------------------------------------------------------------------------
// These settings are used in both SW UART, HW UART and SPI mode
// ----------------------------------------------------------------------------------------------
#define BUFSIZE                        128   // Size of the read buffer for incoming data
#define VERBOSE_MODE                   true  // If set to 'true' enables debug output


// SOFTWARE UART SETTINGS
// ----------------------------------------------------------------------------------------------
// The following macros declare the pins that will be used for 'SW' serial.
// You should use this option if you are connecting the UART Friend to an UNO
// ----------------------------------------------------------------------------------------------
//#define BLUEFRUIT_SWUART_RXD_PIN       9    // Required for software serial!
//#define BLUEFRUIT_SWUART_TXD_PIN       10   // Required for software serial!
//#define BLUEFRUIT_UART_CTS_PIN         11   // Required for software serial!
//#define BLUEFRUIT_UART_RTS_PIN         -1   // Optional, set to -1 if unused


// HARDWARE UART SETTINGS
// ----------------------------------------------------------------------------------------------
// The following macros declare the HW serial port you are using. Uncomment
// this line if you are connecting the BLE to Leonardo/Micro or Flora
// ----------------------------------------------------------------------------------------------
//#ifdef Serial1    // this makes it not complain on compilation if there's no Serial1
//#define BLUEFRUIT_HWSERIAL_NAME      Serial1
//#endif


// SHARED UART SETTINGS
// ----------------------------------------------------------------------------------------------
// The following sets the optional Mode pin, its recommended but not required
// ----------------------------------------------------------------------------------------------
#define BLUEFRUIT_UART_MODE_PIN        12    // Set to -1 if unused


// HARDWARE SPI SETTINGS
// ----------------------------------------------------------------------------------------------
// The following macros declare the pins to use for HW SPI communication.
// SCK, MISO and MOSI should be connected to the HW SPI pins on the Uno, etc.
// This should be used with nRF51822 based Bluefruit LE modules that use SPI.
// ----------------------------------------------------------------------------------------------
#define BLUEFRUIT_SPI_CS               8
#define BLUEFRUIT_SPI_IRQ              7
#define BLUEFRUIT_SPI_RST              4    // Optional but recommended, set to -1 if unused

Is it possible that the shield/bluetooth connection falls into a kind of sleep mode? As I said, the problem only occurs after a few hours…

Any ideas are more than welcome :slight_smile:
Thanks!

Max

Turns out the issue is related to an older firmware version...For anyone else who's facing the same problem: you need to use the Bluefruit LE Connect app on a newer iOS version (today, I used iOS 12) otherwise the app won't show possible firmware updates! I was convinced that the shield would run on the latest firmware...as it turned out today, the latest version is 0.8.0.

Cheers! :slight_smile:

Unfortunately, the firmware update was just a temporary solution. :confused:
The same issue occurs now again: after a few hours of not sending anything to the iPad, the shield is still shown as paired in the iPad Bluetooth settings, but the Bluefruit LE Connect app says: peripheral disconnected :confused:

Any ideas?

The Verbose Mode seems to be part of the problem....the connection seems to be steady after setting it to false...

Hope this helps anyone who's facing similar problems :slight_smile:

1 Like