I am attempting to use the Antrax GSM/GPRS shield (w/o GPS) to receive SMS. Other than the initialization code giving on the website ( http://www.antrax.de/downloads/arduino-gsm-gprs-gps-shield-manual_rev.6_en.pdf), i can find no information on the device. I have no idea what libraries work with it and have found no community that supports it like hw kitchen for instance.
Upon asking the manufacturer on this matter, they sent me links to Telit GE865 data sheets and AT command lists. I know what type of AT commands the module uses, and which ones i need to use, but have no idea how to implement this into the Arduino IDE or how to communicate with the board as a whole.
Obviously not. It looks more like a library than a sketch, and judging by the comment at the start of the file, it's a header file named GSM_GPS_Shield_Mega.h which contains the declarations for a GSM library.
Assuming you have the rest of the library too, what you're missing is one or more example sketches demonstrating how to use it. The manufacturers site says it provides the library and examples so presumably they're around there somewhere.
Yeah there is an example code given, i am not sure where to implement it though.
GSM gsm(7,9600); // (power_pin, baudrate)
GPS gps(9600); // (baudrate)
void setup()
{
if(gps.initializeGPS())
Serial.println("Initialization completed");
else
Serial.println("Initialization can't completed");
}
void loop()
{
delay(300);
gps.setLED(1);
delay(500);
gps.setLED(0);
if(!gps.checkS1())
{
gsm.initializeGSM("1234"); // Enter your SIM-Pin if it's required (Example: "1234") --> the quote signs are important
delay(200);
gsm.makeCall("0176123456789"); // Enter the Destination-Phone-Number (Example: "0176123456789" or "+49176123456789") --> the quote signs are important
}
if(!gps.checkS2())
{
gsm.initializeGSM("1234"); // Enter your SIM-Pin if it's required (Example: "1234") --> the quote signs are important
delay(200);
gsm.sendSMS("0176123456789","Hello World"); // Enter the Destination-Phone-Number (Example: "0176123456789" or "+49176123456789") --> the quote signs are important
}
}
It's time you learned to organize your code properly. Class definitions go in a .h file. Class implementations go in a .cpp file. Class definitions and class implementations do not go in the sketch (.ino file).
You can post code properly, using the Additional Options... link when the file size exceeds the post limit.
A peek at the strcat() function would help shorten your code. A proper understanding of C strings would help, too. A C string is a NULL terminated array of characters. That is ONE null. Not one in every array position. Clearing the coordinates array is simple:
coordinates[0] = '\0';
There is no reason to stuff a NULL in every position in the array.
weestee: Errors read: 621: redefinition of 'GSM gsm'
101: 'GSM gsm' previously declared here
Using_GSM_and_GPS:20: redefinition of 'GSM gsm'
622: 'GPS gps' previously delcared here
The variable named gsm of type GSM is declared in two places. You should have at least suspected this from the wording of the error message, and a search for that variable name would have confirmed your suspicion immediately.
Suggest you fix the initial problem before you worry about what the subsequent errors mean.
I then went into source file and based the code of the sendSMS function, but altering the AT commands to have AT+CMGL=ALL, which is an execution command that reports the list of all messages with a certain status value, stored at a certain position in the SIM card memory.
After creating receiveSMS i added it to the example code and uploaded it to the arduino,as shown below. It uploaded successfully.
GSM gsm(7,9600); // (power_pin, baudrate)
GPS gps(9600); // (baudrate)
void setup()
{
if(gps.initializeGPS())
Serial.println("Initialization completed");
else
Serial.println("Initialization can't completed");
}
void loop()
{
delay(300);
gps.setLED(1);
delay(500);
gps.setLED(0);
if(!gps.checkS1())
{
gsm.initializeGSM("1234");
delay(200);
gsm.receiveSMS("075xxxxxxxx","GSM/GPRS/GPS-Shield");
}
if(!gps.checkS2())
{
gsm.initializeGSM("1234"); // Enter your SIM-Pin if it's required (Example: "1234") --> the quote signs are important
delay(200);
gsm.sendSMS("07535267131","Hello World");
}
}
however on the serial monitor, the response i got was "Initialization completed". then i press switch 1 on shield then i get "ATATE0AT+IPR=9600AT#SIMDET=1AT+CPIN?AT+CREG?AT+CREG?AT+CMGF=1AT=AT+CMGL=ALL07xxxxxxxxx,129".
Now as far as i understand AT+CPIN? is asking for the SIM pin, which during the initialization period it obtains (atleast thats the way it looks in the source library). Additionally AT+CREG? is asking for network connectivity and again, during the initialization this connection was meant to have occured. I will repost the initialization code below.
So confused by this i update the recieveSMS to clarify the answer to these commands. Yet when i re-upload with addition AT commands in it, i get a similar response on the serial monitor.
You are using way too many variables with vague names like state. You are using way to many global variables. You are using way too few comments.
I hate do/while statements. They are rarely the correct construct. Checking the condition (and having it at the top) is far more often the correct construct.
Using an enum for state, and giving the states names makes it a lot easier to understand what your code is supposed to do, and to see if it is actually doing what it is supposed to do.
Of course, I suspect that the problem is that you are sending commands and getting responses, but the response is not associated with the command, since serial communication is asynchronous.