Please help, I am not receiving any data on my and the Bluetooth keeps disconnecting every 5 seconds.
I am using Bluetooth Hm10 module and an ECG sensor as my input. Even though the device is online.
#define BLYNK_USE_DIRECT_CONNECT
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "7ba33741f39c4894a0b560104ed55498";
BLYNK_READ(V5) // Widget in the app READs Virtal Pin V5 with the certain frequency
{
// This command writes Arduino's uptime in seconds to Virtual Pin V5
Blynk.virtualWrite(5, analogRead(A0));
}
void setup()
{
// Debug console
DebugSerial.begin(9600);
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop()
{
Blynk.run();
}
You are awesome Gunner!
Im getting an error
after #simpletimer.h
Blynk_Release_v0.4.6\libraries\Blynk\examples\Boards_Bluetooth\Serial_HM10_HC08\Serial_HM10_HC08.ino:33:25: fatal error: SimpleTimer.h: No such file or directory
You can remove that #include <SimpleTimer.h> line as BlynkTimer (same thing) is now built into the Blynk library (but you will need to upgrade to the 0.4.7 library first)
Thanks I have updated it, here is the new code;
But theres is another error;
Serial_HM10_HC08:43: error: ‘sensorData’ was not declared in this scope
#define BLYNK_USE_DIRECT_CONNECT
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>
SimpleTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "7ba33741f39c4894a0b560104ed55498";
BLYNK_READ(V5) //Blynk app has something on V5
{
sensorData = analogRead(A0); // reading the sensor on A0
Blynk.virtualWrite(V5, sensorData); // sending to Blynk
}
void setup()
{
// Debug console
DebugSerial.begin(9600);
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop()
{
Blynk.run();
timer.run();
}
Add this line below your #includes to declare sensorData as a global variable
int sensorData;
Also, be aware that if your sensor is spitting out data, you might run into BT disconnections. This is where you need to actually set up a timer, which you haven’t done quite yet.
But I think?? you might be OK if your display widget is set to a timed polling mode instead of PUSH. I honestly haven’t needed to use BLYNK_READ() at all, so this is a guess
I always do something like that this way:
timer.setInterval(1000L, readSensor); // Put this in void Setup()
void readSensor() // sensor loop
{
sensorData = analogRead(A0); // reading the sensor on A0
Blynk.virtualWrite(V5, sensorData); // sending to Blynk
}
So far, ; the TX RX button are not in blinking, I am using “Bluetooth” as my device for connection on the Blynk App.
The Blynk App giving an error something is wrong with your bluetooth.
#define BLYNK_USE_DIRECT_CONNECT
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>
int sensorData;
SimpleTimer timer;
char auth[] = "7ba33741f39c4894a0b560104ed55498";
void readSensor() // sensor loop
{
sensorData = analogRead(A0); // reading the sensor on A0
Blynk.virtualWrite(V5, sensorData); // sending to Blynk
}
void setup()
{
timer.setInterval(1000L, readSensor);
DebugSerial.begin(9600);
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop()
{
Blynk.run();
timer.run();
}`Preformatted text`