GM862 & Arduino

Hello, I’ve connected GM862 (on the Sparkfun USB evaluation) to the Arduino Decimila USB board. The plan is to control GM862 from Arduino. I can execute AT commands, e.g., send an SMS message, but I’m unable to read the response. For example, here is a simple example where I just send an AT command. I expect to get an OK response (according to the spec. with ATV0, I should expect .

#include <SoftwareSerial.h>

int rxPin = 7;

int txPin = 8;

SoftwareSerial modem = SoftwareSerial(rxPin, txPin);

void setup() {

pinMode(rxPin, INPUT);

pinMode(txPin, OUTPUT);

modem.begin(9600);

Serial.begin(9600);

modem.print(“ATV0\r\n”);

modem.print(“AT\r\n”);

delay(1000);

// read the 1st character of the response.

// I expect it a valid ASCII character

// but either the code is stuck on reading or

// immediately returns with 0

int response = modem.read();

Serial.println(response);

}

I can see the AT responses fine when I connect to the GM862 USB board directly via a Terminal program. But programatically, I cant get the responses. Any help would be much appreciated. Thank you.

I’m not sure which version of the Arduino IDE you are using, but there were many problem in the original SoftSerial library.

Try using the real serial lines while you are debugging. If that works (or if you cant using that for some reason) try AFSoftSerial or NewSoftSerial. You can find links & threads about those libraries on the main Arduino forum.

That should at least eliminate any problems in the library from the equation.

Two problems:

First your “print” statments need to have the actual carriage return (0x0D) and linefeed (0x0A) characters. Using “\r\n” doesn’t work this way and only sends these characters (literally). Optionally you can use “println”

So your code can become:

modem.print("ATV0");
modem.print(13);
modem.print(10);
modem.print("AT");
modem.print(13);
modem.print(10);

or this may work:

modem.println("ATV0");
modem.println("AT");

Second problem:

SoftwareSerial is non-interrupt based. This means you have to have to actively be listening for data when it arrives or else it’s lost. Your delay(1000) is making you lose the response.

Remove the delay entirely and you should get back some data. Note that the modem.read will “block” until some data comes back. This is another limitation of SoftwareSerial.

I second the comment about looking into NewSoftSerial.