Arduino Mega with HM-10 cannot be connected in blynk app

The HM-10 cannot be connected in the blynk app
Android 11 and Android 6 and iOS 14 both cannot connect in the blynk app
I have checked the TX and RX pin
• Blynk Library version 0.6.1
I

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

SoftwareSerial softwareSerial(17, 16); // RX, TX
char auth[] = "r--4VYjtaMEQ3wORZlcF5kkhap9kNb5l";

void setup()
{
  softwareSerial.begin(9600);
  Blynk.begin(softwareSerial, auth);
}

void loop()
{
  Blynk.run();
}

Please help!

The baud rate you choose has to match what the HM-10 is expecting, otherwise the communication between the Mega and the BT module will fail.

SoftwareSerial doesn’t really work effectively on the Mega at speeds higher than 9600, so you’ll need to configure the HM-10 to use a default baud rate of 9600 and use this in your sketch.
The HM-10 is configured via AT commands.

Pete.

@PeteKnight I have tried 9600 before but also not working…

What AT command did you use to set the HM-10 to that baud rate, and what hardware did you use when doing that?

Pete.

@PeteKnight I am using Arduino Mega 2560 and the sample Arduino provided in the library :
When I click connect, the light on HM-10 will stop flashing for a few second, but after a few seconds it show cannot connect in the app and the HM-10 remain flashing. Thanks!

#define BLYNK_USE_DIRECT_CONNECT

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(17, 16); // 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[] = "r--4VYjtaMEQ3wORZlcF5kkhap9kNb5l";

void setup()
{
  // Debug console
  DebugSerial.begin(9600);

  DebugSerial.println("Waiting for connections...");

  // 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();
}

I guess that means you didn’t understand what I means when I said…

??

Pete.

@PeteKnight I have used in the serial monitor, but it cannot receive OK from HT-10 when I send the AT commands to configure it @@. I don’t know what’s wrong :sob:

How did you connect the HM-10 to your computer when you were doing this?

Have you googled how to do this non-Blynk related task?

Pete.

I believe the Mega 16,17 pinout should read like this

 Serial2.begin(9600);
  Blynk.begin(Serial2, auth);

and 14,15 is number3. Works 4 me…