Arduino Nano + HC-08 does not function properly

Hi,

• Smartphone Android LG G6 with android v9
• Blynk server
• Blynk Library version 0.6.1
I used this guide for the wiring: https://cpl.li/2019/bluetooth-hc08-macos/

I am totally stuck with my arduino nano and bluetooth HC-08 module.
I tried to example script: https://examples.blynk.cc/?board=Arduino%20Nano&shield=HM10%20or%20HC08&example=GettingStarted%2FPushData
But then I get: “exit status 1
‘SerialBLE’ was not declared in this scope”

I looked on this and other forums and tried many things, e.g.
Changed SoftwareSerial SwSerial(10, 11); // RX, TX into SoftwareSerial SerialBLE(10, 11); // RX, TX
Than it can compile and the app finds “HC-42” within bluetooth connecting (button) in the app it says “something went wrong when conneting to your bluetooth device.”
Using the BLE button is says: “Can’t connect. Connecting to Bluetooth device”

At this point I do not know why the example script does not work, how to upgrade it or futher troubleshoot the problems.

Any help is appreciated!

With kind regards,
Rick

PS: Serial monitor gives this:
16:53:46.422 -> [0]
16:53:46.422 -> ___ __ __
16:53:46.422 -> / _ )/ /_ _____ / /__
16:53:46.456 -> / _ / / // / _ / '/
16:53:46.489 -> /
//_, /////_
16:53:46.523 -> /
__/ v0.6.1 on Arduino Nano
16:53:46.556 ->
16:53:46.556 -> [90] Connecting…
16:53:49.631 -> [3230] Login timeout

You should read this…

Pete.

Hi Pete,

Thank you for your response, I already found the post you mentioned but did not figure out on my own how this would translate to the arduino nano.
Having taken a second look I think that because the nano only has one set of RX and TX pins, it can only use the bluetooth module OR use the serial.print for debugging but not both.
Can you confirm this?

With kind regards,
Rick
PS: got the nano connected now, thanks!

The code you linked to in your original post uses a “virtual” SoftwareSerial port to communicate with the HC-08, leaving the physical serial port available for debugging.

Pete.

Hi Pete,

So you are saying I can both communicate with the HC-08 AND debug over Serial at the same time?
Then why doesn’t the following script allow me to connect to the device over bluetooth at all?
I tried changing it to digitial pins 2,3 and wiring it to RX0 and TX1, and of course digital pins 10 and 11 on my arduino Nano

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


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

#include <BlynkSimpleSerialBLE.h>

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

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

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

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

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

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

@Rick please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of the your code so that it displays correctly correctly.

Triple backticks look like this:
```

Pete.

Hi,

Oh yeah I forgot, good tip.
Can you take a look at my code and give some insight in why I cannot have messages over Serial whilst also having the bluetooth module active?

Rick

You can’t use the same serial connection for different purposes. With boards like the Uno and the Nano (which are basically the same, but different form factors) which only have one physical UART, it it is necessary to use SoftwareSerial to create a second software UART.

The hardware UART is broken-out to pins labelled Tx and Rx, and also goes via an onboard TTL to USB connector so that you can connect the USB socket to your PC. For thus reason, it’s usually more convenient to use the hardware UART (referenced as Serial in code) for debugging and the software UART for connection to your Bluetooth or WiFi adapter.

It looks like it should work. Pin 10 (SoftwareSerial Rx on the Arduino needs to connect to the Tx pin on your HC-08 and Pin 1T (SoftwareSerial Rx on the Arduino needs to connect to the Rx pin on your HC-08.

You also need to use the correct baud rate for your HC-08. I assume that as you’ve put 9600 in your sketch then this is what you’ve used with the sketch that did work when you wrote…

Pete.

1 Like