Yeah sorry, as I said a lack of testing leads to these dumb mistakes. Also "Both" means through the apc220 AND on the SD Card. I need the SD Card to function as an airplane's black box AND I need the information on the ground during the flight.
If all you need to do is 'Log' data the peplace the SD card breakout with an Openlog, it will 'Log' everything that goes ou the serial port. Proabaly smaller than the average SD breakout board too.
I see the project is a CANSAT, if there is a competion involved, do we get a prize too ?
Hmmm I'm not sure if I understand, but if I have "Openlog" in my program it will automatically log everything I send to my serial monitor on my SD Card ??
Also, yes, the prize is a cup so you will win a picture of the cup if we win
You need to slow down, and think - "What can I get rid of, and still fulfill the spec?" and if that proves fruitless, "Can I use a better-suited, better specced, processor?"
char c = GPS.read();
if ((c))
-1 will evaluate as true.
Needs more attention to detail
noodlefish:
Hmmm I'm not sure if I understand, but if I have "Openlog" in my program it will automatically log everything I send to my serial monitor on my SD Card ??
If you were logging data so you are seeing it in the Serial Monitor, when you have your flight you just plug in the Openlog and it records everything that would otherwise have been seen in the Serial Monitor.
noodlefish:
AWOL, as I said, I need to both have the information on mySerial and myFile so I thought this was the easyest way to do so.
But you're not writing the same information, which I would have thought to be important, and anyway, you're not looking for the easiest way, you're looking for the way that suits your resources.
Just out of interest, what was the memory usage before you added the SD library, and what is it now?
Ah, I think I have just worked it out, @noodlefish is participating in the UK 2021 CANSAT competition, hence the use of the APC220 and SD card for logging.
text section exceeds available space in board
Sketch uses 36440 bytes (127%) of program storage space. Maximum is 28672 bytes.
Global variables use 2274 bytes (88%) of dynamic memory, leaving 286 bytes for local variables. Maximum is 2560 bytes.
That's after removing SoftwareSerial and adding the F() macro.
Commenting out SPI.h and Adafruit_Sensor.h didn't help since they are apparently not used.
I don't think the GPS is supposed to be logging, the outbound data is going to the APC220 (guessing here), but that kinda screws with the config messages to the GPS.
I don't think the OP has thought this one through.
I'd just log raw sensor data, and leave the smarts to the ground / post mortem stations, if all that's available is a Pro Micro, 'cos making a dent in that 27% is going to be tough without handcrafted custom code.
The OP said that the SD library tipped the balance, but I'd bet it was pretty close to 100% before that. Time to break out the laptop.
I bet a Teensy 4 would work just great though.
@Johnwasser - did you refactor the Stream stuff in your calculation?
TheMemberFormerlyKnownAsAWOL: @Johnwasser - did you refactor the Stream stuff in your calculation?
I'm not sure I understand the question. Are you suggesting that calling .write() instead of .print() and .println() could avoid loading the Stream functions?
No, sorry I was suggesting putting the debug / serial log (radio) / SD file prints into a single function, and passing a reference to the appropriate Stream, to reduce duplication of code.
I'll give it a shot this afternoon - it's still not going to make much of a dent on the 27% though.