Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you. Additionally, some links direct to products from our own brand, DIYables .
About Micro SD Card Module
If you do not know about Micro SD Card Module (pinout, how it works, how to program ...), learn about them in the Arduino - Micro SD Card tutorial.
How It Works
The key-value pairs are pre-stored on the Micro SD Card according to the following format:
Each key-value pair is on one line. In another word, each key-value pair is separated from others by a newline character
The key and value are separated by a = character
Arduino code will search the key and find the corresponding value, and save the value to a variable. The variable type can be int, float, or String
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
If you use an Ethernet shield or any shield that has a Micro SD Card Holder, you do not need to use the Micro SD Card Module. You just need to insert the Micro SD Card to the Micro SD Card Holder on the shield.
How To read config to variables
Create config.txt file on your PC via Notepad or Notepad++
Copy below key-value pairs and paste it to the config.txt:
The Serial Monitor shows the values from variables that is identical to the values saved on the micro SD Card
Now you can modify the code to add more variables.
※ NOTE THAT:
The above code does not care about the order of key-value pairs. It will search for the key from the beginning to the end of the file until the key is matched.
Video Tutorial
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.
You can share the link of this tutorial anywhere. Howerver, please do not copy the content to share on other websites. We took a lot of time and effort to create the content of this tutorial, please respect our work!