RedBearLab Arduino Blend V1.0 Connection Via Bluetooth to iPhone

Details :
• RedBearLab Arduino Blend V1.0 Connection Via Bluetooth to iPhone
• iiPhone 7 256GB Silver MNAU2LL/A
• Blynk Library version=0.5.4
• Trying to connect with these Blynk app settings:
- Connection Device: RebBearLab Blend Micro
- Connection Type: Bluetooth

The code below compiles with the following Arduino log:

Warning: platform.txt from core 'RedBearLab AVR Boards' contains deprecated recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}", automatically converted to recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}". Consider upgrading this core.
Sketch uses 28088 bytes (97%) of program storage space. Maximum is 28672 bytes.
Global variables use 1549 bytes (60%) of dynamic memory, leaving 1011 bytes for local variables. Maximum is 2560 bytes.
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleBLEPeripheral.h>
#include <BLEPeripheral.h>
#include <SPI.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "filled in correctly";

// define pins (varies per shield/board)
#define BLE_REQ   9
#define BLE_RDY   8
#define BLE_RST   4

// create ble serial instance, see pinouts above
BLESerial SerialBLE(BLE_REQ, BLE_RDY, BLE_RST);

void setup()
{
  // Debug console
  Serial.begin(9600);

  SerialBLE.setLocalName("Blynk");
  SerialBLE.setDeviceName("Blynk");
  SerialBLE.setAppearance(0x0080);
  SerialBLE.begin();

  Serial.println("Waiting for connections...");

  Blynk.begin(SerialBLE, auth);
}

void loop()
{
  SerialBLE.poll();

  if (SerialBLE) {    // If BLE is connected...
    Blynk.run();
  }
}

When I press play button I get error that device is not connected. I am not sure how to get it connected or what I am doing wrong or if it is even possible with this old hardware.

In the Arduino console I simply endlessly get:
[504680] Connecting…
[513680] Connecting…
[522680] Connecting…
[531680] Connecting…
[540680] Connecting…
[549680] Connecting…
[558680] Connecting…

As a side note I use the code below to connect to the device via the IOs app LightBlue and send hex integers to trigger an Adafruit_NeoPixel. I am trying to use the Blynk app to do this more elegantly.

//"RBL_nRF8001.h/spi.h/boards.h" is needed in every new project
#include <SPI.h>
#include <EEPROM.h>
#include <boards.h>
#include <RBL_nRF8001.h>


#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif
//
#define PIN 6
//
//// Parameter 1 = number of pixels in strip
//// Parameter 2 = Arduino pin number (most are valid)
//// Parameter 3 = pixel type flags, add together as needed:
////   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
////   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_KHZ800 + NEO_RGBW);
//
//// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
//// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
//// and minimize distance between Arduino and first pixel.  Avoid connecting
//// on a live circuit...if you must, connect GND first.

void setup()
{
  //  
  // For BLE Shield and Blend:
  //   Default pins set to 9 and 8 for REQN and RDYN
  //   Set your REQN and RDYN here before ble_begin() if you need
  //
  // For Blend Micro:
  //   Default pins set to 6 and 7 for REQN and RDYN
  //   So, no need to set for Blend Micro.
  //
  ble_set_pins(9, 8);
  
//   Set your BLE advertising name here, max. length 10
  ble_set_name("SAM BLE");
  
  // Init. and start BLE library.
  ble_begin();
  
  // Enable serial debug
  Serial.begin(57600);
//
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

unsigned char buf[16] = {0};
unsigned char len = 0;

void loop()
{
// any non-zero number evaluates to TRUE in if statement 
// so if there is ble data ready to read from source (ie the phone)
// then if statement below Returns the number of bytes ready for reading.
  if ( ble_available() )
  {
    while ( ble_available() )
    {
      byte output_now = ble_read();
      
      if (output_now==1)
      {
        Serial.println(output_now);
            colorWipe(strip.Color(0, 0, 255), 0); // Blue
            colorWipe(strip.Color(0, 0, 0), 0); // turn off
      }
      
      if (output_now==2)
      {
        Serial.println(output_now);
          allOnecolor(strip.Color(0, 255, 0), 1000); // Blue
          allOnecolor(strip.Color(0, 0, 0), 0); // Blue
      }
      if (output_now==3)
      {
        Serial.println(output_now);
        rainbowCycle(0);
        colorWipe(strip.Color(0, 0, 0), 0); // turn off
      }      
    }
  }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}


// Fill the dots one after the other with a color
void allOnecolor(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    }
  strip.show();
  delay(wait);
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

Any help would be greatly appreciated!!!

Do you have the BLE widget loaded in the project? Can it see and connect to the device? (before pressing the Run (Play) icon)

1 Like

I added the BLE widget and it sees the device but it still cannot connect with BLE or Bluetooth as the connector with the RedBearLab Blend Micro as the device.

Can anyone help me?

I am happy to try anything. Feeling stuck! :crying_cat_face:

BT/BLE seems to be an issue right now… not sure if the Devs are working on it or not, as it is probably a minority connection method.

But I also have had such unreliability with it that I just stopped trying :stuck_out_tongue: Sticking with WiFi and even USB serial for my stuff.

Interesting. I don’t think my Blend V1.0 has wifi capabilities but thanks for the heads-up. I will probably just let this project ride since I can my phone to send hex code to trigger my lights with the iOS LightBlue app in a super janky way.

I am just gonna have to drop a couple bucks and by new hardware that is not discontinued lol.

Thanks @Gunner!