I know BLE is in beta and all that but I’m finding push notifications via BLE to be very unreliable. It seems that if I update multiple widgets in a single go they tend to lag, or there are delays, or something. The serial monitor shows the push updates pretty much as expected so If I had to guess I’d say you aren’t flushing a BLE buffer somewhere in the app.
On a possibly related note, I find that eventually there is a BLE heartbeat timeout.
My app simply consists of 4 value display widgets assigned to V0…V3 and set to PUSH, plus the BLE widget.
Here’s the sketch I’m using, I can send the console output if it helps?:
@BlynkAndroidDev, looks like App stopped responding to heartbeats… @Gaff, could you add a button to control LED or print something and see if it works?
The app is still able to send commands, which the arduino responds to. They show up in the debug output. The BLE light remains connected the whole time and the app never thinks that the arduino is disconnected. If I exit the app and restart it’s able to reconnect for a while until the next timeout.
It’s not just that it doesn’t respond to the heartbeat. It doesn’t handle all the push updates either. Typically it picks up the first few, but then tends to stop. It seems that all messages from arduino -> app are unreliable.
My working theories are:
The arduino isn’t actually flushing the send buffer to BLE
The app isn’t correctly pulling all the messages from BLE
There’s some error when processing messages
If I could see the BLE input as received by the app we could very easily work out which case is causing the problem. Is there a debug build of the app perhaps? Or some way of intercepting these messages?
I injected a couple of ble.flush() commands, and I poll AT+BLEUARTFIFO. The TX buffer is empty almost all of the time so it appears that the arduino is flushing as expected.
I changed the code to call ble.print() instead of Blynk.virtualWrite and connected the arduino to a generic BLE UART app. The app logs the UART messages from the arduino as soon as the arduino sends them (well within ~200ms).
This makes it look like the app is at fault :(. Have you guys had any luck reproducing?
Is there any progress in solving this issue? I am also having the same problem on other hardware: the program I show here should increase a counter on a “Value Display S” widget in the app every 3 seconds. However, when sending value 5,5,5,5 you see 5,5,5,4 in the app. So this clearly shows that the last part of the BLE buffer isn’t flushed somewhere (I guess in the Android app).
I am using
Software:
Android app version 1.13.2 (12/7/2016) running on Android version 5.1.1 on Samsung SM-G800F
Blynk library 0.3.8
Hardware
Arduino nano
HM10 BLE module
My code looks like
#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT
#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>
#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "0d843a65fc98494e91be76faced09ffe";
SoftwareSerial SerialBLE(2, 3); // RX, TXconnected to HM-10
long count;
SimpleTimer timer;
void updateCount()
{
++count;
Serial.println("updateCount");
Blynk.virtualWrite(V6,count);
Blynk.virtualWrite(V7,count);
Blynk.virtualWrite(V8,count);
Blynk.virtualWrite(V9,count);
}
void setup()
{
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(auth, SerialBLE);
while (Blynk.connect() == false) {
// Wait until connected
}
count = 0;
timer.setInterval(3000L, updateCount);
}
void loop()
{
Blynk.run();
timer.run();
}
I’m pretty sure there’s a android / BLE bug somewhere but I never managed to get traction. I was told it was a hardware issue but I’m not so sure. Also see here https://github.com/blynkkk/blynk-library/issues/127
The good news is that I now have an Arduino 101, so I’ll see if I can reproduce on that.
Until the Blynk developpers fix this issue, I use following workaround: simply execute the last virtualWrite 2 times. The problem is that all widgets (such as led) are using virtualwrite in their implementation, so basically always the last command is delayed … (it took quite some time untill I understood why one LED widget was alway showing the wrong colour, I only changed the value when toggling …). Anyhow I finished my Blynk-code of a car robot with 2 motors using HM10 BLE, line followers, RGB LED, buzzer, ultrasonic module with automatic line following or avoidance mode, or manual using joystick. I wait to publish my code as an instructable until this issue is solved. I hope they do, the other bugs that were there were always fixed within days.