Go Down

Topic: cambiar hora GPS uBlox NEO-6m (Read 113 times) previous topic - next topic

Adrian_E

alguien ha conseguido que el GPS uBlox NEO-6m devuelva la hora local, no la UTC, ya que los de ublox no dan soporte, y el soft u-center_v8.18 configura casi todo menos eso, y el restarle las horas no me ha dado buenos resultados si te muestra las 23:00 local, pero te devuelve el dia incorrecto,  aca seria 10 de mayo 23:00, pero en realidad me dice 23:00 11 de mayo, asi que restar no me lo soluciona.

surbyte


Adrian_E

gracias surbyte, lo habia visto, ademas encontre este http://forum.arduino.cc/index.php?topic=199216.0, pero por el echo de ser demasiado novaton me esta llevando demasiado tiempo y los de ublox no responden mail.

surbyte

Bueno este código lo probaste?

Code: [Select]

Roughly based on Adafruit example sketch: "parsing"
Utilizes the Adafruit_GPS library https://github.com/adafruit/Adafruit-GPS-Library
20131115: GPS_Parsing_Test
 Heavily mucked by M. Ray Burnette to simply use (most) any dumb serial TTL GPS for time-date
 Tested with ancient #28146 Parallax module
 Arduino 1.0.5:

*/

#include "Adafruit_GPS.h"
#include "Utilities.h"
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
//#include <AXE133Y.h>
#include <Streaming.h>

//   Connect the GPS TX (transmit) pin to Digital 3 input
SoftwareSerial mySerial(9, 8) ;  // Rx Tx
Adafruit_GPS GPS(&mySerial) ;

// Set GPSDEBUG to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences.
// Could be as simple as checking a digital pin to-Gnd state
#define GPSDEBUG  false  // should be a check of a digital pin to Gnd

uint8_t last_seconds ;
uint8_t TimeZoneHour = 5 ;  // needs to be a pin-to-ground adjustment for DST
uint8_t LocalHour ;
uint8_t LocalMinute ;
uint8_t LocalSecond ;
uint8_t LocalMonth ;
uint8_t LocalDay ;
uint8_t LocalYear ;
byte nRow;                          // line count      (0-5 for NOKIA LCD)
byte nColumn;                       // character count (0-11 for NOKIA LCD)
boolean PM ;
int OLED_Tx    =  5;         // Serial out for OLED
char* PROGMEM BlankLine[]  = {"                "};

// AXE133Y OLED =  AXE133Y(OLED_Tx);
LiquidCrystal lcd(7, 6, 2, 3, 4, 5);  // BEWARE: does not match Arduino Examples

void setup() 
{
 lcd.begin(16, 2) ;
 Serial.begin(115200) ; // connect at 115200 debug output to console
 GPS.begin(9600); // Some GPS are 4800 and some are 9600 or faster
 if(GPSDEBUG) Serial.println("GPS time-date:") ;
 lcd.setCursor(0, 0); lcd << BlankLine[0] ;       // clear lower row
 lcd.setCursor(0, 1); lcd << BlankLine[0] ;       // clear upper row
 delay(500) ;
 lcd.setCursor(0, 0) ;
 lcd.print("by M.R. Burnette") ;
 lcd.setCursor(0, 1) ;
 lcd.print("(c) GPS timedate") ;
 delay(2000) ;  // credits
 lcd.setCursor(0, 0); lcd << BlankLine[0] ;       // clear lower row
 lcd.setCursor(0, 1); lcd << BlankLine[0] ;       // clear upper row
 // Add a DayLightSavingTime or
 // Use multiple digital pins to set any TimeZone
}


void loop()
{
   // read data from the GPS
   char c = GPS.read();
   if (GPSDEBUG)  // Raw character echo to monitor
     if (c) Serial.print(c);

 // if a sentence is received, check the checksum, parse it...
 if (GPS.newNMEAreceived()) {
   if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
     return;  // return to top of loop() if sentence does not verify correctly or completely
 }

 PM = false ;
 // BIG if() active only once per second since this sketch is time-date focused
 if (last_seconds != GPS.seconds) {
   last_seconds =  GPS.seconds ;
   LocalHour    =  GPS.hour ;
   LocalMinute  =  GPS.minute ;
   LocalSecond  =  GPS.seconds ;
   LocalMonth   =  GPS.month ;
   LocalDay     =  GPS.day ;
   LocalYear    =  GPS.year ;

   if(LocalHour >= TimeZoneHour) {
       LocalHour = LocalHour - TimeZoneHour ;
     } else {
       // Correct for period when London is a day ahead
       LocalHour = (LocalHour + 24) - TimeZoneHour ;
       LocalDay  = LocalDay - 1 ;
       if( LocalDay == 0)
       {
         LocalDay   = DaysInMonth[ LocalMonth - 1] ;  // 0 - 11
         LocalMonth = LocalMonth - 1 ;  // January in London still December Westward
         if( LocalMonth == 0)           // GPS months are 01 through 12
         {
           LocalMonth = 12 ;
           LocalDay   = DaysInMonth[ 11 ] ;  // lastday of December
         }
        // Need to deal with LocalMonth = 2 and leapyear (simple... not exhaustive)
         if( LocalMonth == 2 && (LocalYear % 4) ) LocalDay = LocalDay + 1 ;
       }
     }

   if(LocalHour >= 12)
   {
     PM = true ;
     if(LocalHour > 12) LocalHour = LocalHour - 12 ;
   }

   lcd.setCursor(0, 0);

   if(PM) {
     lcd.print("PM    ") ;
   } else {
     lcd.print("AM    ") ;
   }
   
   //lcd.print("GPS   ");
   lcd.setCursor(6, 0) ;
   if(LocalHour < 10) lcd.print(" ") ;
   lcd.print(LocalHour) ;
   lcd.setCursor(8, 0) ;
   lcd.print(":") ;

   lcd.setCursor(9, 0) ;
   if(LocalMinute < 10) {
   lcd.print("0") ;
   lcd.print(LocalMinute) ;
   } else {
     lcd.print(LocalMinute) ;
   }

   lcd.setCursor(11, 0) ;
   lcd.print(":") ;
   lcd.setCursor(12, 0) ;

   if(LocalSecond < 10) {
     lcd.print("0") ;
     lcd.print(LocalSecond) ;  // 12, 13
   } else {
     lcd.print(LocalSecond) ;
   }

   if(PM) {
     lcd.print(" P ") ;     // positions 14, 15 + 1 off screen
   } else {
     lcd.print(" A ") ;
   }

   // The DOY and Month and Date info is shown every 10 seconds
   if((LocalSecond % 10) == 0) {
     lcd.setCursor(0, 1);
     lcd.print(DayOfWeek[dow(LocalYear, LocalMonth, LocalDay)]) ; // positions 0 - 2
     lcd.print("   "); // postition 3 - 5
     lcd.setCursor(6, 1) ;
     lcd.print(NameOfMonth[LocalMonth - 1]) ; // 6 - 8 lower line
     lcd.setCursor(9, 1) ;
     lcd.print(" ") ;
     lcd.setCursor(10, 1) ;
     if(LocalDay < 10) {
       lcd.print(" ") ;  // 10
       lcd.print(LocalDay) ;
     } else {
       lcd.print(LocalDay) ; // 10, 11
     }
     lcd.setCursor(12, 1) ;
     lcd.print(" '") ;  // 12
     lcd.setCursor(14, 1) ;
     lcd.print(LocalYear) ;  // 13, 14
     lcd.print(" ") ; // 15
   }

   if(GPSDEBUG) {
     Serial.print("\nTime: ") ;
     Serial << ((LocalHour<10)?"0":"") ;
     Serial.print(LocalHour, DEC);
     Serial << (":") ;
     Serial << ((GPS.minute<10)?"0":"") ;
     Serial.print (GPS.minute, DEC);
     Serial << (":") ;
     Serial << ((GPS.seconds<10)?"0":"") ;
     Serial.print(GPS.seconds, DEC) ;
     Serial.print("\nDate: ");
     Serial << ((GPS.day<10)?"0":"") ;
     Serial.print(GPS.day, DEC) ;              //DD
     Serial << "/" << ((GPS.month<10)?"0":"") ;
     Serial.print(GPS.month, DEC) ;            //MM
     Serial << "/20" ;
     Serial.println(GPS.year, DEC) ;           //YYYY
   }
 } // BIG if
} // loop




Yo veo que esta parte contempla lo que tu pides

Code: [Select]
if(LocalHour >= TimeZoneHour) {
       LocalHour = LocalHour - TimeZoneHour ;
     } else {
       // Correct for period when London is a day ahead
       LocalHour = (LocalHour + 24) - TimeZoneHour ;
       LocalDay  = LocalDay - 1 ;
       if( LocalDay == 0)
       {
         LocalDay   = DaysInMonth[ LocalMonth - 1] ;  // 0 - 11
         LocalMonth = LocalMonth - 1 ;  // January in London still December Westward
         if( LocalMonth == 0)           // GPS months are 01 through 12
         {
           LocalMonth = 12 ;
           LocalDay   = DaysInMonth[ 11 ] ;  // lastday of December
         }
        // Need to deal with LocalMonth = 2 and leapyear (simple... not exhaustive)
         if( LocalMonth == 2 && (LocalYear % 4) ) LocalDay = LocalDay + 1 ;
       }
     }





Adrian_E

lo  que mas bronca da, es que ublox no responde los mail, y el software que es el u-center, configura de todo menos eso, que  menos mal que este trae un restaurar de fabrica, porque llego un momento que devolvia cualquier dato jaja, y encontre la opcion revert to default configuration sino chau gps.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy