Bonjour,
Je cherche à connaître ma position via le module 3G/GPRS de chez Cooking-Hacks mais impossible...
Sur le sites des codes sont tout fait mais chez moi ça ne marche pas et même avec de petites modifications...
Le matériel utilisé comporte une arduino mega 2560 R3 + le module 3G/GPRS + une batteries 11v + une SIM free...
La connexion ce fait soit en stand Alone soit en A-GPS (Assisté)...
Voir http://nokia-generation.my-goo.net/t154-faq-a-gps-comment-ca-marche
http://pro.01net.com/editorial/319809/le-systeme-a-gps-ou-gps-assiste/
Si je suis en A-GPS je dois interroger un serveur pour connaître les satellites et les interroger..
Apparemment j'interroge bien les satellites mais les données renvoyé sont vides....Pourquoi ?
Si je suis en Stand Alone je recherche des satellites via les ondes puis je les interroges...
La aussi j'interroge bien les satellites mais les données renvoyé sont vides...
Code Stand Alone
int led = 13;
int onModulePin = 2; // the pin to switch on the module (without press on button)
char data[255];
char latitude[11],longitude[12];
char date[6],UTC_time[8];
char speed_OG[6],altitude[6];
int x,y;
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=0;i< 5;i++){
delay(5000);
}
Serial.println("AT+CGPS=1,1"); // starts GPS session in stand-alone mode
delay(100);
}
void loop(){
delay(5000);
Serial.println("AT+CGPSINFO"); // request GPS info
Serial.flush();
x=0;
do{
do{
digitalWrite(led,HIGH);
}
while(Serial.available()==0);
digitalWrite(led,LOW);
data[x]=Serial.read();
Serial.println(data[x]);
x++;
}
while(Serial.read()!='K');
x=24;
y=0;
if(data[x]!=','){
Serial.print("Latitude: "); //shows actual latitude
do{
latitude[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
x++;
Serial.print(" ");
Serial.println(data[x]); //north or south
x+=2;
y=0;
Serial.print("Longitude: "); //shows actual longitude
do{
longitude[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
x++;
Serial.print(" ");
Serial.println(data[x]); //west or east
x+=2;
y=0;
Serial.print("Date: "); //shows date
do{
date[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
x++;
y=0;
Serial.print("\r\nUTC time: "); //shows UTC time
do{
UTC_time[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
x++;
y=0;
Serial.print("\r\nAltitude: "); //shows altitude
do{
UTC_time[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
Serial.println(" m");
x++;
y=0;
Serial.print("Speed: "); //shows speed
do{
speed_OG[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=0x0D);
Serial.println(" knots");
}
else{
Serial.println("GPS information not available, please wait...");
}
}
Réponse
AT+CGPS=1,1
AT+CGPSINFO --> +CGPSINFO:,,,,,,,,
Latitude: FO +CGPSINFO: ,
Longitude: , ,
Date: ,O AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.....
Code A-GPS
int led = 13;
int onModulePin = 2; // the pin to switch on the module (without press on button)
char data[255];
char response[255];
char latitude[11],longitude[12];
char date[6],UTC_time[8];
char speed_OG[6],altitude[6];
int x,y;
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=0;i< 5;i++){
delay(5000);
}
Serial.println("AT+CGSOCKCONT=1,\"IP\",\"free\"");
Serial.flush();
x=0;
do{
while(Serial.available()==0);
response[x]=Serial.read();
Serial.println(response[x]);
x++;
}
while(!(response[x-1]=='K'&&response[x-2]=='O'));
Serial.println("AT+CGPSURL=\"agpss.orange.fr:7275\""); // sets GPS server
delay(100);
while(Serial.read()!='K');
Serial.println("AT+CGPSSSL=0"); // without certificate
delay(100);
while(Serial.read()!='K');
Serial.println("AT+CGPS=1,3"); // starts GPS session in Assisted mode
delay(100);
while(Serial.read()!='K');
}
void loop(){
delay(5000);
Serial.println("AT+CGPSINFO"); // request GPS info
Serial.flush();
for (x=0;x< 255;x++){
data[x]='\0';
}
x=0;
do{
do{
digitalWrite(led,HIGH);
}
while(Serial.available()==0);
digitalWrite(led,LOW);
data[x]=Serial.read();
Serial.println(data[x]);
x++;
}
while(Serial.read()!='K');
x=24;
y=0;
if(data[x]!=','){
Serial.print("Latitude: "); //shows actual latitude
do{
latitude[y]=data[x];
Serial.print(data[x]);
y++;
x++;
if(y==2){
Serial.print(0xF8);
}
if(y==4){
Serial.print(".");
}
}
while(data[x]!=',');
x++;
Serial.print(" ");
Serial.println(data[x]); //north or south
x+=2;
y=0;
Serial.print("Longitude: "); //shows actual longitude
do{
longitude[y]=data[x];
Serial.print(data[x]);
y++;
x++;
if(y==3){
Serial.print(0xF8);
}
if(y==5){
Serial.print(".");
}
}
while(data[x]!=',');
x++;
Serial.print(" ");
Serial.println(data[x]); //west or east
x+=2;
y=0;
Serial.print("Date: "); //shows date
do{
date[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
x++;
y=0;
Serial.print("\r\nUTC time: "); //shows UTC time
do{
UTC_time[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
x++;
y=0;
Serial.print("\r\nAltitude: "); //shows altitude
do{
UTC_time[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=',');
Serial.println(" m");
x++;
y=0;
Serial.print("Speed: "); //shows speed
do{
speed_OG[y]=data[x];
Serial.print(data[x]);
y++;
x++;
}
while(data[x]!=0x0D);
Serial.println(" knots");
}
else{
Serial.println("GPS information not available, please wait...");
}
}
Réponse
AT+CGSOCKCONT=1,"IP","free" --> OK
AT+CGPSURL="agpss.orange.fr:7275"
AT+CGPSSSL=0
AT+CGPS=1,3
AT+CGPSINFO --> CGPSINFO:,,,,,,,,,
Latitude: : ,
Longitude: , ,
Date: ,O AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.....