Hello
I have a projecy and I have to create a scooter tracker (to warn a theft)
I have to send a GPS weft from a GSM
I already have the code to send a SMS and it work but and the weft to receive the GPS tram which work too.
I try to bring together the two codes to send the GSP weft from a GSM but it don't work, If you can correct my mistakes please, thank you
This is my code :
#include <GSM.h> // BIBLIOTHEQUE GPS
#include <TinyGPS++.h> // BIBLIOTHEQUE INCLUE
#include <SoftwareSerial.h> // BIBLIOTHEQUE POUR ECHANGE LIAISON SERIE (USART)
static const int RXPin = 9, TXPin = 7; // LE PORT 9 = RXD et LE PORT 7 = TXD VARIABLES RESTE TOUJOURS LA MEME TOUT AU LONG SU PROG
uint32_t GPSBaud = 9600; // VITESSE GPS = 9600
TinyGPSPlus gps; // Crée un objet TinyGPS ++ appelé "gps"
SoftwareSerial ss(RXPin, TXPin); // LA CONNEXION SERIE PAR RAPPORT AU GPS (9,0)
#define PINNUMBER "3970" // If your SIM has PIN, pass it as a parameter of begin() in quotes
GSM gsmAccess;
GSM_SMS sms;
char remoteNumber[20]; // numero de telephone du destinataire
/**********************************************************************************************************************************************/
void setup() {
Serial.begin(115200); // INITIALISATION DE LA VITESSE LIAISON SERIE
ss.begin(GPSBaud); // INITIALISATION DE LA VITESSE GPS
while (!Serial) { // wait for serial port to connect. Needed for native USB port only
;
}
Serial.println("Envoi SMS"); // ECRIRE ENVOI SMS
boolean notConnected = true; // connection state
while (notConnected) { // TANT QUE CE N'EST PAS CONNECTER A LA SIM
if (gsmAccess.begin(PINNUMBER) == GSM_READY) { // DETECTION DU CODE PIN ET CONTINUER LA POURSUITE
notConnected = false;
} else {
Serial.println("NON CONNECTE"); // SINON AFFICHER NON CONNECTE
delay(1000);
}
}
Serial.println("GSM initialise");
}
/*************************************************************************************************************************************************/
void loop()
{
while (ss.available() > 0) // TANT QUE LA DISPONIBILITE > 0 ("$")
if (gps.encode(ss.read())) // ALORS CODER ET STOCKER LA TRAME GPGGA
{ afficherInfo(); } // aller au sous programme "AFFICHERinfo"
if (millis() > 5000 && gps.charsProcessed() < 10) // Si 5000 millisecondes passent et qu'il n'y a aucun caractère entrant
{
Serial.println(F("No GPS detected: check wiring.")); // sur le port série du logiciel, affiche une erreur "Aucun GPS détecté"
while(true); // TANT QUE C'EST VRAI
}
sendSMS();
}
/***********************************************************************************************************************************************/
void afficherInfo()
{
Serial.print(F("Localisation: "));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(" et "));
Serial.print(gps.location.lng(), 6);
}
else
{
Serial.print(F("INVALID"));
}
Serial.println(); delay(5000);
}
/****************************************************************************************************************************************************/
void sendSMS(){
Serial.print("Entrez un numero de telephone:");
Serial.println(remoteNumber);
Serial.println("ENVOIE");
Serial.println();
Serial.println("Message:");
Serial.println(gps.location.lat(), 6);
Serial.println(F(","));
Serial.println(gps.location.lng(), 6);
sms.beginSMS(remoteNumber);
sms.print(gps.location.lat(), 6);
sms.print(F(","));
sms.print(gps.location.lng(), 6);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}
/***********************************************************************************************************************************************************/
int readSerial(char result[]) {
int i = 0;
while (1) {
while (Serial.available() > 0) {
char inChar = ss.read();
if (inChar == '\n') {
result[i] = '\0';
Serial.flush();
return 0;
}
if (inChar != '\r') {
result[i] = inChar;
i++;
}
}
}
}
and in the attachment, there is the mistakes