Arduino UNO with HC-06 module

Dear Sir/Madam,

I am new to Blynk, I read throught the forum and found the question about HC-06 but none of them can solve my problem.

• Hardware model + communication type. Arduino UNO with HC-06 module
• Smartphone OS: Android 7.1.1
• Blynk server
• Blynk Library version 0.5.2
• Add your sketch code. Serial_HC05_HC06

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>

char auth[] = "YourAuthToken";

void setup()
{
  DebugSerial.begin(9600);

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

  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}

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

I copy and paste the correct Auth Token and it works when Serial USB connection, it is online when Bluetooth connected but no response to button press on Blynk.

Is it still required to have the Internet connection for HC-06 connection?

Yes… for the App to be able to connect to the server for login and authentication code generation & authorisation.

Dear Gunner,

Thanks for your reply. How can I do the connection to the server for login and authentication code generation & authorisation if I insist to use the Bluetooth as the connection between mobile phone and Arduino? Could you please advise the steps?

Best regards,

Kelvin.

Remember, Blynk is an Internet Of Things product… it is designed to work over the internet!

As long as the phone (App) can connect to the server (cloud) via a cell connection to the internet, then the BT link between the phone and the device will work as normal.

The only way to use Blynk completely Internet free, is to have a Local Server running on something like a Raspberry Pi that is also setup to act as an AP for a local private network that the phone can connect to via WiFi… but that is getting to be an advanced and potentially complicated setup… not for beginners or even many intermediary users.

Dear Gunner,

I am familiar with the network connection. My phone can connect to Internet either via the cell network or private network. When I read the description about Bluetooth, it says

Widget for enabling Bluetooth support. At the moment Bluetooth widget supported only for Android and requeirs internet connection in order to login and load your profile. However this will be fixed soon. Also some Blynk widgets not allowed with Bluetooth.

I connect the Bluetooth using the HC-06 and Blynk also say it is online? Is HC-06 compatible? What is the mean of the message say “However this will be fixed soon”?

FYI, the Bluetooth connection between phone and Arduino works and the Blynk also show Online since 16:38 May 28, 2108 but the control not work.

Best regards,

Kelvin.

Only the Developers know… :stuck_out_tongue_winking_eye:

Well, that seems like your wiring and everything are correct… What controls have you tried?

Using a Button on pin 13 is a good test to see if you can light up the Arduino’s built-in LED.

I am heading to :sleeping::sleeping: now… so keep trying… perhaps try using virtual pins and code instead of direct pin connections in the widgets.

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/what-is-virtual-pins

Dear Gunner,

I copy the code from https://examples.blynk.cc/?board=Arduino%20Uno&shield=HC05%20or%20HC06&example=GettingStarted%2FBlynkBlink

#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
    
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

char auth[] = "paste-my-auth-token-here";

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

void setup()
{
  Serial.begin(9600);

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

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

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

When you view my screenshot here https://prnt.sc/jnl1yc you can find the Bluetooth connection is successfully made and Blynk is online.

If I open the Serial Monitor, I find the message
[82] Connecting…
[2223] Login timeout
[5223] Connecting…
[10343] Connecting…
[15463] Connecting…
[17583] Login timeout

but I can’t see the message “Waiting for connections…” coded in the program. How can I view the Serial.println()

Do you have any idea about my Bluetooth connection?

Best regards,

Kelvin.

Make sure you are crossing the connections between the BT and Arduino… RX from one goes to TX of the other and vice versa.

1 Like

Dear Gunner,

Got it. By the way, in the example code, what is the purpose of SwSerial(), it doesn’t seem to be called in setup() or loop().

Above code I copy from https://examples.blynk.cc/?board=Arduino%20Uno&shield=HC05%20or%20HC06&example=GettingStarted%2FBlynkBlink

but below code I open from Arduino IDE > File > Examples > Blynk > Boards_Bluetooth > Serial_HC05_HC06 and it doesn’t work even I have the correct pin connection

#define BLYNK_USE_DIRECT_CONNECT

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(10, 11); // RX, TX

#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>

char auth[] = "paste-my-auth-token-here";

void setup()
{
  DebugSerial.begin(9600);

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

  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}

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

Above code is copied from Blynk 0.5.2. May I know which version of Blynk library the code from https://examples.blynk.cc/?board=Arduino%20Uno&shield=HC05%20or%20HC06&example=GettingStarted%2FBlynkBlink

Looks like small error in sketch that wouldn’t actually affect compiling or function as the 2nd command is the correct one and would supersede the 1st.

image

Normally one of the two #include groups would be commented out depending on use.

Code has no version in of itself… and is very flexible depending on each users hardware and installed libraries… as in there will be times that old commands or library references may need to be edited in old code to match new libraries. Nothing is written in stone :stuck_out_tongue:

Dear Gunner,

Many thanks for your help!