"device is offline" when Blynk connect to HM-10

All is well.
With Mega 2560, HM-10
However, I had successfully accessed made my project work 2 month ago, yet it can’t work and show up “device is offline” on the app.And the auth token is right.
Appreciate for anyone’s help.

#define BLYNK_USE_DIRECT_CONNECT
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
//IN1 左前 7
//IN2 左後 6
//IN3 右前 4
//IN4 右後 5
//ENA 9 左
//ENB 8 右

#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "ba9497ebbb0a48aeb90d4db5da7bbbea";

SoftwareSerial SerialBLE(10,11); // RX, TX
int speedA=9,IN1=7,IN2=6,IN3=5,IN4=4,speedB=8;
int speeds=60;
char val;  // 儲存接收資料的變數

String CarCommand = "FBLRS0123456789q" ;  
void setup()
{
  // Debug console
  Serial.begin(38400);
pinMode(speedA,OUTPUT);
  pinMode(speedB,OUTPUT);
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT);
  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT); 
  
  SerialBLE.begin(38400);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");
}

void loop()
{
  Blynk.run();
}
BLYNK_WRITE(V1) {
 int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  analogWrite(9,60);
  analogWrite(8,60);
}
BLYNK_WRITE(V2) {
 int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
     digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  analogWrite(9,60);
  analogWrite(8,60);
}
BLYNK_WRITE(V3) {
 int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  analogWrite(9,60);
  analogWrite(8,60);
}
BLYNK_WRITE(V4) {
 int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
  digitalWrite(4,LOW);
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(7,LOW);
  analogWrite(9,60);
  analogWrite(8,60);
}
BLYNK_WRITE(V5) {
 int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  digitalWrite(9,0);
  digitalWrite(8,0);
}

BTW my serial monitor only shows connecting and login timeout like the photo below, but I have already connected to the HM-10.

The Mega has 3 extra Hardware Serial ports, and SoftwareSerial will be stressed at anything above 9600, so you should switch to one of those HW ports for more reliability.

E.g. Serial1: 19 (RX) and 18 (TX)

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

Serial1.begin(38400);
Blynk.begin(Serial1, auth);

1 Like

Thanks for your reply.
However, after varying the pins and code, problem didn’t solve,and my Blynk app can’t connect to the HM-10 as well.

On the other hand, I have also tried to change the baud from 38400 to 9600, it didn’t work, either