MajicDesigns / Chroniker

A LED Neopixel Analog Clock with multiple control interfaces (Bluetooth, IR Remote, tact switch)
2 stars 3 forks source link

Bluetooth NAME #2

Open FPVxfun opened 4 years ago

FPVxfun commented 4 years ago

Hi, I'm about to run your project with HC-06 (ZS040 version) Bluetooth module, connected to Serial2 pin (16 and 17). I've selected the #define for HC-06 and enabled serial debug. However serial monitor show the following error:

[Chroniker Clock Debug] Start BT connection at 9600 BT err on NAME: Setup exit, free mem 7058 RUN_INIT RUN_NORMAL

In the smartphone, the APP show "Connected" but every command answer is "0: Timeout [Rcv]".

As written in the following tutorial:

http://www.martyncurrey.com/hc-06-hc01-comv2-0/

I've tried to update the following line in Chroniker_BT.h file:

from const char szEnd = "\r\n"; to const char szEnd = "";

But the problem is the same.

I had no problem with same Arduino hardware and same HC-06 module but with simpler firmware.

Do you have any idea?

Thanks

MajicDesigns commented 4 years ago

Is the serial bit rate set correctly? What is the 'simpler firmware' using?

If you have already set the name in the BT module then you can eliminate the BT initialisation.

The timeout is because the Arduino is not sending a response. This could also be caused by the wrong bit rate.

FPVxfun commented 4 years ago

Simpler firmware is example firmware I used to turn on and off a led via Bluetooth sending a single character, without protocol check.

The bauderate is 9600, according to your settings.

I've found some differences between HC-06 module revisions. My module is ZS040 and answers "OKlinvorV1.8" to command AT+VERSION. Is it your the same?

MajicDesigns commented 4 years ago

No idea. This project was 2.5 years ago for me and I have not looked at it since then. It is likely that firmware is different but the AT commands should be the same.

Have you tried a simple terminal to the BT module and using the BT commands directly from the keyboard? It is possible line endings or other syntax is mismatched.

FPVxfun commented 4 years ago

Yes, I've found some documentation about differences between modules revision. One of them was carriage return and line feed NOT needed on HC-06. I've tried also this, however Arduino IDE is not simple to debug due to limited debug tools built-in. Maybe something is still wrong.

Are you Italian? I live near Verona

MajicDesigns commented 4 years ago

All I can suggest is that you experiment with changing the name through a keyboard interface to the HC-06 (sketch below). Once you have the right format, edit the code for your revision.

I live in Sydney, Australia.

`/* BlueTooth HC-05 Terminal For Setup of HC-05 type BlueTooth Module NOTE: Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right

include

// Hardware Definitions uint8_t HC_05_TXD_ARDUINO_RXD = 8; uint8_t HC_05_RXD_ARDUINO_TXD = 9;

uint16_t BT_BAUD_RATE = 9600;

// Global Objects and Variables SoftwareSerial BTSerial(HC_05_TXD_ARDUINO_RXD, HC_05_RXD_ARDUINO_TXD);

void setup() { // Arduino Serial Monitor Interface Serial.begin(9600); Serial.println("[HC-05 Bluetooth Terminal]"); Serial.println("Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right"); Serial.println("Enter AT commands in top window.");

// Bluetooth Serial Interface BTSerial.begin(BT_BAUD_RATE); // HC-05 in AT command mode at current baud rate }

void loop() // Read and write between Arduino and Bluetooth serial ports { // Bluetooth if (BTSerial.available()) Serial.write(BTSerial.read());

// Arduino - include local echo of characters sent if (Serial.available()) { char c = Serial.read(); Serial.write(c); BTSerial.write(c); } }`

FPVxfun commented 4 years ago

Ok many thanks, I will try for sure! Your example of communication is the more professional I found in the web.

Bye

Il mar 5 mag 2020, 05:51 Marco Colli notifications@github.com ha scritto:

All I can suggest is that you experiment with changing the name through a keyboard interface to the HC-06 (sketch below). Once you have the right format, edit the code for your revision.

I live in Sydney, Australia.

`/* BlueTooth HC-05 Terminal For Setup of HC-05 type BlueTooth Module NOTE: Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right

  • CONNECTIONS:
  • GND
  • Vcc
  • Pin 8 to HC-05 TXD
  • Pin 9 to HC-05 RXD */

include

// Hardware Definitions uint8_t HC_05_TXD_ARDUINO_RXD = 8; uint8_t HC_05_RXD_ARDUINO_TXD = 9;

uint16_t BT_BAUD_RATE = 9600;

// Global Objects and Variables SoftwareSerial BTSerial(HC_05_TXD_ARDUINO_RXD, HC_05_RXD_ARDUINO_TXD);

void setup() { // Arduino Serial Monitor Interface Serial.begin(9600); Serial.println("[HC-05 Bluetooth Terminal]"); Serial.println("Set Serial Monitor to 'Both NL & CR' and '9600 Baud' at bottom right"); Serial.println("Enter AT commands in top window.");

// Bluetooth Serial Interface BTSerial.begin(BT_BAUD_RATE); // HC-05 in AT command mode at current baud rate }

void loop() // Read and write between Arduino and Bluetooth serial ports { // Bluetooth if (BTSerial.available()) Serial.write(BTSerial.read());

// Arduino - include local echo of characters sent if (Serial.available()) { char c = Serial.read(); Serial.write(c); BTSerial.write(c); } }`

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MajicDesigns/Chroniker/issues/2#issuecomment-623839567, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJSRHJVOE36ODUYJCQ4LR3RP6ENRANCNFSM4MYV6R6Q .

FPVxfun commented 4 years ago

Dear Marco, I've found some differences between your code (which I suppose was written for Bluetooth module HC-05) and AT commands that HC-06 module needs:

  1. BAUDERATE: HC-06 needs AT+BAUDx command (x value range is 1 to 8 so 1:1200bps .... 8:115200bps), the answer is OKy (y is the bauderate)
  2. NAME: HC-06 does not answer OKyourname but OKsetname in any case
  3. AT serial command end: HC-06 does not need both carriage return and line feed

Could you please confirm me what kind of bluetooth module was used for the project development? HC-05?

Thanks

MajicDesigns commented 4 years ago

As is in the header file for the project, the code would have been tested with all the nominated BT modules:

// Define the type of BT hardware being used. // Only one of these options is enabled at any time. // The HM-10 comes in two versions - JHHuaMao (HMSoft) version and Bolutek - AT command line ending differ.

define HW_USE_HC05 0

define HW_USE_HC06 1

define HW_USE_HM10_HMSOFT 0

define HW_USE_HM10_OTHER 0

As you have noticed, there are still more variations and this code should be seen as a starting point for your own 'version'. That is why the code to handle the BT initialisation is written in a generic way. Modify the setup styrings to use your particular format and you should be good to go.

FPVxfun commented 4 years ago

Yes, thanks, on my side I've selected HC-06.

However I have some doubts about HC-06 handling code, as I've written yesterday

Il ven 15 mag 2020, 23:26 Marco Colli notifications@github.com ha scritto:

As is in the header file for the project, the code would have been tested with all the nominated BT modules:

// Define the type of BT hardware being used. // Only one of these options is enabled at any time. // The HM-10 comes in two versions - JHHuaMao (HMSoft) version and Bolutek

  • AT command line ending differ.

    define HW_USE_HC05 0

    define HW_USE_HC06 1

    define HW_USE_HM10_HMSOFT 0

    define HW_USE_HM10_OTHER 0

As you have noticed, there are still more variations and this code should be seen as a starting point for your own 'version'. That is why the code to handle the BT initialisation is written in a generic way. Modify the setup styrings to use your particular format and you should be good to go.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MajicDesigns/Chroniker/issues/2#issuecomment-629497498, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJSRHMBDISUL2A7OOOGQA3RRWXRTANCNFSM4MYV6R6Q .