Hi,
I am using an Arduino Uno with the official GSM shield. I am trying to execute the AT commands instead of using the GSM library.
The below codes I got it from one of the post in the forum here as a reference,
http://forum.arduino.cc/index.php?topic=219677.0
#include <SoftwareSerial.h>
SoftwareSerial gsmSerial(2, 3); //Rx Tx
char inChar = 0;
//RESET the modem
void reset() {
Serial.println("Start Reset");
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
delay(12000);
digitalWrite(7, LOW);
delay(1000);
Serial.println("End Reset");
}
void setup() {
Serial.begin(115200);
Serial.println("Setting up!");
reset();
gsmSerial.begin(9600);
Serial.println("Enter your AT commands (with CR & NL)..");
}
void loop() {
if(gsmSerial.available()) {
delay(1);
inChar = gsmSerial.read();
if((inChar >= ' ') && (inChar<='z'))
Serial.print(inChar);
else {
Serial.print(inChar);
if(inChar == 10)
Serial.println();
}
}
if(Serial.available()) {
inChar = Serial.read();
gsmSerial.print(inChar);
}
}
Ok, so when I enter "AT", I get the "OK" reply.
When I enter "ATI", I also get the product revision number.
However, when I call any of the "AT+XXXX" commands, I get this kind of reply,
AT+
+CME ERROR: 100
So, I thought it maybe because of this
if(Serial.available()) {
inChar = Serial.read();
gsmSerial.print(inChar);
}
So, I modified the code above so that I store it in a String first before executing it. But it did not work. Then, I modified the codes as shown below:
#include <SoftwareSerial.h>
#include <string.h>
SoftwareSerial gsmSerial(2, 3); //Rx Tx
char inChar = 0;
//RESET the modem
void reset() {
Serial.println("Start Reset");
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
delay(12000);
digitalWrite(7, LOW);
delay(1000);
Serial.println("End Reset");
}
void setup() {
Serial.begin(115200);
Serial.println("Setting up!");
reset();
gsmSerial.begin(9600);
Serial.println("Enter your AT commands (with CR & NL)..");
//gsmSerial.write("AT\r\n"); //work
//delay(1);
//gsmSerial.write("ATI\r\n"); //product revision
//delay(1);
gsmSerial.write("AT+GSN\r\n"); //no reply at all!!
//delay(1);
//gsmSerial.flush();
Serial.println("after command");
}
void loop() {
if(gsmSerial.available()) {
delay(1);
inChar = gsmSerial.read();
if((inChar >= ' ') && (inChar<='z'))
Serial.print(inChar);
else {
Serial.print(inChar);
if(inChar == 10)
Serial.println();
}
}
if(Serial.available()) {
inChar = Serial.read();
gsmSerial.print(inChar);
}
}
So, yeah, as you can see, I sent this gsmSerial.write("AT+GSN\r\n");
but I do not get any reply at all.
I am trying to execute the commands below and see what are the replies.
/*
* AT+GSN - get IMEI, 100 error
* AT+CGSN - product serial number, 100 error
* AT+CPAS - Mobile equipment activity statys
* AT+CMGS - Send SMS
* AT+CGATT - Attach GPRS
* AT+CGREG - Network registration status
* AT+CGSMS - Select server for MO SMS messages
* AT+QPOWD - Power off
* AT+QSIMSTAT - SIM inserted status reporting
* AT+QSIMDET - Switch on or off detecting SIM card
* AT+QGID - Get SIM card group identifier
* AT+QGPCLASS - Change GPRS multi-slot class
* AT+QMGHEX - Enable to send non-ascii characters SMS
* AT+QSMSCODE - Configure SMS code mode
* AT+QSCANF - Scan power of GSM frequency
* AT+QINISTAT - Query state of initialization
* AT+QNSTATUS - Query GSM network status
* Commands for TCIPIP application toolkit
* AT+QIOPEN - Startup TCP or UDP
* AT+QISEND - Send data through TCP / UDP
*
*/
Kindly advice me on what might I have been missing.
Thank you in advice.