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

BLE HM-10 bluetooth with Arduino UNO and Iphone

#1

Hello,
I am trying to connect an Arduino UNO board with the Blynk app using a HM-10 BT module. I am using the sketch sugested in Blynk library and I have inseretd the BLE widget in the app. Under the project connections settings I have selected BLE. The module is connected to the arduino with softwareSerial RX to the TX in the HM-10 and viceversa and with the vcc and gnd connections to the arduino power supply. When I try connecting from the app selecting as device “HM soft” the module led stops blinking and displays continuos light for a few seconds, than the app displays “Can’t connect” and the module starts blinking again. Does someone know why it is not connecting?
Thanks!

0 Likes

#2

What SoftwareSerial baud rate are you using, and is the same baud rate that the HM-10 is using/expecting?

What are you seeing on the serial monitor when the Uno is connected to your PC?

Pete.

0 Likes

#3

I am using 9600, I have tried with 11520 too. On the serial monitor I am not able to communicate with the HM-10 using AT command.

0 Likes

#4

SoftwareSerial can’t really cope with anything faster than 9600, as it’s creating a virtual COM port via software.
You need to configure your HM-10 to use 9600. If you cant communicate with the HM-10 via serial monitor from your PC (using an FTDI adapter of course) then there’s something wrong with your setup or the HM-10.

Is the USB port of your Uno connected to your PC, and if so what do you see in the serial monitor?

Pete.

0 Likes

#5

Ok I will have to change the Baud rate of HM-10, because its default is probably 11520 and not 9600. I have the arduino connected to the PC via USB and in the serial monitor of the Arduino IDE I am not able to connect to the HM-10, I have tried with AT command.

0 Likes

#6

You should read this:
http://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/

Pete.

0 Likes

#7

I read the document, it was helpful but I am still not able to connect. I have checked the connections with the schematics provided in the website linked, and I am also using their sketch for serial communication with HM-10 module, but when I type the AT command the BT module is not replying. I have tried with the app BLEconnect for iphone and I successfully connected with the module, but still I am not able to do it through the arduino board.
I have never tried with FTDI adapter since I don’t have it, but the sketck provided in the website is starting the HM-10 at 9600 rate, so it should be possible to communicate with it through the arduino ide serial monitor, right?
Is it possible in this way (without FTDI adapter) to configure it to use 9600 so that I can successfully pair it with the arduino?

0 Likes

#9

Up to now I am able to send AT commands from the arduino IDE serial monitor using digital pins 0 and 1 on the board for connections. It is not clear what are the settings for the HM-10 module, e.g. to which setting code each Baud rate corresponds, in some datasheet 9600 is AT+BAUD0 (default setting), in other can be AT+BAUD4,…

0 Likes

#10

Do you get a reply when you send “AT” (with quotes)

0 Likes

#11

I only get a reply if I connect the HM-10 to the D0and D1 pins, not using Software Serial. If instead I try with the sketch for Blynk connection where two other pins are defined as serial RX and TX I don’t get replies with AT, neither with quotes.

0 Likes

#12

Ah you wouldn’t be able to do that using the serial monitor without linking serial to software serial. Or by doing software serial print commands.

Obviously you wouldn’t need to do that when Blynk is setup. I think maybe the RX and TX connections are reversed? What sketch are trying to use and what are your connections from HM-10 to Arduino?

0 Likes

#13

You need to use the Sertal In/Out sketch on the website I linked to earlier and get to the point where typing “AT” followed by a return character gives the reply “OK”.

Issuing an “AT+BAUD?” will then reply with the current baud rate setting. If the answer isn’t “0” (9600) then you’ll need to change this to 9600, so you’ll use the command “AT+BAUD0”.

Pete.

0 Likes

#14

I already set the baud rate, actually it was set at BAUD0 by default, connecting the device to the arduino hardware serial ports D0 and D1, but I am not able to communicate using the sketch you are referring to, actually each time I try to communicate through software serial ports I cannot reach the BT module.

0 Likes

#15

Can you post the sketch you are using?

0 Likes

#16
//  SerialIn_SerialOut_HM-10_01
//
//  Uses hardware serial to talk to the host computer and AltSoftSerial for communication with the bluetooth module
//
//  What ever is entered in the serial monitor is sent to the connected device
//  Anything received from the connected device is copied to the serial monitor
//  Does not send line endings to the HM-10
//
//  Pins
//  BT VCC to Arduino 5V out. 
//  BT GND to GND
//  Arduino D8 (SS RX) - BT TX no need voltage divider 
//  Arduino D9 (SS TX) - BT RX through a voltage divider (5v to 3.3v)
//
 
#include <AltSoftSerial.h>
AltSoftSerial BTserial; 
// https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
 
 
char c=' ';
boolean NL = true;
 
void setup() 
{
    Serial.begin(9600);
    Serial.print("Sketch:   ");   Serial.println(__FILE__);
    Serial.print("Uploaded: ");   Serial.println(__DATE__);
    Serial.println(" ");
 
    BTserial.begin(9600);  
    Serial.println("BTserial started at 9600");
}
 
void loop()
{
    // Read from the Bluetooth module and send to the Arduino Serial Monitor
    if (BTserial.available())
    {
        c = BTserial.read();
        Serial.write(c);
    }
 
 
    // Read from the Serial Monitor and send to the Bluetooth module
    if (Serial.available())
    {
        c = Serial.read();
 
        // do not send line end characters to the HM-10
        if (c!=10 & c!=13 ) 
        {  
             BTserial.write(c);
        }
 
        // Echo the user input to the main window. 
        // If there is a new line print the ">" character.
        if (NL) { Serial.print("\r\n>");  NL = false; }
        Serial.write(c);
        if (c==10) { NL = true; }
    }
}
0 Likes

#17

I’ve added triple backticks to the start and end of your code so that it displays correctly. You should do this yourself in future.

What pins are you using to connect the HM-10 when you use SoftwareSerial?

Pete.

0 Likes