problème avec un GPS pas tres veloce

Bonjour /bonsoir

Je désire faire un variomètre / altimètre couplé avec un GPS pour mesurer ma vitesse sol. La partie variometre/ altimètre est prête, mais j'ai un problème avec le GPS ( plus précisément avec mon .ino ):

Si je ne branche que le GPS et envoie à l'arduino un sketch de test , j'ai pas de problème, j'ai une réponse et les indications de ma position mise à jour dans la seconde.

Avec mon montage, le variomètre met à jour les infos provenant du barometre dans la seconde, mais celles du GPS ne se mettent à jour qu'au bout d'une période variant de 3 à 30 secondes !!!

mon montage comprend un minipro(3.3V) un BMP280 ( i2c) , un écran i2c , le GPS et la batterie (3.7V)

Pourriez vous m'aider à trouver ma faute ...

mon sketch :

#include "Wire.h"
#include "U8glib.h"
#include "BMP280.h"
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
long P0=1035.01;  //1013.25 
BMP280 bmp;
SoftwareSerial ssgps(4,5); // RX(<-TX of GPS module), TX(<-RX of GPS module)
TinyGPSPlus gps;

/*void gpsdump(TinyGPS &gps);
//void printFloat(double f, int digits = 1);

// This function read Nbytes bytes from I2C device at address Address. 
// Put read bytes starting at register Register in the Data array. 
void I2Cread(uint8_t Address, uint8_t Register, uint8_t Nbytes, uint8_t* Data)
{
  // Set register address
  Wire.beginTransmission(Address);
  Wire.write(Register);
  Wire.endTransmission();
 
  // Read Nbytes
  Wire.requestFrom(Address, Nbytes); 
  uint8_t index=0;
  while (Wire.available())
    Data[index++]=Wire.read();
}
 
 
// Write a byte (Data) in device (Address) at register (Register)
void I2CwriteByte(uint8_t Address, uint8_t Register, uint8_t Data)
{
  // Set register address
  Wire.beginTransmission(Address);
  Wire.write(Register);
  Wire.write(Data);
  Wire.endTransmission();
}
*/
// OLED Type

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);

#define u8g_logo_width 100
#define u8g_logo_height 25
//static unsigned char u8g_logo_bits[] = {
const uint8_t u8g_logo_bits[] PROGMEM = { 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
   0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01, 0x00, 0x00,
   0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01, 0x00,
   0x00, 0xc0, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01,
   0x00, 0x00, 0xc0, 0xe1, 0xf8, 0xf0, 0x07, 0xf0, 0x7b, 0xe0, 0xc3, 0xcf,
   0x0f, 0x1f, 0x00, 0xc0, 0xe1, 0xf8, 0xf3, 0x07, 0xf0, 0xff, 0xf0, 0xc7,
   0xcf, 0x8f, 0x3f, 0x00, 0xc0, 0xf1, 0x80, 0x83, 0x03, 0x70, 0xce, 0x79,
   0xcf, 0xc1, 0xc1, 0x71, 0x00, 0xc0, 0x7f, 0xf8, 0x83, 0xe3, 0x73, 0xce,
   0x39, 0xce, 0xc1, 0xc1, 0x7f, 0x00, 0xc0, 0x1f, 0xfc, 0xc3, 0xe1, 0x73,
   0xce, 0x39, 0xce, 0xc1, 0xc1, 0x7f, 0x00, 0xc0, 0x39, 0x9c, 0xe3, 0x00,
   0x70, 0xce, 0x39, 0xce, 0xc1, 0xc1, 0x01, 0x00, 0xc0, 0x71, 0x9c, 0xe3,
   0x00, 0x70, 0xce, 0x79, 0xcf, 0xc1, 0xc1, 0x03, 0x00, 0xc0, 0xe1, 0xfc,
   0xf3, 0x07, 0x70, 0xce, 0xf1, 0x87, 0x8f, 0x8f, 0x3f, 0x00, 0xc0, 0xe1,
   0xf1, 0xf3, 0x07, 0x70, 0xce, 0xe1, 0x03, 0x0f, 0x0f, 0x3f, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00 };

void draw3(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.drawXBMP( 2, 25, u8g_logo_width, u8g_logo_height, u8g_logo_bits);
}


int bouton1=7;
int bouton2=8;
int bouton3=9;
char sT[6];
char sP[9];
char sA[9];
char sA_MIN[9];
char sA_MAX[9];
double A_MIN = 0;
double A_MAX = 0;
double correction =0;
const int numReadings = 3;
float fspeed = 0;
int gpssat = 0;
double readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
double total = 0;                  // the running total
double average = 0;                // the average

void draw(double P, double average, float fspeed) {
  u8g.setFont(u8g_font_gdr14n);
  //dtostrf(P, 4, 1, sP);
  dtostrf(average + correction , 4, 1, sA);

  u8g.setPrintPos(1,14);
  u8g.print(fspeed);

  //u8g.drawStr( 45, 30, sP);
  u8g.setFont(u8g_font_gdr25n);
  u8g.drawStr( 40, 60, sA);
}

void draw2(double T, double A_MIN, double A_MAX) {
  u8g.setFont(u8g_font_gdr14n);

  dtostrf(A_MIN + correction, 5, 0, sA_MIN);
  dtostrf(A_MAX + correction, 5, 0, sA_MAX);
  dtostrf(T, 4, 1, sT);

  u8g.drawStr( 60, 20, sA_MIN);
  u8g.drawStr( 60, 40, sA_MAX);
  u8g.drawStr( 60, 60, sT);
}

void displayInfo() {
    Serial.print(gps.satellites.value());
    Serial.print(";");
    Serial.print(gps.speed.kmph());
    Serial.print(";");
    Serial.print(average);
    Serial.println(); 
}

void setup() {

  Serial.begin(9600);
  ssgps.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  pinMode(bouton1, INPUT_PULLUP);  
  pinMode(bouton2, INPUT_PULLUP);
  pinMode(bouton3, INPUT_PULLUP);
  
    u8g.firstPage();  
  do {
    draw3();
  } while( u8g.nextPage() );
 if (!bmp.begin()) {
    Serial.println("BMP init failed!");
    while (1);
  }
  else Serial.println("BMP init success!");
  bmp.setOversampling(4);

 
delay(3000);
  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_unifont);

   // Arduino initializations
  Wire.begin();
   for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {


   while (ssgps.available() > 0)
    if (gps.encode(ssgps.read())) {
    //displayInfo();
    
    }
    
  if (gpssat <= 3) {
    digitalWrite(LED_BUILTIN, HIGH);
  }
  if (gpssat >= 4) {
    digitalWrite(LED_BUILTIN, LOW);
  }
  
   fspeed = gps.speed.kmph();
   gpssat = gps.satellites.value();
    
  double T, P;
  char result = bmp.startMeasurment();

  if (result != 0) {
    delay(result);
    result = bmp.getTemperatureAndPressure(T, P);

    if (result != 0) {
      double A = bmp.altitude(P, P0) ;

    total = total - readings[readIndex];    // read from the sensor:
  readings[readIndex] = A ;     // add the reading to the total:
  total = total + readings[readIndex];     // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
 
      if ( A > A_MAX) {
        A_MAX = A;
      }

      if ( A < A_MIN || A_MIN == 0) {
        A_MIN = A;
      }


      u8g.firstPage();
      do {
        draw(P, average, fspeed);
      } while ( u8g.nextPage() );
      u8g.firstPage();
      delay(10);


    }
    else {
      Serial.println("Error.");
    }
  }
  else {
    Serial.println("Error.");
  }

 if ( digitalRead(bouton1) == 0)
 { do {
        draw2(T, A_MIN, A_MAX);
      } while ( u8g.nextPage() );
      u8g.firstPage();
      delay(4000);
 }
 
  if ( digitalRead(bouton2) == 0)
 { correction--;
 A_MAX = 0;
 }
 
  if ( digitalRead(bouton3) == 0)
 { correction++;
 A_MIN = 0;
 }
 
  delay(10);

    Serial.print(gps.satellites.value());
    Serial.print(";");
    Serial.print(fspeed);
    Serial.print(";");
    Serial.print(average);
    Serial.println();

}

Olivier

olitask:
Bonjour /bonsoir

Je désire faire un variomètre / altimètre couplé avec un GPS pour mesurer ma vitesse sol. La partie variometre/ altimètre est prête, mais j'ai un problème avec le GPS ( plus précisément avec mon .ino ):

Si je ne branche que le GPS et envoie à l'arduino un sketch de test , j'ai pas de problème, j'ai une réponse et les indications de ma position mise à jour dans la seconde.

Avec mon montage, le variomètre met à jour les infos provenant du barometre dans la seconde, mais celles du GPS ne se mettent à jour qu'au bout d'une période variant de 3 à 30 secondes !!!

mon montage comprend un minipro(3.3V) un BMP280 ( i2c) , un écran i2c , le GPS et la batterie (3.7V)

bonsoir
Dans la mesure où tu "reçois +/- rapidement de l'info GNSS valide"
Il serait bon que tu fasse un log des sentences brutes NMEA, déjà pour voir si cela vient de la lib tinygps++ (perso je ne pense pas) ou d'un probleme plus materiel (alim modules limite, bruit electrique, autres )