Go Down

Topic: Why it is a bad idea to use String with SD card (Read 399 times) previous topic - next topic

samalgerie25

It seems a bad idea to use string when I want to write to SD card, but I need to save names as part of data, so I would like to the reason and if there is any suggestions to avoid such problem?

Nick_Pyner

#1
Jun 19, 2017, 05:37 pm Last Edit: Jun 19, 2017, 05:38 pm by Nick_Pyner
It IS a bad idea. It is not the SD card that is the problem, it is a bad idea to use the String class with Arduinos. You will find plenty info on this but, essentially, Arduinos can't handle them and they (eventually) choke up the memory. The alternatives to avoid Strings depends on what you are doing. It can be as simple as myFile.printing the data that you gathered to make the Strings in the first place. This also saves you from the time wasting exercise of assembling the String.

Also, see dtostrf.

Go Up