NMEA data and some sensor data to SD?

Hello all,
I’ve got a problem with my Arduino code and I don’t have a clue yet how to fix it.
First of all, sorry for my English. I’m trying to give my best.
Second, I’m pretty new in programming. Maybe I made some basic mistakes.

I’m trying to log NMEA data and some sensor data to a SD file. Just log NMEA data or just log sensor data works fine.
But as soon as I put those codes together nothing works anymore. Neither, SD logging nor serial monitor output.
I use some devices from Adafruit, the ultimate GPS breakout, the LSM9DS1 sensor and the MCP9808 sensor.
As I mentioned, I’ve no idea why this is the case.
If this issue is already solved in the forum I’ve failed to see it and would be thankful for a link.

I’ll upload my code (MyLogger). It works for serial monitor output but if I included the SD library nothing works anymore.
I add the two cods which log NMEA data OR the sensor data for better understanding. They both work fine.
The only reason I may see is that the code is quiet large. After compiling I get the message “Low memory available, stability problems may occur”. It uses 89% of SRAM.

ps. I’ve got similar problems with the adafruit_GPS_logger code from the Adafruit GPS library. That’s why I wrote another sketch for NMEA log in the first place.
And I can’t easily chance the SS pin from 10 to something else. It is already soldered on the shield. Put it worked this way in the other sketches

Thanks a lot for your help <3

MyLogger_v.1.0.ino (3.1 KB)

mcp9808_LSM9DS1_Logger_v1.1.ino (3.53 KB)

GPS_logger_v.2.0.ino (1.35 KB)

Please read and follow the instructions in the "How to use this forum" post.

You need to post the minimal code that demonstrates the problem, using code tags ("</>" button), and clearly explain, with examples what "nothing works" means.

But as soon as I put those codes together nothing works anymore.

This is usually because you haven't taken the time to fully understand either program, so the merged program is a mess.

Note: avoid use of Strings. They cause memory problems and program crashes:

String NMEA1;
String NMEA2;

Helpful to say which Arduino you are using !.

The only reason I may see is that the code is quiet large. After compiling I get the message "Low memory available, stability problems may occur". It uses 89% of SRAM.

Not surprised, a largish GPS library, two sensors and an SD library. Most programs that use the SD library will struggle for space on an Arduino UNO etc.

Try an Arduino with more memory perhaps ?

Hello everyone,
sorry for the late response. I was busy changing the code.
I’m using an Arduino UNO. And I would prefer to use the UNO instead of the MEGA.
I tried the old code on an Arduino MEGA and it worked. The only change I made was using hardware serial instead of software serial to connect the GPS module.
I totally agree with you, the Adafruit GPS library is very large and I just used a tiny bit of it. So I avoided to use this library and use an interrupt to read the NMEA Sentence in my new code.
But I see no opportunity to avoid “String” to store NMEA. I thought about a char array first but the length of NMEA sentence changes.
So my first question is: Do you have a good idea to read and save NEMA without using “String”?

The new Code is much smaller works perfectly on the MEGA and fits on the UNO. But it’s still large for the UNO. It uses about 76% of SRAM including the large NEMA string.
Using the UNO I’ve now got the problem that some sentence aren’t completely written. It stops writing the longer sentence at the same number of chars.
For me that sounds like an memory issue again? I just thought about clearing the sensor variable or just declare it in the sensor read/write sup code. Any better ideas?
I already shorted the MCP Library.

Thanks for your thoughts

Ps. @jremington I wasn't able to point one piece of code that makes trubble, sorry

Do you have a good idea to read and save NEMA without using "String"?

Use a zero terminated character array. 83 characters is more than enough.

You only need to recognize and parse $RMC sentences to get the time and position, and it doesn't take much work to decode it. There are many code examples on the web.

You might consider the NeoGPS library, which claims to be the smallest and fastest of them all, and it doesn't require you to save the entire sentence.