0

I am trying to use a hc-05 module for the first time and I have some problems: I already had a hard time finding the right pins for the rx and tx pin that g finally put on rx -> pin0 (rx) and tx -> pin 10. I can send data from the hc-05 to the phone but if I send from the phone to the hc-05 I get weird characters. Here is my code and the configuration. Thank you for your help. [configuration image][1]

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 0); // RX, TX

void setup() {
  Serial.begin(9600);
  pinMode(9,OUTPUT); digitalWrite(9,HIGH);
  Serial.println("Enter AT commands:");
  mySerial.begin(38400);
}

void loop()
{
  if (mySerial.available())  
  Serial.write(mySerial.read()); 
  
 
  if (Serial.available())  
  mySerial.write(Serial.read());
}```


  [1]: https://i.stack.imgur.com/BhED7.jpg
wabhou
  • 3
  • 4
  • don't use hardware Serial pins 0 and 1 for SoftwareSerial. with HC-05 RX to Uno RX you connected the HC-05 directly to the TX of USB chip of the Uno so the data go directly from the computer to the HC-05 skipping the ATmega – Juraj Sep 12 '21 at 13:34
  • thank you for your help but if i don t use the pin 0 I can't even send data from HC-05 to phone and nether from phone to HC_05 i received this in seriaal monitor : 19:41:41.219 -> ⸮x⸮⸮|⸮x⸮⸮⸮⸮x⸮x<⸮⸮x⸮⸮⸮⸮xx⸮x⸮x⸮x⸮x⸮⸮ – wabhou Sep 12 '21 at 17:45
  • use pins 10 and 11 and wire RX to TX (transmit to receive). 10 is RX and 11 is TX then – Juraj Sep 12 '21 at 18:50
  • thank you very much for your help but i didn't really understand what you say but i test and that change nothing. It's really weird thath a can send from HC-05 to phone but from phone to HC-05 i receive this again in serial monitor : 20:36:46.511 -> ⸮⸮⸮⸮xxx⸮xxx⸮xx⸮⸮⸮⸮x⸮⸮⸮⸮. Do you think that this could be linked to a faulty HC-05? – wabhou Sep 13 '21 at 18:40

1 Answers1

0

In fact it is enough just to put the baud rate of the HC-05 also to 9600.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
wabhou
  • 3
  • 4