Display GPS NEO 6M Data to OLED
Display latitude longitude time and date to oled
Components and supplies
1
GY-NEO6MV2
1
Graphic OLED, 128 x 64
1
Arduino Nano R3
Project description
Code
code
arduino
1//created by GHOZIIZG 2//library GPS by mikalhart 3//library oled by evaherrada 4 5#include <TinyGPS++.h> //https://github.com/mikalhart/TinyGPSPlus/blob/master/src/TinyGPS%2B%2B.h 6#include <SoftwareSerial.h> 7#include<Wire.h> 8#include<Adafruit_GFX.h> //https://github.com/adafruit/Adafruit-GFX-Library 9#include<Adafruit_SSD1306.h> //https://github.com/adafruit/Adafruit_SSD1306 10int RXPin = 2; 11int TXPin = 3; 12int GPSBaud = 9600; 13const int lebar=128; 14const int tinggi=64; 15const int reset=4; 16Adafruit_SSD1306 GHOZIIZG(lebar,tinggi,&Wire,reset); 17TinyGPSPlus gps; 18SoftwareSerial gpsSerial(RXPin, TXPin); 19void setup() 20{ 21 GHOZIIZG.begin(SSD1306_SWITCHCAPVCC, 0x3c); 22 GHOZIIZG.clearDisplay(); 23 gpsSerial.begin(GPSBaud); 24} 25 26void loop(){ 27 while (gpsSerial.available() > 0) 28 if (gps.encode(gpsSerial.read())) 29 GHOZIIZG.clearDisplay(); 30 GHOZIIZG.setTextSize(1); 31 GHOZIIZG.setTextColor(WHITE); 32 GHOZIIZG.setCursor(0,1); 33 GHOZIIZG.print(F("latitude: ")); 34 GHOZIIZG.print(gps.location.lat(), 6); 35 GHOZIIZG.setCursor(0,13); 36 GHOZIIZG.print(F("longitude: ")); 37 GHOZIIZG.print(gps.location.lng(), 6); 38 GHOZIIZG.setCursor(0,23); 39 GHOZIIZG.print(F("time: ")); 40 GHOZIIZG.setCursor(30,23); 41 GHOZIIZG.print(gps.time.hour()); 42 GHOZIIZG.setCursor(50,23); 43 GHOZIIZG.print(gps.time.minute()); 44 GHOZIIZG.setCursor(70,23); 45 GHOZIIZG.print(gps.time.second()); 46 GHOZIIZG.setCursor(0,53); 47 GHOZIIZG.setCursor(0,33); 48 GHOZIIZG.print(F("date: ")); 49 GHOZIIZG.setCursor(30,33); 50 GHOZIIZG.print(gps.date.day()); 51 GHOZIIZG.setCursor(50,33); 52 GHOZIIZG.print(gps.date.month()); 53 GHOZIIZG.setCursor(70,33); 54 GHOZIIZG.print(gps.date.year()); 55 GHOZIIZG.setCursor(0,53); 56 GHOZIIZG.print(F("created by GHOZIIZG")); 57 GHOZIIZG.display(); 58 delay(10); 59 60 if (millis() > 5000 && gps.charsProcessed() < 10) 61 { 62 GHOZIIZG.clearDisplay(); 63 GHOZIIZG.setTextSize(1); 64 GHOZIIZG.setTextColor(WHITE); 65 GHOZIIZG.setCursor(0,13); 66 GHOZIIZG.print(F("No GPS detected")); 67 GHOZIIZG.setCursor(0,23); 68 GHOZIIZG.print(F("check the cable and restart the arduino")); 69 GHOZIIZG.display(); 70 while(true); 71 } 72}
Downloadable files
circuit
circuit

circuit
circuit

Comments
Only logged in users can leave comments