0

I have an issue with the communication between my Serial Monitor and my BT HC06 Module. Iam able to send ascii characters from my phone with BT connection to my local serial monitor. When i send characters from my local serial monitor to my BT module i receive something like this: AT -> U or 3 -> 3

I have this issue since i changed the baud from 9600,0,0 to 9600,0,1

Code:

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup()
{
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(9600);  // HC-05 default speed in AT command more
}

void loop()
{

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());
}
1

If I understand you right: You changed the UART settings on the HC05 module and now you are unable to connect to the HC-06.

You use SoftwareSerial for the connection as on an UNO you have only one HardwareSerial port. SoftwareSerial only allows to configure the baud rate. There are work arounds https://forum.arduino.cc/index.php?topic=251764 , but you can also write a little sketch that reconfigure your HC06 UART to 9600,0,0 using the HardwareSerial which can be setup to the new parity settings to connect to the HC-06.

Something like this

void setup() 
{
  //Serial.begin( 9600, SERIAL_8O1 );
  Serial.begin( 9600, SERIAL_8E1 );

  // I do not setup to 9600,0,0 but to 9600,1,0
  // Because the Arduino use the stop bit set by default.
  Serial.println( "AT+UART=9600,1,0" );
}

void loop() {}

I can not try this program, so it's only an example on hoew to reset your HC-05.

Of cause; before you upload the sketch, you have to connect to HC-05 to the Hardware serial pins (0,1).

1

Sorry, my question was not easy to understand. Your solution had not worked for me. I found another libary where its possible to add the parity bit: https://github.com/ledongthuc/CustomSoftwareSerial

This works fine for me.

Thanks for your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.