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