BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Keyestudio HM-10 Shield & Blynk - Making it work with Uno and Mega


#1

So good news folks… I’ve been looking for an alternative to the Arduino 101 from a bluetooth standpoint, and I think I have a winner! As a school, I need to do things on the cheap, and it doesn’t get much cheaper than Keyestudio stuff. I’ve been impressed with the overall quality of the board, and I also talked Jameco into carrying them as well. I wanted to use the Blynk app because of it’s versatility and ability for students to basically build their own app quickly and easily.

Here are the links to the boards that I’m using on Keyestudio’s site:

The Uno - http://www.keyestudio.com/shop/ks0001.html
The Mega - http://www.keyestudio.com/shop/mega.html
The HM-10 Shield - http://www.keyestudio.com/shop/shield/keyestudio-bluetooth-4-0-expansion-shield.html

Here’s the setup for the UNO:
First, the jumpers on the shield come connected to RX and TX pins on the shield and need to be moved over to the 2 and 3 pins as shown in the picture. On the back side of the board they are labeled 2-BT and 3-BR

I also threw on an LED on pin 13 going to ground so that I could test the Blynk app once connected.

(One quick trick with this board that I had to figure out is that you have to flip the power switch to off when uploading code to the UNO or MEGA, then turn it back on once uploaded and connect to the Blynk app)

Here is the code, notice that the pins are set to 2, 3:

#define BLYNK_PRINT Serial


#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

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

SoftwareSerial SerialBLE(2, 3); // RX, TX

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

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

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

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!
}

The Mega is a little bit different. You need to jump the BT and BR pins over to pin 10 and 11 on the Mega board. BT goes to pin 10 and BR goes to pin 11.

Then change the pin numbers in your code… here it is:

#define BLYNK_PRINT Serial


#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

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

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

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

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

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

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!
}

#2

Thanks for the posting… FYI, I fixed the code formatting.