# OLED SSD1306 with GPS

**URL:** <https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070>\
**Category:** Programming\
**Created:** [September 16, 2023, 11:30am UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070 "2023-09-16T11:30:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![quiddi](https://avatars.discourse-cdn.com/v4/letter/q/278dde/32.png) [@quiddi](https://forum.arduino.cc/u/quiddi)\
**Post date:** [September 16, 2023, 11:30am UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/1 "2023-09-16T11:30:30Z")

</div>

Hi there,

My Hardware:  
Arduino Nano with ATmega328  
OLED Display 128x32 with SH1106  
GPS-Sensor ICQUANZX GY-NEO6MV2 NEO-6M

My problem is, that the OLED on its own is working well and the GPS-Sensor on its own is working well. But not both together. With the above code the OLED is working well:

```arduino
//Bibs for OLED
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

//Bibs for GPS
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

//Define Variables for connected GPS-Pins
#define PIN_RXD 5
#define PIN_TXD 4

#define GPS_BAUD 9600

//Define Variables for connected OLED
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RST 13

// Create the OLED display
Adafruit_SH1106G display = Adafruit_SH1106G(128, 64,OLED_MOSI, OLED_CLK, OLED_DC, OLED_RST, OLED_CS);

//TinyGPSPlus tinyGps;
//SoftwareSerial gpsSerial(PIN_RXD, PIN_TXD);

void setup()
{
    // Start OLED
  display.begin(0, true); // we dont use the i2c address but we will reset!
  // Clear OLED
  display.clearDisplay();
}

void loop(){
displayausgabe();
delay(2000);
}

void displayausgabe() {
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SH110X_WHITE);
  display.setCursor(0, 0);
  display.println("Hallo wie geht es dir?");
  display.setCursor(10, 28);
  display.println("Danke gut");
  display.display();
}

```

If I uncomment

```arduino
TinyGPSPlus tinyGps;
SoftwareSerial gpsSerial(PIN_RXD, PIN_TXD);

```

the OLED isn't working any more.  
Do you have any ideas why?

This code is working for the GPS-Sensor and I get the Data from the Sensor to the SerialMonitor:

```arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

#define PIN_RXD 5
#define PIN_TXD 4

#define GPS_BAUD 9600

SoftwareSerial gpsSerial(PIN_RXD, PIN_TXD);
TinyGPSPlus tinyGps;

void setup()
{
    Serial.begin(9600);
    gpsSerial.begin(GPS_BAUD);
}

void loop()
{
    while (gpsSerial.available() > 0){
        tinyGps.encode(gpsSerial.read());
        if (tinyGps.location.isUpdated()){
            Serial.print("Latitude = ");
            Serial.println(tinyGps.location.lat(), 6);
            Serial.print("Longitude = ");
            Serial.println(tinyGps.location.lng(), 6);
            Serial.println("");
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [September 16, 2023, 11:57am UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/2 "2023-09-16T11:57:56Z")

</div>

Why are you using the Adafruit\_SH110X library instead of Adafruit\_SSD1306?

You are using the constructor for software SPI, that may have an interrupt conflict with SoftwareSerial, have you tried using hardware SPI?

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [September 16, 2023, 12:07pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/3 "2023-09-16T12:07:38Z")

</div>

I cannot see software SPI and software Serial working well together.

The Nano has a hardware SPI port, I would suggest you use a library that supports that for the SSD1306.

---

<div class="post-metadata">

**Author:** ![quiddi](https://avatars.discourse-cdn.com/v4/letter/q/278dde/32.png) [@quiddi](https://forum.arduino.cc/u/quiddi)\
**Post date:** [September 16, 2023, 12:45pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/4 "2023-09-16T12:45:18Z")

</div>

> [@david\_2018](#):
>
> Why are you using the Adafruit\_SH110X library instead of Adafruit\_SSD1306?

Srr. that was my fault. I trie to edit the first post. I am using SH1106 and not SSD1306. So my OLED-Display does not support I2C. Is the Adafruit\_SSD1306 compatible with a SPI Connection?

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [September 16, 2023, 2:39pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/5 "2023-09-16T14:39:01Z")

</div>

> [@quiddi](#):
>
> I trie to edit the first post.

Do not edit the original post. It makes the discussion almost impossible to follow.

Post the memory report published just before uploading. You may be running out of RAM memory (the display takes 1K bytes that is not included in the report).

---

<div class="post-metadata">

**Author:** ![quiddi](https://avatars.discourse-cdn.com/v4/letter/q/278dde/32.png) [@quiddi](https://forum.arduino.cc/u/quiddi)\
**Post date:** [September 16, 2023, 3:53pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/6 "2023-09-16T15:53:17Z")

</div>

> [@anon94801460](#):
>
> Post the memory report published just before uploading. You may be running out of RAM memory (the display takes 1K bytes that is not included in the report).

Sketch uses 13500 bytes (43%) of program storage space. Maximum is 30720 bytes.  
Global variables use 713 Bytes (34%) of dynamic memory, leaving 1335 bytes for local variables. Maximum is 2048 bytes.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [September 16, 2023, 3:54pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/7 "2023-09-16T15:54:47Z")

</div>

> [@quiddi](#):
>
> leaving 1335 bytes for local variables.

That means you have about 310 bytes after the display buffer is allocated, which should be OK.

---

<div class="post-metadata">

**Author:** ![quiddi](https://avatars.discourse-cdn.com/v4/letter/q/278dde/32.png) [@quiddi](https://forum.arduino.cc/u/quiddi)\
**Post date:** [September 16, 2023, 6:32pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/8 "2023-09-16T18:32:08Z")

</div>

So, the solution is to buy an OLED with SSD1306 chip that I can use I2C?

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [September 16, 2023, 6:49pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/9 "2023-09-16T18:49:13Z")

</div>

Have you tried using hardware SPI? You will need to rewire the connections between the Nano and the display to use the hardware SPI pins.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [September 16, 2023, 8:41pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/10 "2023-09-16T20:41:27Z")

</div>

> [@quiddi](#):
>
> the solution is to buy an OLED

No, the display is not the problem.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 14, 2024, 8:42pm UTC](https://forum.arduino.cc/t/oled-ssd1306-with-gps/1169070/11 "2024-03-14T20:42:16Z")

</div>

Closed on March 14, 2024, 8:42pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
