From f6fa1e52dacbf30953449467cd8ae3a55993fa52 Mon Sep 17 00:00:00 2001 From: Florian <1technophile@users.noreply.github.com> Date: Tue, 12 May 2020 20:27:05 -0500 Subject: [PATCH] Hm10 details (#614) * Add infos and change HM10 speed to a macro * remove unnecessaries macros --- docs/setitup/ble.md | 13 +++++++++---- main/ZgatewayBT.ino | 8 +------- main/config_BT.h | 1 + 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/setitup/ble.md b/docs/setitup/ble.md index 146d93b..dfe5553 100644 --- a/docs/setitup/ble.md +++ b/docs/setitup/ble.md @@ -1,6 +1,6 @@ # BLE gateway ## Compatible parts -The ESP32 has an integrated BLE module, with this board the BLE gateway don't need any additional hardware. Making it the **advised board for BLE**. +**The ESP32 has an integrated BLE module**, with this board the BLE gateway don't need any additional hardware. Making it the **advised board for BLE**. For Arduino and ESP8266 you can use an HM10 or HM11 below. |Module|Purpose|Where to Buy| @@ -15,8 +15,13 @@ For Arduino and ESP8266 you can use an HM10 or HM11 below. Vcc pin of the board and the HM10 Module to a 5V supply source. Ground pins of the board and the HM10 Module to the ground of the supply source. -The HM10/11 firmware version must be >= v601. -The baud rate of the HM10/11 module must be set to 9600 bauds. + +### Debugging the HM10 +So as to communicate directly with the HM10 you may use [this program](https://github.com/1technophile/serial_modules_debug) from Martin Currey, you can upload it to your ESP board and it will enable without an FTDI to write and read commands directly to the HM10 through the ESP. You may use the Arduino IDE Serial Monitor to read and send the commands. +The baud rate of the HM10/11 module must be set to 9600 bauds , the command `AT+BAUD?` enables to know at which speed the module is set. +So as to set it to 9600 that you may use `AT+BAUD0` command. + +The HM10/11 firmware version must be >= v601, the command `AT+VERS?` enables to know the firmware version. ## Arduino Hardware setup ![BLE Arduino](../img/OpenMQTTgateway_Arduino_Addon_BT.png) @@ -24,4 +29,4 @@ The baud rate of the HM10/11 module must be set to 9600 bauds. ## ESP8266 Hardware setup ![BLE ESP8266](../img/OpenMQTTgateway_ESP8266_Addon_BT.png) - +The implementation with the HM10 module would not have been possible without the work of [Martin Currey]( http://www.martyncurrey.com), thanks! diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index f10d02b..ac01490 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -665,12 +665,7 @@ bool BTtoMQTT() #else // arduino or ESP8266 working with HM10/11 #include - -#define STRING_MSG "OK+DISC:" #define QUESTION_MSG "AT+DISA?" -#define RESPONSE_MSG "OK+DISIS" -#define RESP_END_MSG "OK+DISCE" -#define SETUP_MSG "OK+RESET" SoftwareSerial softserial(BT_RX, BT_TX); @@ -686,7 +681,7 @@ void setupBT() Minrssi = MinimumRSSI; Log.notice(F("BLEinterval: %d" CR),BLEinterval); Log.notice(F("Minrssi: %d" CR),Minrssi); - softserial.begin(9600); + softserial.begin(HMSerialSpeed); softserial.print(F("AT+ROLE1" CR)); delay(100); softserial.print(F("AT+IMME1" CR)); @@ -702,7 +697,6 @@ void setupBT() bool BTtoMQTT() { - //extract serial data from module in hexa format while (softserial.available() > 0) { diff --git a/main/config_BT.h b/main/config_BT.h index bbc7d1c..1b0200a 100644 --- a/main/config_BT.h +++ b/main/config_BT.h @@ -35,6 +35,7 @@ extern void MQTTtoBT(char * topicOri, JsonObject& RFdata); #define MinimumRSSI -100 //default minimum rssi value, all the devices below -90 will not be reported #define Scan_duration 10 //define the time for a scan --WARNING-- changing this value can lead to instability on ESP32 #define HM-10 +#define HMSerialSpeed 9600 // Communication speed with the HM module, softwareserial doesn't support 115200 //#define HM-11 // uncomment this line if you use HM-11 and comment the line above //#define HM_BLUE_LED_STOP true //uncomment to stop the blue led light of HM1X #define BLEdelimiter "4f4b2b444953413a"