Bluetooth module LED shows connected but no code is executing

I have a Arduino nano which is using the below bluetooth module to connect to my android phone.

I have setup a Blynk project to connect to the Arduino with bluetooth. Everything seems to connect fine and the bluetooth module’s “connect” LED lights up.

When I look at the serial monitor however, I get a message that repeats “login timeout”.

Also I have tried including some basic code just to activate the digital pin 13 on the Arduino but that doesn’t even light up. See below my code used to connect to the phone and Blynk app, its basically the standard example supplied by Blynk with my own pin values etc.

I cant get a button on the Blynk app to activate pins on my arduino and more worrying is the fact that I can’t even get pin D13 to light up from the arduino code.

Note sure whats happening here so any advise would be appreciated.

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  Warning: Bluetooth support is in beta!

  You’ll need:
   - Blynk App (download from AppStore or Google Play)
   - Arduino Nano board
   - Decide how to connect to Blynk
     (USB, Ethernet, Wi-Fi, Bluetooth, ...)

  There is a bunch of great example sketches included to show you how to get
  started. Think of them as LEGO bricks  and combine them as you wish.
  For example, take the Ethernet Shield sketch and combine it with the
  Servo example, or choose a USB sketch and add a code from SendData
  example.
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(7, 8); // RX, TX
    
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

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

SoftwareSerial SerialBLE(7, 8); // RX, TX

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

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

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

  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

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!

  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
}

Why these two commands in the void loop() trying to run thousands of times a second? Unnecessary… just run them once in the setup()

And both of these are tying to use the same digital pins… not going to work properly that way :wink:

Thank you very much for the help. Sometime one set of eyes simply isn’t enough :laughing:

I have made the suggested changes, I have also swapped out my bluetooth module for a new HC-06. I can see and connect to the bluetooth with my phone. It even shows up on the Blynk app when I add the bluetooth widget and select “Connect bluetooth device”.

The D13 still isn’t lighting up though and a D12 button i created on the app isnt setting the pin to 1 either.

Any other suggestions? :thinking:

Sorry, I don’t use BT/BLE mutch at all… I find that even when it works its reliability is iffy.

But it is strange you can’t get the built in LED (Pin 13) to work… Move your pinMode() commands to the very beginning of the setup(), followed by the digitalWrite() so they are not blocked when waiting for a Blynk connection. Then all the Serial.begin() followed by the Blynk.begin()

With multiple SoftwareSerial, only one can communicate at a time… so I recommend using only one for the BT module and running debug/programming off of the primary Serial/USB port. You can also try changing the pins used for that to 2 & 3 in case that somehow matters :stuck_out_tongue_winking_eye:

I am also not a fan of using Blynk’s direct pin control. I prefer Virtual Pins and coded functions… Eg.

// Button Widget set to V0 and Switch mode
BLYNK_WRITE(V0) {  // This function is run each time the state changes on the Apps button Widget
digitalWrite(13, param.asInt());  // Send Button state to digital pin
}

Hi Gunner, thank you very much for all the help.

I managed to get it to work. I went wrong in a few places, firstly through I used the HC-06 without a voltage divider so I think I burnt it out. I swapped it with a HC-05 and used a voltage divider on the RX pin and it works!

Your help was much appreciated!

1 Like