Trouble connecting bluetooth to Mega with Android

I have a Samsung Android tablet, an Arduino Mega, and a HM10 bluetooth module.

I was playing around with this about 6 months ago and had it working, but after moving onto another project, I can’t seem to now get it working again.(My bluetooth module did get really hot once, maybe the wires were in the wrong way, so not sure if it has damaged it, but hoping you may be able to tell from the symptoms)

I have connected it as per many diagrams and have…

HM10 MEGA
VCC — 5v
GND — GND
RX — TX (PIN 1)
TX — RX (PIN 0)

I get a flashing light on the BT module. I have then paired it to the Android device, opened Blynk, started a new project, added bluetooth widget and connected to the HMSOFT, i then go back to the project main screen and press play and the BT module LED goes solid.

I load up the sketch from your site however I changed the ‘SoftwareSerial SerialBLE(1, 0); // RX, TX’ part because it had the wrong pin numbers, it had 10,11. (I have tried changing these from 10,11 and 11,10 and 1,0 and 0,1 and nothing works)

#define BLYNK_PRINT Serial

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

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

SoftwareSerial SerialBLE(1, 0); // RX, TX

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

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

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

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

I then open the serial monitor and get the following…


/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.7 on Arduino Mega

[5001] Connecting…
[10121] Connecting…
[15241] Connecting…
[17361] Login timeout
[20361] Connecting…
[22481] Login timeout
[25481] Connecting…
[27601] Login timeout
[30601] Connecting…
[32721] Login timeout
[35721] Connecting…
[40841] Connecting…
[45961] Connecting…
[48081] Login timeout
[51081] Connecting…
[53201] Login timeout
[56201] Connecting…
[58321] Login timeout
[61321] Connecting…
[63441] Login timeout
[66441] Connecting…

I have also tried the above but with a BLE widget, and I also have a HC-06 and have tried the above with that, and nothing works with that either. I have tried it all also with an Arduino Uno with no better results.

The Tablet is connected to the internet and appears to pair and connect with the module, it just won’t connect with the sketch.

It’s a Mega, use Hardware Serial not softserial… e.g. pins 18/19 for Serial1 TX/RX

Serial1.begin(9600);  // via BT Module
Blynk.begin(Serial1, auth);  // Connect to App via BT
1 Like

I have changed it to this…

#define BLYNK_PRINT Serial


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

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

SoftwareSerial SerialBLE(19, 18); // RX, TX

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

  Serial1.begin(9600);  // via BT Module
  Blynk.begin(Serial1, auth);  // Connect to App via BT

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

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

But not sure what you mean about use HARD instead of SOFT???

Either way, what I changed it to above doesn’t work on the HM10 or HC06.

You shouldn’t need this line as you are now using Hardware Serial (AKA actual hardware driven serial interface vs software simulated). https://www.arduino.cc/en/Tutorial/MultiSerialMega

SoftwareSerial SerialBLE(19, 18); // RX, TX

What are you seeing on the IDE serial monitor and is the App showing as device online?

Perfect. Thank you. All working now. Thanks.