HM-10 Bluetooth BLE

I try to work with this module, an Arduino Uno and my Android phone.

With this code:

/****************************************/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(7, 8); // RX, TX
// Connect HM10 Arduino Uno
// TXD Pin 7
// RXD Pin 8

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

mySerial.begin(9600);
}

void loop() {
char c; char d;
if (Serial.available()) {
c = Serial.read();
mySerial.print(c);
Serial.println (“aller”);
}
if (mySerial.available()) {
d = mySerial.read();
Serial.print(d);
Serial.print (“retour”);
}
}
/****************************************/

And the Bleserialport app on my Android Phone.

When I use the “connect” button, the app on my phone find the HM10 module and the connection is OK, the led on the module is steady on.

Then I write something on the Arduino terminal, and I get it on my phone, so this way is OK and each time “aller” is printed on the terminal.

But when I write something on my phone, I get nothing on the terminal and “retour” isn’t printed so it seems that :

if (mySerial.available())

is always false.

May you give me some paths to explore?

Nobody?

Still nobody ?

I specifically avoid BLE but you might find the following background notes useful nonetheless.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

It would appear that the wiring is kosher.

Thank you Nick, I have read this useful document.

I have fitted another HM-10 module still feed with 5V, but the TX of the bluetooth with divisor to have 3.3V and it works !

The code:

// Send LF (10) and Hello! to the phone, “serial bluetooth terminal” app
//

// send the text from the phone to the serial monitor
// RX bluetooth on Arduino pin 10
// TX bluetooth on Arduino pin 11

#include <SoftwareSerial.h>

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

String c;
void setup()
{

bluetooth.begin(9600);
// pinMode(0, INPUT_PULLUP);// only needed for JY-MCU v1.06?
Serial.begin(9600);

bluetooth.write(10);
bluetooth.write(“H”);
bluetooth.write(“e”);
bluetooth.write(“l”);
bluetooth.write(“l”);
bluetooth.write(“o”);
bluetooth.write("!");

Serial.println(“Entrez un texte sur le smartphone”);
Serial.println(“puis validez”);
Serial.println("");

}
void loop() {
while (bluetooth.available())
{
delay(3);
c = bluetooth.readString();

}// end while
if (c.length() >0)
{
Serial.println(c);
c="";

} // end if
}

To be continued…

So, now it works :

With an app on the phone to type a text and send it via bluetooth to the arduino, then from the arduino to RS485 to drive an Hanover flipDot panel (128 * 16)

Here is the code:

// Permet d’envoyer un texte sur la girouette depuis le telephone
// Environ 10 lettres en majuscule, pleine taille : 16 de haut et 3 de large
// Si on envoie davantage, passage à 14 de haut et 2 de large
// Puis 9 de haut et 1 de large
// Ensuite, refus du message
// Attention au cablage du connecteur DMX, différent pour les panneaux LED

// Envoi Hello! vers le telephone, précédé de LF (10)
// Reçoit un texte depuis le téléphone
// Avec l’app “serial bluetooth terminal”
// RX du module bluetooth cablé sur pin 10
// TX du module sur le point milieu des résistances, 2k au 0V et 1k à la pin 11

// recopie du texte reçu dans une autre phrase

//BT
#include <SoftwareSerial.h>

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

int check1; int check2; int check3; int check4; int check5 ; int check6;
int total1 ; int total2;
int taille;
int i;
int toto;

// BT
String c=" “;
String message2; //=” ";

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(4800);

//BT

bluetooth.begin(9600);

bluetooth.write(10);
bluetooth.write(“H”);
bluetooth.write(“e”);
bluetooth.write(“l”);
bluetooth.write(“l”);
bluetooth.write(“o”);
bluetooth.write("!");

}

void loop() { // run over and over

//BT
while (bluetooth.available())
{
delay(3);
c = bluetooth.readString();
}// end while
if (c.length() >0)
{

// remplissage du tableau:
toto= c.length();

for ( int j = 0; j < toto; j++) {
message2=message2 + c.charAt(j);

}
// Serial.println (c); // OK jusqu’ici, correspond au message du telephone

// Serial.println (toto); // correspond bien à la longueur
// Serial.println (message2); //

// Calcul de la taille du tableau = taille tableau / taille element
taille=message2.length();

// Serial.println (taille);
// Boucle pour calculer la somme de tous les éléments
for ( i = 0; i < taille; i = i + 1) {
total1 = total1 + (message2*) ;*
// Serial.println (total1);
}
// ajout du STX, 0, 1 et ETX (voir protocole Hanover)
total2 = total1 + 0x30 + 0x31 + 0x03;
//Calcul checksum (voir protocole Hanover)
check1 = total2 % 256;
check2 = 0x100 - check1;
check3 = check2 / 16;
_check4 = check2 - 16 * check3; _
check5 = check3 + 48;
// si supérieur à 10, calcul pour A B C D E ou F
if (check3>=10) {
check5 = check3 -10 + 65;}
check6 = check4 + 48;
// si supérieur à 10, calcul pour A B C D E ou F
if (check4>=10) {
check6 = check4 -10 + 65;}
// envoi STX (début de message) + 0 1
Serial.print((char) 02) ;
Serial.print((char) 48) ;
Serial.print((char) 49) ;
*// Boucle pour envoyer tout le texte *
for (int k = 0; k < taille; k = k + 1) {

  • Serial.print((char) message2[k]) ;*

  • }*
    // envoi de ETX + checksum
    Serial.print((char) 03) ;
    Serial.print((char) check5) ;
    Serial.print((char) check6) ;
    *delay(1000); *
    c="";
    message2="";
    total1 = 0;

  • } // end if*
    }