Arduino GPS with OLED Display

An attempt at scaling down the GPS logger I made, this one is using a mini GPS receiver from Sparkfun with coordinates displayed on a 0.96″ OLED from Adafruit. It’s still a work in progress just squishing together code from the TinyGPS++ library and using the Adafruit GFX Library

Right now it’s refreshing the entire screen as the coordinates are updated, the plan is to adjust the cursor position and only rewrite the Latitude/Longitude coordinates. The image with the yellow dot will be for when the GPS unit is waiting on satellites(usually takes a few minutes to get a satellite lock) though it’ll probably be a little animated display since that just looks spiffier. So far the only problem is the refresh of the screen. Even without a delay(x) it still has a noticeable flash as the screen is drawn. Though this is most likely because I’ve never used the GFX library before yesterday.

Strangely the GP-635 is hitting 7 satellites while the GPS I used in the data logger was only getting 3, despite both sitting in my apartment with no external antenna attached.

Components:

Arduino Uno
GPS Receiver: GP-635T from Sparkfun
Display: 16 bit color 0.96″ OLED Breakout Board from Adafruit

gp635

connecting

GPS coordinates displayed on a.96" OLED using an Arduino Uno

GPS coordinates displayed on a.96″ OLED using an Arduino Uno

Working code is below, no comments in the code yet except those that exist in the GFX & TinyGPS example code. The GPS RX/TX are connected to Digital Pins 0 & 1 on the Arduino Uno with Vcc connected to 5V, and of course don’t forget to connect the GND. The wiring of the display is shown on the Adafruit site at the link above.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#define sclk 13
#define mosi 11
#define cs   10
#define rst  9
#define dc   8
/*
   This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0  
#define WHITE           0xFFFF

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>
#include <SPI.h>
int numSats;
// Option 1: use any pins but a little slower
Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);  
int i=1;
static const int RXPin = 0, TXPin = 1;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
   ss.begin(GPSBaud);
  display.begin();
  display.fillScreen(BLACK);
  display.setCursor(0,0);
 
}

void loop()
{
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

  numSats=gps.satellites.value();
 
  //display.fillScreen(BLACK);
  //while(gps.satellites.value()==0){

//    display.fillCircle(48,32,10,RED);
//    for(int i=5;i<35;i+=5){
//      display.drawCircle(48,32,i,RED);
//      delay(10);
//      display.fillScreen(BLACK);
//  }
// }
//  if(numSats==0){
//    display.fillCircle(5,5,4,RED);
//  }
//  if(numSats<=2){
    display.fillCircle(5,5,4,YELLOW);
//  } else {
   display.fillCircle(5,5,4,GREEN);
// }
 
if(gps.location.isUpdated()){
  display.fillScreen(BLACK);
  display.setCursor(0,9);
//  float gpsLoc=gps.location.lat();
  display.print("Number of Sats=");
  display.println(numSats);
  display.print("Latitude ");
  display.println(gps.location.lat());
  display.print("Longitude ");
  display.println(gps.location.lng());
  delay(1000);
 
}
 
  smartDelay(1000);

  if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS data received: check wiring"));
}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}

You may also like...