1

Attempting to make gps unit with screen. GPS unit communicates over serial (Adafruit Ultimate GPS Breakout) and I can get GPS data through USB to my pc with Adafruit GPS library softwareserial examples. The screen communicates over I2C (Sunfounder OLED-SSD1306 Module) and I can get display with Adafruit SSD1306 examples. However I cannot get both to happen simultaneously. Board is Adafruit Metro Mini 5v 16MHZ. GPS is using pin 8 for TX and pin 9 for RX. Display is using A4 for SDA and A5 for SCL.

If "Adafruit_GPS GPS(&mySerial);" is not commented the screen will not display anything. If it is commented the screen displays just fine. How do I get both to function simultaneously?

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET -1
#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
Adafruit_GPS GPS(&mySerial);
void setup() {
 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
 for(;;);
 }
 display.display();
 delay(2000);
 display.clearDisplay();
 display.drawPixel(10, 10, SSD1306_WHITE);
 display.display();
 delay(2000);
 testdrawchar();
}
void loop() {
}
void testdrawchar(void) {
 display.clearDisplay();
 display.setTextSize(1); 
 display.setTextColor(SSD1306_WHITE); 
 display.setCursor(0, 0); 
 display.cp437(true); 
 for(int16_t i=0; i<256; i++) {
 if(i == '\n') display.write(' ');
 else display.write(i);
 }
 display.display();
 delay(2000);
}
asked Mar 8, 2020 at 2:02
1
  • I guess, you run out of memory Commented Mar 8, 2020 at 9:37

1 Answer 1

1

The problem was indeed running out of memory (as suggested by Juraj). After finding smaller libraries I was able to get it to work together just fine.

answered May 1, 2020 at 9:04
2
  • This is an incomplete answer. What libraries were chosen? Commented Apr 19, 2021 at 12:31
  • Final list of libraries: #include <AltSoftSerial.h> #include <TinyGPS.h> #include <SoftwareSerial.h> #include "SSD1306Ascii.h" #include "SSD1306AsciiAvrI2c.h" #include <Wire.h> All of the Adafruit libraries were too large, so they all got switched out for more concise, compact libraries that fit my purposes Commented Dec 2, 2022 at 5:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.