HC-05 with MkrZero

Hi

I am using a MKR Zero and have the Serial for the HC-05 on the Pins 13,14 (Internal Serial Port). I can use AT Commands (different code than below), so I know the code for the serial is correct… but I cant get Blynk to connect using the code below.

Is then anything special I need to do to the HC-05 to get it to work with Blynk?


#define BLYNK_PRINT Serial
#define BLYNK_DEBUG

#include <BlynkSimpleSerialBLE.h>

char auth[] = "...xxx...";

void setup() {
  Serial.begin(9600);
  while (!Serial) ;
  Serial.println("Serial DEBUG Setup...");

  Serial1.begin(9600);
  Serial.println("Serial1 BT Setup...");
  while (!Serial1) ;

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

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

Do you get as far as “Waiting for connections…” in your serial monitor?

Pete.

Yes

21:45:16.567 -> Serial DEBUG Setup...
21:45:16.567 -> Serial1 BT Setup...
21:45:16.567 -> Waiting for connections...
21:45:16.567 -> [1930] 
21:45:16.567 ->     ___  __          __
21:45:16.567 ->    / _ )/ /_ _____  / /__
21:45:16.567 ->   / _  / / // / _ \/  '_/
21:45:16.567 ->  /____/_/\_, /_//_/_/\_\
21:45:16.567 ->         /___/ v1.0.0 on MKRZERO
21:45:16.567 -> 
21:45:16.567 -> [1931] Connecting...

Do you have the BT/BLE widget in your app, and have you linked it to the HC-05?

Pete.

Yes have BT widget installed… I should mention I have had the HC-05 and Blynk working with a Uno with Software Serial, but I need to get it working on the MKR Zero.

Auth key is correct as well.

Ian

The MKR Zero is a 3.3v (MAX!!!) device and the HC-05 needs 5v so may not work properly at 3.3v

Hi.

There is a 5V pin that I am running it on with a Voltage divider for the RX. Like I said before I can run AT commands ok.
One thing I have noticed is the LED blinks fast but when the Blynk App tries to connect the LED goes off for 2 seconds and then blinks twice fast and then repeats. When Blynk App goes to sleep it blinks fast again.

Are you intending this to work with the new Blynk IOT App?
Or the Blynk (Legacy) App? (if so, you need to step down to the previous library version)

@Gunner - good catch!

New version doesn’t support BT (yet), so @Ian_Bromley should be using 0.6.1

Pete.

I think using the same forum for both Blynk (Legacy) with it’s years of accumulated users and data, and the new Blynk IoT, that is just adding a confusing mess, is another mistake… But who listens to use old regulars anyhow :stuck_out_tongue:

2 Likes

I am using Blynk (Legacy) and I down graded to 0.6.1 and still the same.

Not sure if the lib matches the Device selected in Blynk to the actual Device found by the library… Blynk doesn’t have a Device “MKRZERO” so I have had to choose “MKR1000” or does it just go on the authkey??

Also I am not getting at serial debug from Blynk, is that normal until it connects?

11:38:25.514 -> Serial DEBUG Setup...
11:38:25.514 -> Serial1 BT Setup...
11:38:25.514 -> Waiting for connections...
11:38:25.514 -> [1120] 
11:38:25.514 ->     ___  __          __
11:38:25.514 ->    / _ )/ /_ _____  / /__
11:38:25.514 ->   / _  / / // / _ \/  '_/
11:38:25.514 ->  /____/_/\_, /_//_/_/\_\
11:38:25.514 ->         /___/ v0.6.1 on MKRZERO
11:38:25.514 -> 
11:38:25.514 -> [1120] Connecting...

The device choice in the App only accounts for the available pins when controlling them directly from the app. You can use anything, or just GENERIC when using vPins

AT commands are simple, slow and sporadic. Blynk communicates a bit more data and relatively consistently.

I am not going to qualify this with links and such, you can Google such or not yourself… but it makes sense to me that as a 5v signal range roughly differentiates a 0 from 1 around 2.5v… dropping a signal to 3.3v on a device made for 5v means it may not reliably catch all the 0 signals.

I am using a 2k and 1k divider so should get around 3.3v

Not what I meant.

Sure you have dropped the max voltage down, but the BT module is still made for 5v signal, and interpreting a crossover between a 0 and a 1 (theoretically at 2.5v) is nowhere near the midpoint voltage of 3.3v (1.65v).

To be sure there is “proper” data connectivity between a 5v and 3.3 v device requires a level shifter, preferably an active one. Yes, a passive voltage divider may work at times, but apparently not all the time in your case.

Honestly… because a serial signal is not a regularly constant voltage/current, as in the case with ON/OFF or even PWM GPIO use, I would personally test (and have done so in past without any issues) with a direct connection… as in NO level shifting… and see what/if any difference that makes.

Do so at your OWN risk :stuck_out_tongue:

And one other suggestion I have heard (but may be just an old mans tale) that it is better to have offset BAUD settings… change one or the other to 19200 or higher.

The debug is the easiest to adjust and the slower BAUD for the BT module would be best when using passive level shifting anyhow.

1 Like

Thanks @Gunner, @PeteKnight but I have tried everything and still no luck. I am going to go back to the Uno with an external SD Card reader.

Thanks again
Ian

1 Like