Sending AT commands From Arduino to GPRS and feedback is garbage

Hello,

In this code to send AT commands to the GPRs through the Arduino, I receive garbage as confirmation at every different speeds.

I would like for instance to obtain OK when I type AT.
I am getting strange chararacters instead.

Is there a way please ?

Thank you

#include <SoftwareSerial.h>

SoftwareSerial mySerial(4,5);

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

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

}

Could we have a screen shot of the 'garbage'?

And less importantly, which device are you trying to communicate with?

Sure

AT at 57600 => �ª¡¨ôujRÿ

Arduino nano and Sim900A from ITEAD Studio

In this site, the guy receives clean text results http://www.simpasture.com/36023.html

I don't, even when I use strictly its code.

Try slowing both baud rates down to 9600, and at the risk of stating the obvious, don't forget to change the rate in the Serial Monitor window.

Yep

Getting a different garbage ;)

GPRS.begin(9600); Serial.begin(9600);

Serial Monitor at 9600

AT => )é

I have spent the last 24 hours playing with my toys without being successful. I start to wonder whether this SIM900A is compatible with my Arduino Nano, or shall I need special libraries...

I have written to ITEAD Studio but no answer yet.

Unfortunately I've got no experience of the Nano so I've run out of ideas!

Looks to me like your using software Serial and the two reads are interfereing with each other a problem associatted with the buffering that is common.

You need to use variable to receve the gsm reply look for the correct termination of the reply before printing on the console..

I would suggest something like..

char Buffer[246]; int fill ;

while (GSMPort.available()) { InC = (char)GSMPort.read(); /// create received Msgs if ( InC == '\x0a') // lokk st Line feed the last character in a reply from any GSM AT command { Buffer[fill] = '\x0'; /// terminate string Serial.print(Buffer); Buffer[0] = '\x0'; /// reset buffer fill = 0; } else { Buffer[fill] = Inc; fill++; }

}

Not an idea method but it does buffer reply until complete will demonstrate the idea..

Also suggest you send

ATE0 ... as first command to stop local echo reply to this is OK

The if you send AT command reply is only OK

If you don't stop local echo

The if you send AT command reply is AT carriage return line feed then OK.

tgsuperspec your code has lots of bad things! Your help is welcome but your code has some really bad things like:

int fill ;//You don't assign a initial value to fill so you cant trust it will be 0 because it will not be! Buffer[fill] = '\x0'; /// terminate string -> Even this is wrong the right way to terminate a string is '\0' Serial.print(Buffer); Buffer[0] = '\x0'; /// reset buffer fill = 0;

I have only been writing C / C ++ for > 30 years ...!!!!

So I will not even bother to point out your mistake in the answer ...