Login Timeout with Arduino Mega and Bluetooth

Hi there,

I’m trying to use Blynk with my setup - Arduino Mega via Bluetooth HC-05 module.

I ran the sample Blynk Blink program, connected to the module through the Bluetooth settings in my Pixel XL phone, then put a Bluetooth module block with the paired device in the Blynk app. In the Arduino serial, I can only get following -

[0] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.2 on Arduino Mega

[83] Connecting...
[2224] Login timeout
[5224] Connecting...
[10344] Connecting...
[15464] Connecting...
[17584] Login timeout
[20584] Connecting...

I’ve made sure that the HC-05 module operates at 9600 baud. Any suggestions as to what might be wrong?

Hello,

First off, I would recommend getting your Mega <–> BT module link tested with some other diagram & example from the internet first. The example sketch in the Sketch Builder is not taking proper advantage of the Mega’s multi-serial capacity.

https://www.arduino.cc/reference/en/language/functions/communication/serial/

Instead of SoftwareSerial I recommend Serial1 (pins 18 & 19)

image

I haven’t tested this… but I think it should work, despite being slapped together off the top-o-me head… :thinking:

#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>

char auth[] = "YourAuthToken";


void setup()
{
  Serial.begin(9600);  // Debug console
  Serial1.begin(9600);  // BT module - Pins 18 (TX1) & 19 (RX1) on MEGA

  Serial.println("Waiting for connections...");
  Blynk.begin(Serial1, auth);
  Serial.println("Connected to App...");
}


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

Thank you so much Gunner for your advice!

I figured out what was causing the login timeout issue -

According to the sample code from Blynk Example Browser,

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

Which implies-

Bluetooth Module RX -> Pin 10
Bluetooth Module TX -> Pin 11

However it should be

Bluetooth Module RX -> Pin 11
Bluetooth Module TX -> Pin 10

I confirmed this multiple times! I’m not sure if it was my knockoff Arduino or cheapo Bluetooth module, but if you are having this issue, try flipping the wire layouts!

Not quite :stuck_out_tongue_winking_eye: … this actually indicates the Arduino’s RX & TX pins… which, for a serial link, go to their opposing pins of the BT or other serial device… Think from mouth (Arduino TX) to ear (BT RX) and vice versa.

And with the Mega, it is still best to use the 2nd hardware serial pins (Serial1) than any software serial option.

1 Like