10 Giugno 2020 alle 19:18
#9185
Partecipante
al momento eccolo, mi segna solo per non corretto fuso orario due ore indietro…
// Arduino GPS real time clock with NEO-6M GPS module, inserito anche time zone ma mi da errore, in ogni caso tale modulo ripeto quello con attacco antenna sma è un miracolo di tecnologia.
#include <TinyGPS++.h> // Include TinyGPS++ library
#include <SoftwareSerial.h> // Include software serial library
#include <LiquidCrystal.h> // Include LCD library
#include <Adafruit_GPS.h>
TinyGPSPlus gps;
#define S_RX 12 // cambiati per prg oriolo nano Define software serial RX pin
#define S_TX 13 // cambiati per prg oriolo nano Define software serial TX pin
SoftwareSerial SoftSerial(S_RX, S_TX); // Configure SoftSerial library
#define LCD_ADDRESS 0x27
#define LCD_ROWS 4
#define LCD_COLUMNS 20
#define LCD_BACKLIGHT 1
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(LCD_ADDRESS); // LCD I2
byte last_second;
char Time[] = "TIME:00:00:00";
char Date[] = "DATA:00/00/2000";
void setup(void) {
SoftSerial.begin(9600);
// set up the LCD's number of columns and rows
//lcd.begin(16, 4);
//lcd.setCursor(0, 0);
lcd.begin(LCD_COLUMNS, LCD_ROWS);
// backlight turned on
lcd.setBacklight(LCD_BACKLIGHT);
lcd.print(Time); // Display time
lcd.setCursor(0, 2); // cambio riga da 1 a 4
// lcd.print(Date); // Display calendar
}
void loop() {
while (SoftSerial.available() > 0) {
if (gps.encode(SoftSerial.read())) {
if (gps.time.isValid()) {
Time[5] = gps.time.hour() / 10 + 48;
Time[6] = gps.time.hour() % 10 + 48;
Time[8] = gps.time.minute() / 10 + 48;
Time[9] = gps.time.minute() % 10 + 48;
Time[11] = gps.time.second() / 10 + 48;
Time[12] = gps.time.second() % 10 + 48;
}
if (gps.date.isValid()) {
Date[5] = gps.date.day() / 10 + 48;
Date[6] = gps.date.day() % 10 + 48;
Date[8] = gps.date.month() / 10 + 48;
Date[9] = gps.date.month() % 10 + 48;
Date[13] =(gps.date.year() / 10) % 10 + 48;
Date[14] = gps.date.year() % 10 + 48;
}
if(last_second != gps.time.second()) {
last_second = gps.time.second();
lcd.setCursor(0, 0);
lcd.print(Time); // Display time
lcd.setCursor(0, 1);
lcd.print(Date); // Display calendar
}
}
}
}