So, when using an library example as a base of your own program - try to understand every command used in the code before insert it to the your sketch.
here is a cleaned up version of your code, getting rid of Strings (typed here from your code)
//GPS
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
//BMP280 Code
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
//SD Card Reader
#include <SD.h>
//GPS
SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);
#define GPSECHO true
//BMP 280
Adafruit_BMP280 bmp;
// buzzer
const byte buzzerPin = 9;
uint32_t lineNumber = 1;
uint32_t timer;
void setup() {
pinMode(buzzerPin, OUTPUT); //Buzzer
Serial.begin(115200);
// BMP
if (!bmp.begin(0x76)) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (true);
}
Serial.println(F("BMP280 Sensor Initiallized!:D"));
// SD
if (!SD.begin(10)) {
Serial.println(F("SD Card Init Failed. Womp Womp D:."));
while (true);
}
Serial.println(F("SD card initialized:D"));
// GPS
GPS.begin(9600);
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
// the parser doesn't care about other sentences at this time
// turn on RMC (recommended minimum) and GGA (fix data) including altitude
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
// turn on only the "minimum recommended" data
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
// Set the update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
// Request updates on antenna status, comment out to keep quiet
GPS.sendCommand(PGCMD_ANTENNA);
delay(1000);
// Ask for firmware version
mySerial.println(PMTK_Q_RELEASE);
Serial.println(F("Device Ready"));
}
void loop() {
char c = GPS.read();
if ((c) && (GPSECHO)) Serial.write(c); // debug
if (GPS.newNMEAreceived() && !GPS.parse(GPS.lastNMEA())) return; // we can fail to parse a sentence in which case we should just wait for another
if (millis() - timer > 2000) { // dump data to SD card every 2s if we have a fix
File dataFile = SD.open("PMData.txt", FILE_WRITE);
if (dataFile) {
dataFile.print(lineNumber++);
dataFile.print(F(", T="));
dataFile.print(bmp.readTemperature(), 2);
dataFile.print(F(" °C, P="));
dataFile.print(bmp.readPressure() / 100.0, 2);
dataFile.print(F(" hPa, Alt="));
dataFile.print(bmp.readAltitude(1013.25), 2);
dataFile.print(F(" m"));
if (GPS.fix) {
dataFile.print(F(", Lat="));
dataFile.print(GPS.latitude, 6);
dataFile.print(GPS.lat); // North or South
dataFile.print(F(", Lon="));
dataFile.print(GPS.longitude, 6);
dataFile.print(GPS.lon); // East or West
dataFile.print(F(", Speed="));
dataFile.print(GPS.speed, 1);
dataFile.print(F(", angle="));
dataFile.print(GPS.angle, 1);
}
dataFile.close();
tone(buzzerPin, 1000, 250);
} else {
Serial.println(F("File failed to open : / "));
}
timer = millis();
}
}
Unfortunately the combination of all the libraries you picked for your needs makes it unsuitable for the Arduino UNO or Nano ➜ there is not enough RAM.
You can explore other libraries which might be less demanding on RAM or you need a more capable Arduino.
if you want a small form factor, look at some ESP32 boards - some are really small or things like the Seeed Studio XIAO SAMD21
(mind 3.3V versus 5V components)
Or at the same size the XIAO ESP32S3 sense, heaps of memory and an SD card and camera.
Oh wow okay. You didn't have to do that lol. Thanks for the help, I'll look through libraries to learn about their functions and uses more so I can write better code. I really appreciate your help and I'll look into smaller form factor chips.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.