Bluetooth BLE to Terminal widget stops updating

From an iPhone 6s, three buttons using virtual pins send data to an Arduino Mega 2560 over a Bluetooth BLE link using an HM-10. When the Arduino receives its single digit inputs, it responds with a 40 byte message back to the iPhone for display on a Terminal widget.

Updating to the terminal widget stops after just a few (varies from ~4 to ~10) messages. To resolve the problem, I disconnect and reconnect the Bluetooth connection.

The Arduino IDE Serial Monitor continues to show the inputs from the iPhone. So it seems the BLE link to the Arduino is OK.

Text inputs from the iPhone keyboard continue to display locally on the Terminal widget. So it seems the terminal widget is OK.

It seems the Bluetooth link just in the direction to the Smartphone from the Arduino is what breaks.

Using Blynk library 0.6.1

Both an Uno and a Mega 2560 exhibit the same behavior.
Using Blynk server.

#define BLYNK_USE_DIRECT_CONNECT
#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

char auth[] = "CRiBbRNWOrWyjAdYciWSP6My2QehNcJf";

SoftwareSerial SerialBLE(10, 11); // Arduino RX, TX

WidgetTerminal terminal(V7);

BLYNK_WRITE(V7)
{
    // Write to Smart Phone Terminal
  if(param.getLength() > 0) {  // avoids a blank message
    terminal.clear();
    terminal.print("From iPhone: ");
    terminal.write(param.getBuffer(), param.getLength());
    terminal.println();
  }
  terminal.flush();
}

// Decrementer button pressed on iPhone
BLYNK_WRITE(V4)
{

 // assigning incoming value from pin V4 to a variable
  if(param.asInt() == 1) {
    terminal.clear();
    terminal.println("Decrementer");
    terminal.println("03-24-1951-70, 234, Yes, No Distance, 4 Digit pairs.");
    Serial.println("Decrementer: ");
  }
  terminal.flush();
}

// Incrementer button pressed on iPhone
BLYNK_WRITE(V5)
{

  // assigning incoming value from pin V5 to a variable
  if(param.asInt() == 1) {
    terminal.clear();
    terminal.println("Incremeter");
    terminal.println("03-24-1951-70, 234, Yes, No Distance, 4 Digit pairs.");
    Serial.println("Incrementer: ");
  }
  terminal.flush();

}

// Selector button pressed on iPhone
BLYNK_WRITE(V6)
{

   // assigning incoming value from pin V5 to a variable
  if(param.asInt() == 1) {
    terminal.clear();
    terminal.println("Selector");
    terminal.println("03-24-1951-70, 234, Yes, No Distance, 4 Digit pairs.");
    Serial.println("Selector: ");
  }
  terminal.flush();
}

void setup()
{

 // Clear the terminal content
  terminal.clear();

  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.flush();  
  terminal.clear();
  
  // Debug console
  Serial.begin(9600);
  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);
  Serial.println("Waiting for connections...");
}

void loop()
{
  Blynk.run();
}

Have you tried using Blynk.virtualWrite(V7, data) rather than the Terminal wrapper object?

Pete.

I replaced both “terminal.println()” statements with a single “Blynk.virtualWrite(V7, 1);” statement. Just the single digit was sent.

Only four messages were received on the iPhone successfully. Then displayed on the Arduino Serial Monitor was “Packet too big: 46903”. The number (46903) varied on three subsequent error messages … e. g. 5219, 30327, 1654. Then the error messages stopped. But the iPhone could continue sending ‘virtual pin messages’ to the Arduino. Similar results were obtained when I disconnected and reconnected the Bluetooth link.

I assume the message that shows up on the Serial Monitor is what is returned to the Arduino from the Blynk Server (?). But does it make sense that the packets could be too large when only a single digit is sent?

Thank you for the help Pete !!

Frank

You should read this:

Pete.

I did what he suggested. It helped. Still not rock solid, but better!!

Thank you Pete.

1 Like

After further testing, the “packet too big” issue is still very prevalent. Bluetooth connectivity just isn’t reliable.

I’m wondering whether anyone has found a Bluetooth module for the Arduino that actually works reliably with iOS and Blynk. I’ve tried three different modules without achieving dependable two-way communications.

Thanks.

Blynk is an IoT solution so most posters on here will be using WiFi

1 Like

I for one would be quite happy to see Bluetooth connectivity dropped from Blynk :pray:

Pete.

OH !! I didn’t realize that Blynk doesn’t support Bluetooth at the same level as wifi.

My application involves control of a device which will be in proximity to an iOS smartphone, but not in proximity to wifi connectivity. So I figured if I could control the device over Bluetooth, nothing else would be required. And the smartphone needs to receive and display immediate feedback as commands are sent to the device.

I have the device built and the Arduino software written. I still need a way to adjust its settings on the fly. I haven’t found a reliable way to do this. I can use IR control, but that calls for an extra device and the feedback piece is missing. I am still learning what is available. I appreciate all the help you folks have provided thus far!

Even if Blynk is not the right technology for this project, I am glad I found it and look forward to using it in future projects.

Thanks,
Frank

The clue is this warning in the Bluetooth examples…

Warning: Bluetooth support is in beta!

Pete.