Adafruit_SSD1306 with TinyGPS++ Not working

hi
I'm working in GPS project which is using NEO 6M with 128X64 OLED display sing Arduino NANO.
Basically I developed sketch as follows,

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <TimeLib.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);

TinyGPSPlus gps;
SoftwareSerial ss(4, 3);

void setup() {
  Serial.begin(115200);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0X3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); 
  }
  display.display();
  delay(2000); 
  display.clearDisplay();
  display.drawPixel(10, 10, SSD1306_WHITE);
  display.display();
  delay(2000);

}

void loop() {
}

This Sketch is working and shows Adafruit logo and pixel correctly.
But when I add this part of TinyGPS++ its not working and gives SSD1306 allocation failed in Serial monitor.

TinyGPSCustom totalGPGSVMessages(gps, "GPGSV", 1);
TinyGPSCustom messageNumber(gps, "GPGSV", 2);
TinyGPSCustom satsInView1(gps, "GPGSV", 3);

I used both parts using examples of libraries.
Why it shows this message when adding this TinyGPSCustom part into my sketch. I cant understand why its happening that way. So I'm hoping your comments for fixing this.
Thank You.

I built your sketch for a Nano in the Web Editor.

Using library Wire at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/avr/1.8.4/libraries/Wire

Using library Adafruit SSD1306 at version 2.5.6 in folder: /mnt/create-efs/webide/0a/33/0a33bd1179c57bfa4a19d1bd3e6cef93:david_prentice/libraries_v2/Adafruit SSD1306

Using library adafruit_gfx_library_1_11_3 at version 1.11.3 in folder: /home/builder/opt/libraries/adafruit_gfx_library_1_11_3

Using library adafruit_busio_1_13_1 at version 1.13.1 in folder: /home/builder/opt/libraries/adafruit_busio_1_13_1

/home/builder/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /tmp/arduino-build-CDAC7738E6737818606BD9476880C85B/sketch_aug12b.ino.elf

Sketch uses 15424 bytes (50%) of program storage space. Maximum is 30720 bytes.

Global variables use 813 bytes (39%) of dynamic memory, leaving 1235 bytes for local variables. Maximum is 2048 bytes.

Which shows that you would only have 1235 - 1024 bytes of SRAM at runtime. i.e. 211 bytes left. Even if it "started" it would crash straight afterwards.

Buy a bigger Arduino e.g. Every, Zero, Due, Mega2560, ...

did you used TinyGPS++ ??

The SSD1306 library alone uses half of the available SRAM memory of the Nano.

Use a different display (e.g. a 16x2 LCD), or buy an Arduino with more memory.

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