Thing Plus Dual-Port Logging Shield Hookup Guide

Pages
Contributors: Ell C, PaulZC
Favorited Favorite 1

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

SparkFun Thing Plus Dual-Port Logging Shield

DEV-19217
$29.95

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.

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!

ATtiny is the chip towards the bottom of the board in the middle

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.

The USB2241 is the larger chip in the middle of the board.

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.

Programming footprint is in the middle of the back of the board

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.

microSD card opens up to the right side of the board

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.

USB-C port is at the top of the board, facing up

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.

The two LEDS are at the opposite side of the board from the USBC port. ACT is on the left, PWR on the right

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.

I2C Jumper on the back of the board on the right side, just under the SDA and SCL pins

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.

LED jumpers are at the top of the back of the board, next to the mounting

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.

The chip select jumpers are on the back of the board, on the left side, under the SCK pin

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!

The serial jumpers are the top most jumpers on the left side of the back of the board

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.

The shield jumper is at the bottom of the back of the board on the left side of the pads for the USBC connector

Board Outline

Board measures 2.3" by 0.90 inches

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:

Here the Thing Plus has female headers soldered on and the dual port logger shield has male headers soldered on.

Once you've got all your headers properly soldered on, line up the pins and connect your Thing Plus and Shield like so:

Line up the male and female headers and gently press the shield and thing plus together

Tadaaaa! All ready for programming!

Two boards are connected and ready to rock!

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:

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".

Where to find example 1 in the file menu

Having a hard time seeing the details? Click the image for a closer look.

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):

For this example, we're using the Esp32 Thing Plus

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:

Serial Monitor output lists I2C address, Firmware version, etc

Having a hard time seeing the details? Click the image for a closer look.

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:

Where to find example 2 in the file menu

Having a hard time seeing the details? Click the image for a closer look.

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:

Sample output of Example 2

Having a hard time seeing the details? Click the image for a closer look.

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.

Where to find example 3 in the menu

Having a hard time seeing the details? Click the image for a closer look.

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:

Output shows the default mode and then puts the shield into SDIO mode for a USB drive

Having a hard time seeing the details? Click the image for a closer look.

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:

Extra drive pops up as D: for me

Having a hard time seeing the details? Click the image for a closer look.

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:

Where to find Example 4 in the menu

Having a hard time seeing the details? Click the image for a closer look.

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:

Output shows putting the shield into deep sleep, then SDIO mode, then waits 30 seconds

Having a hard time seeing the details? Click the image for a closer look.

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:

Check out that extra USB drive!

Having a hard time seeing the details? Click the image for a closer look.

Example 5: Sleep SPI

Example 5 shows the Sleep cycle for SPI mode. Bring up the example in Arduino:

Where to find Example 5 in the menu

Having a hard time seeing the details? Click the image for a closer look.

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 5 output

Having a hard time seeing the details? Click the image for a closer look.

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:

Where to find Example 6 in the menu

Having a hard time seeing the details? Click the image for a closer look.

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 output

Having a hard time seeing the details? Click the image for a closer look.

Troubleshooting

Resources and Going Further

Need more information? Check out some of the links below:

Check out these other power related tutorials from SparkFun:

LilyPad Basics: Powering Your Project

Learn the options for powering your LilyPad projects, LiPo battery safety and care, and how to calculate and consider power constraints on your projects.

LuMini Ring Hookup Guide

The LuMini Rings (APA102-2020) are the highest resolution LED rings available.

Power Delivery Board - USB-C (Qwiic) Hookup Guide

This guide will go over how to use the USB Type-C Power Delivery Board.

Understanding Thermal Resistance

Discussing what thermal resistance is, how it’s used for thermal management, and how to maximize the life of your project.