Thing Plus Dual-Port Logging Shield Hookup Guide
2022-08-16 | By SparkFun Electronics
License: See Original Project
Courtesy of SparkFun
Guide by ELL C, PAULZC
Introduction
The Thing Plus Dual-Port Logging Shield is a Thing Plus/Feather compatible board that lets you ‎access your microSD card over both SPI and USB-C! It is designed to be mounted on or under one ‎of our Thing Plus boards. You can log data to and read data from your microSD card over SPI as ‎usual, using your favorite Arduino SD library. But you can also connect it to your computer via USB-‎C and read and write files at up to 35 MBytes/second! The write speed is card-dependent but, in ‎our tests, we've routinely seen write speeds around 20MB/s. No more removing the microSD to ‎read your data!‎
SparkFun Thing Plus Dual-Port Logging Shield
Required Materials
To follow along with this tutorial, you will need the following materials. You may not need everything ‎though depending on what you have. Add it to your cart, read through the guide, and adjust the cart ‎as necessary.‎
Thing Plus Dual-Port Logging Shield Wish List SparkFun Wish List
Suggested Reading
If you aren’t familiar with the following concepts, we recommend checking out these tutorials before ‎continuing.‎
Voltage, Current, Resistance, and Ohm's Law: Learn about Ohm's Law, one of the most ‎fundamental equations in all electrical engineering.‎
Battery Technologies: The basics behind the batteries used in portable electronic devices: ‎LiPo, NiMH, coin cells, and alkaline.‎
Alternating Current (AC) vs. Direct Current (DC): Learn the differences between AC ‎and DC, the history, different ways to generate AC and DC, and examples of applications.‎
Hardware Overview
ATtiny841‎
The Dual-Port Logging Shield has an ATtiny841 microcontroller on it to act as an arbiter:‎
If you power up your Thing Plus, the ATtiny841 will automatically put the Dual-Port Logging ‎Shield into SPI mode, so your Arduino code can access the microSD card as normal.
If you power the Shield from your computer by connecting it via USB-C, the ATtiny841 will put ‎the Shield into SDIO "thumb drive" mode. Your computer can then read and write data really ‎quickly!‎
If you have both your Thing Plus powered up - and have your computer connected - then you ‎can switch between the two modes by giving the ATtiny841 some very simple commands over ‎I2C!‎
You can configure the ATtiny to automatically default to SPI mode or SDIO "thumb drive" mode if ‎both power sources are powered up simultaneously. It's your choice!‎ USB2241‎
USB2241‎
The USB224x is a fully integrated, single chip solution capable of ultra-high-performance operation. ‎Average sustained transfer rates exceeding 35 MB/s are possible if the media and host can support ‎those rates. The USB224 includes provisions to read/write secure media formats.‎
Programming Footprint
Advanced users can change the shield's USB Vendor ID (VID), Product ID (PID), Manufacturer ‎Name etc. by adding an optional 24C04 (512x8) EEPROM and configuring it with Microchip's ‎USBDM tool.‎
microSD Card Slot
The USB2241, which provides the USB interface, supports FAT32, exFAT, and NTFS on cards up ‎to and including 32GB. Cards larger than 32GB are not supported.‎
USB-C
While attached to the Thing Plus, you can log data to and read data from your microSD card over ‎SPI as usual. But you can also connect the shield directly to your computer via the USB-C port and ‎read/write files directly.‎
LEDs
There are two LEDs on the front of the board; PWR and ACT. PWR should be self-explanatory - it ‎is the LED that lights up when there is power to the shield. ACT stands for activity monitor - this ‎shows data movement on the shield in SDIO "thumb drive" mode.‎
Jumpers
I2C
These split pads are closed by default to enable the shield's I2C pull-up resistors. Please be aware ‎that, with the pull-ups enabled, the shield's VCC will try to back-feed power to the Thing Plus ‎through the pull-ups on both boards. Opening the jumpers will prevent this.‎
The default (unshifted) I2C address is 0x51 but is programmable via the code.‎
LEDS
Should you wish to disable either of the LEDs on the front of the board, cut the trace on the ‎appropriate jumper.‎
Chip Select
By default, the microSD SPI chip select signal is connected to pin A5 on the Thing Plus. If you are ‎already using that pin for something else, you can open the A5 jumper and close A4 or A3 instead.‎
Serial
The ATtiny841 has a Serial (UART) interface but we only make limited use of it in the standard ‎shield firmware. If you want to, you can connect the ATtiny serial pins to the standard Thing Plus ‎Serial pins by closing the RXD and TXD jumpers. You will then see some diagnostic messages at ‎‎9600 baud when the ATtiny powers up. These jumpers are really there for any advanced users who ‎want to write their own firmware for the ATtiny!‎
SH
By default, the USB-C shield is connected to the shield GND (0V). You can isolate the shield if you ‎want to by opening the SH jumper.‎
Board Outline
Hardware Hookup
In order to use your Dual Port Logger as a shield, you'll need to solder some headers on. My ‎ESP32 Thing Plus has female headers already soldered on, so for this tutorial, we've used male ‎headers on the Dual Port Logging Shield like so:‎
Once you've got all your headers properly soldered on, line up the pins and connect your Thing ‎Plus and Shield like so:‎
Tadaaaa! All ready for programming!‎
Software Installation
Note: The Dual Port Logging Shield Arduino examples assume you are using the latest version of ‎the Arduino IDE on your desktop. If this is your first-time using Arduino, please review the following ‎tutorials. ‎
The SparkFun Dual-Port Logging Shield Arduino Library can be downloaded with the Arduino ‎library manager by searching 'SparkFun Dual-Port Logging Shield Arduino Library' or you can ‎grab the zip from here or from the GitHub repository to manually install:‎
SPARKFUN DUAL-PORT LOGGING SHIELD ARDUINO LIBRARY (ZIP)‎
Example 1: Read I2C Address/Firmware Version
Now that we've got our hardware sorted out, let's have a look at some examples.‎
In this first example, we're just going to report out on our I2C address and Firmware Version.‎
To start, plug your Thing Plus with its Dual Port Logging Shield into your computer, open a new ‎Arduino sketch, and click "File > Examples > SparkFun Dual-Port Logging Shield Arduino ‎Library > Example1_Read_I2CAddress_FirmwareVersion_DefaultMode."‎
Note: If you are using an Artemis Thing Plus, you will need to change Wire to Wire1 in the example ‎code!‎
Choose the correct Board and Port (as seen here):‎
And then upload the code to your Thing Plus. When you open the Serial Monitor with the correct ‎baud, you should see something like the following:‎
‎‎
Example 2: Set I2C Address
Example 2 shows you how to change the I2C address of the shield. Let's bring it up in Arduino:‎
Note: If you are using an Artemis Thing Plus, you will need to change Wire to Wire1 in the example ‎code!‎
Make sure you select the correct board and port, and then smash that upload button. Once the ‎code is compiled and uploaded, go ahead an open the Serial Monitor. You should see something ‎like the following:‎
‎Example 3: Change Mode
There are different modes available for the Dual Port Logging Shield. Example three shows you ‎how to change between SDIO (thumb drive) and SPI modes!‎
To start, let's pull up example 3 in Arduino.‎
Note: If you are using an Artemis Thing Plus, you will need to change Wire to Wire1 in the example ‎code. You'll also need to change the Chip Select - for the Artemis Thing Plus, A5 is D24.‎
Make sure you've chosen the correct board and port (as seen in example 1) and then upload the ‎code to your Thing Plus. When you open the Serial Monitor with the correct baud, you should see ‎something like the following:‎
Make sure your Dual Port Logger is ALSO plugged in, and when the example runs, you'll see an ‎additional drive pop up like so:‎
Example 4: Sleep SDIO
In this example, we're going to look at the deep sleep functionality, and like Example 3, this example ‎will also bring up the Dual Port Logging Shield as a drive. Go ahead and bring up example 4 in ‎Arduino:‎
Note: If you are using an Artemis Thing Plus, you will need to change Wire to Wire1 in the example ‎code!‎
Make sure you've chosen the correct board and port (as seen in example 1) and then upload the ‎code to your Thing Plus. When you open the Serial Monitor with the correct baud, you should see ‎something like the following:‎
Make sure your Dual Port Logger is ALSO plugged in, and when the example runs, you'll see an ‎additional drive pop up like so:‎
Example 5: Sleep SPI
Example 5 shows the Sleep cycle for SPI mode. Bring up the example in Arduino:‎
Note: If you are using an Artemis Thing Plus, you will need to change Wire to Wire1 in the example ‎code!‎
Make sure you've chosen the correct board and port (as seen in example 1) and then upload the ‎code to your Thing Plus. When you open the Serial Monitor with the correct baud, you should see ‎something like the following:‎
Example 6: Set Default Mode
If you run into a snag, setting things back to default is always a good way to go. This example will ‎do just that!‎
Bring it on up in Arduino:‎
Note: If you are using an Artemis Thing Plus, you will need to change Wire to Wire1 in the example ‎code!‎
Make sure you've chosen the correct board and port (as seen in example 1) and then upload the ‎code to your Thing Plus. When you open the Serial Monitor with the correct baud, you should see ‎something like the following:‎
Troubleshooting
‎Need help? ‎
If your product is not working as you expected or you need technical assistance or information, ‎head on over to the SparkFun Technical Assistance page for some initial troubleshooting. ‎
If you don't find what you need there, the SparkFun Forums are a great place to find and ask for ‎help. If this is your first visit, you'll need to create a Forum Account to search product forums and ‎post questions.‎
Resources and Going Further
Need more information? Check out some of the links below:‎

