Hi,
I am developing a project with Arduino Uno + 3G GPS([u]http://www.cooking-hacks.com/index.php/documentation/tutorials/arduino-3g-gprs-gsm-gps?utm_source=banner_3g_shield&utm_medium=banner[/u]) shield and the goal is to Receive GPS coordinates(Lat and Long) and send them to a server DataBase. The problem is that The Arduino will be on a car without a connection to a PC, just with a power supply. Ok..my question is if I use AT commands on the code and upload them, for example: Serial.println("AT+CGSOCKCONT=1,\"IP\",\"net2.vodafone.pt\"");
will the arduino execute them without a PC connected with the serial monitor opened?
I'm going to show an example of a code, I think it wont work without a PC connections because i use serial.println to use AT commands, and it only works with the serial monitor opened..
char http_data[1024];
int http_data_size;
int led = 13;
int onModulePin = 2; // the pin to switch on the module (without press on button)
char server[ ]="findismai.altervista.org";
char port[ ]="80";
void switchModule(){
digitalWrite(onModulePin,HIGH);
delay(2000);
digitalWrite(onModulePin,LOW);
}
void setup(){
Serial.begin(115200); // UART baud rate
delay(2000);
pinMode(led, OUTPUT);
pinMode(onModulePin, OUTPUT);
switchModule(); // switches the module ON
for (int i=3;i>0;i--){
Serial.print("Aguarde... ");
Serial.println(i);
delay(5000);
}
Serial.print("Aguarde... ");
Serial.println(0);
Serial.println("AT+CGSOCKCONT=1,\"IP\",\"net2.vodafone.pt\"");
Serial.flush();
while(Serial.read()!='K');
//FIXME on restart
}
void loop()
{
Serial.print("AT+CHTTPACT=\""); //Connects with the HTTP server
while(Serial.read()!='K');
Serial.print(server);
Serial.print("\",");
Serial.println(port);
Serial.flush();
int x=0;
do{
while(Serial.available()==0);
http_data[x]=Serial.read();
x++;
}while(!(http_data[x-1]=='T'&&http_data[x-2]=='S')); //waits for response "REQUEST"
Serial.println("GET http://findismai.altervista.org/insert.php?latitude=41.111111&longitude=-8.222222 HTTP/1.1");
Serial.println("Host: findismai.altervista.org");
Serial.println("Content-Length: 0");
//FIXME
Serial.write(0x0D);
Serial.write(0x0A);
Serial.write(0x0D);
Serial.write(0x0A);
Serial.write(0x1A); //sends ++
while(Serial.read()!='K');
while(Serial.read()!=' ');
do{
if(Serial.available()>0){ //using if to check if Serial.available() is bigger than 0, instead of while
http_data[x]=Serial.read();
x++;
}
}while(!(http_data[x-1]=='>'&&http_data[x-2]=='l'&&http_data[x-6]=='/')); //Program stops at first occurence of "/ l>"
Serial.println(http_data);
while(1);
}
Please help
Best regards
Pedro Celeste