The other half of the adalogger FeatherWing is the SD card. The SD card is how we store long term data. While the Feather may have a permanent EEPROM storage, its only a couple hundred bytes - tiny compared to a 2 gig SD card. SD cards are so cheap and easy to get, its an obvious choice for long term storage so we use them for the 'Wing!

The FeatherWing kit doesn't come with an SD card but we carry one in the shop that is guaranteed to work. Pretty much any SD card should work but be aware that some cheap cards are 'fakes' and can cause headaches.

Add mega-storage in a jiffy using this 4 GB micro-SD card. It comes with a SD adapter so you can use it with any of our shields or adapters! Preformatted to FAT so it works out of...
Out of Stock

You'll also need a way to read and write from the SD card. Sometimes you can use your camera and MP3 player - when its plugged in you will be able to see it as a disk. Or you may need an SD card reader. The Wing doesnt have the ability to display the SD card as a 'hard disk' like some MP3 players or games, the Feather does not have the hardware for that, so you will need an external reader!

This is the cutest little microSD card reader/writer - but don't be fooled by its adorableness! It's wicked fast and supports up to 64 GB SDXC cards! Simply slide the card into...
Out of Stock

Formatting under Windows/Mac

If you bought an SD card, chances are it's already pre-formatted with a FAT filesystem. However you may have problems with how the factory formats the card, or if it's an old card it needs to be reformatted. The Arduino SD library we use supports both FAT16 and FAT32 filesystems. If you have a very small SD card, say 8-32 Megabytes you might find it is formatted FAT12 which isnt supported. You'll have to reformat these card. Either way, its always good idea to format the card before using, even if its new! Note that formatting will erase the card so save anything you want first

We strongly recommend you use the official SD card formatter utility - written by the SD association it solves many problems that come with bad formatting!

The official SD formatter is available from https://www.sdcard.org/downloads/formatter_4/

Download it and run it on your computer, there's also a manual linked from that page for use

Basic SD Card Test

The Arduino SD Card library has a built in example that will help you test the Wing and your connections

Open the file listfiles example sketch in the SD library:

This sketch will not write any data to the card, just list the contents. This can be very useful when trying to figure out whether an SD card is supported. Before trying out a new card, please try out this sketch!

Scroll to the line where you see SD.begin() and change the value in the parentheses to match the chip select (CS) pin for your board.

  • On ESP8266, the SD CS pin is on GPIO 15
  • On Atmel M0, M4, 328p or 32u4 it's on GPIO 10
  • On Teensy 3.x it's on GPIO 10
  • On STM32F2/WICED, its on PB5
  • On ESP32, it's on GPIO 33
  • On nRF52832, it's on GPIO 11
  • On nRF52840, it's on GPIO 10

OK, now insert the micro SD card into the FeatherWing and upload the sketch.

Open up the Serial Monitor and you should see a listing of the files and folder layout. The specifics will depend on the card contents, but should look something like:

If you have a bad card, or some other formatting issue, you'll probably see:

It couldn't even initialize the SD card. This can also happen if there's a soldering error or if the card is really damaged

If you're having SD card problems, we suggest using the SD formatter mentioned above first to make sure the card is clean and ready to use!

Next steps!

Once you know the SD card works, check out the SD card library examples, SD library documentation and Notes!

Example logging sketch

If you want to try saving data to the SD card in the simplest sketch, try this example. You can adjust the delay() to set how often analog data is read from pin A0 and saved to the SD card. The red LED will blink if there's an error, and the green LED will blink when data is written to the SD card.

You will need to change the sketch's SD_CS pin to match the SD card's Chip Select pin on your Feather!
https://gist.github.com/ladyada/13efab4022b7358033c7

If you really want to make sure you save every data point, put a

logfile.flush();

right after the logfile.print's however this will cause the adalogger to draw a lot more power, maybe about 3x as much on average (30mA avg rather than about 10mA)

This guide was first published on Sep 06, 2016. It was last updated on Sep 06, 2016.

This page (Using the SD Card) was last updated on Feb 25, 2021.

Text editor powered by tinymce.