Hi,
I´m using the same shield and I never would by one again, before I had looked for a well designed library.
In the flyer everything sounds well and easy but, all in all it is a fake in my eyes. It takes most of my Uno pins, and is using spi and serial, so normally one has to use a Mega to work with the board.
My target was to build a batterie-guard, sending me a SMS when the temperatur is lower than 3°C and the voltage is lower than 11.5V for example) additionaly when I call the shield with some keywords in a SMS it should send me the gathered data.
It took hours with testing and reading reading and testing, and I´m not ready yet.
The following code will ask for the time and will list some SMS from the SIM card.
I have to work on it - because I cannot understand why this ff... shield is sendig different results when
using
Serial.p r i n t (char(incomingbyte))
instead of
Serial.p r i n t l n (char(incomingbyte));
Because I am not a coder it is really hard for me, to code that.
Maybe you are more successfull. Would be nice to have a hint.
I think it is important to know about the length of buffer size of the shield, but I havent found any hint to that..
after some testst I used 140 to see any results at all.
Additionally I used some delays, because I think the shield needs some time , but its just a rough work, not well formatted and only for testing.
Try it and you will see, maybe it is helpfull for you.
Good luck
OnkelHotte
#include "Arduino.h"
#include <GSM_GPS_Shield.h>
#include <SPI.h>
GSM gsm(7,9600); // (power_pin, baudrate)
GPS gps(9600); // (baudrate)
void setup()
{
if(gps.initializeGPS())
Serial.println("Initialisierung erfolgreich");
else
Serial.println("Initialisierung fehlgeschlagen(warum auch immer)");
}
void loop()
{
gps.getGPS(); //GPS-Koordinaten abrufen
Serial.print(gps.coordinates); //und ausgeben
if(gps.coordinates[0] == 'n') // GPS-Fix da ??
{ Blink_GPS_NOK(); } //hektisch blinken
else
{ Blink_GPS_OK(); } //entspannt blinken
//------------------------------------------------------------
//----- Tel anrufen ---
//------------------------------------------------------------
if(!gps.checkS1()) //linker Taster unter der GPS-Antenne
{
gsm.initializeGSM("5555");
delay(200);
gsm.makeCall("055276648"); //funzt einwandfrei
}
//------------------------------------------------------------
//----- SMS Senden ---
//------------------------------------------------------------
if(!gps.checkS2()) // rechter Taster unter der GPS-Antenne
{
gsm.initializeGSM("5552");
delay(200);
// gsm.sendSMS("01713542267",gps.coordinates);
/* read_Puffer();
Serial.println("AT+CGMR\r"); //Ausgabe der Software-Version des Boardsnummer des Boards
read_Puffer();delay(200);
Serial.println("AT+CGMM\r"); //Ausgabe der Telit-Modul-Info
read_Puffer();delay(200);
Serial.println("AT+CMEE=2"); //Fehlermeldungen in ausführlichem Schriftformat
read_Puffer();delay(200);
Serial.print("AT+CMGF=1"); // SMS in Text Modus
read.Puffer();delay(200);
Serial.println("AT+CMGR=1\r"); //Lies SMS an Index Nummer 1
read_Puffer();delay(200);
*/
Serial.println("AT+CCLK?");delay(50); //Uhrzeit und Datum ausgeben (nicht bei allen providern--> funktioniert prima!)
read_Puffer();delay(500); //funktiniert einwandfrei
Serial.println("AT+CMGL=\"ALL\"\r"); //Liste alle SMS auf
delay(50);read_Puffer();delay(200);
/*
Serial.println("AT+CPMS?\r");
read_Puffer();
Serial.println("AT+IPR?"); // Abfrage der baudrate -->
read_Puffer();
*/
}
}
//------------------------------------------------------------
//----- GSM-Board-Puffer Behandlung ---
//------------------------------------------------------------
void read_Puffer() //auslesen der länge des GSM-SMS-Puffers
{
int incomingbyte = 0; //Variablenname
//Serial.flush(); //seriellen Puffer komplett leeren hat bei jedem Aufruf zwei Zeichen gelöscht
for (int i = 0; i < 140; i++) //140 Stellen des Puffers einlesen
// while (Serial.available() > 0 )
{
incomingbyte=Serial.read(); //Variable aus Serieller Schnittstelle einlesen
//Serial.print(" --> ");
Serial.println(char(incomingbyte)); // und ausgeben ..
}
}
//------------------------------------------------------------
//----- Blinker für GPS ---
//------------------------------------------------------------
void Blink_GPS_OK() //Ja, Koordinaten sind da ... entspannt blinken
{
delay(300); gps.setLED(1);
delay(500); gps.setLED(0);
}
void Blink_GPS_NOK() // Nein, Koordinaten nicht da, hektisch blinken ..
{
delay(20); gps.setLED(1);
delay(20); gps.setLED(0);
delay(20); gps.setLED(1);
delay(20); gps.setLED(0);
delay(250);
}