I'm brand new to Arduino.
Here are my project parts:
SparkFun RedBoard Qwiic (ATmega328)
SAM-M8Q (Qwiic) GPS Breakout
Zio Qwiic OLED Display (1.5inch, 128x128)
Goal:
Create a "Sensor Box" to display various sensor readings on the OLED display. GPS info, Temp and Humidity, etc.
Current problem:
When I try to add additional sensor outputs to the OLED display, the display stops showing live data. I tiried adding the temperature output from a DHT11, and all of the "dynamically updated" GPS info just stopped showing up on the OLED.
Suspected cause:
Running out of memory
Solutions I have considered:
- Using the F() string shortcut - I can't figure out how to make this work. Do I need to add an Include statement? Also, all the examples I see of for the F() are in Serial.println - I'm not using serial
- Using something else besides String - I tried to use byte for MPH and Number of Sats, but it didn't seem to make a difference.
Where I need help:
- Do I just need a board with more SRAM to solve this problem?
- Is there something I'm doing in my code that is wasting SRAM?
- Am I even on the right track? Could my problem be something else?
Other thoughts:
I believe the libraries are taking up the most SRAM. If I'm just using basic functionality, is there a smaller Library I can use?
#include <SparkFun_Ublox_Arduino_Library.h>
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add "u8g2.setBusClock(400000);" into setup() for speedup if possible */
SFE_UBLOX_GPS myGPS;
void setup(void) {
u8g2.begin();
}
void loop(void) {
if (myGPS.begin() == false) {
myGPS.setI2COutput(COM_TYPE_UBX);
myGPS.saveConfiguration();
}
float latitude = myGPS.getLatitude();
latitude = latitude / 10000000;
float longitude = myGPS.getLongitude();
longitude = longitude / 10000000;
int speedMMperS = myGPS.getGroundSpeed();
float speedMPH = speedMMperS / 447.00;
int8_t numSats = myGPS.getSIV();
//Convert to Strings For Display on OLED
String strLat = String(latitude, 6);
String strLong = String(longitude, 6);
String strMPH = String(speedMPH, 1);
String strSATS = String(numSats);
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0, 15, "LAT: ");
u8g2.drawStr(42, 15, strLat.c_str());
u8g2.drawStr(0, 30, "LON: ");
u8g2.drawStr(42, 30, strLong.c_str());
u8g2.drawStr(0, 45, "MPH: ");
u8g2.drawStr(42, 45, strMPH.c_str());
u8g2.drawStr(0, 60, "SATS: ");
u8g2.drawStr(48, 60, strSATS.c_str());
} while ( u8g2.nextPage() );
delay(1000);
}
Thank you in advance for the help! I have read and searched over the forum before posting, which is where I got the suggestions above. But, before I go buy a new board with more RAM, I want to be sure my thought process is correct!