Reading AT command response from console window

Hello all,

We are using Arduino Uno board for our application. We have interfaced this board to an external GSM module via UART connection. With the help of Arduino board, we are sending AT commands to the GSM module and seeing the response in the console window.

I want to know how can we read the AT response from the console window.

we want to read the response and stores into the buffer, print the buffer data again on the console window.

Is there any special commands or codes are there to read the AT responses from Arduino console window?

Please respond on this problem.

Thank you

some terminal emulators such as Teraterm Pro and realterm have facilities for logging received data
an alternative is to write your own application, e.g. using Visual Studio C#, C++ or VB with the SerialPort component or java with the jSerialComm library

Do you want the arduino to read it again from the console window?

If so, you can't. But you can store the response in the Arduino in a suitable buffer with sufficient size. Next you can use the content of the buffer.

You have the program that prints the commands to the console window.
So change this programm to store the interesting parts to your variables/buffers.

There are many tutorials to handle serial input,
but collecting characters in a buffer until cr/lf is read without chance of writing outside the buffer
is all what it takes, and that's a nice small programming exercise.

There is no need to read back the console window.

If you can not change the Arduino code (because it was lost, it's not your Arduino, ...),
@horace gave good advice for that road.

Thanks to all of you for your quick responses.


How can I store the response in the buffer and use it back?

Do you have any simple example code which I can refer and implement in my code?


Please share some of the tutorials for handling serial input with me, those I will refer and implement same in my code.

Thank you

Please share some of the tutorials for handling serial input with me, those I will refer and implement same in my code.

You do understand the word exercise?

It is something you do to learn/practice something.

Because it is a recurring problem, I use a class to handle serial input.

#include <WhandallSerial.h>  //

// simple handler just checks the start of line for "AT "

void processLine(const char* buf) {
  if (!strncmp_P(buf, PSTR("AT "), 3)) { // PSTR is similar to F, but gives a char*
    Serial.print(F("AT: "));

SSerial console(Serial, processLine); // used serial and handler

void setup() {
  console.begin(64); // buffer size

void loop() {
  console.loop();    // collect chars and call handler for each line

You can read serial input basics to understand serial communication and get ideas how to read serial data. Or you can rely on Whandall's library and code.

Or you can rely on Whandall's library and code.

It can handle Nextion data too (triple 0xff delimiter and embedded 0x00), so it's worth a look anyway.
It even comes with doxygen mini documentation. :wink:

I like to have the line processing in a function, that way loop gets less complex.
And the buffer mechanism knows exactly when it's save to reuse the buffer.