3

I just connected an A6 GSM module and wrote a code to interact with it through the serial monitor connecting at 9600 baud rate. but the character "?" just keeps coming nonstop and nothing else works.

Here is my code:

#include<SoftwareSerial.h>

SoftwareSerial gprs(8, 9);

void setup(){
  gprs.begin(9600);
  Serial.begin(9600);
}

void loop(){
  while (gprs.available())
    Serial.write(gprs.read());

  while (Serial.available())
    gprs.write(Serial.read());
}

Serial monitor output

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Abraham
  • 12,140
  • 4
  • 56
  • 92
  • did you connect ground? – Juraj Dec 04 '20 at 12:21
  • @Juraj yes, both the arduino and the gsm grounds have been connected to the power grouond – Abraham Dec 04 '20 at 12:46
  • I vaguely seem to remember something about the A6 GSM module being set at the factory to 115200 baud. Not sure, but you could try that baud rate and see what happens. Also, did you cross the TX and RX wires? – ocrdu Dec 04 '20 at 19:15
  • 1
    @ocrdu Thank you, that was how it worked for me. – Abraham Dec 04 '20 at 20:42

1 Answers1

1

I later found you should connect it at 115200 baud rate, and if you want to change the baud rate, command it to do so while you are on default baud rate.

AT+IPR=9600   -- to change it
AT&W          -- to save the change

and lowering the baud rate is crucial if using software serial. (the second command should be sent after reconnecting at 9600, since the first command changes the baud rate)

Abraham
  • 12,140
  • 4
  • 56
  • 92