Hello All!
I’ve only started playing with Arduino and Blynk a few weeks ago, so I’m still to figure it out and am apt to go around in circles trying to get things to work.
Here’s my situation, I’m using Bluetooth LE for a sketch and Blynk is disconnecting everytime the Android phone goes to sleep. It seems like this wasn’t happening about a week ago.
Did something change with the BLE widget when the Bluetooth widget was added about a week ago? Or am I just remembering it wrong? It doesn’t seem like you should have to reconnect the BLE widget everytime the phone wakes up.
Here’s my hardware:
Nexus 6 with Android 7.0
Sparkfun RedBoard (Uno Clone)
AdaFruit BlueFruit LE Shield
And a sketch to demonstrate what I’m doing:
/////////////////////////////////////
//
// Simple example of Blynk, debug, and BLE
//
// V0 Button Widget
// V1 LED Widget
// BLERG! The debug lines need to be at the top of the sketch!
#define BLYNK_PRINT Serial // Defines the object that is used for printing
// #define BLYNK_DEBUG // Optional, this enables more detailed prints
// #define BLYNK_USE_DIRECT_CONNECT // This doesn't seem to work at the moment
// Adafruit Bluefruit LE Shield which uses SPI
#include <SPI.h>
#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>
#include <Adafruit_BLE.h>
#include <Adafruit_BluefruitLE_SPI.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
#define BLUEFRUIT_SPI_CS 8
#define BLUEFRUIT_SPI_IRQ 7
#define BLUEFRUIT_SPI_RST 4
#define BLUEFRUIT_VERBOSE_MODE true
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
WidgetLED led1(V1);
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ble);
ble.begin(BLUEFRUIT_VERBOSE_MODE);
ble.factoryReset(); // Optional
ble.setMode(BLUEFRUIT_MODE_DATA);
led1.off();
}
void loop()
{
Blynk.run(); // All the Blynk Magic happens here...
}
BLYNK_WRITE(V0)
{
int p = param.asInt();
int l = led1.getValue();
BLYNK_LOG("Button is %i and %i", p, l);
if (p == 1)
{
led1.on();
}
else if (p == 0)
{
led1.off();
}
}
Any ideas or thoughts?
Thanks for any help,
digger