I’m trying to get my first sketch running with Blynk. I’m using an Arduino UNO with the Adafruit Bluefruit LE SPI friend (not the UART version) I’ve successfully run one of the examples from Adafruit, so I know the board is wired properly and working. I’m using the Blynk example code builder with the options: selected Board:“UNO”, Connection:“Adafruit Bluefruit BLE,” Example:”Terminal”. When I tried to compile it, I get a compiler error that BLESerial.h was not found. I then moved the files BLESerial.h and BLESerial.cpp from BLEPeripheral/examples/serial to BLEPeripheral/src and the code compiles. However when I run the sketch, I see nothing on the Serial monitor. I added some print statements - I can see “begin” but not “back from begin”, which tells me the code is getting stuck in the statement: “SerialBLE.begin()” Can someone help me getting going with Blynk? Thanks!
*************************************************************
For this example you need BLEPeripheral library
from http://librarymanager/all#BLEPeripheral
or https://github.com/sandeepmistry/arduino-BLEPeripheral
Warning: Bluetooth support is in beta!
You can send/receive any data using WidgetTerminal object.
App project setup:
Terminal widget attached to Virtual Pin V1
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>
#include <BLEPeripheral.h>
#include "BLESerial.h"
#include <SPI.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "SzmdVHp0W1ESp5vEx302h0x1NpHDql08";
// define pins (varies per shield/board)
#define BLE_REQ 10
#define BLE_RDY 2
#define BLE_RST 9
// create ble serial instance, see pinouts above
BLESerial SerialBLE(BLE_REQ, BLE_RDY, BLE_RST);
// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);
// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget
BLYNK_WRITE(V1)
{
// if you type "Marco" into Terminal Widget - it will respond: "Polo:"
if (String("Marco") == param.asStr()) {
terminal.println("You said: 'Marco'") ;
terminal.println("I said: 'Polo'") ;
} else {
// Send it back
terminal.print("You said:");
terminal.write(param.getBuffer(), param.getLength());
terminal.println();
}
// Ensure everything is sent
terminal.flush();
}
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.setLocalName("Blynk");
SerialBLE.setDeviceName("Blynk");
SerialBLE.setAppearance(0x0080);
Serial.println(F("begin"));
SerialBLE.begin();
Serial.println(F("back from begin"));
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
// Clear the terminal content
terminal.clear();
// This will print Blynk Software version to the Terminal Widget when
// your hardware gets connected to Blynk Server
terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
terminal.println(F("-------------"));
terminal.println(F("Type 'Marco' and get a reply, or type"));
terminal.println(F("anything else and get it printed back."));
terminal.flush();
}
void loop()
{
SerialBLE.poll();
Blynk.run();
}