GPS skylab skm53 et arduino mega 2560

bonjour.
nouveau sur ce forum je cherche de l aide pour mon GPS skylab skm53 connecte sur les pin RX 50, TX 51 de ma carte arduino mega 2560(seul les pin 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 peuvent etre utilise en RX). mon problème: ss.available() revois toujours 0 alors que ss.read() renvois des chaine.

RX GPS connecte au TX arduino.
TX GPS connecte au RX arduino.
VCC GPS -> 5V arduino.
GND GPS ->GND arduino.

librairie utilisee: TinyGPS 12

sketch:

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).
*/

TinyGPS gps;
SoftwareSerial ss(50, 51);

void setup()
{
Serial.begin(9600);
ss.begin(9600);

Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
Serial.println("by Mikal Hart");
Serial.println();
}

void loop()
{
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;

if (ss.available())
{
Serial.print("GPS available");
Serial.print(ss.available());
}

else
{
Serial.print("GPS not available");
Serial.print(ss.available());
}
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ss.available())
{
char c = ss.read();
// Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}

if (newData)
{
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print("LAT=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" LON=");
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
Serial.print(" SAT=");
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
Serial.print(" PREC=");
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
}

gps.stats(&chars, &sentences, &failed);
Serial.print(" CHARS=");
Serial.print(chars);
Serial.print(" SENTENCES=");
Serial.print(sentences);
Serial.print(" CSUM ERR=");
Serial.println(failed);
}

Mets ton code avec la balise code stp.

Ajoute dans ton loop au tout début :

ss.listen();

Sinon la library SoftwareSerial ne fonctionne pas !

sketch

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).
*/

TinyGPS gps;
SoftwareSerial ss(50, 51);

void setup()
{
  Serial.begin(9600);
  ss.begin(9600);
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;
  
  ss.listen();
  Serial.println(ss.listen());

if (ss.available()) 
  {
    Serial.print("GPS available");
    Serial.println(ss.available());
  }
    
else 
{
    Serial.print("GPS not available");
    Serial.println(ss.available());
  }
  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      Serial.print(ss.read());
            // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
}

Il y a un probleme dans cette partie :

 while (ss.available())
    {
      char c = ss.read();
      Serial.print(ss.read());
            // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }

Tu as déjà lu un caractère. donc ecris plutôt : Serial.print(c);

correction du code:

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).
*/

TinyGPS gps;
SoftwareSerial ss(50, 51);

void setup()
{
  Serial.begin(9600);
  ss.begin(9600);
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;
  
  ss.listen();
  Serial.println(ss.listen());

if (ss.available()) 
  {
    Serial.print("GPS available");
    Serial.println(ss.available());
  }
    
else 
{
    Serial.print("GPS not available");
    Serial.println(ss.available());
  }
  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      Serial.print(c);
            // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
}

résulta dans le moniteur série:

la condition

if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;

n est jamais vraie. quelqu'un aurai la solution merci d avance.

as tu essayé les exemples fournis avec la librairie TinyGps ?

Que disent-ils ? Sinon tu ne semble pas capter de satellites non ?

sinon essaye le sketch de ce lien.

http://competefornothing.com/?p=113

Problème résolu: il faut attendre quelque minutes l initialisation et l acquisition des données satellite du module GPS

merci

ptilu29:
résulta dans le moniteur série:

bonjour
ce n'est pas un probleme de connection entre module gps et arduino
c'est simplement que ton module GPS n'a pas de fix (zero satellites réceptionnés= pas de fix meme dégradé)
ton probleme viens très surement de là

quelles sont tes conditions de test ? , dégagement de l'antenne de réception ?

voir la sentence GGA
GGA - essential fix data which provide 3D location and accuracy data.

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47

Where:
GGA Global Positioning System Fix Data
123519 Fix taken at 12:35:19 UTC
4807.038,N Latitude 48 deg 07.038' N
01131.000,E Longitude 11 deg 31.000' E
1 Fix quality: 0 = invalid
1 = GPS fix (SPS)
2 = DGPS fix
3 = PPS fix
4 = Real Time Kinematic
5 = Float RTK
6 = estimated (dead reckoning) (2.3 feature)
7 = Manual input mode
8 = Simulation mode
08 Number of satellites being tracked
0.9 Horizontal dilution of position
545.4,M Altitude, Meters, above mean sea level
46.9,M Height of geoid (mean sea level) above WGS84
ellipsoid
(empty field) time in seconds since last DGPS update
(empty field) DGPS station ID number
*47 the checksum data, always begins with *

If the height of geoid is missing then the altitude should be suspect. Some non-standard implementations report altitude with respect to the ellipsoid rather than geoid altitude. Some units do not report negative altitudes at all. This is the only sentence that reports altitude.

bonjour.
qu' un pourrai m expliquer cette instruction, merci d avance

Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);

Salut,

C'est ce qu'on appelle une opération ternaire. C'est une manière plus concise de faire un if / else.

Si on se concentre sur cette partie :

TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat

On teste la valeur de TinyGPS::GPS_INVALID_F_ANGLE. Si elle est différente de 0, le résultat vaut 0.0, sinon le résultat vaut flat.
Ensuite on compare ce résultat à flat.

On pourrait d'ailleurs décomposer ainsi :

float result = TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat;
Serial.print(flat == result, 6);

Ou encore écrire :

float result = 0;
if (TinyGPS::GPS_INVALID_F_ANGLE)
{
    result = 0.0;
}
else
{
    result = flat;
}
Serial.print(flat == result, 6);