Maker.io main logo

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

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‎

attiny_1

 

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

usb_2

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_3

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_4

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_5

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

leds_6

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_7

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

leds_8

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

chip_9

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!‎

serial_10

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

sh_11

Board Outline

board_12

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

hardware_13

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

connect_14

Tadaaaa! All ready for programming!‎

ready_15

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

file_16

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

choose_17

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

upload_18 ‎‎

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

example_19

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

open_20

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

start_21

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

code_22

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

logger_23

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

sleep_24

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

monitor_25

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

dual_26

Example 5: Sleep SPI

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

cycle_27

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

code_28

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

default_29

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

monitor_30

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

制造商零件编号 DEV-19217
SPARKFUN THING PLUS DUAL-PORT LO
SparkFun Electronics
¥243.80
Details
制造商零件编号 WRL-15663
SPARKFUN THING PLUS ESP32 WROOM
SparkFun Electronics
¥183.15
Details
制造商零件编号 U050-006-GY-MAX
CBL USB2.0 A PLUG-MCR B PLUG 6'
Tripp Lite
¥220.84
Details
制造商零件编号 AP8GMCSH4-B
MEM CARD MICROSD 8GB CLASS 4
Apacer Memory America
¥136.43
Details
制造商零件编号 WRL-15574
SPARKFUN THING PLUS - ARTEMIS
SparkFun Electronics
¥183.15
Details
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum