Problems using multiple libraries .... Arduino Crash!

I am trying to build a small project to take Record GPS and Temperature data onto an SD Card.

The GPS works by itself.
The Temperature Sensor works by itself.
The SD Card works by itself.
All together it crashes the Arduino with random characters going across the screen or general lock-up.

Here are the libraries I’m using. Also I show where I can comment out the temperature sensor and write only GPS data to the SD card.

#include <SD.h> // FOR SD Card
#include <SoftwareSerial.h> // For GPS
#include <TinyGPS.h> // For GPS
#include <OneWire.h> // Commenting this and all assoc code stops lockup.
#include <DallasTemperature.h> // Commenting this and all assoc code stops lockup.

Any ideas why stuff crashes with that combination of libraries and how to fix it?

Out of memory? Search the site for the freemem code.

i would also out of mem; i ran int othe same thing with a huge int array and the TVout library on a uno

I am a programming novice and not sure how to clear out the unused memory. I don’t really care about optimal performance just that it can work for a couple of hours without crashing. Below is my loop function which I assembled looking at the examples on my sensors. Any advice on how to use that library to make my program work?

void loop()
bool newdata = false;
unsigned long start = millis();

// Every second we print an update
while (millis() - start < 1000)
if (feedgps())
newdata = true;

// Get Temperature data
float temp1c = sensors.getTempCByIndex(0);
float temp1f=temp1c*1.8+32;

int raw = 0;
for (int i=0; i<16; i++){
raw += analogRead(A0);
raw /=16;
float cooked = cook(raw);

// Define - get GPS data
float flat, flon;
unsigned long age, date, time, chars = 0;
unsigned short sentences = 0, failed = 0;
gps.f_get_position(&flat, &flon, &age);

// print Serial Data in CSV format for screen
Serial.print(", “);
Serial.print(”, “);
Serial.print(”, “);
//Serial.print(“PSI”); // Temp PSI placeholder
Serial.print(cooked, 2);
Serial.print(”, “);
print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 2);
Serial.print(”, “);
print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
Serial.print(”, “);
print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 9, 4);
Serial.print(”, “);
print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);
Serial.print(”, “);
print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
Serial.print(”, “);
print_float(gps.f_speed_mph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
Serial.print(”, ");
print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);

// Write same data to file in CSV format
// Ignore print_ functions for complexity
if (myFile) {
fprint_date(myFile, gps);
myFile.print(", “);
myFile.print(”, “);
myFile.print(”, “);
//myFile.print(“PSI”); // Temp PSI placeholder
myFile.print(cooked, 2);
myFile.print(”, “);
//print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 2);
myFile.print(”, “);
//print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
myFile.print(”, “);
//print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 9, 4);
myFile.print(”, “);
//print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);
myFile.print(”, “);
//print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
myFile.print(”, “);
//print_float(gps.f_speed_mph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
myFile.print(”, ");
//print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);


a good way is to get rid of any excessive integers and or replace then with a byte if possible. but you dont really have any...

It may not be the actual sketch, which you should post all of, by the way. The SD library takes a lot of SRAM on its own. The conbination of libraries you are using might just not fit.