Guten Tag miteinander,
im Rahmen einer Projektarbeit an unserer Hochschule im Studiengang Gartenbau, möchten wir gerne die Position eines sich bewegendem Obejektes bestimmen und im Browser darstellen.
Dazu haben wir bisher einen Arduino UNO und das zugehörige GSM/GPRS/GPS-Shield der Firma Antrax gekauft. In den Beispielpogrammen der Herstellerfirma, war auch schon ein Code, der unseren Anforderungen sehr nahe kommt.
Dabei handelt es sich um das Beispiel "gsm_gprs_gps_httpget".
Der Code ermöglicht die Bestimmung eines Standortes welcher dann nach einem Knopfdruck an einen Server übermittelt wird. Das funktioniert bisher wunderbar.
Leider ist es uns bis jetzt nicht gelungen, den Arduino so einzurichten, dass er ununterbrochen (zb. alle 60 Sekunden) seine Position bestimmt und an den Server übermittelt und kein Knopfdruck notwendig ist.
Bisher haben wir die "if-Abfrage", in der Überprüft wird ob der Taster1 gedrückt wurde einfach herauskommentiert, woraufhin auch eine Position, ohne Tasterdruck, übermittelt wurde. Wenn dann aber der Vorgang neu Initialisiert wird, bricht der Vorgang bei der GSM-Einwahl ab. Wir haben die Ausgabe des seriellen Monitors mit in den Anhang kopiert.
Wir haben im Anschluss unterschiedliche Möglichkeiten probiert, zB. die Implementierung von Watchdog am Ende des Sketches, so das der Arduino neu bootet und erneut die Position übermittelt, was aber nicht zu dem von uns erhofften Ergebnis geführt hat.
Da wir nur über geringe Programmierkenntnisse verfügen, hoffen wir, dass uns hier jemand helfen kann.
Es geht auch nur um die Wiederholung. Der Rest, zB. der Verarbeitung der Daten auf dem Server, oder der Darstellung im Browser ist uns schon gelungen.
Mit freundlichen Grüßen,
Stonl
/*
gsm_gprs_gps_httpget.ino - Example to send a HTTP GET to an internet server
Version: 2.0
Date: 09.05.2014
Company: antrax Datentechnik GmbH
Use with: Arduino UNO (ATmega328) & Arduino Duemilanove (ATmega328)
EXAMPLE:
This code will try to send a HTTP GET which contents gps coordinates to the antrax test loop server.
We only use basic AT sequences (with the library), for detailed information please see the "Telit_AT_Commands_Reference_Guide_rxx.pdf"
(Telit internal document no. 80000ST10025a) and "Telit_Modules_Software_User_Guide_rxx.pdf" (Telit internal document no. 1vv0300784)
WARNING: Incorrect or inappropriate programming of the mobile module can lead to increased fees!
*/
#include <gsm_gprs_gps.h>
#include <SPI.h>
void setup()
{
// GSM
GSM.begin();
// Serial.println("init GSM/GPRS/GPS-Shield!");
// GPS initialization
if(GPS.initializeGPS())
Serial.println("Initialization completed");
else
Serial.println("Initialization can't completed");
delay(1000);
}
void loop()
{
int result;
int i,j;
char httpget_str[100] = "";
char filtered_gps_coordinates[50] = "";
//---------------------------------------------------------------------------------------------------------------
// let's register in the GSM network with the correct SIM pin!
// ATTENTION: you MUST set your own SIM pin!
result = GSM.initialize("1357");
if(result == 0) // => everything ok?
{
Serial.print ("ME Init error: >"); // => no! Error during GSM initialising
Serial.print (GSM.GSM_string); // here is the explanation
Serial.println("<");
while(1);
}
//---------------------------------------------------------------------------------------------------------------
// let's wait for a valid gps signal. You can see when the led flashs slowly (1 time in a second) that there is
// a valid gps signal.
// When you push the button "s1" you will send the current coordinates to the "antrax Test Loop Server"
while(1)
{
GPS.getGPS(); // get the current gps coordinates
//Serial.print(GPS.coordinates); // show the current gps coordinates
// GPS-LED
if(GPS.coordinates[0] == 'n') // valid gps signal yet?
{
delay(20); // => no!... wait
GPS.setLED(1);
delay(20);
GPS.setLED(0);
delay(20);
GPS.setLED(1);
delay(20);
GPS.setLED(0);
}
else
{
delay(300); // => yes!... push the button
GPS.setLED(1);
delay(500);
GPS.setLED(0);
}
//if(!GPS.checkS1()) // did you push the button?
{
//---------------------------------------------------------------------------------------------------------------
// connect to GPRS with the correct APN (server, access, password) of your provider
// ATTENTION: you MUST set your own access parameters!
result = GSM.connectGPRS("public4.m2minternet.com","egal","egal"); // provider "ASPIDER" (with a SIM chip)
// result = GSM.connectGPRS("internet.t-mobile.de","t-mobile","whatever");// example for T-Mobile, Germany
// result = GSM.connectGPRS("gprs.vodafone.de","whatever","whatever"); // example for Vodafone, Germany
// result = GSM.connectGPRS("internet.eplus.de","eplus","whatever"); // example for e-plus, Germany
// result = GSM.connectGPRS("internet","whatever","gprs"); // example for O2, Germany
if(result == 0) // => everything ok?
{
Serial.print ("GPRS Init error: >"); // => no! Error during GPRS initialising
Serial.print (GSM.GSM_string); // here is the explanation
Serial.println("<");
while(1);
}
//---------------------------------------------------------------------------------------------------------------
// send the following HTTP GET: http://www.antrax.de/WebServices/responder.php?data=52+06.4720N,08+39.7816E
// this is a HTTP GET to the "antrax Test Loop Server" and you can look for the result
// under http://www.antrax.de/WebServices/responderlist.html
// The parameter are the GPS coordinates
// replace all spaces with '+' character in the GPS coordinates (this is necessary for spaces in an url)
memset((void *)filtered_gps_coordinates, 0, sizeof(filtered_gps_coordinates));
j = 0;
for(i = 0; i < strlen(GPS.coordinates); i++)
{
if(GPS.coordinates[i] == ' ')
{
filtered_gps_coordinates[j++] = '+';
}
else
{
filtered_gps_coordinates[j++] = GPS.coordinates[i];
}
}
// build http-get string
sprintf(httpget_str, "%s%s%s", "GET /WebServices/responder.php?data=", filtered_gps_coordinates, " HTTP/1.1");
// send the http-get string
result = GSM.sendHTTPGET("www.antrax.de", httpget_str);
if(result == 0) // => everything ok
{
Serial.print ("HTTP GET error: >"); // => no! Error during data sending
Serial.print (GSM.GSM_string); // here is the explanation
Serial.println("<");
while(1);
}
Serial.println("HTTP GET successfully ..."); // => yes!
Serial.println(GSM.GSM_string); // here is the answer of the web server
while(1); // END OF DEMO
}
}
}
Ausgabe des Seriellen Monitors
Initialization completed
AT
AT+IPR=9600
ATE0
AT#SELINT=2
AT#SIMDET=1
AT#QSS=0
AT+CMEE=2
AT+CPIN?
AT+CPIN=3232
AT&K0
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CREG?
AT+CGATT?
AT+CGDCONT=1,"IP","internet.t-mobile.de"
AT#USERID="t-mobile"
AT#PASSW="whatever"
AT#SGACT=1,1
AT#SD=1,0,80,"www.gemini-project.de",0
GET XXXXXX-xXXXXxximport?daten=no+valid+gps+signal HTTP/1.1
Host: www.XXxxxxxX-XXX.de
User-Agent: antrax
Connection: close
Initialization completed
AT
AT+IPR=9600
ATE0
ME Init error: ><