Page 1 of 1

Sending AT commands through serial monitor

Posted: Fri Mar 03, 2017 2:05 pm
by Brown
I'm using the Arduino Uno board with Quectel M10 GPRS shield. I want to send AT commands through the serial monitor. I load the following code and send AT commands through the serial monitor. I dont see the AT command sent or response received on the serial monitor output window. Any help is appreciated..

/Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2,3);

void setup()
{
mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate
}

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

}

Re: Sending AT commands through serial monitor

Posted: Fri Mar 03, 2017 2:06 pm
by Junaid_Shahid
Brown wrote:
Fri Mar 03, 2017 2:05 pm
I'm using the Arduino Uno board with Quectel M10 GPRS shield. I want to send AT commands through the serial monitor. I load the following code and send AT commands through the serial monitor. I dont see the AT command sent or response received on the serial monitor output window. Any help is appreciated..

/Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2,3);

void setup()
{
mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate
}

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

}
I suggest you add a Serial.println() call in setup() so you can confirm that the USB serial connection is working correctly. I don't see anything wrong with the code, so I suggest you double check the connections to the modem and the serial settings. Have you check that the pins used for mySerial are the correct way round wrt the wiring connections? How do you know that the modem is using 19200 bps? If there's any possibility that it's starting off at another speed, or with different serial settings, try changing the mySerial setup to see if you can get a response from it.

Also, please correct the bogus comment in setup(). :)
Recommended:
HOW TO USE ARDUINO SERIAL MONITOR