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());
}
asked Nov 19, 2019 at 14:59

2 Answers 2

2

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 :)

answered Nov 19, 2019 at 20:20
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).

answered Nov 19, 2019 at 16:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.