OLED SSD1306 with GPS

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:

//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

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:

#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("");
        }
    }
}

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?

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.

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?

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).

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.

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

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

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.

No, the display is not the problem.