I’m using an Artemis Openlog and Neo-M9N GPS board to make a GPS datalogger and have been using one of the SD examples for testing out writing to the SD card. I got that to work then copy/pasted the relevant sections into the code I had written to read the GPS board (which had been working perfectly). Now the SD card won’t initialise. I thought I’d wrecked the SD card so I checked it and I can read/write to it in windows. I formatted it and then copied a small .txt file onto it to make sure and it works fine in windows explorer but it just won’t initiallise. I went over and over the code and there was nothing added which could have messed it up, such as writing to it and not closing the file etc.
I then went back to the code I had working to test the read/write to the SD card and that card doesn’t initialise in the code anymore. I took another SD card and it does. I’m hesitant to try this card in the GPS code as I fear I’ll “wreck” it as well.
I’m wondering if there’s something in the GPS library which could be interfering with the SD card stuff?
There’s nothing in the SF GNSS library that could interfere with your SD card - either the older version of the library or the newer v2.0. The datalogging examples in v2.0 do log to SD card but they do that through the standard Arduino SD library. There is no SD functionality built-in to the GNSS library.
Thanks for the info. I fixed it last night. I re-formatted the SD card using a program I think was called “sdformat”. This allowed that SD card to work in the SD test code.
I went back to my GPS datalogger code and found a silly error. I was closing the file at the end of the main loop (I did this so I could remove the SD card or kill power without corrupting the card) but not re-opening it each time, so it was opened once, written to, closed then repeatedly closed. It obviously didn’t like this. Once I changed this I can now log the GPS data I need to the SD card, so it’s all good. My application was to log GPS speed at at least 10Hz to log my sprinting speed whilst training, looks like it will do that for me.
Only thing is that if the GPS board loses power it takes at least 30 seconds to lock onto satellites again, which is a bummer as I would rather not have it powered up all the time for fear of running the very small lipo down too far.