Bonjour,
Dans le cadre d'un projet j'utilise un module GRPS (de Seedstudio) et un GPS (PMB-648).
Je rencontre un problème lorsque j'utilise les deux en même temps.
Sans GPS, le GRPS m'envoie "test", avec GPS, il m'envoie les coordonnées alors que je lui ai jamais demandé.
Voici le code principal.
SoftwareSerial mySerial(7, 8);
TinyGPS gps;
SoftwareSerial nss(6, 255);
void setup()
{
delay(1000);
Serial.begin(19200);
mySerial.begin(19200);
nss.begin(4800);
}
void loop()
{
char numero[100];
char message[1000];
strcpy(numero,"**********");
strcpy(message,"test");
if (Serial.available())
switch(Serial.read())
{
case 't':
SendTextMessage(numero,message);
break;
}
if (mySerial.available())
Serial.write(mySerial.read());
}
Le code de la fonction SendTextMessage :
void SendTextMessage(char numero[100], char message[1000])
{
// Serial.print("Envoi d'un SMS au ");
// Serial.print(numero);
// Serial.println(".");
//Serial.println("Contenu : ");
//Serial.print(message);
//Serial.println("");
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(100);
mySerial.print("AT + CMGS = \"");//send sms message, be careful need to add a country code before the cellphone number
delay(100);
mySerial.print(numero);//the content of the message
delay(100);
mySerial.println("\"");//the content of the message
delay(100);
mySerial.println(message);//the content of the message
delay(100);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
mySerial.println();
Serial.println("Envoi OK");
Serial.println("");
}
Mes 2 problèmes sont les suivants :
- si je dé-commente ce qui est commenté au début de la fonction sendtextmessage, je ne reçois aucun SMS
- Si le GPS est branché, il m'envoie des coordonnées au lieu d'envoyer test
Merci de votre aide !