1

I am currently trying to send my sensor data from my Arduino to an android app made on android studio using an HC05 module for Arduino.

I tried to configure the HC05 as every tutorial on the internet says, but i meet some problems.

I am using the arduino code:

 #include <SoftwareSerial.h>

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

int PotPin = A7;
int Vdata = 15;

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

void loop()
{
  Vdata = analogRead(PotPin);
  if (mySerial.available())  
  Serial.write(mySerial.read());
  
  if (Serial.available())  
  mySerial.write(Serial.read()); 


}

When I type "AT" in the Serial monitor, it returns me "OK" (that is normal).

But when I try to see the name/the address/the password of the module, it returns me "Error:(0)". The strangest thing is that the command " AT+NAME="NameWanted" " or even " "AT+PWD="4321" " works since it correctly changes the name of the module.

I looked on the internet but I didn't see someone with the same problem as mine, I hope someone will lead me to the solution!

Thanks

Romain
  • 13
  • 3
  • Maybe CR/LF issue, check out here https://robotics.stackexchange.com/questions/2056/bluetooth-module-hc-05-giving-error-0 – Nino Jul 08 '21 at 21:34
  • On your serial monitor, select `BOTH NL & CR` and send `AT+NAME?`. According to this [document](https://s3-sa-east-1.amazonaws.com/robocore-lojavirtual/709/HC-05_ATCommandSet.pdf) you need to send CR (\r) and NL (\n). This will automatically add these and send `AT+NAME?\r\n` as required – Mr. Panda Jul 10 '21 at 10:53
  • Thank you for your responses. I finally figured out what was wrong: me. I never saw that a "?" is requiered at the end of an AT command.. – Romain Jul 15 '21 at 19:30

1 Answers1

0

I found out what's the problem. My mcu's bauderate was bigger (115200), then my hc05's bauderate (38400). With this bauderate, my MCU sent the messages faster, then hc05 could read it. So, I decreased the bauderate of my MCU and now it's working

cigien
  • 57,834
  • 11
  • 73
  • 112
Daniel Pal
  • 21
  • 5
  • I found out what's the problem. My mcu's bauderate was bigger (115200), then my hc05's bauderate (38400). With this bauderate, my MCU sent the messages faster, then hc05 could read it. So, I decreased the bauderate of my MCU and now it's working. – Daniel Pal Dec 27 '21 at 23:59
  • Please add the solution to the answer itself. Currently, your answer is not a valid answer, since it doesn't provide a solution, and is liable to be deleted. – cigien Dec 28 '21 at 02:31
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/30685446) – Sercan Dec 28 '21 at 07:30