Bonjour, je travaille sur un projet qui est d'envoyer des coordonnées GPS par sms. Le projet fonctionne comme cela : Je reçois un sms, arduino calcule les coordonnées GPS et les envoie en retour. Le problème c'est que le GPS n'est pas détecté, il marche en individuel mais je n'arrive pas à le faire fonctionner avec le shield gsm.
Je travaille avec une carte Arduino UNO, un shield gsm sim900 et un GPS EM-406 Breakout.
PS : pour le moment, in n'y a que la partie réception et affichage des coordonnées
Voici le résultat sur le moniteur série :
affichage de coordonnees gps apres reception d'un sms
GSM initialized
SMS recu de :
+336XXXXXXXX
O
FIN DU MESSAGE
Coordonnees GPS
Location: INVALID Date/Time: INVALID INVALID
Bonjour, pour ce qui est des pins, je les définis avec mon branchement en reliant le gps sur les pins 4 & 5, je branche RX sur 4 et TX sur 5.
Pour l'objet gpsSerial, jai vu ca sur un exemple pour faire fonctionner le gps, j'ai supposé que c'était pour mémoriser les pins utilisés pour RX et TX.
bonjour,
as tu regardé les exemples de AltSoftSerial.h ?
#include <AltSoftSerial.h>
// AltSoftSerial always uses these pins:
//
// Board Transmit Receive PWM Unusable
// ----- -------- ------- ------------
// Teensy 3.0 & 3.1 21 20 22
// Teensy 2.0 9 10 (none)
// Teensy++ 2.0 25 4 26, 27
// Arduino Uno 9 8 10
// Arduino Leonardo 5 13 (none)
// Arduino Mega 46 48 44, 45
// Wiring-S 5 6 4
// Sanguino 13 14 12
AltSoftSerial altSerial;
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor to open
Serial.println("AltSoftSerial Test Begin");
altSerial.begin(9600);
altSerial.println("Hello World");
}
void loop() {
char c;
if (Serial.available()) {
c = Serial.read();
altSerial.print(c);
}
if (altSerial.available()) {
c = altSerial.read();
Serial.print(c);
}
}
et ceux de tynigps++
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;
J'ai l'impression que tu t’emmêles les pinceaux avec gps et gpsSerial. Si c'est gpsSerial qui gère ton gps, dans ta fonction displayInfo(), tu devrais utiliser gpsSerial plutôt que gps, non ?
Bonjour, je ne vois pas trop où tu veux en venir avec les exemples, je viens de les regarder et si j'ai bien compris, lorsque la library AltSoftSerial est utilisée avec une arduino UNO, les ports 8 et 9 sont déjà utilisés ?
Et j'ai tester en branchant RX et TX sur 3 et 4.
Pour ce qui est de gps et gpsSerial, j'ai pris cet exemple sur internet qui marche très bien pour le gps donc je ne pense pas que ça vienne de là.
Voici l'exemple gps qui marche bien :
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
This example uses software serial and the TinyGPS++ library by Mikal Hart
Based on TinyGPSPlus/DeviceExample.ino by Mikal Hart
Modified by acavis
*/
// Choose two Arduino pins to use for software serial
// The GPS Shield uses D2 and D3 by default when in DLINE mode
static const int RXPin = 3, TXPin = 4;
static const uint32_t GPSBaud = 4800;
// Create a TinyGPS++ object called "gps"
TinyGPSPlus gps;
// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);
void setup()
{
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(9600);
// Start the software serial port at the GPS's default baud
gpsSerial.begin(GPSBaud);
Serial.println(F("DeviceExample.ino"));
Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (gpsSerial.available() > 0)
if (gps.encode(gpsSerial.read()))
displayInfo();
// If 5000 milliseconds pass and there are no characters coming in
// over the software serial port, show a "No GPS detected" error
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected"));
while(true);
}
}
void displayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 20);
Serial.print(F(","));
Serial.print(gps.location.lng(), 20);
}
else
{
Serial.print(F("INVALID"));
}
Serial.print(F(" Date/Time: "));
if (gps.date.isValid())
{
Serial.print(gps.date.month());
Serial.print(F("/"));
Serial.print(gps.date.day());
Serial.print(F("/"));
Serial.print(gps.date.year());
}
else
{
Serial.print(F("INVALID"));
}
Serial.print(F(" "));
if (gps.time.isValid())
{
if (gps.time.hour() < 10) Serial.print(F("0"));
Serial.print(gps.time.hour()+2);
Serial.print(F(":"));
if (gps.time.minute() < 10) Serial.print(F("0"));
Serial.print(gps.time.minute());
Serial.print(F(":"));
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(F("."));
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.print(gps.time.centisecond());
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}
Bonjour, je ne vois pas trop où tu veux en venir avec les exemples, je viens de les regarder et si j'ai bien compris, lorsque la library AltSoftSerial est utilisée avec une arduino UNO, les ports 8 et 9 sont déjà utilisés ?
Et j'ai tester en branchant RX et TX sur 3 et 4.
Le fait de regarder les exemples sert a comprendre le fonctionnement des lib parfois
avec cette libn IL FAUT utiliser les 8 et 9 pour l'équipement que tu veux connecter avec cette lib.
le message est indiqué en plus AltSoftSerial always uses these pins
tu peux par contre utiliser SoftwareSerial pour 2 ports série
Bonjour, suit à votre réponse, j'ai changé mon branchement, j'ai mis RX et TX sur 8 et 9, et j'ai également changé les RXPin et TXPin dans le programme mais j'ai toujours le problème de non-détection du GPS
Ensuite, la library SoftwareSerial n'est pas compatible avec la library TinyGPS++, un message d'erreur s'affiche :
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_3'
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_5'
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_4'
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here