Hi, /dev.
I can't use serial.print, because the device has a stand alone atmega328p.
I've tried this. It shows in sequence:
stato: RTC
data/ora:
577224377.24
speed: 0.00
#include <NMEAGPS.h> // Using Neo-GPS lib
#include <EEPROM.h>
#include <NeoSWSerial.h> //Serial com
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 12, 13, 7); // RS, EN, D4, D5, D6, D7
static const int RXPin = A5, TXPin = 6;
NeoSWSerial gpsSerial(RXPin, TXPin);
NMEAGPS gps;
gps_fix fix;
// #define gpsPort Serial1 // you may be using a different serial port
int contr=0; // Correzione manuale al contrasto automatico (-10...+10)
String stato;
int dataOraA;
int dataOraB;
unsigned long t1=0;
byte n=0;
void setup()
{
Serial.begin( 9600 );
// Serial.println( F("status,date/time,speed") );
// gpsPort.begin( 9600 );
gpsSerial.begin(9600); //Starting GPS at a 9600 baud rate
lcd.begin(16,2);
pinMode(11, OUTPUT);// PWM out per contrasto automatico
if(EEPROM.read(0)==255) contr=70; else contr=EEPROM.read(13); // Carica il valore del contrasto
analogWrite(11,contr); // Applica il contrasto memorizzato
}
extern void detectRTCtimeOnly();
void loop()
{
if (gps.available( gpsSerial ))
{
fix = gps.read();
detectRTCtimeOnly();
if (fix.valid.status)
{
if (fix.status < gps_fix::STATUS_TIME_ONLY)
stato="RTC";
else if (fix.status == gps_fix::STATUS_TIME_ONLY)
stato="GPS";
else stato=String(fix.status); // 3 or above
}
else stato='-';
if (fix.valid.date || fix.valid.time)
{
Serial << fix.dateTime;
dataOraA= fix.dateTime;
dataOraB= fix.dateTime_cs;
Serial.print( '.' );
if (fix.dateTime_cs < 10)
Serial.print( '0' );
Serial.print( fix.dateTime_cs );
}
Serial.print( ',' );
if (fix.valid.speed)
Serial.print( fix.speed_kph() );
Serial.println();
}
if(millis()-t1>999)
{
t1=millis();
n+=1; if(n>3) n=1;
stampa();
}
}
void stampa()
{
lcd.clear();
if(n==1)
{
lcd.print(F("stato: "));
lcd.print(stato);
}
else if(n==2)
{
lcd.print(F("data/ora: "));
lcd.print(dataOraA);
lcd.print('.');
if (dataOraB<10) lcd.print('0');
lcd.print(dataOraB);
}
else if(n==3)
{
lcd.print(F("speed: "));
lcd.print(fix.speed_kph());
}
}
void detectRTCtimeOnly()
{
if (fix.valid.status && (fix.status == gps_fix::STATUS_TIME_ONLY)) {
// The MTK3339 will never send this value,
// but this is how you might detect it on ublox GPS devices.
return;
}
bool noSatellites = not fix.valid.satellites or (fix.satellites == 0);
bool haveTime = fix.valid.date or fix.valid.time;
bool tracking = fix.valid.status and (fix.status >= gps_fix::STATUS_STD);
if (not tracking) {
// Look for tracked satellites from the GSV sentences
for (uint8_t i=0; i < gps.sat_count; i++) {
if (gps.satellites[ i ].tracked) {
tracking = true;
break;
}
}
}
if (haveTime and tracking and noSatellites) {
// Force the fix status even though no NMEA sentences set it
fix.valid.status = true;
fix.status = gps_fix::STATUS_TIME_ONLY;
}
} // detectRTCtimeOnly
Every 3 seconds data/ora increases by 3.
"GPS" doesn't appear.