Variometer with gps - NeoGPS library

Hello everyone, I'm trying to modify a sketch related to a variometer to implement the GPS sensor, but despite a thousand tests done I have the sketch that is error-free by the compiler, but I don't see the GPS altitude and speed on the display.
Thank you

#include <Wire.h>                   // Biblioteca de interface I2C

#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>                     // Biblioteca Piezo Tone
#include "U8glib.h"

#define tone_out1 8
#define tone_out2 9

#include <VoltageReference.h>

VoltageReference vRef;




U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);  // Display which does not send AC
Adafruit_BMP280 sensor_bmp;

short speaker_pin1 = 8;                //arduino speaker output -
short speaker_pin2 = 9;                //arduino speaker output +

float vario_down = -1.1;               // Definir a redução
float vario_up; 
float alt[51];
float tim[51];
float beep;
float Beep_period;
float mux;

float Alt0;                 // Altura zero, no momento da inclusão +!
float vario=0;

float Altitude = 0;
float Temperature = 0;
unsigned long bounseInput4P = 0UL;
unsigned long time;

unsigned char samples=10;
unsigned char maxsamples=50;
unsigned char countPressVal = 0;
unsigned char tela = 0;

bool tmp1 = 0;
bool countPress = 0;
bool bounseInput4S = 0;
bool bounseInput4O = 0;

//relogio
unsigned char relogio=0;
unsigned char segundo = 0, minuto = 0, hora = 0;
unsigned long UtlTime;
unsigned long lastMillis;

boolean  thermalling = false;

void play_welcome_beep()                 // Saudações de áudio
{
    for (int aa=100;aa<=800;aa=aa+100)
    {
        tone(tone_out1,aa,200);       
        tone(tone_out2,aa+3,200);
        delay(50);
    }
}

//oled images
const uint8_t rook_bitmap[] PROGMEM = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF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0xE6, 0x60, 0xC0, 0xC1, 0xC1, 0xCE, 0x60, 0x70, 0x40, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0xCC, 0xEC, 0x99, 0x89, 0xCE, 0x46, 0x62, 0x6C, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0xC9, 0xD9, 0x93, 0x93, 0x9C, 0xCC, 0xE7, 0xD9, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0xC0, 0x38, 0x00, 0x40, 0x04, 0x00, 0x30, 0x38, 0x7F, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
#include <TinyGPS++.h> 
#include <SoftwareSerial.h>
#include<Wire.h>
//#include<Adafruit_GFX.h>
//#include<Adafruit_SSD1306.h>
int RXPin = 2;
int TXPin = 3; 
int GPSBaud = 9600; 
const int lebar=128;
const int tinggi=64;
const int reset=4;
//Adafruit_SSD1306 GHOZIIZG(lebar,tinggi,&Wire,reset);
TinyGPSPlus gps;
SoftwareSerial gpsSerial(RXPin, TXPin);



void draw(void) {
  
  u8g.setColorIndex(1); // Instructs the display to draw with a pixel on.
  u8g.setFont(u8g_font_8x13Br); //para o alfabeto completo com caracteres tirar o r do font_8x13Br
  if(tela == 0){
    u8g.drawBitmapP( 0, 0, 16, 64, rook_bitmap);
  }
  else if(tela == 1){
    u8g.setColorIndex(0);
    u8g.setColorIndex(1);
    u8g.drawStr( 25, 30, "Thiagogo"); //acentos http://www.ascii-code.com/
    u8g.drawStr( 37, 50, "Vario v1.0"); 
  }
  
  if(tela == 2){
  u8g.setColorIndex(0);
  u8g.setColorIndex(1);

  unsigned char posVar = 0;
  unsigned char posAlt = 0;
//temperatura

    u8g.setPrintPos(0, 14);
    u8g.print(gps.speed.kmph());
    //u8g.drawStr( 35, 14, "C"); //acentos http://www.ascii-code.com/


//caixa e m/s vario

    u8g.drawFrame(50,0,78,35); //quadrado vario
    u8g.drawStr(103, 30, "M\057s"); //m/s

    u8g.drawStr(120, 64, "M"); //M altimetro
    
    
//sensibilidade e relogio
  if(relogio==1){
    u8g.drawStr(0, 30, "v");
    u8g.setPrintPos(10, 30);
    u8g.print(mux);
  }
  else{
    String timex = "";
    if(hora < 10){
    timex += "0";
    }
    timex += hora;
     if (segundo%2==0)
        {
    timex += ":";
        }
        else{
    timex += " "; 
        }
    if(minuto < 10){
    timex += "0";
    }
    timex += minuto;
    
    u8g.setPrintPos(0, 34);
    u8g.print(timex);
  }


//altimetro
if (Altitude >= 1000)
    {
      posAlt = 28;
    }
    else
    {
      posAlt = 48;
    }
    u8g.setFont(u8g_font_fub20n); //se for so numeros usar o n no fim u8g.setFont(u8g_font_fub20n);
    u8g.setPrintPos(posAlt, 64);
    u8g.print(gps.altitude.meters());

    //vario
    if (vario < 0)
    {
      posVar = 52;
      if(vario < -0.1){
      u8g.drawTriangle(113,15, 122,7, 105,7);
      }
    }
    else
    {
      posVar = 61;
      if(vario > 0.1){
      u8g.drawTriangle(114,6, 124,15, 104,15);
      }
    }
    u8g.setPrintPos(posVar, 27);
    u8g.print(vario,1);


  //bateria
  int vcc = vRef.readVcc();

    u8g.drawFrame(4,42,4,2);
    u8g.drawFrame(2,44,8,18);
    if(vcc > 3800){
     u8g.drawStr( 1, 60, "."); 
    }
    if(vcc > 3900){
     u8g.drawStr( 1, 55, "."); 
    }
    if(vcc > 4000){
     u8g.drawStr( 1, 50, "."); 
    }
    
  }
}

void setup()
{
    Wire.begin();                   // Inicializa i2c
    pinMode(4, INPUT);
    digitalWrite(4, HIGH);
    bounseInput4O =  digitalRead(4);// Resistor Pullup
    pinMode(tone_out1, OUTPUT);  // Dinâmica pin8 de saída -
    pinMode(tone_out2, OUTPUT);  // Speaker pin9 saída +
    sensor_bmp.begin(); // Sensibilidade do sensor de pressão
    vRef.begin(); //inicia leitura da voltagem da bateria
    play_welcome_beep();

    //GHOZIIZG.begin(SSD1306_SWITCHCAPVCC, 0x3c);
  //GHOZIIZG.clearDisplay();
  gpsSerial.begin(GPSBaud);
}

void loop(void)
{

    //oled display
    time = millis() / 300;
  u8g.firstPage();  
  // Tempo de calibragem
  if (time <= 10)
  {
    tela = 0;
  }
  else if(time >10 && time <= 20){
    tela = 1;
  }
  else
  {
    tela = 2;
  }
  

    bool  bounceTmp =  (digitalRead (4));
    
    if (bounseInput4S)          // Bounce protecção
    {
        if (millis() >= (bounseInput4P + 40))
        {bounseInput4O= bounceTmp; bounseInput4S=0;}
    }
    else{
        if (bounceTmp != bounseInput4O )
        {bounseInput4S=1; bounseInput4P = millis();}
    }
    if (!(bounseInput4O))
    {
        if (! countPress)
        {
            countPressVal++;
            
//mostra relogio e variaçaõ
lastMillis = millis();
relogio = 1;
            
            for (int i = 0; i < countPressVal; i++)  // Perder o número do menu
            {
                tone(tone_out1,1800,40); 
                delay(80);                
            }
            countPress = 1;
        }   
    }
    else{
        countPress=0;
    }
    if (countPressVal < 0 ) countPressVal = 0;
    if (tmp1) countPressVal = 0;            // == MENU SENSIBILIDADE PARA LEVANTAR ==
    if((countPressVal) == 0) {mux = 0.3;}  // 1 sinal
    if((countPressVal) == 1) {mux = 0.5;} // 2 sinal
    if((countPressVal) == 2) {mux = 0.8;}  // 3 sinal
    tmp1 =  countPressVal  >=  3;
    vario_up = mux;

    //mostra relogio e variaçaõ
            if (lastMillis > 0 && (millis() - lastMillis > 3000))
        {
                relogio = 0;
                lastMillis = 0;        
         }
    
    float tempo=millis();
    float N1=0;
    float N2=0;
    float N3=0;
    float D1=0;
    float D2=0;
    Altitude = (sensor_bmp.readAltitude(1013.25));
    Temperature = (sensor_bmp.readTemperature());
   
    
        
    for(int cc=1;cc<=maxsamples;cc++){                                   // averager
        alt[(cc-1)]=alt[cc];
        tim[(cc-1)]=tim[cc];
    };
    alt[maxsamples]=Altitude;
    tim[maxsamples]=tempo;
    float stime=tim[maxsamples-samples];
    for(int cc=(maxsamples-samples);cc<maxsamples;cc++){
        N1+=(tim[cc]-stime)*alt[cc];
        N2+=(tim[cc]-stime);
        N3+=(alt[cc]);
        D1+=(tim[cc]-stime)*(tim[cc]-stime);
        D2+=(tim[cc]-stime);
    };
    
    vario=1000*((samples*N1)-N2*N3)/(samples*D1-D2*D2); // Cálculo de som

    if ((tempo-beep)>Beep_period)
    {
        beep=tempo;
        if (vario>vario_up && vario<15 )
        {
            Beep_period=350-(vario*5);
            tone(tone_out1,(1000+(100*vario)),300-(vario*5)); // Som em ascensão
            tone(tone_out2,(1003+(100*vario)),300-(vario*5));
            thermalling = true;
        }
        else if ((vario < 0 ) && (thermalling == true))
        {
            thermalling = false; 
         // tone_out2.play(200, 800); Predpotok // Som (é opcional)
            
        }
        else if (vario< vario_down){         // Som a afundar
            Beep_period=200;
            tone(tone_out1,(300-(vario)),340);
            tone(tone_out2,(303-(vario)),340);
            thermalling = false;
        }
    }

//relogio
if(millis()-UtlTime<0)   
{     
UtlTime=millis();   
}   
else{     
segundo=int((millis()-UtlTime)/1000);   
}   
if(segundo>59)   
{     
segundo=0;     
minuto++;     
UtlTime=millis();     
if(minuto>59)     
{       
hora++;       
minuto=0;
}
}


      do {
    draw();
  } while( u8g.nextPage() );
    //fim oled display
}

Do the TinyGPS++ examples work ?
Is the GPS unit indoors ?
Has it got a lock on the satellites ?

You left out the part where you read data from the GPS.

the gps with other sketches works correctly but I don't understand how to fix this.

How do the example sketches read the GPS data before printing it ?

1 Like

sorry i don't understand, i'm really beginner with coding

The TinyGPS++ DeviceExample loop() function looks like this

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

Does your sketch have any code like that which tests whether GPS data is available and, if so, encodes it ready to be displayed ?

The code for the gps I have extrapolated from this sketch


 //created by GHOZIIZG
//library GPS by mikalhart
//library oled by evaherrada 

#include <TinyGPS++.h> //https://github.com/mikalhart/TinyGPSPlus/blob/master/src/TinyGPS%2B%2B.h
#include <SoftwareSerial.h>
#include<Wire.h>
#include<Adafruit_GFX.h> //https://github.com/adafruit/Adafruit-GFX-Library
#include<Adafruit_SSD1306.h> //https://github.com/adafruit/Adafruit_SSD1306
int RXPin = 2;
int TXPin = 3; 
int GPSBaud = 9600; 
const int lebar=128;
const int tinggi=64;
const int reset=4;
Adafruit_SSD1306 GHOZIIZG(lebar,tinggi,&Wire,reset);
TinyGPSPlus gps;
SoftwareSerial gpsSerial(RXPin, TXPin);
void setup()
{
  GHOZIIZG.begin(SSD1306_SWITCHCAPVCC, 0x3c);
  GHOZIIZG.clearDisplay();
  gpsSerial.begin(GPSBaud);
}

void loop(){
  while (gpsSerial.available() > 0)
    if (gps.encode(gpsSerial.read()))
     GHOZIIZG.clearDisplay();
     GHOZIIZG.setTextSize(1);             
     GHOZIIZG.setTextColor(WHITE);
     GHOZIIZG.setCursor(0,1);      
     GHOZIIZG.print(F("aLTIT: "));
     GHOZIIZG.print(gps.altitude.meters(), 1);
     GHOZIIZG.setCursor(0,13);
     GHOZIIZG.print(F("sPEED: "));
     GHOZIIZG.print(gps.speed.kmph(), 1);
     GHOZIIZG.setCursor(0,23);      
     GHOZIIZG.print(F("time: "));
     GHOZIIZG.setCursor(30,23);
     GHOZIIZG.print(gps.time.hour());
     GHOZIIZG.setCursor(50,23);
     GHOZIIZG.print(gps.time.minute());
     GHOZIIZG.setCursor(70,23);
     GHOZIIZG.print(gps.time.second());
     GHOZIIZG.setCursor(0,53);
     GHOZIIZG.setCursor(0,33);      
     GHOZIIZG.print(F("date: "));
     GHOZIIZG.setCursor(30,33);
     GHOZIIZG.print(gps.date.day());
     GHOZIIZG.setCursor(50,33);
     GHOZIIZG.print(gps.date.month());
     GHOZIIZG.setCursor(70,33);
     GHOZIIZG.print(gps.date.year());
     GHOZIIZG.setCursor(0,53);
     GHOZIIZG.print(F("created by GHOZIIZG"));
     GHOZIIZG.display();
      delay(10);

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    GHOZIIZG.clearDisplay();
    GHOZIIZG.setTextSize(1);             
    GHOZIIZG.setTextColor(WHITE);
    GHOZIIZG.setCursor(0,13);      
    GHOZIIZG.print(F("No GPS detected"));
    GHOZIIZG.setCursor(0,23);      
    GHOZIIZG.print(F("check the cable and  restart the arduino"));
    GHOZIIZG.display();
    while(true);
  }
}

What happens when you run it ?

This last sketch works correctly, but when I implement it in the other one the gps values are always zero.

I am trying to compile for Arduino Nano with NeoGps, but I have a refresh of the data, if not after several seconds.
Someone can help me out, please.

#include <NMEAGPS.h>
#include <NeoSWSerial.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>                     // Biblioteca Piezo Tone
#include "U8glib.h"

#define tone_out1 8
#define tone_out2 9

#include <VoltageReference.h>

VoltageReference vRef;

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);  // Display which does not send AC
Adafruit_BMP280 sensor_bmp;

static const int RXPin = 2, TXPin = 3;
NeoSWSerial gpsPort(RXPin, TXPin);

static const uint32_t GPSBaud = 9600;
NMEAGPS gps;
gps_fix fix;
//uint8_t fixCount = 0;




short speaker_pin1 = 8;                //arduino speaker output -
short speaker_pin2 = 9;                //arduino speaker output +

float vario_down = -1.1;               // Definir a redução
float vario_up;
float alt[51];
float tim[51];
float beep;
float Beep_period;
float mux;
float Altgps;
float Speedgps;
float Alt0;                 // Altura zero, no momento da inclusão +!
float vario = 0;

float Altitude = 0;
float Temperature = 0;
unsigned long bounseInput4P = 0UL;
unsigned long time;

unsigned char samples = 10;
unsigned char maxsamples = 50;
unsigned char countPressVal = 0;
unsigned char tela = 0;

bool tmp1 = 0;
bool countPress = 0;
bool bounseInput4S = 0;
bool bounseInput4O = 0;

//relogio
unsigned char relogio = 0;
unsigned char segundo = 0, minuto = 0, hora = 0;
unsigned long UtlTime;
unsigned long lastMillis;

boolean  thermalling = false;

void play_welcome_beep()                 // Saudações de áudio
{
  for (int aa = 100; aa <= 800; aa = aa + 100)
  {
    tone(tone_out1, aa, 200);
    tone(tone_out2, aa + 3, 200);
    delay(50);
  }
}


void draw(void) {

  u8g.setColorIndex(1); // Instructs the display to draw with a pixel on.
  u8g.setFont(u8g_font_8x13Br); //para o alfabeto completo com caracteres tirar o r do font_8x13Br
  if (tela == 0) {
  }
  else if (tela == 1) {
    u8g.setColorIndex(0);
    u8g.setColorIndex(1);
    u8g.drawStr( 25, 30, "Thiagogo"); //acentos http://www.ascii-code.com/
    u8g.drawStr( 37, 50, "Vario v1.0");
  }

  if (tela == 2) {
    u8g.setColorIndex(0);
    u8g.setColorIndex(1);

    unsigned char posVar = 0;
    unsigned char posAlt = 0;

    //Speed
    u8g.setPrintPos(0, 14);
    u8g.print(Speedgps, 1);


    //sensibilidade e relogio
    if (relogio == 1) {
      u8g.drawStr(0, 30, "v");
      u8g.setPrintPos(10, 30);
      u8g.print(mux);
    }
    else {
      String timex = "";
      if (hora < 10) {
        timex += "0";
      }
      timex += hora;
      if (segundo % 2 == 0)
      {
        timex += ":";
      }
      else {
        timex += " ";
      }
      if (minuto < 10) {
        timex += "0";
      }
      timex += minuto;

      u8g.setPrintPos(0, 34);
      u8g.print(timex);
    }


    //altimetro
    if (Altitude >= 1000)
    {
      posAlt = 28;
    }
    else
    {
      posAlt = 48;
    }
    u8g.setFont(u8g_font_fub20n); //se for so numeros usar o n no fim u8g.setFont(u8g_font_fub20n);
    u8g.setPrintPos(posAlt, 64);
    u8g.print(Altgps, 1);

    //vario
    if (vario < 0)
    {
      posVar = 52;
      if (vario < -0.1) {
        u8g.drawTriangle(113, 15, 122, 7, 105, 7);
      }
    }
    else
    {
      posVar = 61;
      if (vario > 0.1) {
        u8g.drawTriangle(114, 6, 124, 15, 104, 15);
      }
    }
    u8g.setPrintPos(posVar, 27);
    u8g.print(vario, 1);


    //bateria
    int vcc = vRef.readVcc();

    u8g.drawFrame(4, 42, 4, 2);
    u8g.drawFrame(2, 44, 8, 18);
    if (vcc > 3800) {
      u8g.drawStr( 1, 60, ".");
    }
    if (vcc > 3900) {
      u8g.drawStr( 1, 55, ".");
    }
    if (vcc > 4000) {
      u8g.drawStr( 1, 50, ".");
    }

  }
}

void setup()
{

  Serial.begin(9600);
  gpsPort.begin(GPSBaud);

  Wire.begin();                   // Inicializa i2c
  pinMode(4, INPUT);
  digitalWrite(4, HIGH);
  bounseInput4O =  digitalRead(4);// Resistor Pullup
  pinMode(tone_out1, OUTPUT);  // Dinâmica pin8 de saída -
  pinMode(tone_out2, OUTPUT);  // Speaker pin9 saída +
  sensor_bmp.begin(); // Sensibilidade do sensor de pressão
  vRef.begin(); //inicia leitura da voltagem da bateria
  play_welcome_beep();
}

void loop(void)
{
  /*This print on the serial port exists only temporarily for control,
    once everything appears correctly on the screen it must be deleted.
  */

  while (gps.available( gpsPort )) {
    fix = gps.read();
  }
  if (fix.valid.speed) {
    Speedgps = (fix.speed_kph());
    Serial.print(Speedgps, 2);
  }
  if (fix.valid.altitude) {
    Altgps = (fix.altitude());
    Serial.print(Altgps, 3);
  }



  //oled display
  time = millis() / 300;
  u8g.firstPage();
  // Tempo de calibragem
  if (time <= 10)
  {
    tela = 0;
  }
  else if (time > 10 && time <= 20) {
    tela = 1;
  }
  else
  {
    tela = 2;
  }


  bool  bounceTmp =  (digitalRead (4));

  if (bounseInput4S)          // Bounce protecção
  {
    if (millis() >= (bounseInput4P + 40))
    {
      bounseInput4O = bounceTmp;
      bounseInput4S = 0;
    }
  }
  else {
    if (bounceTmp != bounseInput4O )
    {
      bounseInput4S = 1;
      bounseInput4P = millis();
    }
  }
  if (!(bounseInput4O))
  {
    if (! countPress)
    {
      countPressVal++;

      //mostra relogio e variaçaõ
      lastMillis = millis();
      relogio = 1;

      for (int i = 0; i < countPressVal; i++)  // Perder o número do menu
      {
        tone(tone_out1, 1800, 40);
        delay(80);
      }
      countPress = 1;
    }
  }
  else {
    countPress = 0;
  }
  if (countPressVal < 0 ) countPressVal = 0;
  if (tmp1) countPressVal = 0;            // == MENU SENSIBILIDADE PARA LEVANTAR ==
  if ((countPressVal) == 0) {
    mux = 0.3; // 1 sinal
  }
  if ((countPressVal) == 1) {
    mux = 0.5; // 2 sinal
  }
  if ((countPressVal) == 2) {
    mux = 0.8; // 3 sinal
  }
  tmp1 =  countPressVal  >=  3;
  vario_up = mux;

  //mostra relogio e variaçaõ
  if (lastMillis > 0 && (millis() - lastMillis > 3000))
  {
    relogio = 0;
    lastMillis = 0;
  }

  float tempo = millis();
  float N1 = 0;
  float N2 = 0;
  float N3 = 0;
  float D1 = 0;
  float D2 = 0;
  Altitude = (sensor_bmp.readAltitude(1013.25));
  Temperature = (sensor_bmp.readTemperature());



  for (int cc = 1; cc <= maxsamples; cc++) {                           // averager
    alt[(cc - 1)] = alt[cc];
    tim[(cc - 1)] = tim[cc];
  };
  alt[maxsamples] = Altitude;
  tim[maxsamples] = tempo;
  float stime = tim[maxsamples - samples];
  for (int cc = (maxsamples - samples); cc < maxsamples; cc++) {
    N1 += (tim[cc] - stime) * alt[cc];
    N2 += (tim[cc] - stime);
    N3 += (alt[cc]);
    D1 += (tim[cc] - stime) * (tim[cc] - stime);
    D2 += (tim[cc] - stime);
  };

  vario = 1000 * ((samples * N1) - N2 * N3) / (samples * D1 - D2 * D2); // Cálculo de som

  if ((tempo - beep) > Beep_period)
  {
    beep = tempo;
    if (vario > vario_up && vario < 15 )
    {
      Beep_period = 350 - (vario * 5);
      tone(tone_out1, (1000 + (100 * vario)), 300 - (vario * 5)); // Som em ascensão
      tone(tone_out2, (1003 + (100 * vario)), 300 - (vario * 5));
      thermalling = true;
    }
    else if ((vario < 0 ) && (thermalling == true))
    {
      thermalling = false;
      // tone_out2.play(200, 800); Predpotok // Som (é opcional)

    }
    else if (vario < vario_down) {       // Som a afundar
      Beep_period = 200;
      tone(tone_out1, (300 - (vario)), 340);
      tone(tone_out2, (303 - (vario)), 340);
      thermalling = false;
    }
  }

  //relogio
  if (millis() - UtlTime < 0)
  {
    UtlTime = millis();
  }
  else {
    segundo = int((millis() - UtlTime) / 1000);
  }
  if (segundo > 59)
  {
    segundo = 0;
    minuto++;
    UtlTime = millis();
    if (minuto > 59)
    {
      hora++;
      minuto = 0;
    }
  }



  do {
    draw();
  } while ( u8g.nextPage() );
  //fim oled display
}



I'm sorry. I do not understand this statement. Can you describe the problem in more detail?

I see the GPS data printed on the serial line scrolling quickly, while on the oled display, speed and altitude are updated even after several minutes, and I don't understand why.

T.

I don't see anywhere where you display Speedgps or Altgps on the OLED.

you can find them in the "void draw" section where I have the print parameters on the OLED.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.