[SOLVED] SIM900 Receive AT command but don't work

Hello,

I use Arduino Mega 2560 Rev3 and a SIM900 from Sainsmart (link), so when i send AT commands with this simple code :

void setup()
{
 Serial1.begin(9600);               // the GPRS baud rate   
 Serial.begin(9600);                 // the GPRS baud rate   
}

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

}

Thats works, i receive some response from the SIM900 but there are some problems, more details :

The SIM900 is connected to RX1 and TX1. The TX to the RX of the Arduino, and same for the RX -> TX.

Finally, SIM900 works when i send "AT", "AT+CPIN=1234"...

but when i send "AT+CGREG?" i receive "+CGREG= 0,0". I see CGREG must be at "0,2" There is a log :

AT

OK
AT+CPIN=1234

OK
ÿ
RDY // what is that ??

+CFUN: 1

+CPIN: SIM PIN
AT+CGREG?

+CGREG: 0,0

OK

So i don't understand, for sure i have a sim card into the SIM900 :)

Thanks for some response to this bug D:

WORKS !

New alimentation 5v 2A with a new antenna, and a fully functional code for send a SMS :

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

void sendSMS() { sendAT("AT"); delay(1000); sendAT("AT+CPIN=1234"); delay(5000); sendAT("AT+CGREG?"); sendAT("AT+IFC=1,1"); sendAT("AT+CMGF=1"); sendAT("AT+CLIP=1"); sendAT("ATE0"); sendAT("AT+COLP=1"); sendAT("AT+CMGS=\"0650398386\""); sendAT("Hello from MEGA !"); sendCTR(); }

void sendAT(String cmd) { Serial1.println(cmd); delay(500); readSerial(); }

void sendCTR() { Serial1.println((char)26); delay(3000); readSerial(); }

void readSerial() { while(Serial1.available()){ Serial.write(Serial1.read()); } }

void loop() { sendSMS(); do {} while (1); }

Good luck if u have the same problem :D