Skip to content
Neri Karra Neri Karra

How to use a 1.54 inch 128x64 OLED with a GPS module?

How to Use a 1.54 Inch 128x64 OLED with a GPS Module

To get a 1.54 inch 128x64 oled display working with a GPS module, you need to wire them to a microcontroller like an Arduino or ESP32, then write code that parses NMEA sentences from the GPS and pushes the data to the OLED via SPI or I2C. The OLED itself is a monochrome graphic display with a resolution of 128x64 pixels, typically driven by the SSD1309 or SH1106 controller. Most modules use SPI for faster refresh rates, which is critical when you’re updating GPS coordinates in real time. The GPS module, like a u-blox NEO-6M or NEO-8M, outputs serial data at 9600 baud by default, using NMEA 0183 protocol. You’ll need to connect the GPS TX pin to the microcontroller’s RX pin, and the OLED’s DC, CS, MOSI, SCK, and VCC pins to the corresponding SPI pins. A common mistake is forgetting to level-shift the logic voltage—most OLEDs and GPS modules run at 3.3V, but some Arduino boards operate at 5V. If you’re using a 5V board, use a voltage divider or a logic level converter on the data lines. The OLED’s operating voltage is 3.3V to 5V, but the logic pins are 3.3V-tolerant, so you can power it from 5V but keep the data lines at 3.3V. The GPS module’s VCC pin can take 3.3V to 5V, but the TX output is 3.3V, which is safe for most microcontrollers. For the OLED, the SPI interface uses four pins: CS (chip select), DC (data/command), MOSI (master out slave in), and SCK (serial clock). Some modules also have a RESET pin, but you can tie it to the microcontroller’s reset or a GPIO. The display resolution of 128x64 pixels means you can show up to 8 lines of text if you use a 6x8 font, or 4 lines with a 12x16 font. For GPS data, you typically want to show latitude, longitude, speed, altitude, and time. The NMEA sentences like $GPGGA and $GPRMC contain these fields. For example, $GPGGA provides time, latitude, longitude, fix quality, number of satellites, and altitude. $GPRMC gives speed, course, and date. You’ll need to parse these strings in your code. Libraries like TinyGPS++ or NeoGPS handle the parsing efficiently. They extract the data into structured variables, which you then format into strings and send to the OLED. The OLED library, such as Adafruit SSD1306 or U8g2, handles the graphics. You can use the print() function to display text, but you need to set the cursor position manually. For example, display.setCursor(0, 0) puts the text at the top-left corner. The display’s pixel density is about 128 dots per inch, so text is crisp but small. If you’re reading it from a distance, consider using a larger font. The refresh rate of the OLED is around 100 Hz for SPI, but the GPS data updates at 1 Hz, so you don’t need to push updates faster than that. In fact, updating the display too often can cause flickering. Use a timer or a flag to update only when new GPS data is available. The power consumption of the OLED is about 20 mA at full brightness, which is low compared to a TFT display. The GPS module draws about 45 mA during acquisition and 25 mA when tracking. Combined, the total draw is under 100 mA, which is fine for USB power or a small battery. If you’re building a portable device, you can put the microcontroller to sleep between GPS updates. The ESP32, for example, has deep sleep modes that draw only a few microamps. You can wake it up on a timer or when the GPS sends a pulse. The OLED can also be turned off via software by sending a sleep command (display.ssd1306_command(SSD1306_DISPLAYOFF)). This reduces power to about 1 µA. For wiring, let’s be specific. On an Arduino Uno, the SPI pins are 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). But the OLED doesn’t use MISO, so you only need MOSI and SCK. The CS pin goes to pin 10, DC goes to pin 9, and RESET goes to pin 8. The GPS module’s TX goes to pin 3 (RX) using SoftwareSerial. You can also use hardware serial on pins 0 and 1, but that interferes with uploading code. The OLED’s VCC goes to 5V, and GND to GND. The GPS module’s VCC goes to 5V, and GND to GND. If you’re using an ESP32, the SPI pins are different. The default VSPI pins are MOSI (23), MISO (19), SCK (18), and CS (5). You can assign any GPIO for DC and RESET. For example, DC to pin 16, RESET to pin 17. The GPS module’s TX goes to pin 4 (RX2), and you can use HardwareSerial2. The ESP32 runs at 3.3V, so no level shifting is needed. The OLED’s logic pins are 3.3V-tolerant, so it’s safe. Now, let’s talk about the code structure. First, include the libraries: #include , #include , #include , and #include . Define the OLED pins: #define OLED_CS 10, #define OLED_DC 9, #define OLED_RESET 8. Create an instance: Adafruit_SSD1306 display(OLED_CS, OLED_DC, OLED_RESET);. For the GPS, create a TinyGPSPlus object and a SoftwareSerial object: SoftwareSerial ss(3, 4); (RX on pin 3, TX on pin 4). In setup, initialize the display with display.begin(SSD1306_SWITCHCAPVCC) and clear it. Then set the baud rate for the GPS: ss.begin(9600). In the loop, feed the GPS data: while (ss.available() > 0) { gps.encode(ss.read()); }. Then check if new data is available: if (gps.location.isUpdated()). Inside that block, clear the display, set the cursor, and print the data. For example: display.clearDisplay(); display.setCursor(0, 0); display.print("Lat: "); display.print(gps.location.lat(), 6); display.setCursor(0, 16); display.print("Lng: "); display.print(gps.location.lng(), 6); display.display();. The display() function sends the buffer to the OLED. The buffer size is 1024 bytes (128x64/8), which fits in the microcontroller’s RAM. The Adafruit library uses a 1KB buffer, so it’s fine for an Uno or ESP32. The TinyGPS++ library also uses minimal RAM. The parsing is efficient, but you need to handle the case where the GPS hasn’t locked yet. Check gps.location.isValid() before printing. If invalid, print “No Fix” or show the number of satellites. The number of satellites is available via gps.satellites.value(). You can also show the HDOP (horizontal dilution of precision) via gps.hdop.value(). For altitude, use gps.altitude.meters(). For speed, use gps.speed.kmph(). For time, use gps.time.hour(), gps.time.minute(), and gps.time.second(). The time is in UTC, so you might need to add an offset. The OLED can show all this data on one screen if you use a small font. For example, using a 6x8 font, you can fit 8 lines of 21 characters each. That’s enough for latitude, longitude, altitude, speed, time, and satellites. You can also create a second screen that shows a map or a compass, but that requires more complex graphics. The display’s contrast can be adjusted via software using display.ssd1306_command(SSD1306_SETCONTRAST) with a value from 0 to 255. Higher values make the pixels brighter but consume more power. The typical contrast value is 128. The OLED’s viewing angle is 160 degrees, so it’s readable from almost any direction. The response time is under 10 microseconds, so there’s no ghosting. The display works in temperatures from -40°C to 85°C, which is useful for outdoor GPS applications. The GPS module’s operating temperature is similar, but the ceramic antenna might be affected by extreme cold. For best performance, place the GPS antenna with a clear view of the sky. The u-blox modules have a sensitivity of -161 dBm, which is good for urban canyons. The OLED’s SPI clock speed can be set to 8 MHz or higher. The Adafruit library defaults to 4 MHz, but you can increase it to 8 MHz for faster updates. The GPS module’s baud rate can be increased to 115200 for faster data transfer, but the default 9600 is fine for most applications. The NMEA sentences are short, so 9600 baud is enough. The OLED’s pixel size is 0.21 mm, so the total display area is about 27 mm by 13 mm. That’s small but readable. If you need a larger display, you can use a 2.42 inch OLED, but the 1.54 inch is a good balance between size and power. The module’s thickness is about 1.5 mm, making it easy to mount in a case. The GPS module’s size is about 25 mm by 25 mm, with a height of 4 mm. You can mount both on a breadboard or a custom PCB. The wiring is straightforward, but use short wires to avoid noise on the SPI lines. The SPI clock signal can cause interference with the GPS antenna if the wires are too long. Keep the GPS module at least 10 cm away from the OLED and the microcontroller. The GPS antenna is active, so it needs 3.3V power. The u-blox modules have a built-in antenna, but you can also connect an external antenna. The OLED’s driver IC is the SSD1309, which supports both SPI and I2C. The SPI mode is faster, but I2C uses only two wires. If you’re short on pins, use I2C. The I2C address is typically 0x3C or 0x3D. The OLED’s I2C speed is 400 kHz. The GPS module’s output is serial, so you need a UART. The ESP32 has multiple UARTs, so you can use hardware serial. The Arduino Uno has only one hardware serial, so you need SoftwareSerial. The SoftwareSerial library works but has limitations. It can’t handle high baud rates reliably, and it uses interrupts. For a more robust setup, use an Arduino Mega or a Teensy. The Mega has four hardware serial ports. The Teensy has even more. The OLED’s SPI interface is compatible with the Teensy’s SPI library. The update rate for the display is limited by the GPS update rate, which is 1 Hz. The OLED can update at 100 Hz, so there’s no bottleneck. The bottleneck is the GPS module’s fix time. A cold start takes about 27 seconds for a u-blox module. A hot start takes 1 second. The OLED can show a countdown or a status message during the fix. The fix quality is indicated by the GPS fix flag. A value of 1 means no fix, 2 means 2D fix, and 3 means 3D fix. You can display this on the OLED. The number of satellites used in the fix is also available. The OLED’s font library includes many fonts, from small to large. The U8g2 library has a font called u8g2_font_6x10_tf that is 6 pixels wide and 10 pixels tall. This font fits 21 characters per line and 6 lines on the screen. If you use a 12x16 font, you get 10 characters per line and 4 lines. That’s enough for the most important data. You can also use a custom font for symbols like degree signs or arrows. The OLED’s buffer is a bitmap, so you can draw shapes like circles, rectangles, and lines. For example, you can draw a progress bar for the GPS fix. The display’s memory is static, so you don’t need to refresh it constantly. The SSD1309 controller has a built-in charge pump that generates the negative voltage for the OLED pixels. This means you don’t need an external negative voltage supply. The charge pump is enabled by default. The display’s brightness is uniform across the screen. The contrast can be adjusted in 256 steps. The power consumption is proportional to the number of pixels lit. A full white screen draws about 20 mA, while a black screen draws less than 1 mA. The GPS module’s power consumption is independent of the display. The total system power is about 70 mA. If you’re using a battery, a 1000 mAh LiPo battery will last about 14 hours. You can extend the battery life by dimming the display or turning it off when not in use. The GPS module can be put into power-saving mode by sending a command via UART. The u-blox modules support a “power save mode” that reduces the update rate to 1 Hz and turns off the acquisition engine. This cuts power to 10 mA. The OLED can be turned off via software. The combination of both can reduce the total power to 15 mA. That’s enough for a 24-hour run on a 500 mAh battery. The GPS module’s accuracy is about 2.5 meters for the NEO-6M and 1.5 meters for the NEO-8M. The OLED’s resolution is 128x64 pixels, so you can’t show a map with high detail, but you can show a simple compass or a direction arrow. The compass would require a magnetometer, but that’s a different module. The OLED can also show the GPS time with high accuracy. The GPS time is derived from atomic clocks, so it’s accurate to within 100 nanoseconds. The OLED can display the time in HH:MM:SS format. The date is also available from the GPS. The display can show the date in DD/MM/YYYY format. The GPS module’s update rate is 1 Hz, so the time updates every second. The OLED’s refresh rate is much faster, so the time display is smooth. The code for the time display is similar to the location display. You just need to format the time variables. For example: char timeStr[9]; sprintf(timeStr, "%02d:%02d:%02d", gps.time.hour(), gps.time.minute(), gps.time.second()); display.print(timeStr);. The sprintf function is available in the Arduino environment. The OLED’s font library includes a 7-segment font for a digital clock look. The U8g2 library has a font called u8g2_font_7Segments26x42_mn that is 26 pixels wide and 42 pixels tall. This font is large enough to fill the entire screen with a single digit. You can use it for a large time display. The GPS module’s time is in UTC, so you need to add the time zone offset. For example, for Eastern Standard Time, subtract 5 hours. The time zone offset can be stored in a variable and adjusted manually. The OLED can also show the date and time on the same screen. The layout can be designed with two lines: one for the date and one for the time. The font size can be smaller for the date and larger for the time. The OLED’s graphics library allows you to set the text size with display.setTextSize(2) for double-size text. This makes the text 12 pixels tall and 12 pixels wide per character. A double-size font fits 10 characters per line and 5 lines. That’s enough for the time and date. The GPS module’s speed is available in knots, km/h, or mph. You can convert it to the desired unit. The altitude is in meters. The OLED can show the altitude with one decimal place. The accuracy of the altitude is about 10 meters for the GPS. The OLED’s display of altitude is useful for hiking or drone applications. The number of satellites is a good indicator of signal quality. The OLED can show a bar graph of the satellite signal strength. The signal strength is available in dBHz from the GPS module. The u-blox modules output the signal strength for each satellite in the $GPGSV sentence. The TinyGPS++ library can parse this. The OLED can draw a bar for each satellite. The bar height represents the signal strength. The display’s resolution of 128 pixels wide allows for up to 12 bars, each 10 pixels wide. The bars can be drawn using the display.fillRect() function. The color is white on black, but you can invert the display by setting the inverse mode. The OLED supports inverse mode via display.invertDisplay(true). This swaps the black and white pixels. It’s useful for high-contrast displays in bright sunlight. The OLED’s reflectivity is low, so it’s not as readable as a reflective LCD in direct sunlight. But the high contrast helps. The GPS module’s antenna should be placed away from the OLED to avoid interference. The OLED’s driver IC generates a high-frequency clock that

From the Atelier

Carry something made by a single pair of hands.

Browse the current season — fewer than 2,400 pieces are released each year, and many editions are already spoken for.

Shop the Collection