Quantcast
Channel: SparkFun Tutorials
Viewing all 1123 articles
Browse latest View live

SparkFun Qwiic Dual Solid State Relay Hookup Guide

$
0
0

SparkFun Qwiic Dual Solid State Relay Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1187

Introduction

Introducing the SparkFun Qwiic Dual Solid State Relay. The Qwiic Dual Solid State Relay sports two solid state relays rated up to 25A at 240 VAC so you can switch some serious power with this board all from a single Qwiic connector attached to an Arduino or other low-powered microcontroller. The Dual Solid State Relay is the little sibling of our Qwiic Quad Solid State Relay Kit intended for users looking for a smaller solid state relay option.

SparkFun Qwiic Dual Solid State Relay

SparkFun Qwiic Dual Solid State Relay

COM-16810
$149.95

In this tutorial we'll detail the hardware on the Dual Solid State Relay, how to connect it to an Arduino or other microcontroller and how to use the examples included in our Arduino library and Python package.

Required Materials

You will need a microcontroller to control the Qwiic Dual Solid State Relay in order to follow along with this tutorial. Below are a few options that come Qwiic-enabled out of the box:

SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
5
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
5
SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

DEV-15795
$19.95
1
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
4

We also have a Python package available for this and our other Qwiic Relay boards so you can use a Raspberry Pi as your controller as well. A few Pi's we carry are listed below:

Raspberry Pi 3 B+

Raspberry Pi 3 B+

DEV-14643
$35.00
31
Raspberry Pi 4 Model B (4 GB)

Raspberry Pi 4 Model B (4 GB)

DEV-15447
$55.00
9
Raspberry Pi 4 Model B (2 GB)

Raspberry Pi 4 Model B (2 GB)

DEV-15446
$35.00
2
SparkFun Raspberry Pi 4 Desktop Kit - 4GB

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

KIT-16386

If your chosen microcontroller is not already Qwiic-enabled, you can add that functionality with one of the following items:

SparkFun Qwiic Shield for Arduino

SparkFun Qwiic Shield for Arduino

DEV-14352
$6.95
4
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic pHAT v2.0 for Raspberry Pi

SparkFun Qwiic pHAT v2.0 for Raspberry Pi

DEV-15945
$5.95
1
SparkFun Qwiic SHIM for Raspberry Pi

SparkFun Qwiic SHIM for Raspberry Pi

DEV-15794
5

You will also need at least one Qwiic cable to connect your Qwiic Dual Solid State Relay to your microcontroller:

Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95

Required Tools

With the Qwiic system, soldering is not required to use the Qwiic Dual Solid State Relay but you will need a pair of wire strippers and a screwdriver to assemble your AC load.

Self-Adjusting Wire Strippers

Self-Adjusting Wire Strippers

TOL-14872
$16.95
2
Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$3.95
5
SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3
Wire Strippers - 20-30AWG

Wire Strippers - 20-30AWG

TOL-15220
$10.95
1

Suggested Reading

If you aren't familiar with the Qwiic system, we recommend reading here for an overview:

Qwiic Connect System

We would also recommend reading through the following tutorials if you are not familiar with the concepts covered in them:

Serial Communication

Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!

Working with Wire

How to strip, crimp, and work with wire.

Electric Power

An overview of electric power, the rate of energy transfer. We'll talk definition of power, watts, equations, and power ratings. 1.21 gigawatts of tutorial fun!

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Hardware Overview

The SparkFun Qwiic Dual Solid State Relay is built on a similar design to our Qwiic Quad Relay and uses an ATTiny84 to act as the "brain" for the board. To allow for faster and quieter switching of the load, this board uses solid state relays instead of electromechanical relays. The ATTiny84 comes pre-programmed with firmware to accept commands via I2C from an attached microcontroller so you can keep other I/O pins free for other uses.

In this section we'll cover the hardware present on the Qwiic Dual Solid State Relay and note some of the unique functionality of the components.

Solid State vs Mechanical Relays

Let's talk briefly about two types of relays before we get into the details on the solid state relays included with the kit. A relay is a special kind of switch that has a switching mechanism inside isolated from the switch. This allows us to control the high-output side of the relay from a low-power input like a microcontroller.

Now, when it comes to the comparing an electromechanical relay (EMR) and a solid state relay (SSR), the primary difference is an EMR uses an electromagnetic field to physically close a mechanical switch inside the relay where an SSR uses a semiconductor like a MOSFET or an opto-isolator to switch the load on and off. This allows the SSR to switch at much higher speeds than an EMR and also increases their durability since there are no moving parts inside. Theoretically, and if used within spec, an SSR can last forever where EMR's are designed with an expected lifetime. EMR's are typically cheaper and also can allow multiple loads on a single relay (if it has multiple contacts) where SSR's are limited to a single load.

There is a lot of discussion out there about which type of relay is best but it really comes down to two things: budget and versatility. This brief outline covers the very basics of electromechanical and solid state relays so with some more research you can decide which type of relay will be best suited for your project. For a short yet informative overview of electromechanical relays, check out this section of our Qwiic Quad Relay Hookup Guide.

SSRF-240D25 Solid State Relays

The board includes two PCB-mount SSRF-240D25 solid state relays from Tyco Electronics. Let's cover some characteristics from the relay's datasheet so you know what to expect from them and the Dual Solid State Relay.

CharacteristicRange
Input Voltage3V-15V
Supply Current15mA @5V (20 mA @3.3V)
Load Voltage12-280VAC
Max Current (Through Relay) 25A (@240 VAC)

Photo highlighting relays and screw terminals
Heads up! The 25A rating for these relays is for forced air cooling installations. Without forced air cooling, a max of 10A continuous draw is recommended per the datasheet.

The relays use the Zero Voltage Cross trigger method so when operating on a 60Hz AC carrier signal you can switch the relays up to 120 times per second! Read on in the Arduino Examples section where we'll demonstrate how to do that using a PWM signal.

Both relays' outputs are tied to their own 2-pin screw terminal so all you need to connect your load is a pair of wire strippers and a screwdriver. We've also included two footprints so you can solder 5mm LEDs to act as indicators for when the load is powered.

One last note before we move on from the relays. The relay control circuit is designed for a Normally Open circuit only. This means your load is normally off until the relay is switched on. For more information on how this circuit is configured, check out the schematic and the relay datasheet.

ATTiny84

The ATTiny84 comes pre-programmed with firmware to control the two relays on the board via I2C commands. The ATTiny84's I2C address is 0x0A by default. There is also a 2x3 header broken out on the back of the board for programming the ATTiny84. This is primarily used for programming during manufacturing but you can re-program the IC if you would like. You an download and modify the firmware from the Hardware GitHub repo.

Photo highlighting ATTiny84 IC
Need help re-programming the ATTiny84? Take a look at our Tiny AVR Programmer Hookup Guide and our Re-Programming the LilyTiny/LilyTwinkle Tutorial.

Power

Power for the board is provided either via the Qwiic interface or through the labeled 3.3V and GND pins broken out on the bottom left of the board.

Qwiic and I2C Interface

The I2C interface is broken out to two Qwiic connectors on either side of the board as well as 0.1"-spaced header pins for those who prefer a more traditional soldered connection. We have also broken out the ATTiny84's reset pin in case you would like to reset the IC without resetting your entire circuit.

Photo highlighting Qwiic and I2C Interface pins

Jumpers

If you have never worked with solder jumpers and PCB traces before or would like a quick refresher, check out our How to Work with Solder Jumpers and PCB Traces tutorial for detailed instructions and tips.

There are three jumpers on the Qwiic Dual Relay labeled PWR, I2C and ADR. The PWR jumper enables the Power LED, the I2C jumper pulls the SDA and SCL lines to 3.3V and the ADR jumper sets the I2C address of the ATTiny84.

Photo highlighting solder jumpers

Power Jumper

The power jumper (labeled PWR) controls voltage to the power LED on the board. This jumper is closed by default. To disable the power LED, simply open the jumper by severing the trace in between the two pads. Disabling the power LED can help reduce the total current draw of the board.

Address Jumper

The address jumper (labeled ADR) sets the I2C address for the ATTiny84. The jumper is closed by default with the address set to 0x0A. Opening the jumper will change the address to 0x0B.

I2C Jumper

The I2C Jumper pulls the SDA and SCL lines to 3.3V via two 4.7K Ohm resistors. The jumper is closed by default. Open this jumper if you have multiple sensors connected to the bus with their own pull-up resistors enabled to avoid causing the parallel equivalent resistance creating too strong of a pull-up for the bus to operate correctly. As a general rule, disable all but one pair of pull-up resistors if multiple devices are connected to the bus.

Note: If you disable the pull-up resistors on your Qwiic Dual Relay, make sure the rest of your I2C bus is operating at 3.3V Logic. If your bus is running at a different logic, you will need to shift that logic to 3.3V to avoid damaging the ATTiny84 on this board.

Board Dimensions

The Qwiic Dual Solid State Relay measures 3.55" x 2.65" (90.17mm x 67.31mm) and includes nine mounting holes that fit a 4-40 screw so you have plenty of mounting options.

Qwiic Dual Solid State Relay Board Dimensions
Having trouble seeing the detail in the dimensional drawing? Click on the photo for a larger view

With all the hardware included with the Qwiic Dual Solid State Relay covered, now it's time to connect it to your microcontroller and assemble your high voltage load circuit.

Hardware Assembly

With SparkFun's Qwiic ecosystem, connecting the Dual Solid State Relay to your circuit is a breeze! Before we connect the Dual SSR to your microcontroller circuit, we'll want to prepare and assembly our AC load(s) and connect them to the screw terminals for each relay.

Output Load Assembly

Next up we'll want to prepare our AC load we are controlling with the relays. This assembly requires you to cut and strip wire for your AC load. If you need help or tips for working with wire take a look at this tutorial:

Working with Wire

February 8, 2013

How to strip, crimp, and work with wire.

You'll have to cut and strip one of the wires on your load AC line and then connect the cut ends to the relay you intend to use with your load. Make sure the cable is NOT plugged into the wall as you cut into the wire. After your wire is cut and stripped, connect the ends to the screw terminal for one of the relays and use a screwdriver to tighten them securely. Repeat the process for your second AC load.

Connecting to Microcontroller

Once the AC side of your circuit is assembled, we can go ahead and plug everything in. Plug one end of a Qwiic cable into your Relay board and the other into the Qwiic connector on your microcontroller. If your chosen microcontroller is not Qwiic-enabled, you can use something like this Qwiic adapter cable to make the proper connections to your microcontroller's I2C pins.

Fully assembled Relay circuit (only one relay is in use here)
Having trouble seeing the detail in the image? Click on it for a larger view!

Alternatively, you can use the PTH pins broken out on the board but you will need to solder to them for a proper connection. If you are not familiar with through-hole soldering take a look at this tutorial:

How to Solder: Through-Hole Soldering

September 19, 2013

This tutorial covers everything you need to know about through-hole soldering.

Now that our Qwiic Dual Solid State Relay connected to the microcontroller and the A/C load(s) is prepared and connected securely to a relay, it's time to upload some code to switch it on and off.

Qwiic Relay Arduino Library

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

The SparkFun Qwiic Relay Arduino Library works with all SparkFun Qwiic Relay boards to help you use your Qwiic Relay to its full functionality. You can click the link below to download the file or navigate through the Arduino Library Manager by searching SparkFun Qwiic Relay. You can also go the Github page and get it directly.

Library Functions

The list below outlines all of the functions of the Qwiic Relay library along with short descriptions of what they do. The examples cover nearly all of the functions so we recommend referring to them for help integrating the functions into your own code.

These functions will work with all SparkFun Qwiic Relay boards.

  • bool begin(TwoWire &wirePort = Wire); - Initialize the Qwiic Relay on the I2C bus
  • float singleRelayVersion(); - Returns the version number of the firmware present on your relay board.
  • void turnRelayOn(uint8_t relay); - Turn the given relay on. For example, turnRelayOn(1); will toggle the first relay.
  • void turnRelayOff(uint8_t relay); - Turn the selected relay off. Similar to the above function, select values between 1 and 4 to turn the chosen relay off.
  • void toggleRelay(uint8_relay) - Toggles the selected relay to the opposite state. The function first checks the status of the relay and is toggled to either on or off depending on what the status check returns.
  • void turnAllRelaysOn(); - Turns all relays on the board on.
  • void turnAllRelaysOff(); - Turns all relays on the board off.
  • void toggleAllRelays(); - Toggles all relays on the board to the opposite state.
  • uint8_t getState(uint8_t relay); - Returns the status of the selected relay. Returns 1 if on or 0 if off.
  • bool changeAddress(uint8_t newAddress); - Changes the I2C address of the Qwiic Relay. The new address is written to the memory location in EEPROM that determines the address.

The below function is intended for the Qwiic Solid State Relay boards only. It will not work on either of the Qwiic Mechanical Relay boards.

  • bool setSlowPWM(uint8_t relay, uint8_t pwmValue); - Starts a slow PWM (1Hz) with a range from 0-120 for the selected relay. The PWM range is limited to 0-120 as this is the maximum PWM resolution for Zero-crossing SSR's at 60Hz. Setting pwmValue to 120 will give you 100% duty cycle and continuously keep the selected relay switched on.

Arduino Examples

The examples included with the SparkFun Qwiic Relay Arduino Library work with all Qwiic Relay boards with one exception. Example 7 - Slow PWM was added specifically for the two Qwiic Solid State Relay boards to demonstrate how to use the setSlowPWM(uint8_t relay, uint8_t pwmValue); function. As mentioned in the previous section, this function will only work on the SSR boards and not the EMR boards. In this section we'll explore this example to explain how it works and how to modify it.

Also, take note that depending on which Qwiic Relay board you are using, you'll need to alter the I2C address definition in the beginning of all of the examples. Below you can see the proper definition for the default address on the Qwiic Dual Solid State Relay:

language:c
#define RELAY_ADDR 0x0A

If you have altered the ADR jumper or changed the I2C address using the bool changeAddress(uint8_t newAddress); function, adjust the above definition accordingly.

One last note before we move into the example. This example was originally written for the Quad Solid State Relay Kit and defines the relay object, Qwiic_Relay, as quadRelay(RELAY_ADDR); which may be a bit confusing if you are not using that kit. The code will work just fine with that object definition but if you would prefer, you can alter that object to something else. If you do alter this definition, you will need to replace that object call in each function that uses the old one. The code below demonstrates these modifications to Example 7.

Example 7 - Slow PWM

If you are not familiar with how Pulse Width Modulation works or what we mean by "duty cycle", head on over to our Pulse Width Modulation Tutorial for a detailed introduction to how this type of signal works.

This example generates a Pulse Width Modulation (PWM) signal from the ATTiny84 on the board to quickly switch a selected relay on and off. Note, the code below is NOT identical to Example7_Slow_PWM. This example was originally written for the Qwiic Quad Solid State Relay Kit and sets slowPWM values for four relays so we've included a modified version below that sets up only two relays and also uses the default I2C address for the Dual Solid State Relay.

You can copy the code below and paste it into a new Arduino sketch or, if you you prefer, you can open the default example in Arduino by navigating to File>Examples>SparkFun Qwiic Relay Arduino Library>Example7_Slow_PWM. Next, open the Tools menu and select your board (in our case, Arduino Uno) and the correct Port your board enumerated on.

language:c
#include <Wire.h>
#include "SparkFun_Qwiic_Relay.h"

#define RELAY_ADDR 0x0A // Alternate address 0x0B


Qwiic_Relay dualRelay(RELAY_ADDR); 

void setup()
{
  Wire.begin(); 
  Serial.begin(115200);

  // Let's make sure the hardware is set up correctly.
  if(!dualRelay.begin())
    Serial.println("Check connections to Qwiic Relay.");
  else
    Serial.println("Ready to flip some switches.");

  Serial.println("Let's turn each relay on, one at a time.");
  // To turn on a relay give the function the number you want to turn on (or
  // off).

 dualRelay.setSlowPWM(1, 75);
 dualRelay.setSlowPWM(2, 75);
 Serial.println(dualRelay.getSlowPWM(1));
 Serial.println(dualRelay.getSlowPWM(2));


}

void loop()
{
}

Upload the code and open your serial monitor with the baud set to 115200. The code prints out whether or not the initialization of the Qwiic Dual SSR was successful and then prints the PWM value for each relay set using the setSlowPWM(); function. Let's take a closer look at the code.

The code sets up each relay to run at a default PWM value of 75 (62.5% duty-cycle). Try playing around with the PWM values set in the setSlowPWM(); function for each relay to see how it affects the behavior of your load(s).

language:c
// To turn on a relay give the function the number you want to turn on (or
// off).
quadRelay.setSlowPWM(1, 75);
quadRelay.setSlowPWM(2, 75);

Note, as we mentioned in the previous section, the PWM resolution is capped at 120 since the relay cannot switch more times than that in one second on a 60Hz signal.

The code also demonstrates how to use the getSlowPWM(); function by printing out the PWM value set for each relay:

language:c
Serial.println(quadRelay.getSlowPWM(1));
Serial.println(quadRelay.getSlowPWM(2));

If Arduino isn't your jam, head on to the next section where we cover the Python package for this and our other Qwiic Relay boards.

Qwiic Relay Python Package

Note: This example assumes you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi, please checkout our tutorial on Python Programming with the Raspberry Pi and the Raspberry Pi SPI and I2C Tutorial.

We've written a Python package to control the Qwiic Relay family including the Qwiic Dual Solid State Relay. You can install the sparkfun-qwiic-relay Python package hosted by PyPi through a command interface. If you prefer to manually download and build the libraries from the GitHub repository, you can download the package by clicking the button below:

(*Please be aware of any package dependencies. You can also check out the repository documentation page, hosted on Read the Docs.)

Installation

Note: Don't forget to double check that the hardware I2C connection is enabled on your Raspberry Pi or other single board computer. The Raspberry Pi tutorials linked in the note above cover how to enable the Pi's I2C bus.

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-relay package. On systems that support PyPi installation via pip3 (use pip for Python 2) is simple using the following commands:

For all users (Note: the user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic-relay

For the current user:

language:bash
pip3 install sparkfun-qwiic-relay

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line (use python for Python 2):

language:bash
python3 setup.py install

To build a package for use with pip3:

language:bash
python3 setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip3.

language:bash
cd dist
pip3 install sparkfun_qwiic_relay-<version>.tar.gz

Dependencies

This Python package has a few dependencies in the code, listed below:

language:python
from __future__ import print_function
import math
import qwiic_i2c

Function Overview

For a full overview of all the functions included with the Qwiic Relay Py package, head on over to the ReadtheDocs page.

Python Examples

Now that you have the Qwiic Relay Py package installed, it's time to check out the examples included with the package.

Qwiic_Relay_ex1 - The Basics

This example demonstrates the basics of turning relays on and off and reading relays' statuses. The code initializes the Dual SSR on the I2C bus and steps through the different ways to turn both relays on and off and shows how to read the status of both relays.

The example was written to work by default with the Qwiic Quad Relay Kit so we'll need to modify the I2C address call and we'll also want to remove references to a third and fourth relay. The code below is NOT the same as qwiic_relay_ex1.py and has been modified to work with the Dual SSR board. Copy the code below or you can open the example from your install of the Qwiic Relay Python package:

language:python
from __future__ import print_function
import qwiic_relay
import time
import sys


QUAD_RELAY = 0x6D
SINGLE_RELAY = 0x18
QUAD_SOLID_STATE_RELAY = 0x08
DUAL_SOLID_STATE_RELAY = 0x0A

#Be sure to initialize your relay with the proper address.
myRelays = qwiic_relay.QwiicRelay(DUAL_SOLID_STATE_RELAY)

def runExample():

    print("\nSparkFun Qwiic Relay Example 1\n")

    if myRelays.begin() == False:
        print("The Qwiic Relay isn't connected to the system. Please check your connection", \
            file=sys.stderr)
        return

    #Turn on relays one and two
    myRelays.set_relay_on(1)
    myRelays.set_relay_on(2)
    time.sleep(1)

    #Print the status of all relays
    for relayNum in range(2):
        current_status = None
        if myRelays.get_relay_state(relayNum) is True:
            current_status = "On"
        else:
            current_status = "Off"
        print("Status 1: " + current_status + "\n")

    #Turn off 1 and turn on 2
    myRelays.set_relay_off(1)
    myRelays.set_relay_on(2)
    time.sleep(1)


    #Turn all relays on, then turn them all off
    myRelays.set_all_relays_on()
    time.sleep(1)

    myRelays.set_all_relays_off()



if __name__ == '__main__':
    try:
        runExample()
    except (KeyboardInterrupt, SystemExit) as exErr:
        print("\nEnding Example 1")
        sys.exit(0)

Example 2 - Slow PWM

The second example included with the Python package demonstrates how to use the set_slow_pwm() function. The example starts just like the first by initializing the Dual SSR on the I2C bus and then sets the PWM duty-cycle for each relay and uses the get_slow_pwm() function to print the PWM value set for each relay.

Just like Example 1, this was written to work by default with the Qwiic Quad Relay Kit so modify the I2C address call and remove references to a third and fourth relay like above. Similarly, the code below is NOT the same as qwiic_relay_ex2.py and has been modified to work with the Dual SSR board. Copy the code below or you can open the example from your install of the Qwiic Relay Python package and modify it to work with your Dual SSR:

language:python
from __future__ import print_function
import qwiic_relay
import time
import sys

QUAD_RELAY = 0x6D
SINGLE_RELAY = 0x18
QUAD_SOLID_STATE_RELAY = 0x08
DUAL_SOLID_STATE_RELAY = 0x0A

#Be sure to initialize your relay with the proper address.
myRelays = qwiic_relay.QwiicRelay(DUAL_SOLID_STATE_RELAY)

def runExample():

    print("\nSparkFun Qwiic Relay Example 2\n")

    if myRelays.begin() == False:
        print("The Qwiic Relay isn't connected to the system. Please check your connection", \
            file=sys.stderr)
        return

    #Note that our range is 0-120 for setting a PWM value as there are only 120 times where the zero crossing relay can switch in one second

    myRelays.set_slow_pwm(1, 30) #25% duty cycle
    myRelays.set_slow_pwm(2, 60) #50% duty cycle

    #Print out our PWM values 
    for relayNum in range(1, 5):
        pwmValue = myRelays.get_slow_pwm(relayNum)
        print("PWM Value for relay " + str(relayNum) + ": " + str(pwmValue))
    #Let the slow PWM run for a while
    time.sleep(15)


    #Set all relays off 
    myRelays.set_slow_pwm(1, 0)
    myRelays.set_slow_pwm(2, 0)

if __name__ == '__main__':
    try:
        runExample()
    except (KeyboardInterrupt, SystemExit) as exErr:
        print("\nEnding Example 1")
        sys.exit(0)

Each relay is set to a different duty cycle to demonstrate how that affects the behavior of the load and will run for 15 seconds. Want your relay to pulse at a 50% duty cycle? Set the slow PWM value to 60. Note: Just like the Arduino Library, the PWM resolution is limited to 0-120 since there are only 120 times where the zero crossing relay can switch in one second.

That's all for the basics of our Python package! Try using the various functions included here to write your own code for your next relay project.

Resources and Going Further

For more information, take a look through the resources below:

Looking for inspiration for your next power control project? Check out these other Power tutorials from SparkFun:

Single Supply Logic Level Converter Hookup Guide

The Single Supply Logic Converter allows you to bi-directionally translate signals from a 5V or 3.3V microcontroller without the need for a second power supply! The board provides an output for both 5V and 3.3V to power your sensors. It is equipped with a PTH resistor footprint for the option to adjust the voltage regulator on the low side of the TXB0104 for 2.5V or 1.8V devices.

LuMini 8x8 Matrix Hookup Guide

The LuMini 8x8 Matrix (APA102-2020) are the highest resolution LED matrix available.

Beginner Parts Kit Identification Guide

The essential parts for beginning (or even experienced) hobbyists that gives you all of the basic through-hole components you will need to get started playing with embedded projects. We'll identify a few parts in the kit and provide a few basic circuits to get started!

LiPo Charger Plus Hookup Guide

This tutorial shows you how to hook up and use the SparkFun LiPo Charger Plus board.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado


The ClockClock Project

$
0
0

The ClockClock Project a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1299

Introduction

What time is it?! It's time for an awesome Alchitry project, that's what! In this tutorial I’m going to walk you through how I built a ClockClock using the Alchitry Au to control all the motors.

Image of the clock clock on the wall

What is a ClockClock? It is simply a clock made of clocks! The idea is to use many analog style clocks together to form the digits of the time. So meta.

First, let me start by saying this wasn’t my original idea. I came across this concept a few years ago and always thought it would be a great demo FPGA project since it requires so many control signals. The original clock can be found here.

There are a couple reasons this project makes such a great FPGA demo project. First, the clock requires 48 stepper motors. There are 24 “clocks” and each one has two independent hands. Using a standard step/direction stepper driver means you need two control signals per motor or 96 outputs. I wanted to be able to disable the drivers when the clock was stationary to save power. This added four more outputs (one for each “digit” of the clock). I also wanted to use an Arduino to generate the animations as it would be much easier to do this in code than hardware. To talk to the Arduino, I decided to use I2C over the Alchitry Au’s Qwiic connector. This required two more IO pins for a total of 102. Conveniently, the Alchitry Au has exactly 102 IO pins.

Besides showing off the massive amount of IO FPGAs are capable of, this project uses the Qwiic connector on the FPGA in a semi-unconventional way. The FPGA in this project acts as a peripheral instead of as a controller. The Arduino is the controller and issues all the commands to the FPGA. I actually think this will be a useful paradigm for many projects.

Some tasks are very simple in software but incredibly complicated in hardware. The opposite is also true. By linking a microcontroller and FPGA together you get the best of both worlds. The Qwiic connector on both boards makes this easy.

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.

Tools

While there are quite a few ways to machine parts for this project, here are the tools we used:

  • CNC Machine
  • Shapeoko XXL

You Will Also Need

Suggested Reading

If you aren't familiar with the Qwiic system, we recommend reading here for an overview.

Qwiic Connect System
Qwiic Connect System

We also recommend checking out these tutorials before continuing.

Programming an FPGA

Come look at the basics of working with Field Programmable Gate Arrays.

How Does an FPGA Work?

The What, How, Why, and When of Field Programmable Gate Arrays, aka FPGAs

First FPGA Project - Getting Fancy with PWM

An initial project using Alchitry's onboard FPGA to manipulate PWM

Physical Build

In this section I’m going to be fairly brief as the focus of this tutorial is on FPGA designs and not woodworking.

Click on each of the links below to access and download the project files:

The project first started with trying to figure out how to make one of the clock movements. I needed two stepper motors and a way to connect them to two concentric output shafts.

Originally, I found these super tiny stepper motors on Amazon that measured a tiny 8 x 9.2mm! I designed a piece that had two big gears and two small gears that would press fit onto the motors.

Tiny, melty stepper motors

Unfortunately, these little motors just weren’t up for the task of turning the gears. They output only the smallest amount of torque and trying to drive them hard enough to work made them heat up to the point of them melting the 3D printed PLA parts.

Giving up on these, I ordered a bunch of 28BYJ-48 stepper motors. These are quite a bit bigger but still plenty small for the clock. They also are internally geared and output plenty of torque. The internal gearing also means they have enough internal resistance to easily keep their position when powered off.

I designed a movement where the minute hand would be directly driven off the motor shaft and the hour hand would be driven via a gear so the motor could be offset to the side.

Here are some renders of the design. This first render shows the two output shafts. The center longer shaft connects directly to the motor inline with it. The outer shaft is attached to the gear and that gear is driven by the second motor. The hour and minute hands are friction fit onto these two shafts.

Render of the two output shafts

The friction fit allows the hands to be repositioned into a neutral position before the clock is powered on. This is important because even though stepper motors are great for controlling precise positions, they have no way of knowing where they start.

Render of the hands in neutral position

The motors were simply super glued onto the mounting pegs. All the parts were printed on my Prusa MK3S in black PLA.

Render of the motors superglued in place

This is a photo of the first finalized movement I printed and assembled.

Action shot of the first assembled clock

Once I had a working design, I was able to batch out the 24 of these I needed.

Batch 3D brinting working design

3d printed parts in a bin

Assembled clock motors in a bin

The next step was to create the frame. I made it out of two planks of maple. The first plank I resawed into three thinner pieces that I could glue together to make the face.

3 thinner pieces of maple to make the face of the clock clock

gluing the three pieces of the clock clock face together

I could then use my CNC to flatten and cut out the profile.

Using CNC to flatten and cut the profile

The clock is too big for my Shapeoko XXL so I had to do all the operations in two halves. Once I had the first side done, I could flip it over and flatten out the other side to get the entire face perfectly flat.

Flattening and CNCing the other half of the face

The board was then ready to mill out the pockets for the clocks.

CNCing the face of the clock clock

CNC clock face hole

When I made the face plate, it turned out a little thinner than I was originally planning after facing it. That led me to make the bottom of the pockets only 1.5mm thick. This still turned out to be plenty strong.

I then built up a frame and glued it together.

gluing together the face of the board to the frame

glued frame of the clock clock

Next, I had to make the hands. I chose to use padauk which is a nice red wood that turns to a deep reddish brown over time. I used this wood for drawer pulls in my kitchen where the clock would be hung and I thought it would look good if they matched.

CNCing the clock hands

The hands were machined out of ⅛” stock that I milled down to 2mm thick.

Lookit all those little clock hands

With the hands done, I glued all the movement assemblies to the clock.

gluing all the movement assemblies to the clock

Four of them are rotated at weird angles to make room for the power supply. This is a 12V 6A supply that is plenty for all the motors.

I used generic A4988 stepper drivers to control the motors. I was able to bend the motor pins and plug the motors directly into them after swapping two of the wires on the motor's connector.

SparkFun motor driver with headers soldered into place

SparkFun motor driver all hooked up

With all these attached, I could start wiring them all up to power.

Wiring all the motor drivers to power

This picture is missing two movements because I was short 4 motors at the time.

Each driver needed to be wired up to the 12V supply for the motors and 3.3V for the control logic.

Lots and lots of wires.

Each group of 6 that makes up a digit also had their enable pins wired together and routed to the Alchitry Au. Every driver had a direction and step signal that had to be wired back to the Au as well. As you can tell from the picture, the wiring quickly became a huge tangle.

Even more wires

I needed a way to set the time so I added four Qwiic buttons. Since I was already doing enough wiring, using the Qwiic connectors made it a LOT easier. The top pair is hour up/down and the bottom pair is minute up/down.

After the buttons, there is a RV-8803 real-time clock also connected to the Qwiic bus. The RTC being battery backed meant that I wouldn’t need to set the time every time I reprogrammed or unplugged the board.

Finally, the Alchitry Au is connected. It has to be at the end of the chain since it only has one Qwiic connector on it. I also removed the power wire from the Qwiic cable so the 3.3V regulator on the Alchitry Au wouldn’t conflict with the 3.3V regulator on the RedBoard Turbo.

The microcontroller is the RedBoard Turbo. I used this simply because it had a Qwiic connector and I had it on hand. Really, any microcontroller with a Qwiic connector could be used. The computational power needed is minimal.

The Alchitry Au and the RedBoard Turbo both require 5V. I used a small regulator intended for RC vehicles that would regulate the 12V down to 5V at up to 2A.

I wired up the stepper drivers to use half stepping. Initially I set it up to use 1/16 micro stepping but the motors made an audible whine when not on a half or full step. I also really didn’t need the resolution.

Alchitry Au is connected

The 102 wires going into the FPGA don’t really matter what pins they connect to. It is only important you keep track of which ones you choose. The actual pinout is defined in the constraint file of the FPGA design.

With all the wiring done, I could clean up the wiring a bit and put the hands on the clock.

Wiring has been cleaned up a bit

Faces put onto the clocks

That’s basically it for the physical build. The wiring wasn’t complicated, just very tedious.

FPGA

With any FPGA design it is important to outline what you want it to do before you start. In this case I needed to create something that could accept commands over I2C and step the motors accordingly.

I settled on the commands being a number of steps and a value corresponding to the period between steps. I originally thought about making the controller fancier with automatic ramping of the steppers but it turned out not to be necessary and would just complicate coordination between the hands.

I also wanted to be able to queue up a series of commands. That would make the Qwiic timing not important as each command would just be executed one after another.

Finally, I need the design to figure out when steps would be issued and enable/disable the motors accordingly to save power.

The Animator

To start off, I created a module that would control a single stepper motor. This module would accept a command to step so many steps with a specified delay between each step. It would then generate the appropriate direction and step signals for the stepper motor driver.

Here is the code for the module.

module animator (
    input clk,  // clock
    input rst,  // reset
    signed input stepCount[16], // it can be negative to indicate direction
    input delayCycles[16],      // cycles between each step
    input newAnimation,         // flag for new animation 
    output busy,                // flag the animator is busy and won't accept animations
    output step,                // step signal for the driver
    output direction            // direction signal for the driver
  ) {

  .clk(clk) {
    // The driver requires each "step" pulse to be at least 1us so we make them 2us
    pulse_extender stepExt(#MIN_PULSE_TIME(2000));

    dff dirCt[8];      // counter for waiting after changing direction. 200ns delay required
    dff counter[16+8]; // counter for delaying between steps. The +8 is the pre-divider

    .rst(rst) {
      fsm state = {IDLE, DIR_WAIT, STEP};
      dff dir;         // saved direction of the motor
      dff delayCt[16]; // saved delay count
      dff steps[16];   // saved number of steps (absolute value)
    }
  }

  always {
    busy = state.q != state.IDLE; // busy when not idle
    step = stepExt.out;           // step output is the extended pulse

    stepExt.in = 0;               // default to no new step
    direction = dir.q;            // output the saved direction

    case (state.q) {
      state.IDLE:
        if (newAnimation && stepCount != 0) {   // if new animation with steps (skip 0 step animations)
          state.d = state.DIR_WAIT;             // move to next state
          dir.d = stepCount[stepCount.WIDTH-1]; // direction is the sign of the step input (0 = positive, 1 = negative)
          steps.d = stepCount[stepCount.WIDTH-1] ? -stepCount : stepCount; // save the absolute value of stepCount
          delayCt.d = delayCycles;              // save the number of delay cycles
        }
      state.DIR_WAIT:
        dirCt.d = dirCt.q + 1;                  // wait for the direction output after it changed
        if (&dirCt.q) {                         // if done waiting
          state.d = state.STEP;                 // move to stepping state
        }
      state.STEP:
        counter.d = counter.q + 1;              // increment step delay counter
        if (counter.q[counter.WIDTH-1-:16] == delayCt.q) { // if counter has reached the delay count
          counter.d = 0;                        // reset counter
          stepExt.in = 1;                       // send a pulse
          steps.d = steps.q - 1;                // decrement the number of steps remaining
          if (steps.q == 1) {                   // if no more are left
            state.d = state.IDLE;               // return to idle
          }
        }
    }
  }
}

The first thing to note is that the stepper controller I used required that the direction input be stable for at least 200ns before and after rising edge of the step input. It also required that the step pulse have a minimum time high or low of 1us.

The step pulse width is easily achieved using the pulse_extender module from the component library. This module takes single cycle pulses and extends them to the specified length. In this case I set the length to be 2us to be nice and safe.

Once a new animation command is received, the direction output is set and the module waits for the dirCt to overflow. This counter holds 256 values and when using a 100MHz clock, that means it waits 2.56us. This is significantly longer than the 200ns required but it ensures that there are no timing issues with the long wires. Tightening the timing here wouldn’t make any performance difference either.

The stepping state increments a counter and steps each time it overflows. This counter has a pre-divider of 8 so each increment of delayCycles in the animation command is 256 extra delay cycles. This pre-divider allowsdelayCycles` to stay relatively small at 16 bits but still allow for a very wide range of speeds.

Even with this pre-divider, I found the lowest delayCycles could be safely set is around 760. That corresponds to 8 seconds for a full rotation.

Enable Gate

The next module to tackle is the enable gate. This module is responsible for gating, or blocking, the new animation flag to the animators while the motors are being enabled. It also makes sure the motors stay enabled long enough after an animation to complete their last step.

The module takes in the new animation pending flags for 12 different motors. It then enables the motors and waits a while, 42ms, for the drivers to re-energize the motors and the motors to settle.

After this period, it allows the pending animation flag to pass onto the animators.

While any animator in the group is running, it keeps the motors enabled. Once the last one is done, it keeps the motors enabled for another 42ms before disabling them.

Here’s the code for the module.

module enable_gate (
    input clk,  // clock
    input rst,  // reset
    output new_animation[12], // output to the animators
    input fifo_empty[12],     // input from fifos (pending animations)
    input animator_busy[12],  // input from animators
    output enable             // output to the stepper drivers
  ) {

  .clk(clk) {
    .rst(rst) {
      dff onCtr[22];          // counter to ensure motors are fully on (22bits ~ 42ms)
      dff offCtr[22];         // counter to keep motors on after animators finish (22bits ~ 42ms)
    }
  }

  sig running; // value used to know when the motors should be on

  always {
    // run when we have pending animations or are actively running
    running = |(animator_busy | ~fifo_empty); 

    // enable flag is set when running or onCtr isn't 0 (it is reset after offCtr overflows)
    enable = running || (onCtr.q != 0);

    // pass on new_animation flag only when onCtr is full
    new_animation = ~fifo_empty & 12x{&onCtr.q};

    if (running) {
      offCtr.d = 0;            // reset off counter
      if (!&onCtr.q) {         // if not full
        onCtr.d = onCtr.q + 1; // increment onCtr
      }
    } else {                     // not running
      if (!&offCtr.q) {          // if offCtr not full
        offCtr.d = offCtr.q + 1; // increment offCtr
      } else {                   // if offCtr is full
        onCtr.d = 0;             // reset the onCtr
      }
    }
  }
}

When the module is sitting idle, onCtr is 0 and offCtr will max out. When a pending animation is detected (the fifo isn’t empty), the enable output is set and onCtr is incremented each cycle.

Once onCtr is full, the new_animation flags are passed through.

Once all the animations have been performed, offCtr is incremented. Once it reaches its maximum value, onCtr is reset which disables the motors.

An interesting line to look at is the first line in the always block.

running = |(animator_busy | ~fifo_empty); 

This line can be a bit cryptic if you aren’t familiar with bitwise reduction operators. The goal of this line is to take the 12 animator_busy signals and the 12 fifo_empty signals and turn them into a single bit.

First, we can think about a single case. Any one motor is running if the fifo isn’t empty or it is currently busy. This can be taken care of by animator_busy | ~fifo_empty. A single pipe (vertical bar, |) is a bitwise OR. This will OR each of the bits of the two operands together keeping the bit width the same. The tilda (~) is a bitwise inversion. This flips each of the bits in fifo_empty.

After those operations we now have a 12 bit wide signal that says when each animator is running. However, we need to condense this into a single bit. The OR reduction operator is used here. The pipe operator, when placed in front of a value without a preceding value, will OR all the bits in the signal together and output a single bit.

In this case, that means if any of the motors are running, running will be 1.

Later on in the module, I use the AND reduction operator to check if all the bits in a signal are 1 (aka the max value). This works the same way as the OR reduction operator but ANDs ever bit together. Basically, it is 1 if they all are 1 and 0 otherwise.

You can also use the carrot (^) to perform an XOR reduction which will be 1 if there are an odd number of 1s.

Qwiic

We are now going to look at the top level module which takes care of the Qwiic interface and glues everything together.

Let’s just jump into it.

module au_top (
    input clk,              // 100MHz clock
    input rst_n,            // reset button (active low)
    output led [8],         // 8 user controllable LEDs
    input usb_rx,           // USB->Serial input
    output usb_tx,          // USB->Serial output
    output step[48],        // step output to motors
    output dir[48],         // direction output to motors
    output enable[4],       // enable output to motors (one per digit)
    inout sda,              // Qwiic SDA
    input scl               // Qwiic SCL
  ) {

  sig rst;                  // reset signal

  .clk(clk) {
    // The reset conditioner is used to synchronize the reset signal to the FPGA
    // clock. This ensures the entire FPGA comes out of reset at the same time.
    reset_conditioner reset_cond;

    dff ani_id[6];            // saved ID for the motor
    signed dff ani_steps[16]; // saved number of steps
    dff ani_delay[16];     // saved delay counts
    dff byteCt;               // byte flag for 16bit numbers

    .rst(rst) {
      i2c_peripheral qwiic (.sda(sda), .scl(scl)); // i2c peripheral module for qwiic interface

      dff ledReg[8]; // reg to hold the LED values (useful for qwiic testing)

      fsm state = {IDLE, ENABLE, LED, ANIMATION_STEPS, ANIMATION_DELAY, ANIMATION_PUT};

      animator animators[48]; // need 48 individual animators (one per motor)

      // need one fifo per animator, 32 bits wide for 16 bit steps and 16 bit delay
      // the 128 depth is definitely overkill and 16 would probably be plenty for the
      // current usage.
      fifo ani_fifos[48] (#SIZE(32), #DEPTH(128)); 

      enable_gate gates[4]; // modules to control the enable signals (one per digit)
    }
  }

  var i;

  always {
    reset_cond.in = ~rst_n; // input raw inverted reset signal
    rst = reset_cond.out;   // conditioned reset

    led = ledReg.q;         // output ledReg to the leds

    usb_tx = usb_rx;        // echo the serial data

    // the ~ here flips every motor direction so positive steps would go clock-wise
    // the 48hAAAAAAAAAAAA constant has every other bit flipped so the geared motors
    // and direct drive motors will turn the hands the same way
    dir = animators.direction ^ ~48hAAAAAAAAAAAA;
    step = animators.step;
    enable = ~gates.enable; // enable of the controllers is active low so invert the bits

    qwiic.tx_data = 8bx; // this design is "write only" and never sends data to the microcontroller
    qwiic.tx_enable = 0; // never send data

    // combined groups of 12 motors for the four enable gates
    for (i = 0; i < 4; i++) {
      gates.fifo_empty[i] = ani_fifos.empty[i*12+:12];
      gates.animator_busy[i] = animators.busy[i*12+:12];
      animators.newAnimation[i*12+:12] = gates.new_animation[i];
      // only remove a value from the fifo when the gate passes the new_animation flag
      // and the animator isn't busy
      ani_fifos.rget[i*12+:12] = gates.new_animation[i] & ~animators.busy[i*12+:12];
    }

    // for each motor split the fifo output to the animator signals
    for (i = 0; i < 48; i++) {
      animators.stepCount[i] = ani_fifos.dout[i][15:0];
      animators.delayCycles[i] = ani_fifos.dout[i][31:16];
    }

    // default to no new animations
    ani_fifos.wput = 48b0;

    // always input the saved delay and steps
    // this line takes the two values, joins them, packs them into a 1x32 array,
    // and finally duplicates it 48 times into a 48x32 array
    // essentially, it just feeds the same 32 bits to each of the 48 fifos
    ani_fifos.din = 48x{{c{ani_delay.q, ani_steps.q}}};

    case (state.q) {
      state.IDLE:
        byteCt.d = 0;
        if (qwiic.rx_valid) {                    // new data
          case (qwiic.rx_data) {                 // case on the value
            8hFF: state.d = state.LED;           // make "address" FF the LEDs for testing
            default:
              ani_id.d = qwiic.rx_data[5:0];     // default to "address" as the motor id
              state.d = state.ANIMATION_STEPS;  
          }
        }
      state.LED:
        if (qwiic.rx_valid) {        // if new data
          state.d = state.IDLE;      // return to idle
          ledReg.d = qwiic.rx_data;  // show value on the LEDs
        }
      state.ANIMATION_STEPS:
        if (qwiic.rx_valid) {                                // if new data
          ani_steps.d = c{ani_steps.q[7:0], qwiic.rx_data};  // save byte and shift old byte
          byteCt.d = ~byteCt.q;                              // flip byte counter
          if (byteCt.q == 1) {                               // if second byte
            state.d = state.ANIMATION_DELAY;                 // go to delay capture state
          }
        }
      state.ANIMATION_DELAY:
        if (qwiic.rx_valid) {                                // if new data
          ani_delay.d = c{ani_delay.q[7:0], qwiic.rx_data};  // save byte and shift old byte
          byteCt.d = ~byteCt.q;                              // flip byte counter
          if (byteCt.q == 1) {                               // if second byte
            state.d = state.ANIMATION_PUT;                   // go to put state
          }
        }
      state.ANIMATION_PUT:
        state.d = state.IDLE;                                // return to idle
        ani_fifos.wput[ani_id.q] = 1;                        // put the new animation into the correct fifo
    }

    if (qwiic.stop) {          // if I2C stop condition is detected
      state.d = state.IDLE;    // reset to IDLE
    }
  }
}

The Qwiic interface is handled by the i2c_peripheral module. This module is a bit complicated since it breaks out the start/stop signals and requires you to provide direction when it should accept data or send data.

For our case, we can simplify it a lot by only reading in data. The important flags become rx_valid which tells us a new byte has been read in and stop that says the I2C transaction was stopped and we should reset. The output rx_data has the value of the byte read in when rx_valid is high.

If you want to respond to something, you need to monitor the start, next, and write flags. On the next clock cycle you can set tx_enable to 1 and provide data to send on tx_data. This will cause the module to write that byte instead of listen for one.

The start flag signals your ID was detected on the bus. At the same time that this is set, write will tell you if the last bit in the ID byte indicated a read (0) or write (1).

Again, we can ignore all this for this design.

The protocol I used for each transaction is the first byte is the address followed by the command’s data. For addresses 0-47, four bytes are expected. The first two are the step count and the second two are the delay count. Address 8hFF is special in that it only expects one byte after it and is used to set the LEDs on the Au. This is useful for testing the Qwiic bus.

I also made it so that you don’t need to start/stop the I2C transaction for each animation. Every 5 byte packet is a valid animation and it will loop after the last byte is received. This allows you to send all 48 motors a new animation in a single transaction.

FIFOs

This design is set up with 48 FIFOs to hold additional animations while the animators are busy. These are created from the fifo component in the component library.

Each FIFO is 32 bits wide and 128 entries deep. The 32 bits are split into 16 for the delay and 16 for the step counts. 128 entries deep is overkill for the current usage but would allow for many short animations to be stacked if I wanted to implement ramping and faster movements on the other side. The Au has plenty of built-in block RAM to fit all this anyways.

The FIFO follows a first-word-fallthrough style where when empty is 0, indicating there is data, the value is already available on dout. Setting rget to 1 will remove the entry and show the next entry on the following clock cycle.

To supply data to the FIFO, simply put the data on din and set wput to 1. You may also want to check that full isn’t 1, or your data may be ignored.

Bit Assignments

In the beginning of the always block there is quite a bit of array/bit manipulation.

In Lucid, you can conveniently make modules arrays and have their ports packed into arrays. In some cases of our design, like the step outputs, we can directly assign these arrays as the bits perfectly line up.

In other cases, we need to split them out into subsections. When this happens it is convenient to use for loops. Remember that for loops can’t be realized in hardware and need to have a fixed number of iterations so they can be unrolled during synthesis. They are simply a way to write things more compact.

For example, the first for loop goes through four iterations with i being 0 through 3.

The first line will evaluate to the following for the first iteration.

gates.fifo_empty[0] = ani_fifos.empty[0+:12];

The [0+:12] bit selector means starting at bit 0, select 12 bits above it. So bits 0-11 are selected.

In the next iteration, it will evaluate to the following.

gates.fifo_empty[1] = ani_fifos.empty[12+:12];

Here, the second enable gate gets the bits 12-23.

All four iterations could be listed out.

gates.fifo_empty[0] = ani_fifos.empty[0+:12];
gates.fifo_empty[1] = ani_fifos.empty[12+:12];
gates.fifo_empty[2] = ani_fifos.empty[24+:12];
gates.fifo_empty[3] = ani_fifos.empty[36+:12];

This would create an identical circuit in the FPGA. However, I’m sure you’ll agree that this is cumbersome to type out and maintain.

It is very common to use the start/width bit selectors in for loops instead of the start/stop bit selectors. This is because you can’t use start/stop selectors with non-constant values.

The start/width selector used above ensures that the width of the selection is always 12 bits wide. You can’t realize a signal that changes width in hardware as you can’t spontaneously create or remove connections.

In this case I used the up variant of the selector by using the +:. You can also use -: to use the down variant of the selector. This selects the start bit and the bits below it.

For example, [11-:12] is the same as [0+:12]. They both select bits 0-11.

Pin Assignments

At this point you may be wondering how the step and dir signals map to the IO pins on the Au.

This mapping is defined in a constraint file. In this case they are in the clockclock.acf file. The acf extension is for Alchitry Constraint File. This format is very simple and allows you to specify the pin names as the pins on the Alchitry boards instead of the FPGA. For example, A2 maps to the second pin of the top left header (bank A) on the Au.

If you open this file you’ll see a whole bunch of lines that look like this.

pin step[0] A2;
pin dir[0] A3;

Each IO port needs to be mapped to a physical pin. The format is the pin keyword followed by the signal name and finally the physical pin location.

You can also add the pullup or pulldown keyword to add an internal pullup/down resistor to the pin. However, `pulldown is ignored on the Cu as the Lattice FPGA doesn’t have internal pulldown resistors.

Most of the pins on an FPGA are fully interchangeable and the pinout I used for the clock was super arbitrary with the exception of the Qwiic signals since they are wired to the Qwiic connector.

All that was important for this project was that I kept them all straight.

Software Setup and Programming

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

The microcontroller I used was the RedBoard Turbo, but as I said before, any board with a Qwiic connector could likely be used.

First, I had to install the libraries for the board and the Qwiic RV8803 RTC and buttons. The buttons below will take you to the respective setup tutorials for each.

The code itself isn’t too complicated but the structure is something I end up doing for many designs.

Basically, I built up layers of abstraction until I got to an easy to use layer that made managing the numbers and performing animations easy.

The first layer is, of course, the FPGA. The FPGA gives us an interface to make a motor perform a certain number of steps with a fixed delay between them.

I used the Wire library built into Arduino to manage the I2C bus. This allowed me to make a simple function that would send a single animation.

language:c
void sendAnimation(uint8_t id, int16_t steps, uint16_t delay_cycles) {
  int32_t p = currentPosition[id] + steps;
  while (p < 0) p += FULL_CIRCLE;
  currentPosition[id] = p % FULL_CIRCLE;
  Wire.write(id);
  Wire.write((uint8_t)(steps >> 8));
  Wire.write((uint8_t)(steps & 0xFF));
  Wire.write((uint8_t)(delay_cycles >> 8));
  Wire.write((uint8_t)(delay_cycles & 0xFF));
}

Two special things here is that I have a constant FULL_CIRCLE declared which is the number of steps in a full rotation. This is 4096 in my case.

This is used to update a global array of position values of the motors. By always using this function to send the animations, the position of the motors is known.

It isn’t very convenient to think of motion in terms of steps and delays. Instead, it is much easier to think of them in terms of degrees and duration. In other words, instead of thinking “take 2048 steps with 760 delay cycles between each step” it makes much more sense to think “turn 180 degrees over 4 seconds.”

I wrote a function that could take care of that translation.

language:c
void animate(uint8_t id, float deg, float duration) {
  float steps = deg * FULL_CIRCLE / 360.0f;
  if (steps > 32767 || steps < -32768) {
    animate(id, deg / 2, duration / 2);
    animate(id, deg / 2, duration / 2);
    return;
  }

  float cycles = constrain(duration * 390625 / abs(steps), 760, 65535);

  sendAnimation(id, (int16_t)steps, (uint16_t)cycles);
}

First, it turns the degrees into steps by again using the FULL_CIRCLE constant. It then checks if there are too many steps for a single animation command and recursively calls itself with half the animation each.

The delay cycles are then calculated. The 390625 value is the number of cycles in a second (100,000,000 / 256 = 390,625). The cycles need to be bound to the range of 760 to 65535. The 760 minimum was empirically found by testing how fast the motors could reliably spin without skipping a step. It is also 8 seconds per revolution.

The upper bound is really high and shouldn’t ever be hit. It would take 687 seconds to do a full rotation. The current design can’t go slower than this. If you needed it to, you would have to change the FPGA’s pre-scaler or the size of the delay cycle value.

The final abstraction I needed was a function to simply tell the motor to move to a position. This would use the currentPosition value to calculate the minimum rotation needed to get to that point. This is helpful when showing the actual time since I can just call it with all the positions the hands need to be in and don’t have to adjust for where they currently are.

language:c
void moveTo(uint8_t id, float pos, float duration) {
  float curDeg = (float)currentPosition[id] * 360.0f / FULL_CIRCLE;
  float angle = pos - curDeg ;

  if (angle > 180)
    angle = angle - 360;
  if (angle < -180)
    angle = 360 + angle;

  animate(id, angle, duration);
}

It starts by calculating the angle the hand is currently at. Then it gets the angle it needs to move by subtracting the desired angle by the current angle.

This angle may end up being the long way around; the two if statements check for this and switch it to the smaller of the two paths. For example, if the difference of the angles was 270, it would be better to move -90 degrees instead.

To show the actual time, I needed a map for all the digits. This was easy enough to do by simply drawing out how I wanted each number to look and writing down the angles for each hand.

I entered all these into a 2D array that could be used to look up any digit.

language:c
const float digitAngles[10][12] = {{270, 180, 0, 180, 270, 0, 90, 180, 0, 180, 90, 0}, // 0
  {180, 180, 0, 180, 0, 0, 225, 225, 225, 225, 225, 225}, // 1
  {270, 180, 270, 0, 270, 270, 90, 90, 90, 180, 90, 0}, // 2
  {270, 180, 0, 180, 270, 0, 90, 90, 90, 90, 90, 90}, // 3
  {180, 180, 0, 180, 0, 0, 180, 180, 90, 0, 225, 225}, // 4
  {270, 270, 270, 180, 270, 0, 90, 180, 90, 0, 90, 90}, // 5
  {270, 270, 270, 180, 270, 0, 90, 180, 0, 180, 90, 0}, // 6
  {270, 180, 0, 180, 0, 0, 90, 90, 225, 225, 225, 225}, // 7
  {270, 180, 270, 0, 0, 270, 90, 180, 90, 0, 0, 90}, // 8
  {270, 180, 0, 180, 0, 0, 90, 180, 90, 0, 225, 225} // 9
};

With this, I could use the RTC to get the time and display the digits.

language:c
void showTime() {
  uint8_t digits[4];
  digits[0] = rtc.getMinutes() % 10;
  digits[1] = rtc.getMinutes() / 10;
  digits[2] = rtc.getHours() % 10;
  digits[3] = rtc.getHours() / 10;
  for (uint8_t d = 0; d < 4; d++) {
    Wire.beginTransmission(0x50);
    for (uint8_t m = 0; m < 12; m++) {
      moveTo(m + 12 * d, digitAngles[digits[d]][m], 4.0f);
    }
    Wire.endTransmission();
  }
}

It is worth mentioning that my code assumes the hands start at the 12:00 position (straight up). This is the 0 degree mark for all my positions.

In the Arduino loop() function, I put code that would check the RTC every 100ms and update the time if it changed.

If the hour changed, I also had it perform an animation. I wrote three simple ones that it randomly selects to perform before settling on the new hour.

Inside loop() I also check the state of the four buttons. My original plan was to use the Qwiic Button’s FIFO interface to keep track of each press, but I ran into a bug that I outlined here.

Instead, I ended up keeping track of the state myself and just used the isPressed() function to check their current state.

When any individual button is pressed, I update the time. The four buttons allow me to set the minutes and hours independently.

I also added a feature where if you press both hour up and hour down at the same time, the hands will all move to the 12:00 position. This is incredibly helpful if you need to power off the clock or reprogram the Arduino as you don’t have to manually readjust every hand.

That about sums up the design. Take a simple interface and build upon it until it is useful.

Troubleshooting

Conclusion

This project turned out to be substantially more work that I originally thought it would when I started. The vast majority of my time was spent with the physical build and the wiring. It also took me a while to come up with a solid working movement design. The FPGA and Arduino designs actually came together with minimal hiccups.

Using the Qwiic connector on the Au to talk to a microcontroller is likely to be one of its most useful use cases. I was pleasantly surprised by how easy it was to set up on the Arduino side having never used Qwiic (or I2C) on an Arduino before.

There are a few things that could be improved if someone were to make another one of these.

First, the clock is pretty loud. The individual motors are all pretty quiet, but then you glue them to a pretty thin piece of wood it really amplifies it. I should have looked into some kind of sound dampening way to mount the motors. Maybe using some kind of soft rubber glue instead of super glue to attach them. The wood is also only 1.5mm thick for most of the face which really makes it reverberate.

I’m thinking I may try to pour liquid rubber onto the backside of the board to help dampen the noise.

The other major issue is that the stepper motors are internally geared and the gearing has backlash. This means that depending on the direction the hand was moving it may or may not be where it is supposed to be. They seem to get off a few degrees when switching directions due to the play. It isn’t the end of the world but it is off just enough to be painfully obvious. I may be able to write some code that could compensate for it but it isn’t consistent across motors and would have to be fine tuned.

This could be fixed with motors that aren’t geared. I had a hard time finding small stepper motors for this though that weren’t prohibitively expensive.

I hope this demo project has given you a good example of what can be done with an FPGA and hopefully sparks some ideas for your own projects!

Resources and Going Further

Production files:

Alchitry's website has more great resources, including tutorials, projects, and the Alchitry Forum.

If you'd like to delve deeper into the world of FPGAs and Lucid, check out "Learning FPGAs: Digital Design for Beginners with Mojo and Lucid HDL" by Justin Rajewski. It's available on Amazon and is a great resource for understanding and ultimately designing your own FPGAs.

We are continually expanding our offering of tutorials and products related to FPGAs. Check out some of the following tutorials!

How Does an FPGA Work?

The What, How, Why, and When of Field Programmable Gate Arrays, aka FPGAs

First FPGA Project - Getting Fancy with PWM

An initial project using Alchitry's onboard FPGA to manipulate PWM

External IO and Metastability

Why external signals can cause metastability and how to use constraint files to manage this

&nbsp

FPGA chip

&nbsp


learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

SparkFun Qwiic GPIO Hookup Guide

$
0
0

SparkFun Qwiic GPIO Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1210

Introduction

The SparkFun Qwiic GPIO is an I2C device aimed at simplifying adding extra GPIO pins to a microcontroller. The board uses the TCA9534U I/O Expander IC from Texas Instruments to add up to 8 digital inputs and outputs controlled via an I2C interface. The TCA9534U features three address select pins that can be set to configure eight unique addresses meaning you can have up to 64 I/O pins controlled from a single I2C bus!

SparkFun Qwiic GPIO

SparkFun Qwiic GPIO

DEV-17047
$5.95

To simplify wiring everything up, we've broken out all eight of the general-purpose I/O pins on the TCA9534U along with several power rail pins to latch terminals and, as you would expect from a Qwiic board, the I2C interface is broken out to a pair of Qwiic connectors.

Controlling the TCA9534 is relatively straightforward but to make things even easier, we've written an Arduino Library and a Python Package for the Qwiic GPIO to make writing code for it as easy as possible.

In this guide we'll go over everything you need to know about the Qwiic GPIO so you can add those extra I/O pins to your circuit with ease!

Required Materials

In order to follow along with this tutorial you'll need a few items along with your Qwiic GPIO. First, you'll need a microcontroller to communicate with the board. Below are a few options that come Qwiic-enabled out of the box:

SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
5
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
5
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
4
SparkFun Qwiic Micro - SAMD21 Development Board

SparkFun Qwiic Micro - SAMD21 Development Board

DEV-15423
$19.95
4

If your preferred microcontroller does not have a Qwiic connector, you can add one using one of the following products:

SparkFun Qwiic Shield for Thing Plus

SparkFun Qwiic Shield for Thing Plus

DEV-16790
$3.95
SparkFun Qwiic Shield for Arduino

SparkFun Qwiic Shield for Arduino

DEV-14352
$6.95
4
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic Shield for Arduino Nano

SparkFun Qwiic Shield for Arduino Nano

DEV-16789
$3.95

Finally, you'll need at least one Qwiic cable and possibly some hook up wire or jumper cables. Below are a few options for each of those cable types:

Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)

Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)

PRT-11026
$2.25
20
Hook-Up Wire - Assortment (Stranded, 22 AWG)

Hook-Up Wire - Assortment (Stranded, 22 AWG)

PRT-11375
$16.95
18
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50

Suggested Reading

If you aren't familiar with the Qwiic system, we recommend reading here for an overview:

Qwiic Connect System

We would also recommend taking a look at the following tutorials if you aren't familiar with the concepts covered in them:

Polarity

An introduction to polarity in electronic components. Discover what polarity is, which parts have it, and how to identify it.

Serial Terminal Basics

This tutorial will show you how to communicate with your serial devices using a variety of terminal emulator applications.

Processor Interrupts with Arduino

What is an interrupt? In a nutshell, there is a method by which a processor can execute its normal program while continuously monitoring for some kind of event, or interrupt. There are two types of interrupts: hardware and software interrupts. For the purposes of this tutorial, we will focus on hardware interrupts.

How to Work with Jumper Pads and PCB Traces

Handling PCB jumper pads and traces is an essential skill. Learn how to cut a PCB trace, add a solder jumper between pads to reroute connections, and repair a trace with the green wire method if a trace is damaged.

Hardware Overview

As we mentioned in the Introduction, the Qwiic GPIO features the TCA9534 I/O Expander to communicate with up to eight digital input/output pins via I2C. In this section we'll examine the characteristics of the TCA9534 as well as the features of the Qwiic GPIO breakout.

TCA9534 I/O Expander IC

The TCA9534 from Texas Instruments provides an I2C to parallel digital input output interface. We'll cover the basics here but for a thorough overview of the TCA9534 refer to the datasheet. The IC has an operating input voltage range of 1.65V to 5.5V but we recommend powering it with 3.3V via either the Qwiic connector or through any of the 3.3V and Ground pins to maintain compatibility with other Qwiic devices.

Photo highlighting TCA9534 IC.

The TCA9534 supports both standard (100kHz) and fast mode (400kHz) I2C frequencies. The IC also features an active-low interrupt pin that is activated when any pins configured as an input have a different state from the Input Port register state. This means you can connect this INT pin to an interrupt-capable pin on your microcontroller to passively monitor devices connected to the TCA9534. For more information on this functionality, refer to section 8.3.2 in the TCA9534 datasheet and Example 4 - Interrupt in the Qwiic GPIO Arduino Library.

Three hardware pins (A0, A1 and A2) are dedicated I2C address select pins. We've added three jumpers to the Qwiic GPIO to allow users to have up to 8 boards on the same bus. The Solder Jumpers section below goes into more detail on how those pins and jumpers are used on the Qwiic GPIO.

Latch Terminals

The Qwiic GPIO breaks out all eight of the TCA9534's I/O pins, the interrupt pin, as well as several power rail pins (3.3V and Ground) to four 4-pin latch terminals so wiring peripherals to the board is extremely easy. All you need to do is insert a stripped wire into your preferred terminal opening and press down firmly on the latch handle to secure the wire into place.

Photo highlighting latch terminals.

Each I/O pin defaults as an input at power on. Sending the appropriate commands will switch them to an output and you can also invert the polarity of each pin as well via I2C. Read on to the Qwiic GPIO Arduino Library and Python package sections for more information on how to configure and interact with these pins.

Qwiic and I2C Interface

As you have come to expect with Qwiic boards, the connections for the I2C bus (SDA, SCL, GND and 3.3V) on the Qwiic GPIO are broken out to a pair of Qwiic connectors as well as standard 0.1" spaced PTH pins for those who would prefer to solder to them. The default I2C address for the Qwiic GPIO is 0x27.

Photo highlighting Qwiic and I2C interface.

Solder Jumpers

If you have never worked with solder jumpers and PCB traces before or would like a quick refresher, check out our How to Work with Solder Jumpers and PCB Traces tutorial for detailed instructions and tips.

The Qwiic GPIO has six solder jumpers to configure the board labeled I2C, PWR, INT, A0, A1 and A2. This section covers what each jumper's functionality is and how to configure them.

Photo highglighting Qwiic GPIO solder jumpers.

I2C Jumper

This jumper ties the SDA and SCL lines to 3.3V via two 4.7kΩ resistors. The default state is closed. To disable the pull-up resistors, simply sever the traces in between the pads to open the jumper. If you have multiple Qwiic GPIO's or other I2C devices on the same bus, disable all but one pair of pull-up resistors to avoid creating too strong of a resistance on the SDA and SCL lines.

Power Jumper

This jumper controls voltage to the power LED on the board. It ties the anode of the power LED to 3.3V via a 1kΩ resistor. The default state is closed. To disable the power LED, open the jumper by severing the trace between the two pads. Disabling the power LED will help reduce overall current consumption of the board.

Interrupt Jumper

This jumper ties the TCA9534's interrupt pin to 3.3V via a 10kΩ resistor and its default state is closed. This holds the Interrupt pin HIGH so it can be driven LOW when an interrupt event is monitored by the TCA9534. Open the jumper if you have another pullup on the Interrupt pin.

Address Jumpers

The three address jumpers on the Qwiic GPIO: ADR0, ADR1 and ADR2, set the I2C address of the TCA9534 by pulling them either to 3.3V or 0V/Ground. The default state of all three jumpers is closed and they tie each address pin to 3.3V via a 2.2kΩ resistor. This configuration sets the default I2C address to 0x27. By opening or closing these jumpers you can alter the address of the TCA9534 so you can have up to eight of these boards on a single I2C bus. Click the button to open the table below showing the various jumper configurations and what I2C address each configuration sets:

Board Dimensions

The Qwiic GPIO is a bit larger than our standard Qwiic breakout size (1" x 1"). It measures in at 2.40" x 1.50" (60.96mm x 38.10mm) and has four mounting holes that fit a 4-40 screw.

Qwiic GPIO Dimensional Drawing

Now that we are more familiar with the hardware present on the Qwiic GPIO it's time to hook it up to our microcontroller and attach some peripherals to the I/O pins. Next up we'll detail how to assemble the board and your Qwiic GPIO circuit.

Hardware Assembly

The Qwiic system makes connecting the Qwiic GPIO to your chosen microcontroller a breeze. All you need to do is connect your Qwiic GPIO to your chosen development board with a Qwiic cable or adapter cable. If you would prefer to not use the Qwiic connectors, you can connect to the 0.1" header pins broken out on the side of the board.

If you prefer to use the PTH pins broken out on the Qwiic GPIO you will need to solder to them. For a temporary connection for prototyping, these IC Hooks are a great option to make that connection. For users not familiar with through-hole soldering take a look at this tutorial:

How to Solder: Through-Hole Soldering

September 19, 2013

This tutorial covers everything you need to know about through-hole soldering.

Connecting peripherals to the GPIO is simple as well with the latch terminals. If you are using hook-up wire, make sure you've stripped the end, insert it into the appropriate terminal (making sure it is "open") and then press down on the latch terminal firmly to secure the wire in place. Depending on how you intend to use the I/O pin you'll want to connect your other wire to either a 3.3V or Ground pin. For demonstration purposes, we're using LEDs and buttons to act as our inputs and outputs (respectively).

Demo circuit showing Qwiic GPIO connected to two LEDs and two buttons
Having trouble seeing the detail in this mess of jumper wires? Click on the photo for a larger view!

With the Qwiic GPIO circuit assembled and connected to your microcontroller it's time to get some code uploaded and start controlling the extra I/O pins via I2C!

Qwiic GPIO Arduino Library

Note: This library assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

The SparkFun Qwiic GPIO Arduino Library helps to make interfacing between the TCA9534 and your Arduino microcontroller simple. In this section we'll list all of the functions available in the library as well as brief descriptions about what they do.

Library Functions

We've outlined all the functions in the Arduino library below along with some quick descriptions of what they do. The examples cover nearly all of the functions so you may want to refer to those for help with writing your own code using them.

Device Setup & Settings

  • bool begin(TwoWire &wirePort, uint8_t address); - Initialize the TCA9534 on the I2C bus. If you have set the TCA9534 to an alternate I2C address using the ADR jumpers, enter that here.
  • bool pinMode(uint8_t gpioNumber, bool mode); - Sets the mode of the selected GPIO pin on the TCA9534. For example, pinMode(0, GPIO_OUT); sets pin 0 as an output. All I/O's default to Inputs on power up.
  • bool pinMode(bool *gpioPinMode); - An alternative to the above function to set the entire port as an input or output. This accepts a bool defined in your setup to set all eight GPIO pins at once. Refer to Example1B - Write_GPIO_Port for more information on using this function.
  • bool invertPin(uint8_t gpioNumber, bool inversionMode); - Invert the polarity of the selected GPIO pin on the TCA9534.
  • bool invertPin(bool *inversionMode); - Invert the polarity of the entire port of the TCA9534. Refer to Example 3B - Inversion_Port for a demonstration of how to set up and use this function.

GPIO Reading and Writing

  • bool digitalWrite(uint8_t gpioNumber, bool value); - Your basic Digital Write function. Write to the selected GPIO pin either HIGH or LOW.
  • bool digitalWrite(bool *gpioOutStatus); - Write to the entire port set up using a bool to either HIGH or LOW.
  • bool digitalRead(uint8_t gpioNumber); - Standard Digital Read function. Returns the status of the selected GPIO pin.
  • uint8_t digitalReadPort(bool *gpioInStatus); - Read the status of the entire port set up using a bool. Returns status of all selected pins on the port. Take a look at Example2B - Read_GPIO_Port for reference.

Advanced Functions

These functions are intended for experienced users to write and read specific bits and registers.

  • bool readBit(uint8_t regAddr, uint8_t bitAddr); - Read a specific bit in a selected register.
  • bool writeBit(uint8_t regAddr, uint8_t bitAddr, bool bitToWrite); - Write to a specific bit in a selected register.
  • uint8_t readRegister(uint8_t addr); - Read a specific register.
  • bool writeRegister(uint8_t addr, uint8_t val); - Write to a specific register.

Next up we'll cover the examples included with the Qwiic GPIO Arduino library to see these functions in action along with explaining a bit more on how to set up the port options for pinMode();, invertPin(); and digitalWrite();.

Arduino Examples

The Qwiic GPIO Arduino Library has three examples split into single pin and port variants to demonstrate how to set up control the TCA9534 along with a fourth example demonstrating how to use the external interrupt capability. In this section we will go over those examples and highlight a few things to take note of when setting up your Qwiic GPIO in code.

Note: If you are using the SparkFun Qwiic Micro - SAMD21 Development Board as shown in the Hardware Assembly section you'll need to add this quick define due to how the SAMD architecture handles ports: #define Serial SerialUSB
This definition helps a ton when working with chip architectures that have multiple serial ports you need to call specifically instead of using a general Serial calls. Simply update that definition with whichever serial port you want to use for serial prints via USB.

Example 1A: Write GPIO

A basic digital write example. Open Example 1A in Arduino by navigating to File > Examples > SparkFun Qwiic GPIO Arduino Library > Example1a-Write_GPIO. This example sets up GPIO 0 as an output and toggles it HIGH and LOW. The code starts up by initializing the Qwiic GPIO on the I2C bus on the default address and sets GPIO0 as an output:

language:c
myGPIO.pinMode(0, GPIO_OUT); //Use GPIO_OUT and GPIO_IN instead of OUTPUT and INPUT_PULLUP

Take note to use GPIO_OUT or GPIO_IN instead of the standard Arduino setup of OUTPUT and INPUT_PULLUP when setting the GPIO pin as an input or output. We use these alternates because the TCA9534's I/O pins default as an INPUT (pin mode = True) so GPIO_IN = true and GPIO_OUT = false are defined in the library to set the pin mode to avoid confusion. After we've set up GPIO 0 as an output, the code toggles it HIGH and LOW using digitalWrite(); every second and prints out the GPIO status via serial.

Demo circuit for example 1 using an LED as the output.

The demo circuit above shows a visual representation of GPIO 0 being toggled HIGH and LOW using an LED. If you want to control more pins, simply add another myGPIO.pinMode(); for whichever pin you want to use to set it as an output and then control it using myGPIO.digitalWrite();.

Example 1B: Write GPIO - Port

This version of writing to the Qwiic GPIO controls the entire port (all eight GPIO pins). In order to set up the port we need to define the number of GPIO pins we are using as well as construct a boolean to define each pin as either an input or output. Since this example is for writing to the port, all eight pins are defined as outputs:

language:c
#define NUM_GPIO 8

bool currentPinMode[NUM_GPIO] = {GPIO_OUT, GPIO_OUT, GPIO_OUT, GPIO_OUT, GPIO_OUT, GPIO_OUT, GPIO_OUT, GPIO_OUT};

Along with the pin mode, we also need to define the initial state of each GPIO:

language:c
bool gpioConfig[NUM_GPIO] = {HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW}

With the GPIO port configured, the code initializes the Qwiic GPIO on the I2C bus and then alternates the state of each pin every second using a function specific to this example called flipGPIO();:

language:c
void flipGPIO()
{
    for (uint8_t arrayPosition = 0; arrayPosition < NUM_GPIO; arrayPosition++)
    {
        gpioConfig[arrayPosition] = !gpioConfig[arrayPosition];
    }
}

Example 2A: Read GPIO

Example 2A demonstrates how to read an individual GPIO pin on the TCA9534. It starts by setting up GPIO 0 as an input, reads its state and prints out whether it is HIGH or LOW via serial. Similar Example 1, GPIO 0 is set up but in this case is set as an input using pinMode(0, GPIO_IN);. The code then monitors the pin's state every 250ms and prints the state via serial. You can view the main loop below:

language:c
void loop() {
  bool gpioState = myGPIO.digitalRead(0);
  switch (gpioState) {
    case true:
      Serial.println("HIGH");
      break;
    case false:
      Serial.println("LOW");
      break;
  }
  delay(250);
}

Demo circuit for example 2 using pushbutton for input.

The example circuit pictured above demonstrates how to monitor an active HIGH input on the Qwiic GPIO by driving the selected I/O pin (in this case GPIO 0) LOW whenever the button is pressed.

Note: Defining a pin as an input is not absolutely necessary since GPIO pins on the TCA9534 default to inputs on power on. We include that call in any example using inputs in case an I/O pin used in the example was set as an output without power-cycling the Qwiic GPIO.

Example 2B: Read GPIO - Port

Example 2B demonstrates how to read the entire GPIO port on the TCA9534. The code sets up all eight GPIO pins just like Example 1B using a boolean but this time all pins are set as inputs. We also need to set up a second boolean for the GPIO pin status due to how the port read register of the TCA9534 works:

language:c
bool gpioStatus[NUM_GPIO]

With the port set up and configured, we can move on to initializing the Qwiic GPIO on the I2C bus and start reading the status of the entire GPIO port. As the comment in the code below explains, in order to read from the port you can either return the full register value as an unsigned 8-bit integer or by passing an array of 8 booleans modified by the function that returns the status of each pin. The example defaults to the latter and sets up an array for the port read:

language:c
void loop() {
  //There are two ways to read from a port, either by returning the full register value as a uint8_t, or passing in an array of 8 boolean's to be modified by the function with the statuses of each pin
  uint8_t portValue = myGPIO.digitalReadPort(gpioStatus);

  Serial.print("uint8_t: ");
  Serial.println(portValue, BIN);
  Serial.print("Bool array: ");
  for (uint8_t arrayPosition = 0; arrayPosition < NUM_GPIO; arrayPosition++) {
    Serial.print(arrayPosition);
    Serial.print(": ");
    switch (gpioStatus[arrayPosition])
    {
      case true:
        Serial.print("HIGH");
        break;
      case false:
        Serial.print("LOW");
        break;
    }
  }
  Serial.println("\n");
  delay(100);
}

Example 3A: Inversion

Example 3A shows how to invert the signal polarity of an input on the Qwiic GPIO. Polarity inversion only works on pins configured as an input so first we set the pin mode and then we invert the polarity. Input pins default to active HIGH so inverting it changes it to active LOW. Below you can see the setup required for pin inversion:

language:c
myGPIO.pinMode(0, GPIO_IN);
myGPIO.invertPin(0, INVERT);

Once we have set up the pin as an input and inverted the polarity the main loop reads the status of the pin every 100ms:

language:c
void loop() {
  bool status = myGPIO.digitalRead(0);    
  switch (status)
    {
      case true:
        Serial.println("GPIO 0: HI");
        break;
      case false:
        Serial.println("GPIO 0: LO");
        break;
    }
  delay(100);
}

Example 3B: Inversion - Port

Example 3B, as you might expect by now, exhibits how to invert the entire port on the Qwiic GPIO. The code starts as the other port examples do by defining the number of pins and setting the pin mode of all pins on the port. It then inverts half of the pins' polarity using a second boolean. The setup can be seen below:

language:c
#define NUM_GPIO 8

bool currentPinMode[NUM_GPIO] = {GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN};

bool inversionStatus[NUM_GPIO] = {INVERT, INVERT, INVERT, INVERT, NO_INVERT, NO_INVERT, NO_INVERT, NO_INVERT};

The main loop is identical to Example 2B - ReadGPIO - Port and prints out the state of the port register using an unsigned 8-bit integer.

Example 4: Interrupt

Heads Up! In this example we use D13 as our interrupt pin since the code was written for use with a SparkFun RedBoard/Arduino Uno. If you are using a different microcontroller with your Qwiic GPIO, take a look through its documentation to see which pins can be used as an interrupt and then adjust this definition: #define INTERRUPT PIN 13 to the selected pin. If you are not familiar with using processor interrupts on a microcontroller, this tutorial will help you get started.

Example 4 demonstrates how to use the interrupt pin on the TCA9534 when any input pin registers a change. The interrupt pin is active LOW and will return to HIGH once the input register is read. We've broken the INT pin out to a latch terminal so you can connect a wire to that terminal and tie it to the interrupt-capable pin on your microcontroller. If you prefer, the INT pin is also broken out to a PTH pin you can solder to. Whichever option you choose, connect the interrupt pin on your Qwiic GPIO to D13 on your Arduino (assuming you are using an Uno/RedBoard).

The code starts similarly to our other Port examples by defining the number of GPIO pins and setting their pin status. Along with the GPIO pins, we define the interrupt pin on our microcontroller. You can view the pertinent bits of this code below:

language:c
#define NUM_GPIO 8

#define INTERRUPT_PIN 13

bool currentPinMode[NUM_GPIO] = {GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN, GPIO_IN};

bool gpioStatus[NUM_GPIO];

bool dataReady = true;

With everything defined, the setup initializes the Qwiic GPIO on the I2C bus, sets the interrupt pin on the microcontroller as an input, "primes" it by writing it HIGH and tells our microcontroller to treat it as an interrupt:

language:c
pinMode(INTERRUPT_PIN, INPUT_PULLUP);
digitalWrite(INTERRUPT_PIN, HIGH);
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), ISR, FALLING);

Now that our interrupt pin is configured the code monitors the GPIO pins' statuses and any time the status changes, the interrupt pin on the Qwiic GPIO will be driven LOW. You can view the entire loop and ISR function below:

language:c
void loop() {
  if (dataReady) {
    myGPIO.digitalReadPort(gpioStatus);
    for (uint8_t arrayPosition = 0; arrayPosition < NUM_GPIO; arrayPosition++) {
      Serial.print(arrayPosition);
      Serial.print(": ");
      switch (gpioStatus[arrayPosition])
      {
        case true:
          Serial.print("HI ");
          break;
        case false:
          Serial.print("LO ");
          break;
      }
    }
    Serial.println();
    dataReady = false;
  }
}

void ISR() {
  dataReady = true;
}

That wraps up the Arduino examples but if you would prefer to use Python instead with a different development board or single-board computer like the Raspberry Pi, read on to the next two sections where we'll detail how to use the Qwiic GPIO Python Package.

Qwiic GPIO Python Package

Note: This package assumes you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi, please checkout our tutorial on Python Programming with the Raspberry Pi and the Raspberry Pi SPI and I2C Tutorial.

Along with the Arduino Library, we've written a Python package to control the Qwiic GPIO. You can install the sparkfun-qwiic-gpio Python package hosted by PyPi or if you prefer to manually download and build the libraries from the GitHub repository, you can grab them by clicking the button below (*Please be aware of any package dependencies. You can also check out the repository documentation page, hosted on Read the Docs.):

Installation

Note: Don't forget to double check that the hardware I2C connection is enabled on your Raspberry Pi or other single board computer.

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-gpio package. On systems that support PyPi installation via pip3 (use pip for Python 2) is simple using the following commands:

For all users (note: the user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic-gpio

For the current user:

language:bash
pip3 install sparkfun-qwiic-gpio

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line (use python for Python 2):

language:bash
python3 setup.py install

To build a package for use with pip3:

language:bash
python3 setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip3.

language:bash
cd dist
pip3 install sparkfun_qwiic_gpio-<version>.tar.gz

Dependencies

This Python package has a few dependencies in the code, listed below:

language:python
from __future__ import print_function
import math
import qwiic_i2c

Function Overview

For a full overview of all the functions included with the Qwiic GPIO Py package, head on over to the ReadtheDocs page.

Python Examples

With the Qwiic GPIO Python Package installed, we can start working with the examples included with it. In this section we'll go over each example and highlight pertinent bits of code. To run the examples, download or copy the code into a file then open/save the example file (if needed) and execute the code in your preffered Python IDE.

Qwiic GPIO Example 1

This example sets up all eight I/O pins as outputs and toggles them on and off each second. Note you need to define the mode of each pin as well as call setMode to write the configuration to the Qwiic GPIO. Copy the code below and execute it in your chosen Python IDE.

language:python
from __future__ import print_function
import qwiic_gpio
import time
import sys

def runExample():

    print("\nSparkFun Qwiic GPIO Example 1\n")
    myGPIO = qwiic_gpio.QwiicGPIO()

    if myGPIO.isConnected() == False:
        print("The Qwiic GPIO isn't connected to the system. Please check your connection", \
            file=sys.stderr)
        return

    myGPIO.begin()
    myGPIO.mode_0 = myGPIO.GPIO_OUT
    myGPIO.mode_1 = myGPIO.GPIO_OUT
    myGPIO.mode_2 = myGPIO.GPIO_OUT
    myGPIO.mode_3 = myGPIO.GPIO_OUT
    myGPIO.mode_4 = myGPIO.GPIO_OUT
    myGPIO.mode_5 = myGPIO.GPIO_OUT
    myGPIO.mode_6 = myGPIO.GPIO_OUT
    myGPIO.mode_7 = myGPIO.GPIO_OUT
    myGPIO.setMode()

    while True:
        myGPIO.out_status_0 = myGPIO.GPIO_HI
        myGPIO.out_status_1 = myGPIO.GPIO_HI
        myGPIO.out_status_2 = myGPIO.GPIO_HI
        myGPIO.out_status_3 = myGPIO.GPIO_HI
        myGPIO.out_status_4 = myGPIO.GPIO_HI
        myGPIO.out_status_5 = myGPIO.GPIO_HI
        myGPIO.out_status_6 = myGPIO.GPIO_HI
        myGPIO.out_status_7 = myGPIO.GPIO_HI
        myGPIO.setGPIO()
        print("set hi")
        time.sleep(1)
        myGPIO.out_status_0 = myGPIO.GPIO_LO
        myGPIO.out_status_1 = myGPIO.GPIO_LO
        myGPIO.out_status_2 = myGPIO.GPIO_LO
        myGPIO.out_status_3 = myGPIO.GPIO_LO
        myGPIO.out_status_4 = myGPIO.GPIO_LO
        myGPIO.out_status_5 = myGPIO.GPIO_LO
        myGPIO.out_status_6 = myGPIO.GPIO_LO
        myGPIO.out_status_7 = myGPIO.GPIO_LO
        myGPIO.setGPIO()
        print("set lo")
        time.sleep(1)


if __name__ == '__main__':
    try:
        runExample()
    except (KeyboardInterrupt, SystemExit) as exErr:
        print("\nEnding Example 1")
        sys.exit(0)

Qwiic GPIO Example 2

Example 2 shows how to read each I/O pin when they are configured as inputs. It first sets up all pins using the setMode function as we did in Example 1. The code then monitors and prints out the status of each input every 0.25 seconds. You can copy the entire example below or open it from your downloaded copy of the Python package:

language:python
from __future__ import print_function
import qwiic_gpio
import time
import sys


def runExample():

    print("\nSparkFun Qwiic GPIO Example 2\n")
    myGPIO = qwiic_gpio.QwiicGPIO()

    if myGPIO.isConnected() == False:
        print("The Qwiic GPIO isn't connected to the system. Please check your connection",
              file=sys.stderr)
        return

    myGPIO.begin()
    myGPIO.mode_0 = myGPIO.GPIO_IN
    myGPIO.mode_1 = myGPIO.GPIO_IN
    myGPIO.mode_2 = myGPIO.GPIO_IN
    myGPIO.mode_3 = myGPIO.GPIO_IN
    myGPIO.mode_4 = myGPIO.GPIO_IN
    myGPIO.mode_5 = myGPIO.GPIO_IN
    myGPIO.mode_6 = myGPIO.GPIO_IN
    myGPIO.mode_7 = myGPIO.GPIO_IN
    myGPIO.setMode()

    while True:
        myGPIO.getGPIO() #This function updates each in_status_x variable
        print("GPIO 0:", end="")
        print(myGPIO.in_status_0, end="")
        print("GPIO 1:", end="")
        print(myGPIO.in_status_1, end="")
        print("GPIO 2:", end="")
        print(myGPIO.in_status_2, end="")
        print("GPIO 3:", end="")
        print(myGPIO.in_status_3, end="")
        print("GPIO 4:", end="")
        print(myGPIO.in_status_4, end="")
        print("GPIO 5:", end="")
        print(myGPIO.in_status_5, end="")
        print("GPIO 6:", end="")
        print(myGPIO.in_status_6, end="")
        print("GPIO 7:", end="")
        print(myGPIO.in_status_7)
        time.sleep(.25)

if __name__ == '__main__':
    try:
        runExample()
    except (KeyboardInterrupt, SystemExit) as exErr:
        print("\nEnding Example 1")
        sys.exit(0)

Qwiic GPIO Example 3

Example 3 demonstrates how to invert an I/O pin configured as an input. We first set all eight pins as inputs and then invert half of them using the setInversion(self) function. As we covered in the Arduino Examples section, each I/O pin set as an input defaults to an active HIGH input so inverting it switches it to an active LOW input. Again, note that you need to define the inversion status of each pin you wish to invert and then write that data using the setInversion function.

language:python
from __future__ import print_function
import qwiic_gpio
import time
import sys


def runExample():

    print("\nSparkFun Qwiic GPIO Example 3\n")
    myGPIO = qwiic_gpio.QwiicGPIO()

    if myGPIO.isConnected() == False:
        print("The Qwiic GPIO isn't connected to the system. Please check your connection",
              file=sys.stderr)
        return

    myGPIO.begin()
    myGPIO.mode_0 = myGPIO.GPIO_IN
    myGPIO.mode_1 = myGPIO.GPIO_IN
    myGPIO.mode_2 = myGPIO.GPIO_IN
    myGPIO.mode_3 = myGPIO.GPIO_IN
    myGPIO.mode_4 = myGPIO.GPIO_IN
    myGPIO.mode_5 = myGPIO.GPIO_IN
    myGPIO.mode_6 = myGPIO.GPIO_IN
    myGPIO.mode_7 = myGPIO.GPIO_IN
    myGPIO.setMode()

    myGPIO.inversion_0 = myGPIO.INVERT
    myGPIO.inversion_1 = myGPIO.NO_INVERT
    myGPIO.inversion_2 = myGPIO.INVERT
    myGPIO.inversion_3 = myGPIO.NO_INVERT
    myGPIO.inversion_4 = myGPIO.INVERT
    myGPIO.inversion_5 = myGPIO.NO_INVERT
    myGPIO.inversion_6 = myGPIO.INVERT
    myGPIO.inversion_7 = myGPIO.NO_INVERT
    myGPIO.setInversion()

    while True:
        myGPIO.getGPIO()  # This function updates each in_status_x variable
        print("GPIO 0:", end="")
        print(myGPIO.in_status_0, end="")
        print("GPIO 1:", end="")
        print(myGPIO.in_status_1, end="")
        print("GPIO 2:", end="")
        print(myGPIO.in_status_2, end="")
        print("GPIO 3:", end="")
        print(myGPIO.in_status_3, end="")
        print("GPIO 4:", end="")
        print(myGPIO.in_status_4, end="")
        print("GPIO 5:", end="")
        print(myGPIO.in_status_5, end="")
        print("GPIO 6:", end="")
        print(myGPIO.in_status_6, end="")
        print("GPIO 7:", end="")
        print(myGPIO.in_status_7)
        time.sleep(.25)

if __name__ == '__main__':
    try:
        runExample()
    except (KeyboardInterrupt, SystemExit) as exErr:
        print("\nEnding Example 1")
        sys.exit(0)

Resources and Going Further

That wraps up this Hookup Guide! For more information about the Qwiic GPIO, take a look at the following links:

Not sure where to start with your next input/output project? These Input Tutorials might help for inspiration:

no tutorials found

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Setting up a Rover Base RTK System

$
0
0

Setting up a Rover Base RTK System a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1362

Introduction

This tutorial will walk you through setting up a base and rover so that your rover can have the ~14mm accuracy that surveyors use! This can be useful for all sorts of projects including agriculture, drones, mapping, and even some extreme geocaching.

ZED-F9P connected via USB to SW Maps

The SW Maps app for Android connected to a ZED-F9P over USB C using RTK and a serial radio

We’ve been using the ZED-F9P from u-blox for a few years now. While it is a bit pricey (~$200) it is a fraction of the cost of other RTK systems ranging from $3,000 to $20,000 or more! The ZED-F9P is as impressively powerful as it is configurable. We will also be making liberal use of u-center from u-blox - don’t worry, we’ve got a tutorial for that. Unfortunately u-center is currently only for Windows. For the more adventurous, SparkFun has created a popular and powerful u-blox Arduino library that can do everything u-center can from an Arduino.

Quick note: You will see the terms GPS and GNSS used interchangeably throughout this tutorial. GNSS, or Global Navigation Satellite System, is the collective term for all GPS (USA), GLONASS (Russia), BeiDou (China), and Galileo (EU) satellites. GPS was the predominant constellation up to about 2017. After this time enough BeiDou satellites were functional and enough GLONASS satellites were transmitting additional bands (L2, etc) that advanced receivers are now designed to receive signals from a variety of constellations rather than just GPS. This is a very good thing. With more satellites and more frequencies we can improve accuracies greatly. Said differently, you don’t own a GPS receiver, you own a GNSS receiver. Congrats!

Do I really need RTK?

Great question. With a ZED-F9P and a u-blox L1/L2 antenna (and no RTK correction data) we’ve seen 30 or more satellites and horizontal positional accuracies better than 300mm. This is incredibly precise for a single receiver and should be adequate for many projects. RTK is a challenge to setup but once complete you should be able to obtain an RTK fix which has 14mm of accuracy (the precision is sub millimeter). To put the ZED-F9P in perspective, the SAM-M8Q is a great receiver, but can only receive L1 frequencies and has horizontal accuracy of 2.5m (2500mm). The ZED-F9P is far more accurate.

Note: It's best to get an RTK system worked out from the comfort of your desk. Don't go into the field with a laptop and try to get everything working outside.

Suggested Reading

Before getting started, be sure you are comfortable with Getting Started with U-Center and be sure to checkout our What is GPS RTK? tutorial.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

What is GPS RTK?

Learn about the latest generation of GPS and GNSS receivers to get 14mm positional accuracy!

Getting Started with U-Center for u-blox

Learn the tips and tricks to use the u-blox software tool to configure your GPS receiver.

GPS-RTK2 Hookup Guide

Get precision down to the diameter of a dime with the new ZED-F9P from Ublox.

Updating the Receiver Firmware

Please make sure both base and rover receivers have the most up to date firmware from u-blox. As of writing, there has been a new v1.13 firmware release. U-blox provides a simple to use upgrade tool inside of u-center. You can find the latest firmware for all u-blox receivers on their website under the documentation and resources tab. We found our ZED-F9Ps benefitted from migrating from v1.12 to v1.13. We can now receive from EGNOS!

Lots of satellites being received

Look at all those satellites!

alt text

Firmware version 1.13

To check your firmware, open the messages window. Shrink the NMEA branch by double clicking on ‘NMEA’. Expand the UBX branch and look for ‘MON’ or monitor. Expand MON and look for VER (last on the list). FWVER will indicate your current firmware version.

Using the firmware update tool in u-center

If you have an older version of firmware download the latest binary from u-blox. Open the Tools->Firmware Update menu and follow the prompts. Note: We had to uncheck ‘Enter safeboot before update’ to get our module to update.

Setting Up a Temporary Base

GPS RTK antenna on camera tripod

A basic GNSS antenna on a tripod

The first step in a base/rover setup is setting up a base station. There are a few ways to set up a base station: a temporary base station is faster but less precise. A static base station takes more time to set up and configure but provides the greatest precision. There is a third option and that is getting your correction data from a public feed. That option is covered in this tutorial and so we will not cover public correction data in this tutorial.

We’ve covered setting up a temporary base station in a previous tutorial but we will go a bit more in depth here. Additionally, this tutorial will cover the settings required for the ZED-F9P (rather than the previous generation NEO-M8P).

Above is the u-blox antenna attached to the ground plate, on top of a tripod, with SMA cable running indoors to the receiver. This is a great setup for experimenting and for short trips to the field. The purpose of a GNSS RTK base is to not move. Once you tell a receiver that it is a base station (ie, not moving) it will begin to look at the satellites zooming overhead and calculate its position. As the environment changes the signals from the GNSS (Global Navigation Satellite System - the collective term for GPS, GLONASS, Beidou, Galileo satellites) network change and morph. Because the base knows it is motionless, it can determine the disturbances in the ionosphere and troposphere (as well as other error sources) and begin to calculate the values needed to correct the location that the satellites are reporting to the actual location of the base station. These values are unsurprisingly called ‘correction values’ and are encoded into a format called RTCM. (RTCM stands for Radio Technical Commission for Maritime but is just a name for a standard akin to “802.11”. Don’t worry about it.). You will often see the term RTCM3 being used; this is simply correction data being transmitted using version 3 of the RTCM format.

Ok, so how do we set up a base? You’ll need the following:

Things you will need:

  • A ZED-F9P receiver with a USB cable connected to your computer.
  • A clear view of the sky. Not indoors, not near a window, outside with nothing around. The accuracy of the entire system depends on the ability to see as many satellites as possible.
  • An antenna. We enjoy and promote the use of low-cost antennas and gear. You can easily spend >$2,000 on a commercial grade GNSS antenna but we’ve had great success with the u-blox L1/L2 antenna. You must absolutely have an antenna that is L1/L2 compatible. A simple magnetic GPS antenna will receive L1 frequencies but RTK will be very inaccurate if it’s even possible.
  • If your antenna does not have a built in ground plane (the u-blox antenna does not) you will need to add a metal ground plate. A car’s roof will act as a ground plate as well.
  • A tripod or car roof to mount the antenna. We’ve found cheap camera tripods work fine. We designed the ground plates to have a compatible 1/4"-20 hole so they screw directly onto the tripod.
  • A way to get the RTCM correction data to the rover: computer with internet connection, serial point to point radio, XBee modules, etc. We will be using the 915MHz Serial Telemetry Radio kit.
  • An SMA extension cable (~10m or whatever you need to get from outside to your work computer).

Note: The accuracy of the base’s location will be reflected in the accuracy of the rover’s position. Said differently, if the base is incorrectly recorded 1m away from its actual location than all the rover readings will be exactly 1m wrong. It’s really important to locate the antenna with a clear view of the sky and to obtain an accurate base station location.

SparkFun GPS-RTK2 Board - ZED-F9P (Qwiic)

SparkFun GPS-RTK2 Board - ZED-F9P (Qwiic)

GPS-15136
$219.95
20
SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic)

SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic)

GPS-16481
$219.95
5

Once you’ve got the antenna in place, connect the ZED-F9P to USB and to the antenna. We offer two variants of the Qwiic RTK. If you’ve got the SparkFun GPS-RTK2 with U.FL antenna connection, you’ll need to connect the U.FL to SMA adapter. Here are some good pictures to show you how to correctly connect a U.FL cable. If you’ve got the SparkFun GPS-RTK-SMA simply screw the antenna onto the SMA connector.

Open u-center and connect to the corresponding COM port that Windows created when the board was connected.

Opening the COM port in u-center

Having Problems With COM Ports? Please checkout our tutorial on u-center specifically. It will walk you through driver install and determining which COM port is the receiver.

u-center with GNSS data

You should begin to see things change and data flowing through. Above shows the ZED-F9P running for a few minutes obtaining a heap of satellites and achieving 0.9m horizontal accuracy. Let’s open the Messages window and begin configuring the module.

Messages window showing many branches

First, close the NMEA branch to get it out of the way. Open the UBX branch and then the CFG configuration branch. The number of configuration options can be overwhelming at first but over time they can become quite helpful. We are looking for MSG.

Take this moment and ask yourself how you will be transmitting the correction data from the base to the rover. The correction data, or RTCM, varies in size but is approximately 1 to 2k bytes per second. Tiny compared to downloading a song or video, but just large enough that LoRa and smaller packet radios may not be able to handle it. We recommend using a Serial Telemetry Radio. Running at 915MHz, these radios can hit ~300m out of the box at 100mW with a 500mW option available as well. The radios act as a transparent serial passthrough at 57600bps (out of the box). We’ve found them to be just about perfect for Base to Rover RTCM communication with the only limitation being distance. If you need miles of range, you will need to get your HAM radio license and crank the power. But if you’re just getting started with RTK, these radios are great!

Enabling RTCM messages

We are going to assume a telemetry radio will be attached to UART2 of the ZED-F9P. From u-center Messages window, enable the following messages for both UART2 and USB.

  • RTCM3.3 1005
  • RTCM3.3 1074
  • RTCM3.3 1084
  • RTCM3.3 1094
  • RTCM3.3 1124
  • RTCM3.3 1230 x 5 (Enable message every 5 seconds)

As you set each setting, you will need to press the ‘Send’ button. It doesn’t hurt to press the ‘Poll’ button to verify the setting has stuck.

We recommend enabling these messages for both USB and UART2 as shown in the photo. This will tell the module to begin transmitting just these RTCM sentences (message types) once the module has completed its survey. UART2 is best used for sending serial RTCM in/out. USB is enabled so that we will be able to see and verify that RTCM messages are actually being output by the module.

Set UART2 baud to 57600bps

Next, set UART2 to the appropriate baud rate. Scroll down to the ‘PRT’ or port settings. Select UART2. By default it is 38400bps and the radios expect 57600bps. Increase the speed. Remember to press ‘Send’.

Save settings to BBR/Flash

Now scroll up to the CFG or config option. This menu allows us to save the current settings. When you plug in your module again, you won’t have to re-do all these settings. BBR is battery backed RAM. There is a small battery on the SparkFun GPS-RTK boards that should maintain the settings for over a week. The Flash setting records the settings to flash memory as well so if the battery loses power, flash will maintain the settings (also called non-volatile memory or NVM).

Starting the Survey In with settings

The last thing to do is to initiate a survey in. Navigate to the TMODE3 menu, set the mode to '1 - Survey-In', set the observation time to 60s, and required accuracy to 5m. These are the settings that u-blox recommends. Press ‘Send’ and sit back. It can take many minutes for the module to obtain enough fixes to have a standard deviation less than 5m.

Note: You can enter the observation time and required accuracy values then save the current settings to BBR/Flash. This will effectively tell your module to survey-in at every power-on. This can be handy in many field deployments where u-center is not available but use it with caution. I have been very confused a few times when my device stopped updating its position because I had left it in survey-in mode and didn’t realize it.

Enable the SVIN message

To monitor the status of the survey, scroll down, exiting the CFG section and enter the NAV section. Right click on ‘SVIN’ and click on Enable Message. This will tell the module to send the status of this register every second. Once the module has gotten 60s of data and the mean standard deviation is less than 5m then the survey will report ‘Complete!’. This module’s lat/long/height will no longer change because it has been fixed.

Checking the PVT Fix Type

You can verify the survey in is complete by checking the PVT message. If the Fix Type is ‘TIME’ then you know you have successfully setup a base. Congrats!

Viewing the packet console

Furthermore, we can view the RTCM messages. Open the packet console. If the RTCM messages have been enabled and the survey-in is complete, we should see the RTCM messages scroll by. Note: The RTCM messages are not visible ASCII like NMEA sentences, they are encoded bytes of data. You can't 'see' them in the Text Console but they are shown in the Packet Console.

What about fast update rates? The ZED-F9P is capable of outputting up to 30Hz fix rates. This is an astounding amount of math. “Isn’t moar, better?”™ Not really for RTK. The base is transmitting correction values once per second. We could increase the output of the module to 4 or 10Hz, but because the conditions between you and the satellites are not changing that quickly, it really only bogs down your radio link.

The Radio connected to UART2 of the GPS-RTK-SMA

The last thing we need to do is attach our radio. Cut the 6 pin JST-GH cable that came with the Serial Radio Telemetry kit in half. Plug the cable into one radio and note where the TX, RX, 5V and GND pins fall. Go slow. I wired TX/RX backwards and caused myself an hour’s worth of grief. I recommend stripping one wire at a time as this makes it clear which wire I’m working on. Solder the wires as follows:

  • Radio 5V - RTK 5V
  • Radio TX - RTK RX2
  • Radio RX - RTK TX2
  • Radio GND - RTK GND

For the advanced readers of this tutorial, go ahead and wire solder the second radio cable to your rover module in exactly the same way.

Shown above, I wired the radio to the 6-pin UART2 header. This space is normally used for the 6-pin connection to a Bluetooth module so if you’d like to leave those pins open (for future potential Bluetooth) you can also solder the radio to the TX2/RX2 pins on the side of the GPS-RTK board. We wired the radio to 5V instead of 3.3V on the 6-pin header. We have seen the radios work at 3.3V but a high voltage should get you the maximum transmit distance.

Now is a good time to mark your module with a sharpie or a ‘BASE’ label so you know which module is which.

Advanced User Trick

Saving a configuration file

Rather than hunting and pecking each individual setting it can be handy to have various configuration files at the ready to configure a given module. Click on Tools->Receiver Configuration. This will allow you to save the current configuration to a file and load it onto a new unit. Here is the survey-in prep configuration that I use (RTCM messages enabled, UART2 set to 57600, no survey-in settings). Save the link as 'survey-in-config.txt' and load using u-center. Once you load the config be sure to record it to BBR/Flash.

Rover Setup

We're going to assume you've got a base station setup, either as a temporary base or with ECEF coordinates (we’ll go into that advanced topic later). u-blox has some good documents on how to set up the ZED-F9P in rover mode but it's surprisingly easy. The rover simply needs to be fed RTCM corrections and it will enter RTK Float, then RTK Fix.

Open u-center and connect to the rover module. Multiple instances of u-center can be started if you have multiple modules connected to one computer.

Set UART2 baud to 57600bps

Navigate to the CFG / PRT message and configure UART2. We want to set UART2 to 57600bps to match the base and the telemetry radio kit we will be using.

Save settings to BBR/Flash

Now save these port settings so they get loaded at each power-on.

Note: If you ever run into problems with the configuration of a module you can always select 'Revert to default configuration' and hit send. This should give your module a good brainwash returning it to the default factory settings. This command will also reset the BBR/Flash settings.

Serial Telemetry Radio attached to SparkFun ZED-F9P

Solder the other half of the radio cable to the UART2 on the rover receiver. The setup is exactly the same as before with the base receiver:

  • Radio 5V - RTK 5V
  • Radio TX - RTK RX2
  • Radio RX - RTK TX2
  • Radio GND - RTK GND

Time for a test! Power up the rover and base and you should see the green LED on the radios go from blinking to solid indicating the radios detect each other and are passing serial data between them. A blinking red LED on the radios indicates serial data being transmitted.

That’s it! This rover module is now ready for the field. It is still recommended to have u-center handy to view the status of the rover as it receives RTCM corrections. As the rover receives RTCM it will quickly move from a 3D fix, to RTK Float, to RTK Fix.

u-center showing positional accuracy

There are a few messages to watch while the rover achieves RTK Fix. NAV/HPPOSECEF will show overall positional accuracy, NAV/HPPOSLLH will show the horizontal accuracy. NAV/PVT will show the fix type as it progresses from 3D, to RTK Float, to RTK Fixed.

PSST: We messed up. The RTK LED on the GPS-RTK boards is wired to ground instead of 3.3V. This means the RTK LED will be on in normal non-RTK mode. Once RTCM is being received and the module enters RTK Float the LED will blink. Once enough corrections are received, the RTK LED will turn off indicating RTK Fixed mode which is the best, 14mm horizontal accuracy situation.
  • RTK LED On = Regular Satellite Mode
  • RTK LED Blinking = RTK Float, ~<500mm accuracy
  • RTK LED Off = RTK Fix, 14mm acurracy

SW Maps appSW Maps showing 14mm horizontal accuracy

SW Maps is a great way to view and use the positional information from the ZED-F9P

Once the rover has achieved RTK fixes, what next? The ZED-F9P will be outputting high-precision coordinates UART1 and USB. Any microcontroller that can parse serial can figure out where it is in the world with millimeter accuracy. For surveying applications, we have been blown away with the android app SW Maps. Made by an impressive team in Nepal, SW Maps is a superb app to connect to ZED-F9Ps and record various GIS and surveying points of interest (POI).

Phone connected to ZED-F9P over USB C

Connecting a ZED-F9P to SW Maps is as simple as a USB C to C cable (assuming your cell phone is USB-C, microB OTG also works). The ZED-F9P will show up as a serial device on Android. SW Maps will connect and display all the position data, RTK status, give the user the ability to record waypoints, tracks, survey information, and notes; perfect for DIY surveying of infrastructure and properties.

In the image above we are using a camera monopod with a bolt on cell phone holder and have been really pleased with the setup (be sure to get a holder capable of 1" / 27mm diameter in order to bolt to the monopd).

Note: If you plan to use SW Maps there are two additional settings that we recommend setting with u-center before going into the field.

  1. Enable GxGST messages

Enable GxGST message for USB

Turning on GxGST for USB interface

Turning on the GxGST NMEA sentence will transmit the various, lat, long, horizontal, and vertical positional errors. This sentence is needed to see the values in SW Maps GNSS Status window.

Enabling SV numbering and high precision NMEA

Enable High Precision NMEA and SV numbering
  1. Enable High Precision mode

This will extend the decimals of Lat/Long and setting the Numbering used for SVs will get around a NMEA limit for satellites in view. And High precision NMEA increases the number of decimal places from 5 to 7.

$GNGLL,4005.42027,N,10511.08674,W,180753.00,A,D*63

$GNGLL,4005.4202248,N,10511.0867652,W,180817.00,A,D*60

Again, if you plan to use these settings on a regular basis consider saving them to BBR/Flash so that they will be loaded at each power-on.

SW Maps built in NTRIP client

In addition to being able to connect directly to u-blox receivers, when you select a u-blox RTK receiver inside SW Maps and connect, you will be able to enable an NTRIP Client. Once logged in to an NTRIP caster, your phone will download the correction data from the server over its cellular connection and pass the RTCM to the GNSS receiver over USB. SW Map is just amazing! Note: In this example we are using the 915MHz Serial Telemetry Radios to transmit the RTCM correction data so you do not need to connect an NTRIP Client for corrections... But you can see where we are headed in the next tutorial!

Troubleshooting RTCM

Viewing RTCM messages from the radio in packet console

If you’re unsure RTCM messages are coming through the RF link, disconnect the JST cable from the radio on the rover and attach a microB USB cable into the 915MHz radio. This will create a COM port. Open u-center and connect to the radio at 57600bps as if it were a GNSS receiver. Then open the packet console. If RTCM messages are being received from the base, u-center will correctly interpret the incoming RTCM messages and display them in the packet console.

Resources and Going Further

Deploy! You're ready to start testing with RTK. Head out into the world.

It’s time to go into the field. If you’ve configured your modules and saved the settings to BBR/Flash they should be able to be powered up and autonomously begin the RTK link. Once the base has completed its survey-in process it should begin transmitting RTCM over the radio link. After receiving only a few seconds worth of RTCM over the radio link the rover's ZED-F9P receiver should enter RTK Float, then RTK Fix, and begin outputting high accuracy positional data. You also have the option of using a microcontroller on one or both receivers to tailor the configuration based on conditions, location, etc. The microcontroller, in conjunction with the SparkFun u-blox Arduino Library can configure the module for custom setups in the field.

We recommend experimenting with the basic radio-linked RTK setup to get used to the process. In our next tutorial we will show you how to use NTRIP to connect a rover to your correction data over a cellular link.

Here are some additional tutorials you may find interesting.

Building an Autonomous Vehicle: The Batmobile

Documenting a six-month project to race autonomous Power Wheels at the SparkFun Autonomous Vehicle Competition (AVC) in 2016.

What is GPS RTK?

Learn about the latest generation of GPS and GNSS receivers to get 14mm positional accuracy!

Getting Started with U-Center for u-blox

Learn the tips and tricks to use the u-blox software tool to configure your GPS receiver.

GPS-RTK2 Hookup Guide

Get precision down to the diameter of a dime with the new ZED-F9P from Ublox.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

SparkFun Qwiic Shield for Teensy Hookup Guide

$
0
0

SparkFun Qwiic Shield for Teensy Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1296

Introduction

The SparkFun Qwiic Shield for Teensy and SparkFun Qwiic Shield for Teensy Extended provide an easy-to-assemble way to add the SparkFun Qwiic ecosystem to Teensy development boards. Both of these shields connect the I2C bus (GND, 3.3V, SDA, and SCL) on your Teensy to four SparkFun Qwiic connectors. The Qwiic ecosystem allows for easy daisy chaining so, as long as your devices are on different addresses, you can connect as many Qwiic devices as you'd like.

SparkFun Qwiic Shield for Teensy

SparkFun Qwiic Shield for Teensy

DEV-17119
$3.95
SparkFun Qwiic Shield for Teensy - Extended

SparkFun Qwiic Shield for Teensy - Extended

DEV-17156
$4.50

Required Materials

To follow along with this tutorial, you will need a Teensy development board with either the "standard" or "extended" form factor. Here are is a collection of the compatible boards. Note, some of them come with headers pre-populated, so keep that in mind when considering which headers to populate on your shield.

Teensy 4.1

Teensy 4.1

DEV-16771
$26.95
2
Teensy 4.0

Teensy 4.0

DEV-15583
$19.95
6
Teensy 4.1 (Headers)

Teensy 4.1 (Headers)

DEV-16996
$30.95
Teensy 4.0 (Headers)

Teensy 4.0 (Headers)

DEV-16997
$22.95

The Qwiic Shield includes a set of stackable headers to fit the Teensy footprint but you may also need some headers to solder to your Teensy. Or if you would prefer to use another header type for your shield assembly we've listed a few options below:

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
Female Headers

Female Headers

PRT-00115
$1.50
7
Teensy Header Kit

Teensy Header Kit

PRT-13925
$1.50
Now you probably would not want the Qwiic Shield for Teensy if you didn't have any Qwiic products to use with it, right? Well, if you don't have any Qwiic products, the following might not be a bad place to start:
SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)

SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)

GPS-15712
$64.95
2
SparkFun 16x2 SerLCD - RGB Text (Qwiic)

SparkFun 16x2 SerLCD - RGB Text (Qwiic)

LCD-16397
$19.95
SparkFun Qwiic Motor Driver

SparkFun Qwiic Motor Driver

ROB-15451
$14.95
1
SparkFun Cryptographic Co-Processor Breakout - ATECC508A (Qwiic)

SparkFun Cryptographic Co-Processor Breakout - ATECC508A (Qwiic)

DEV-15573
$4.95$4.10

You will need some of our Qwiic cables to connect your devices to the shield. Below are a few options:

Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95

Lastly, if you want to use a non-Qwiic I2C device, these adapters help to convert it to a Qwiic connector:

Qwiic Cable - Breadboard Jumper (4-pin)

Qwiic Cable - Breadboard Jumper (4-pin)

PRT-14425
$1.50
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
Qwiic Cable - Female Jumper (4-pin)

Qwiic Cable - Female Jumper (4-pin)

CAB-14988
$1.50

Required Tools

You will need a soldering iron, solder, and general soldering accessories to solder the header pins to the Qwiic shields:

Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.50
2
Soldering Iron - 30W (US, 110V)

Soldering Iron - 30W (US, 110V)

TOL-09507
$9.95
7

Suggested Reading

If you aren't familiar with the Qwiic system, we recommend reading here for an overview:

Qwiic Connect System
Qwiic Connect System

We would also recommend taking a look at the following tutorials if you aren't familiar with them:

How to Solder: Through-Hole Soldering

This tutorial covers everything you need to know about through-hole soldering.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Getting Started with the Teensy

Basic intro to the Teensy line of products, with soldering and programming suggestions.

Arduino Shields v2

An update to our classic Arduino Shields Tutorial! All things Arduino shields. What they are and how to assemble them.

Hardware Overview

Qwiic Connectors

The Qwiic Shields for Teensy each have four Qwiic connectors on them. The two on the edges are the standard horizontal connectors and the two in the middle are vertical connectors.

Note, the horizontal Qwiic connector on the "top" (aka North end) of the non-extended version is positioned slightly downward to allow space for proper cable insertion, and to avoid any conflicts with the nearby 6-pin header on the edge of the board.

Teensy Qwiic ConnectorsTeensy Extended Qwiic Connectors

Program Button

Each of these shields have a "PROG" button. This is to allow easier access to a programming button for each time you want to upload to the Teensy. Note, it is electrically in parallel with the "PROG" button on the Teensy boards themselves. This means that you can choose to use either the button on your Teensy or the button on the shield. If your shield is located on top of your Teensy (using stack-able headers), then it will be much more accessible to use the button on the shield, rather than trying to reach under the shield.

Teensy Program ButtonTeensy Extended Program Button

I2C Jumper

This jumper is a little different than our normal I2C pull up jumpers as it is open by default. The jumper only needs to be closed if your attached I2C device does not have pull up resistors. Essentially all SparkFun I2C breakouts come with pull up resistors on them so if you are using a Qwiic I2C device or another SparkFun I2C device, you can most likely leave it open. When closed, the SDA and SCL lines are pulled to 3.3V by 4.7K&ohm; resistors. If you have never worked with solder jumpers before, check out this tutorial for some tips and tricks for working with them.

Teensy I2C JumperTeensy Extended I2C Jumper

External Power Input

These shields include an optional 3.3V power input. The 3.3V pin off of the Teensy is rated to supply 250mA. If your project requires more than that on the Qwiic 3.3V power rail, then you should consider supplying a separate power source and soldering it into the header pins labeled "ALT 3V3". Note, you must also cut the jumper labeled "ISO" to properly isolate the Teensy's 3.3V power rail from your external.

Optional External Power InputExtended Optional External Power Input

Note, when using the external power input header, you may notice a slight voltage drop. This is because we have included a protective diode in the circuit. For most applications, this will be fine to leave in place. For more advanced users, we have included a bypass jumper to easily bypass this jumper and have a direct connection to the 3.3V power net.

Schematic highlightExternal power input header and bypass jumper

Board Dimensions

The Qwiic Shield for Teensy measures 0.70in x 1.40in (17.78mm x 35.56mm). The extended version measures 0.70in x 2.40in (17.78mm x 60.96mm). Note, because these are such small form factor boards, they do not have any standoff holes. They simply rely on the headers for both electrical connections and "mounting hardware".

Qwiic Shield for Teensy DimensionsQwiic Shield for Teensy Extended Dimensions

Hardware Assembly

To get started using the Qwiic Shield for Teensy, solder the headers onto your Teensy board and your Qwiic Shield. You may choose to use the included stackable header kit or any combination of male/female breakaway headers. Below we show a couple options using standard breakaway headers. Note, for best access to the program button on the shield and the two vertical Qwiic connectors, it is best to have it be the top of your stack.

Teensy 4.0 and shield with M/F headers soldered into place.Teensy 4.1 and extended shield with M/F headers soldered into place.

Once you have soldered headers to your shield and connected it to your Teensy, it's time to start connecting Qwiic devices! Below you can see an example of each shield connected to the appropriate Teensy (4.0 or 4.1). Here we used our standard breakaway headers along with a couple of Qwiic Devices chained to it.

Teensy Example HookupTeensy Extended Example Hookup

If you are using the upper-most qwiic connector on the Qwiic Shield for Teensy, please check out the following tips. It helps to bend/curl your Qwiic cable a bit before inserting it into the right-angle connector on the sheild.

Qwiic Cable

Qwiic Cable with a bend.

With the bend in place, you can better align it before inserting it all the way.

Qwiic Cable Being Inserted

Initial alignment.

To avoid stressing the cable wires, it is best to push the Qwiic connector using your fingernails on the sides of the connector plastic. Tweezers can also do the trick.

Qwiic Cable Inserted with Fingernails

Pressing on the sides of the plastic is ideal.

Resources and Going Further

That's a wrap! Your Qwiic Shield for Teensy/Teensy Extended is now ready to connect to any of a host of Qwiic devices SparkFun offers. For more information, take a look at the resources below.

Qwiic Shield for Teensy

Qwiic Shield for Teensy Extended

Even More Resources

If you are having trouble getting your Qwiic devices to connect using your newly assembled Qwiic Shield, you may want to take a look at these tutorials for help troubleshooting and reworking your shield.

Now that you have your Qwiic Shield ready to go, it's time to check out some Qwiic products. Below are a few to get started.

SparkFun Triple Axis Magnetometer Breakout - MLX90393 (Qwiic)

SparkFun Triple Axis Magnetometer Breakout - MLX90393 (Qwiic)

SEN-14571
$14.95
SparkFun 9DoF IMU Breakout - ICM-20948 (Ding and Dent)

SparkFun 9DoF IMU Breakout - ICM-20948 (Ding and Dent)

DD-15182
$8.95
Qwiic Arcade - Red

Qwiic Arcade - Red

SPX-15591
$5.95
SparkFun GPS Breakout - NEO-M9N, Chip Antenna (Qwiic)

SparkFun GPS Breakout - NEO-M9N, Chip Antenna (Qwiic)

GPS-15733
$69.95
1

Before you go, here are some other tutorials using the Qwiic Connect System you may want to look through:

SparkFun LoRa Gateway 1-Channel Hookup Guide

How to setup and use the LoRa Gateway 1-Channel in Arduino.

Qwiic Pro Kit Project Guide

The Qwiic Pro Kit was designed to allow users to get started with Arduino without the need for soldering or a breadboard. We've included three inputs (a joystick, accelerometer, and proximity sensor) and one display that can be daisy chained to the RedBoard Turbo (SAMD21) Development Board.

Qwiic Atmospheric Sensor (BME280) Hookup Guide

Measure temperature, humidity, barometric pressure with the SparkFun Atmospheric Sensor Breakout BME280 (Qwiic).
New!

The ClockClock Project

Tell the time with this fantastic Alchitry project using clocks to make a clock!

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

How to Build a DIY GNSS Reference Station

$
0
0

How to Build a DIY GNSS Reference Station a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1363

Introduction

SparkFun RTK Base Station

The SparkFun RTK Base Station complete with an NTRIP internet connection and a 915MHz RF connection

GNSS Real Time Kinematics (RTK) is amazing but one of the major confusion points is getting access to correction data. We’ve covered how to get publicly accessible RTCM correction data in previous tutorials but it can be spotty. We’ve covered how to set up your own temporary base to send RTCM correction data over a telemetry radio link, but what if you are a kilometer or more from your base? This tutorial will focus on setting up your own fixed antenna on your roof or other fixed structure and configuring a mini-computer to serve that data over the internet where it can be accessed by WiFi or more commonly, from a cellular phone or modem. Consider this the sequel to Setting up a Rover Base RTK System.

Suggested Reading

Before getting started, be sure you are comfortable with Getting Started with U-Center and be sure to checkout our What is GPS RTK? tutorial.

What is GPS RTK?

Learn about the latest generation of GPS and GNSS receivers to get 14mm positional accuracy!

Getting Started with U-Center for u-blox

Learn the tips and tricks to use the u-blox software tool to configure your GPS receiver.

GPS-RTK2 Hookup Guide

Get precision down to the diameter of a dime with the new ZED-F9P from Ublox.
New!

Setting up a Rover Base RTK System

Getting GNSS RTCM correction data from a base to a rover is easy with a serial telemetry radio! We'll show you how to get your high precision RTK GNSS system setup and running.

We’re going to talk a lot about NTRIP. I found all the descriptions and graphics describing NTRIP to be frustratingly confusing. NTRIP is just a fancy means of getting correction data from a spot, over the internet, to a rover. Think of it like a music stream for your rover. For your rover to jam, you need to provide it a constant source of music. There’s a ton of services out there for music (youtube, Spotify, Pandora). Similarly, there are all sorts of sources for RTCM (Trimble, Leica, Telit, etc). All these RTCM services charge different amounts of money and act just differently enough to be confusing. But all I want is my music!

This tutorial will show you how to generate your own GNSS correction data and push it to the internet, all for free (or the cost of a dedicated mini-PC if you need it)! You’ll be your own music streaming service! Your rover will be able to listen to that correction data using a cell phone connection. Yes we will talk about NTRIP clients and servers and mount points, but don’t worry; it’s just passing bytes from one computer to another over the internet.

Static Base Setup & LASERS!

In the previous tutorial we described how to create a temporary base station with the 1 to 10 minute survey-in method. The temporary base method is flexible, but it is not as accurate and can vary dramatically in time required. The ZED-F9P has a much faster way to provide base corrections: if you know the location of your antenna, you can set the coordinates of the receiver and it will immediately start providing RTCM corrections. The problem is ‘what is the location of the antenna?’. It’s as if you need a soldering iron to assemble your soldering iron kit. Where do we start?

Why don’t I just survey-in my fixed antenna to get its location?

While a survey-in is easy to set up and fine for an in-the-field way to establish the location of a base, it’s not recommended for getting the fixed location of a static base station as it is less accurate. Instead, PPP or Precise Point Positioning is far more accurate and is recommended for obtaining your antenna’s position. It’s a similar process but involves bouncing frick’n lasers off of satellites!

A major problem is that the predicted orbits are often off by one meter or more. Ground stations bounce lasers off the individual satellites as they pass overhead and use this new data to compute the actual orbits of the satellites. Using this new ephemeris data, when it becomes available, combined with the receiver’s raw data, better fixes can be computed. This is the basis of PPP.

From Gary Miller’s PPP HOWTO

L1/L2 antenna attached to roof

L1/L2 antenna semi-fixed to a flat roof

The PPP process works like this:

  • Install an antenna in a fixed location
  • Gather 24 hours worth of raw GNSS data from that antenna
  • Pass the raw data to a processing center for PPP
  • Obtain a highly accurate position of the antenna we use to set a ‘Fixed Mode’ on a receiver

There are some great articles written about PPP. We’ll scrape the surface but for more information checkout:

Affix Your Antenna

You don’t want your antenna moving once you’ve determined its position. Consider investing in a premium antenna but we’ve used the classic u-blox L1/L2 antenna with good success. Mount the antenna to a proper ground plane to a fixed surface that has a very clear view of the sky. No nearby anything.

u-blox antenna on SparkFun parapet

The u-blox antenna attached to SparkFun’s parapet

We mounted the u-blox antenna to the ferrous flashing around the top of the SparkFun building. While not completely permanent, the magnets on the u-blox antenna are tested to survive automobile strength winds so it should be fine in the 100+ MPH winds experienced in the front range of Colorado. The u-blox ANN-MB-00 antenna has a 5m cable attached but this was not long enough to get from the SparkFun roof to the receiver so we attached a 10m SMA extension. It’s true that most L1/L2 antennas have a built-in amplifier but every meter of extension and every connector will slightly degrade the GNSS signal. Limit the use of connector converters and use an extension as short as possible to get where you need.

If you want to use a higher grade antenna that doesn’t have a magnetic base we’ve come up with a great way to create a stable fix point without the need for poking holes in your roof!

Antenna on roof attached to cinderblock

Yes that’s a cinder block. Don’t laugh. It works!

Most surveying grade antennas have a ⅝” 11-TPI (threads per inch) thread on the bottom of the antenna. Luckily, ⅝” 11-TPI is the thread found on wedge anchors in hardware stores in the US. Wedge anchors are designed to hold walls to foundations but luckily for us we can use the same hardware to anchor an antenna. (We’ve also heard of concrete anchors that use epoxy so be sure to shop around.)

Old Weather Station with concrete blocks

I needed to mount an antenna to my roof. Luckily, I had two, left over cinder blocks from a weather station that, based on the Electric Imp, had long since been retired.

Drilling a hole in the cinder block

Step one is drilling the ⅝” hole into the cinder block. The masonry bit cost me $20 but cheaper, less fancy ones can be had for less than $10. The blue tape shows me the depth I’m trying to hit. The cinder block is 3.5” thick so I settled on ~2.5” deep. Once the hole is drilled, tip the block upside down to get most of the cement dust out. Then pound the anchor into place.

A broken cinder block

Ooops!

Don’t get greedy! I pounded the anchor so far it split the block. Luckily, I had a second block!

Foundation anchor in place

Once the anchor is ~2 inches into the hole tighten the bolt. This will draw the achor back up compressing the collar into place. Note: I finger tightened the bolt and added a ½ turn with a wrench. If you really go after the bolt and tighten it too much you risk pushing the collar out further and breaking the cinder block in half (see Ooops! picture above). We are not anchoring a wall here, just a 400g antenna.

Antenna affixed to the anchor

I used a 2nd bolt, tightened against the antenna base, to lock it into place and prevent rotation in either direction. Astute readers will notice my TNC to SMA adapter in the picture above. It’s the wrong gender. Originally, I used an SMA extension to connect my GPS-RTK-SMA to my u-blox L1/L2 antenna on my roof. The GPS-RTK-SMA expects a regular SMA connection so the end of the extension would not connect to this adapter. So before you get out the ladder, test connect everything! Luckily I have a set of adapters and found the right TNC to SMA converter to suit my needs.

Antenna on roof with Boulder Flatirons

It’s a bit of work getting 35lbs of concrete onto a roof but the view is pretty spectacular!

I wrapped the SMA extension once around the base. In case anything pulls on the SMA cable the tension will be transferred to the bolt rather than the TNC connection to the antenna.

Lightning Warning: My antenna profile is lower than the parapet so lightning strikes are unlikely. Your antenna may be the highest point around so consider lightning protection.

Gather Raw GNSS Data

Once you’ve got the antenna into a location where it will not move or be moved we need to establish its location. Open u-center and verify that you can get a lock and see 25+ satellites with your ZED-F9P. Assuming you’ve got good reception, we now need to set the receiver to output raw data from the satellites.

Enable the RAWX message

Once the RXM-RAWX message is enabled for USB, verify reception in the packet viewer.

Viewing a RAWX packet in the Packet Viewer

Viewing a RAWX packet in the Packet Viewer

RAWX messages are binary so you won’t be able to see them in the text viewer.

Pressing the record button

Pressing the record button

Hit the record button. This will record all the data (NMEA, UBX, and RAWX) from the receiver to a *.ubx file. Allow this to run for 24 hours. Don’t worry if you go long but do realize that a 24 hour file will be ~300MB so don’t let it run for a month.

Graph of record time vs position error

From Suelynn Choy ‘GNSS Precision Point Positioning’ presentation 2018

Capturing 6 hours is good, 24 is slightly better (note the logarithmic scale for position error in the graph above). Most PPP analyzation services will accept more than 24 hours of data but they may truncate it to 24 hours. If you capture 30 hours of RAWX data, that’s ok, we will show you how to trim a file that is too long.

RTKLIB conversion of ubx to obs

The 300MB UBX file will need to be converted to RINEX (Receiver Independent Exchange Format). The popular RTKLIB is here to help. We recommend the rtklibexplorer’s modified version of RTKLIB (available for download here) but you can obtain the original RTKLIB here. Open RTKCONV. Select your UBX file and hit ‘Convert’. Our 300MB file took ~30 seconds to convert. You should see an *.obs file once complete.

Opening an OBS file to view the start and stop time

An OBS file with 14 hours of data

If your data file is 25 hours or a little more, that’s fine. If you need to cut your RINEX file down because it’s too large (or 40 hours long) you can trim the time window. Convert the entire file then click on the notepad icon to open the OBS file. You’ll see the GPS start time and stop time for this capture.

Limiting the time window of the conversion

Using these times, you can limit the time window to whatever you need and re-convert the file.

Why don’t we crank up the fix rate? Moar is better!™

The ZED-F9P can go up to 30Hz. Why not get RAWX data at greater than 1Hz? Because nature doesn’t move that fast. Most PPP analyzation services will ignore anything greater than 1Hz. OPUS goes so far as to “decimate all recording rates to 30 seconds”. And, your OBS files will be monstrously large. If 24 hours is 300MB at 1Hz, it follows that 24 hours at 30Hz will be ~9 gig. So no, keep it at 1Hz.

We now need to pass the raw GNSS satellite data in RINEX format (*.obs) through a post processing center to try to get the actual location of the antenna. There are a handful of services but we’ve had great luck using the Canadian CSRS-PPP service. The US National Geodetic Service provides a service called OPUS but we found it to be frustratingly limited by file size and format issues. Your mileage may vary.

Selecting ITRF upload on CSRS for PPP

Zip your obs file then create an account with CSRS. Select ITRF then upload your file. Twiddle your thumbs for a few hours and you should receive an email with a fancy PDF report of your antenna’s location.

Output from CSRS

The SparkFun antenna with +/-7mm of accuracy! :O

If all goes well you should have a very precise location for your antenna. For u-blox receivers we are most interested in ECEF coordinates. ECEF is fascinating. Rather than lat and long, ECEF is the number of meters from the internationally agreed upon reference frame of the center of mass of the Earth. Basically, your ECEF coordinates are the distance you are from the center of the Earth. Neat.

Now that you’ve got the ECEF position of your antenna, let’s tell the ZED-F9P where its antenna is located with a few millimeters of accuracy.

Setting ECEF coordinates in u-center

Return to the TMODE3 message and enter the ECEF coordinates from the report. Assuming this receiver is attached to a fixed antenna, we recommend saving these settings to BBR/Flash so that every time this receiver powers on it will immediately enter TIME mode and start outputting RTCM data.

RTCM output in packet view

Almost immediately following ECEF entry your module should begin outputting RTCM messages. Use the packet viewer to confirm. If you don’t see them be sure to check out the previous tutorial describing how to set up a base station. More than likely you have not enabled the required RTCM message. Again, be sure to save your setting to BBR/Flash so that at every power on, this receiver will begin broadcasting correction data without user intervention.

Mini-Computer Setup

You’ve got your antenna setup. You’ve got the ZED-F9P outputting RTCM. Nice work! Now how do we get this data out to the world and into rovers everywhere?

Correction data is good up to 10km from a given base location. That said, for every 10km you add beyond it will add 1.5cm worth of inaccuracy to the location (I need to find the source of this statement, but I’m pretty sure it’s true). 10km is a long way to transmit over a wireless link so let’s use the internet instead!

A NUC connected to ZED-F9P, internet, and radio

NUC connected to a ZED-F9P and a 915MHz radio over USB

You will need an internet connected, dedicated computer to connect to the ZED-F9P, receive the serial data, and then forward that data on to the internet. We recommend using a PC for casting. Yes, Windows is painful and not as stable as Linux but because u-center is Windows only it's really the only option. It is extremely handy to be able to remote desktop into the dedicated machine, twiddle a few receiver settings using u-center, and continue broadcasting. I’m not sure how to get this same flexibility in Linux. Additionally, I am far from being a sysadmin. The following can be a helpful method for configuring your dedicated computer but really it’s just me, recording my notes, so that I can recreate the system when I need it.

  • Procure a derelict machine with Windows. We spent ~$100 for a mini-PC. Any old PC should do, you certainly don’t need hefty processing power. If possible, get a mini PC that includes mounting hardware. This will make it easier to attach to a wall or outdoor enclosure.
  • Within the mini-PC’s BIOS, enable auto-power on after power loss. Enable remote desktop. There are plenty of tutorials showing how to do this. The goal is to get the mini-PC to a point where you can configure and control the PC from the comfort of your desk, not the roof.
  • Consider making the IP address of the mini-PC static either from the mini-PC or your router via the mini-PC’s MAC address. This will make accessing the mini-PC over RDP (remote desktop protocol) a bit easier.
  • If you plan to access the mini-PC from an external network you will need to enable port forwarding on port 3389 (for RDP) to the static IP address of the mini-PC.
  • If you plan to use u-center as a caster you’ll need to enable port forwarding on port 2101 (for NTRIP) to the static IP address of the mini-PC (more in the following sections).
  • Disable windows power saving. The mini-PC should never turn off. If you’re worried about energy costs, it’s not zero, but we measured approximately 4.4W while the unit was tethered to the GNSS receiver and broadcasting. This is $5.07 a year at $0.13 per kWh (the US average in 2020).

At this point, be sure you can access the PC via remote desktop. If successful, install the mini-PC into the field. We should be able to configure everything else remotely.

alt text
  • If the computer will be outside consider one with a built-in GFCI outlet. This Orbit enclosure is very nice.
  • Turn off all Windows notifications (use the Notifications and Actions sub menu).
  • For security reasons disable Bluetooth and if you’re using wired ethernet, consider disabling WiFi.
  • Install u-center.
  • Install a local copy of rtkexplorer’s version of RTKLIB.
  • Install a serial terminal of your choice.
  • Connect the ZED-F9P over USB C.
  • Connect the antenna (fixed or semi-fixed).
  • Consider connecting a 915MHz radio over USB microB (not soldered to the ZED-F9P breakout). More on this later.

A NUC connected to ZED-F9P, internet, and radio

The hardware installation is unique to each site. At my home, I have the mini-PC indoors with the antenna cable coming through a gap in a window jam. At SparkFun, the mini-PC is housed in an Orbit External Enclosure with Power (really handy!). Picture hanging strips make it easy to install electronics to an enclosure; the velcro backing holds the device in place while allowing a user to pull apart a system when needed. Once everything is installed, RDC into the machine and confirm that you can configure the GNSS receiver using u-center.

If you haven’t already, or if your antenna has moved at all, consider re-running the PPP survey of your antenna as described in the previous section.

Caster Setup

Now that you have the Windows mini-PC setup, let’s talk casting. As previously mentioned, NTRIP is the industry standard for moving RTCM corrections over the internet. For our purposes we need to ‘cast’ from the base station and use a ‘client’ at the rover to get access to the caster.

There are a variety of options available:

  • Use u-center’s built in Caster/Client
  • Use STRSVR’s built in Caster
  • Use STRSVR as the Server and RTK2GO as a Caster

There are a few ways to pipe data from the ZED-F9P to the internet. We’ll start with the easiest:

U-center as a Caster

Using u-center as an NTRIP caster

Select Receiver->NTRIP Server/Caster

U-center has a very easy to use NTRIP caster. In terms of ease-of-use, this is by far the easiest (second only to using radios that require no configuration). Simply enter a user name, password, and mount point info and click ok. U-center will automatically configure the receiver to broadcast the RTCM sentences, and begin transmitting correction data over port 2101 to anyone who hits this PC’s IP address with the proper credentials (usually using an NTRIP client).

Pros:

  • Crazy easy to set up.

Cons:

  • You’ll need to poke a hole in your router for port 2101 (not the most secure).
  • There is not currently a way to auto-start u-center in caster mode. This means that every time the mini-PC loses power or reboots you will need to log into the machine, open u-center, and restart the caster.

We recommend using u-center to ‘kick the tires’ of NTRIP. It’s very satisfying and a great learning experience to get correction data, but long term u-center is not our choice.

STRSVR as Caster

STRSVR as caster

It says caster! Don't be fooled.

Really quick, and just because I lost a day trying to make this work: RTKLIB does not support NTRIP casting even though it displays it.

RTKLIB manual doesn’t support NTRIP caster

Pros:

  • STRSVR can be auto-started

Cons:

  • Caster doesn’t do anything

STRSVR and RTK2GO

The winner really is using STRSVR as a NTRIP Server (it’s confusing but this means to upload data to a server on the internet) and then RTK2GO as the NTRIP Caster.

STRSVR as Server

There are a variety of Windows applications out there that claim to be an NTRIP caster. We found them to be generally terrible. The easiest solution is using RTK2GO. RTK2GO seems to be a pet project of SNIP. We recommend creating a mount point and a password through RTK2GO.com. Yes it looks spammy but we found it is the best solution.

Note: We quickly got banned from RTK2GO because, after completing our registration, we started STRSVR and pointed it at rtk2go.com with the temporary password. Very quickly (1-2 minutes) our account and password were active. Which means our broadcasting at RTK2GO with the temp password became invalid. After ~60 seconds of invalid connections by STRSVR (because the PW changed from temp to permanent) our IP was banned for a few minutes, then hours. Our recommendation is to just wait a few minutes. Do not connect STRSVR to RTK2GO using the temp password. Just wait for the confirmation email from RTK2GO, respond with the ‘yes I’m not a robot email’, and wait for the email from RTK2GO that says your mount point and password are valid. At that point, start STRSVR with your credentials.

STRSVR setup for RTK2GO

With your mount point and password point STRSVR at RTK2GO. Because we are pushing data to an NTRIP server we don't need to open port 2101 on our local network.

STRSVR with lots of valid data

Then press ‘Start’. Within a few seconds the lights should turn green indicating that data from the ZED-F9P is correctly transmitting to RTK2GO. Good. Give yourself ~60 seconds and then open a browser and go to rtk2go.com:2101. This should show you the list of current mount points. Your mount point should be on there. If not, check that you have the correct PW entered, that the base is correctly set up with RTCM messages turned on, and in TIME mode.

Note: When you close STRSVR it will save these settings. If you run 'strsvr.exe -auto' it will start STRSVR and automatically start casting.

RTK2go page showing mount points

Hello my beautiful Boulder mount points!

Congrats! You’re getting wonderfully close to the finish line. You are welcome to grab a surveyor setup, go out into the field, and use SW Maps to connect to your correction data using the built in NTRIP client. You can also use u-center to act as a client.

Advanced Trick - Add a Radio

SparkFun 915MHz Antenna

The SparkFun 915MHz Antenna

Of course we have a 915MHz antenna on the roof of SparkFun. So why not hook it up? Unlike the small GNSS antenna in the previous section, this antenna has significant lightning protection.

STRSVR with radio turned on as well

STRSVR is very powerful. You can pipe your RTCM data to multiple places, not just a NTRIP server. We attached a 100mW 915MHz radio to USB. It enumerated as a COM port. We can then add that COM port (remember to set the baud rate to 57600bps to match the radio) to STRSVR so that the RTCM data goes to both the NTRIP server and to the radio. This allows us to use a radio connection for local area RTK and swap to cellular if we get outside the range of the radio.

Why not solder the radio to UART2 like in the previous tutorial?

Changing the settings on the radio via AT commands

Changing the settings on the radio via AT commands

By connecting the radio to USB it allows us to configure the radio over a terminal window. If it was wired directly to the UART2 on the ZED-F9P the correction data would transmit, but this way we can modify the radio’s AIR_SPEED and other settings to get greater range.

Schedule a Task

We need STRSVR to start automatically. STRSVR will remember its settings and will automatically start with the last used settings by running strsvr.exe -auto. Now let’s create a Task in windows to ensure it starts at every power on.

Create new task

Open the Windows Task Scheduler app and create a new Task.

alt text

Tell the task to run STRSVR with '-auto'.

Set Triggers for task

The main things are running the optional ‘-auto’ command, the task should start at startup without need for logon, and the task should delay 30 to 60 seconds. We found that this task (STRSVR) would fail to start at Windows startup possibly because the ZED-F9P and/or the radio COM ports were not yet enumerated. Delaying for 30 seconds or more fixes the issue. And if the program ever shuts down or crashes for some reason the task schedule should, every hour, restart STRSVR, if it is not already running.

Once your task is defined, reset your mini-PC and verify that it automatically starts STRSVR and begins broadcasting.

Deploy!

Using SW Maps to get correction data over NTRIP

Using SW Maps to get correction data over NTRIP

That’s it! You should now be able to point the NTRIP Client of your choice at RTK2GO.com, port 2101, with your mount point and password and receive the correction data from your base to any number of rovers in the field within 10km of your base. We recommend SW Maps heartily as it's incredibly easy to pull the correction data down from RTK2GO over the cellular network and automatically pass that data back to a rover configured ZED-F9P. It can be a bit of work setting up a dedicated correction base station but with the right setup the base should run for many months or years without supervision.

I’ve had a ton of fun learning about RTK and surveying. But I’ve learned not to get too hung up on learning where this exact spot is in the world. Space is relative and changing just like time. I don’t mean to rock your world but the north american tectonic plate is moving at 2cm per year. So just enjoy the now now.

Further Reading

Need more RTK? Checkout some of these additional tutorials:

What is GPS RTK?

Learn about the latest generation of GPS and GNSS receivers to get 14mm positional accuracy!

Getting Started with U-Center for u-blox

Learn the tips and tricks to use the u-blox software tool to configure your GPS receiver.

GPS-RTK2 Hookup Guide

Get precision down to the diameter of a dime with the new ZED-F9P from Ublox.
New!

Setting up a Rover Base RTK System

Getting GNSS RTCM correction data from a base to a rover is easy with a serial telemetry radio! We'll show you how to get your high precision RTK GNSS system setup and running.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

MicroMod Machine Learning Carrier Board Hookup Guide

$
0
0

MicroMod Machine Learning Carrier Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1395

Introduction

The MicroMod Machine Learning Carrier Board combines some of the features of our SparkFun Edge Board and SparkFun Artemis boards, but allows you the freedom to explore with any processor in the MicroMod lineup without the need for a central computer or web connection. Voice recognition, always-on voice commands, gesture, or image recognition are possible with TensorFlow applications. An on board accelerometer and Qwiic ports allow you even more flexibility.

Let's dive in, get a good look at what's available to us, and go over a few quick examples!

Required Materials

You are absolutely going to want to get one of these gems. Pick one up here:

SparkFun MicroMod Machine Learning Carrier Board

SparkFun MicroMod Machine Learning Carrier Board

DEV-16400
$19.95

You'll need a processor board to get started. Here we use the Artemis Processor Board, but there are a number of others you can choose from.

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95

You'll also need a USB-C cable to connect the Carrier to your computer and if you want to add some Qwiic breakouts to your MicroMod project you'll want at least one Qwiic cable to connect it all together. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Suggested Reading

The SparkFun MicroMod ecosystem is a unique way to allow users to customize their project to their needs. Do you want to send your weather data via a wireless signal (eg. Bluetooth or WiFi)? There's a MicroMod processor for that. Looking to instead maximize efficiency and processing power? You guessed it, there's a MicroMod processor for that.

MicroMod Logo
MicroMod Ecosystem

We also recommend taking a look through the following tutorials if you are not familiar with the concepts covered in them:

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

Hardware Overview

Common Components

Most SparkFun MicroMod Carriers will have some common components and all MicroMod Carriers will have the keyed M.2 MicroMod Connector to plug your processor into. The photo and list below outline some of the components you can expect on most SparkFun MicroMod Carriers.

  • M.2 MicroMod Connector - This special keyed M.2 connector lets you install your MicroMod Processor of choice on your Machine Learning Carrier Board.
  • USB-C Connector - Connect to your computer to program your Processor and also can provide power to your MicroMod system.
  • 3.3V Regulator - Provides a regulated 3.3V and sources up to 1A.
  • Qwiic Connector - The standard Qwiic connector so you can add other Qwiic devices to your MicroMod system.
  • Boot/Reset Buttons - Push buttons to enter Boot Mode on Processor boards and to Reset your MicroMod circuit.
  • microSD Slot - Insert a microSD card for reading and writing data.

Annotated photo showing which parts are common components

Machine Learning MicroMod Carrier Board Specific Components

Digital MEMS Microphones

What's better than ONE microphone? TWO!

  • Microphone 1 supports a PDM interface and is enabled by default. To disable this mic, cut the EN1 jumper. For more information on this microphone, refer to the datasheet here.
  • Microphone 2 supports an I2S interface and is disabled by default. To enable EN2, solder the jumper pads to close the circuit. For more information on this microphone, refer to the datasheet here.

IMage of the microphones highlighted on the board

GPIO

Along the sides of the Machine Learning Carrier Board, we've broken out dedicated PTHs for UART, digital, analog, pulse width modulation, and SPI. You may also notice that we've included a ground rail on the right side of the board.

General GPIO pins are highlighted

I2C Specific GPIO

Additionally, we've broken out the I2C SDA and SCL lines, with 3V3 and GND to complete your I2C functionality. These are primary I2C pins - they are connected to the Qwiic connector.

I2C specific GPIO pins are highlighted

Accelerometer

The LIS2DH12 is an ultra-low-power, high performance, three-axis linear accelerometer belonging to the “femto” family with digital I2C/SPI serial interface standard output. If you need more detail on this little guy, refer to the Datasheet here.

Image of the board with the accelerometer highlighted

Camera Connector

With this 24 pin connector, you can add image recognition to your machine learning board by popping in the Himax CMOS Imaging Camera.

Image of the board with the camera connector highlighted

JTAG

An unpopulated JTAG footprint is available for more advanced users who need breakpoint level debugging. We recommend checking out our JTAG section for the compatible male header and a compatible JTAG programmer and debugger.

Image of the board with SWD pins for JTAG debugging highlighted

RTC Battery

We've included a 3V Lithium Rechargeable Battery as a backup power source.

Image of the board with the Li battery highlighted

Jumpers

VE Jumper

VE Jumper on the back of the board is highlighted

VIN and 3V3 Jumpers

Cutting these jumpers will disable the VIN and 3V3 LEDs on the front of the board.

Highlighted VIN and 3V3 jumpers

I2C Jumper

If you are daisy-chaining multiple Qwiic devices, you will want to cut this jumper; if multiple sensors are connected to the bus with the pull-up resistors enabled, the parallel equivalent resistance could create too strong of a pull-up for the bus to operate correctly. As a general rule of thumb, disable all but one pair of pull-up resistors if multiple devices are connected to the bus. To disable the pull up resistors, use an X-acto knife to cut the joint between the highlighted jumper pads.

Highlighted I2C jumper

RESET PTH

Need an external reset button? These PTH allow you to tie in to the reset functionality.

Highlighted Reset plated through holes

Machine Learning MicroMod Carrier Pin Functionality

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D+
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0)1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D+
3.3V_EN43USB_D+
3.3V21GND
NameBottom Pin   Top    PinName
(Not Connected)75GND
7473CAMERA_D5
RTC_3V7271CAMERA_D6
7069CAMERA_D7
6665CAMERA_HSYNC
6463CAMERA_VSYNC
6261SPI_CIPO
6059SPI_COPI
5857SPI_SCK
CAMERA_MCLK5655SPI_CS
CAMERA_PCLKI2S_SD5453
PDM_DATI2S_WS5251
PDM_CLKI2S_SCK5049BATT_VIN/3
CAMERA_D44847PWM1CAM_VDD
CAMERA_D34645
CAMERA_D24443
CAMERA_D14241
CAMERA_D04039
A13837
A03433
PWM03231
2423SWDIO
2221SWDCK
2019RX1
CAMERA_TRIGD11817TX1
CAMERA_INT1615
I2C_SCL1413
I2C_SDA1211BOOT
HEADER_CSD0109VIN
87GND
RESET65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Hardware Hookup

To get started with the Machine Learning Carrier Board, you'll need a compatible processor board. Here we are using the Artemis MicroMod Processor Board.

Align the top key of the MicroMod Artemis Processor Board to the screw terminal of the Machine Learning Carrier Board and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Note: There is no way to insert the processor backward since the key prevents it from mating with the M.2 connector and as an extra safeguard to prevent inserting a processor that matches the key, the mounting screw is offset so you will not be able to secure an improperly connected processor board.

MicroMod Processor Board inserted into the carrier board - Top angle

The Processor Board will stick up at an angle, as seen here:

MicroMod Processor Board inserted into the carrier board

Once the board in the socket, gently hold the MicroMod Processor Board down and tighten the screw with a Phillip's head.

screwing in the machine screw

Once the board is secure, your assembled MicroMod system should look similar to the image below!

Top down image of Machine Learning Carrier Board with Artemis Processor board inserted correctly

Connecting Everything Up

With your processor inserted and secured it's time to connect your carrier board to your computer using the USB-C connector on the Carrier. Depending on which carrier you choose and which drivers you already have installed, you may need to install drivers.

Note: Make sure that for whatever processor board you choose, you have the correct board definitions installed.

For this particular tutorial, we are using the Artemis MicroMod Processor Board. Board definitions for this processor board can be found in the Software Setup and Programming section of the Artemis MicroMod Processor Board Hookup Guide.

If you are using a different processor board, go to our MicroMod Processor Boards landing page, find your processor board, and head on over to that tutorial for help installing your board definition.
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

To get started uploading code and working with your Machine Learning Carrier Board, make sure you have the Artemis MicroMod board definition selected under your Tools>Board menu (or whatever processor you've chosen to use).

Arduino Board Select

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


Then select your serial port under the Tools>Port menu.

Port Selection for the Artemis MicroMod Processor Board

Loading Blink

Let's start with something basic - let's blink an LED. Go to File->Examples->01.Basics->Blink.

Blink Basics Example in the pulldown

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


With everything setup correctly, upload the code! Once the code finishes transferring, you should see the STAT LED on the Artemis Processor Board begin to blink!

If the blue LED remains off, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the reset button to get your Artemis MicroMod to run the sketch.

Look at all the blinks!

blink blink blink

Example 2: Accelerometer

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

SparkFun has written a library to work with the LIS2DH12 Accelerometer that's included on this board. You can obtain this library through the Arduino Library Manager by searching for "LIS2DH12". Find the one written by SparkFun Electronics and install the latest version. If you prefer downloading libraries manually, you can grab them from the GitHub Repository. We've linked the datasheet for the accelerometer in the Resources and Going Further section, but if you'd like it handy, you can also refer to it here.

With your library installed, navigate to the examples located under File->Examples->SparkFun LIS2DH12 Arduino Library. Let's load up Example1_BasicReadings to get you started.

File->Examples->SparkFun LIS2DH12 Arduino Library

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


Making sure you have the correct board and port selected, go ahead and upload your code. Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. You should see x y and z locations flying by, telling you the directions the accelerometer is reading!

Accelerometer serial output

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


Troubleshooting

Resources and Going Further

Want more information on the SparkFun Machine Learning Carrier Board? Check out these links!

MicroMod Documentation:

Looking for some project inspiration using your Machine Learning Carrier Board? The tutorials below can help you get started!

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
New!

MicroMod ESP32 Processor Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod ESP32 Processor Board
New!

MicroMod All The Pins (ATP) Carrier Board

Access All The Pins (ATP) of the MicroMod Processor Board with the Carrier Board!
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Getting Started with MicroMod

$
0
0

Getting Started with MicroMod a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1189

Introduction

MicroMod is a compact interface to connect a microcontroller to various peripherals. You can generally think of the MicroMod system as a ‘brain’ plugging into a ‘carrier board’.

Processor inserted into the Carrier Board M2 Slot

A MicroMod processor board is approximately 22x22mm and can insert into any MicroMod carrier board. A small screw holds the processor board in place. Whereas the original M.2 standard was designed for swapping out peripherals (user could change one solid state hard drive to a larger one) the MicroMod standard is designed for swapping out controllers (user can start with a powerful processor and then change to a low power controller to extend battery life).

Suggested Reading

If you aren't familiar with the MicroMod ecosystem, we recommend reading here for an overview.

MicroMod Logo
MicroMod Ecosystem

If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.

Serial Peripheral Interface (SPI)

SPI is commonly used to connect microcontrollers to peripherals such as sensors, shift registers, and SD cards.

Pulse Width Modulation

An introduction to the concept of Pulse Width Modulation.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

How Does It Work?

The MicroMod standard leverages the M.2 connector and specification to increase the availability of parts and reduce the cost of the connector. All MicroMod ‘brains’ share a common pinout. For example, the I2C pins for the MicroMod ESP32 are in the same position as the I2C pins on the MicroMod Artemis.

A varient of MicroMod carrier boards give the user access to different technologies. Because the MicroMod connector is standardized, the controller can be easily and quickly swapped out as processing power, power consumption, and wireless connectivity. For example, a user may start with the MicroMod Artemis and a RFID carrier board. They then might decide they need WiFi for their project. Swapping to the MicroMod ESP32 allows the user to instantly add WiFi capabilities without changing the underlying hardware.

Hardware Overview

What Connector and Key Does MicroMod Use?

MicroMod uses the common M.2 connector. This is the same connector found on modern motherboards and laptops. We recommend the connector with 4.2mm height.

M.2 Connector Socket ViewM.2 Connector View from Back
M.2 Connector Socket ViewM.2 Connector View from Back

TE makes the 2199230-4 that is widely available and for reasonable cost (1k budgetary pricing is $0.56). You can also order the MicroMod DIY Carrier Kit that includes 5 of the connector, screw, and reflow-able standoff.

There are various locations for the plastic ‘key’ on the M.2 connector to prevent a user from inserting an incompatible device. The MicroMod standard uses the ‘E’ key but diverges from the M.2 standard by moving the mounting screw 4mm to the side. The ‘E’ key is fairly common so a user could insert a M.2 compatible Wifi module but because the screw mount doesn’t align, the user would not be able to secure an incompatible device into a MicroMod carrier board.

What is a Processor Board?

SparkFun MicroMod Processor Board Outline

Each processor board follows the M.2 standard of '2222' or 22x22mm overall size.

Each processor board is approximately 22x22mm and has a microcontroller or processor on it. The pins on the processor are brought to the card edge to match the MicroMod pinout specification.

Every processor board is expected to need only USB D+/- to be programmed. This means that a processor that does not have built-in USB Support must have it added. For example: the Artemis Processor board has the CH340E added to provide serial programming support.

Every processor board is expected to have one on-board status LED that is not routed to the board edge.

Note: The MicroMod spec moves the screw position from the board's center line to 4mm right-of-center. This is meant to prevent incorrect mixing of a growing number of devices that use the M.2 connector (such as WiFi cards, SSDs, cellular modems, etc) and MicroMod devices. While a user could insert a WiFi card into a SparkFun data logging carrier board the screw holes would not line up making it obvious the devices don't work together.

The MicroMod spec may incorporate larger sizes in the future, and users are welcome to create their own processor boards, but note that the standoff hole on most carrier boards will be located to fit the 2222 MicroMod key.

What is the MicroMod Pinout?

Below is the general MicroMod interface pinout for v1.0 processor and carrier boards.

Not all of the pins are guaranteed to be connected when using the MicroMod form factor. Please see the documentation specific to your processor board for more information.

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D-
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_RX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0))1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V procided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interfae compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Each pin on the M.2 connector is specified to have a given function. There are additional rules to the MicroMod specification to ensure cross platform compatibility. At the extreme case, a maximum of 49x GPIOs are supported. In general, MicroMod focuses on interface types and locations. For example, if a carrier board requires PWM capabilities then the carrier board should leverage pins 32 (aka PWM0) and 47 (aka PWM1) as these are most likely to support PWM.

Supported Interfaces:

  • USB for programming and serial debug
  • 2x Analog Dedicated
  • 2x PWM Dedicated
  • 2x Digital I/O Dedicated
  • 12x GPIO
  • 2x I2C
  • 2x SPI
  • 2x UART
  • SDIO
  • USB-HOST
  • CAN
  • SWD
  • PDM / PCM / I2S
  • Differential ADC

12x GPIOs may not sound like much but once all the other interfaces have been connected (UART, SPI, I2C, PWM, ADC) 12x GPIOs should cover most remaining applications.

Hardware Hookup

To get started with MicroMod, you'll need a processor board as well as a carrier board. Here we are using the Artemis MicroMod Processor Board with the Machine Learning Carrier Board. Align the top key of the MicroMod Artemis Processor Board to the screw terminal of the Machine Learning Carrier Board and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Note: There is no way to insert the processor backward since the key prevents it from mating with the M.2 connector and as an extra safeguard to prevent inserting a processor that matches the key, the mounting screw is offset so you will not be able to secure an improperly connected processor board.

Processor inserted into the Carrier Board M2 Slot

The Processor Board will stick up at an angle (at around 20°), as seen here:

MicroMod Processor Board inserted into the carrier board

Once the board in the socket, gently hold the MicroMod Processor Board down and tighten the screw with a Phillip's head. We recommend the classic SparkFun reversible mini-screw driver or the fancier pocket screw driver set but any #00 or #000 Phillip's head driver should work.

screwing in the machine screw

Once the board is secure, your assembled MicroMod system should look similar to the image below!

Top down image of Machine Learning Carrier Board with Artemis Processor board inserted correctly
Note: If you've never connected an CH340 device to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our section on How to Install CH340 Drivers" for help with the installation.

Designing with MicroMod

Can I Make My Own MicroMod Processor Board?

Absolutely. SparkFun is an open source hardware company and is not patenting this interface. All we ask is that you don’t fork the spec, follow the rules, and try not to muddy the community by introducing competing or partially compatible similar interfaces.

We recommend starting from one of our open source processor board designs. Currently all these files are EAGLE PCB format. If you have a different PCB package and you'd like to add your design to the list as a reference design please let us know!

Additionally, we've written Designing with MicroMod that goes into depth about how to create a good processor and carrier board.

Can I Make My Own MicroMod Carrier Board?

Absolutely! This where things get really exciting. We’ve got a variety of resources including a connector footprint and symbol for Eagle PCB. We had multiple carrier boards already designed and open source so you can use them as a reference design and starting point. We can’t wait to see what you make.

MicroMod Carrier Board connector and schematic symbol

We recommend starting from one of our open source carrier board designs. Currently all these files are EAGLE PCB format. If you have a different PCB package and you'd like to add your design to the list as a reference design please let us know!

Additionally, we've written Designing with MicroMod that goes into depth about how to create a good processor and carrier board.

When designing your own carrier board keep these rules of thumb in mind:

  • All carrier boards must provide a regulated 3.3V supply capable of 1A.
  • All carrier boards must provide a USB D+/- connection for programming.
  • Not all processor boards have connections to every pin.
  • The A0/1, PWM0/1, and D0/1 should be supported by every processor board so you can trust that those pins will be available.
  • UART1, SPI, and I2C ports are super common and on nearly every processor board, but peripherals beyond those varies between processor boards. For example: support for a 2nd I2C port varies a lot so if your carrier board requires the 2nd I2C port be aware of what processor boards will be supported.

To help get you started with your own custom carrier board we've put together the MicroMod DIY Carrier Kit that includes 5 of the connector, screw, and standoff so that you can get all the ‘special’ parts you may need to make your own carrier board.

SparkFun MicroMod DIY Carrier Kit (5 pack)

SparkFun MicroMod DIY Carrier Kit (5 pack)

KIT-16549
$6.95

The M.2 connector has a 0.5mm pitch and alignment pegs. Hand stenciling and reflow-at-home is possible but we recommend using a stainless steel stencil (do not use mylar) and a higher quality reflow oven (sorry hot plate!) to help prevent jumpers.

Tell Me about Heat Sinking!

One of the benefits to the M.2 standard is the ability to put components under the module. Using this we can now add heatsinks to our microcontrollers!

For this reason we recommend the connector with 4.2mm height. TE makes the 2199230-4 that is widely available and for reasonable cost (1k budgetary pricing is $0.56).

What if I Need A LOT of GPIO?

There are applications where a user will need more than 12 GPIO. The MicroMod specification is flexible. If you would like to design a MicroMod that has only a few peripherals connected (for example, just UART and I2C) and leaving the rest for GPIO (45 available for GPIO in this example) that’s fine. Your carrier board would utilize the UART and I2C pins in the normal location and GPIOs in non-standard locations. This would prevent other MicroMods from being absolutely compatible (perhaps one or two of the MicroMod Artemis would not be able to drive your carrier board’s relays) but it’s allowed. You, the designer, just need to think about the tradeoffs.

We’ve written a guide for creating a MicroMod Processor Board but here are the guiding principles:

  • Connect dedicated hardware of the microcontroller to the available I2C, SPI, UART, USB, USB_HOST, CAN, SDIO, and JTAG pins exposed on the MicroMod connector edge.
  • Next, A0/A1 on the MicroMod connector edge should be assigned to pins on the microcontroller that are exclusively ADC (no PWM capability).
  • PWM0/PWM1 should be assigned to pins that are exclusively PWM (no ADC capability).
  • D0/D1 should be assigned to pins that are exclusively GPIO (no ADC or PWM capability)
  • Remaining pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc) positions
  • The intent is to guarantee PWM, ADC, and Digital Pin functionality on those specific pins. Whereas Gx pins do not guarantee ADC/PWM function.
  • If the microcontroller lacks a specific pin function, and has left over GPIO, they can be over-ruled with GPIO. For example, CTS/RTS can be overwritten with a GPIO if the microcontroller does not have flow control.

For more information, check out the Designing with MicroMod tutorial.

New!

Designing with MicroMod

October 21, 2020

This tutorial will walk you through the specs of the MicroMod processor and carrier board as well as the basics of incorporating the MicroMod form factor into your own PCB designs!

Resources and Going Further

Now that you are familiar with the basics of the MicroMod, check out some of related following tutorials with MicroMod!


learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado


MicroMod Data Logging Carrier Board Hookup Guide

$
0
0

MicroMod Data Logging Carrier Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1329

Introduction

The MicroMod Data Logging Carrier Board is similar the SparkFun Logomatic to offer users a dedicated data logging board but adds the ability for you to pick a MicroMod Processor Board to customize it for your next data logger project. The Data Logging Carrier board was designed specifically for low power control and sensor data harvesting with the MicroMod ecosystem.

SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$19.95

The Data Logging Carrier Board allows you to control power to both the Qwiic connector on the board as well as a dedicated power pin for non-Qwiic peripherals such as serial UART or SPI devices so you can pick and choose when to power the peripherals you are monitoring the data from. It also features a charging circuit for single-cell Lithium-ion batteries along with an RTC battery-backup circuit to maintain power for a real-time clock circuit on your Processor Board.

Required Materials

Like all of our MicroMod Carrier Boards, there is no processor included but instead you can plug in a Processor Board of your choice to the MicroMod M.2 connector on the carrier. Below are a few options to choose for your processor:

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$14.95
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95

You'll also need a USB-C cable to connect the Carrier Board to your computer to program your Processor and for serial USB communication. If you want to add some Qwiic breakouts to your MicroMod project you'll want at least one Qwiic cable to connect it all together. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Along with a Processor Board, the pertinent cables and sensors or other items you intend to log the data from, you'll need a microSD card. Lastly, if you would like to have your MicroMod Data Logging project be battery powered, you'll want a single-cell Lithium-ion battery. Below are a few options for both of those accessories:

Lithium Ion Battery - 1Ah

Lithium Ion Battery - 1Ah

PRT-13813
$9.95
7
Lithium Ion Battery - 2Ah

Lithium Ion Battery - 2Ah

PRT-13855
$12.95
6
microSD Card - 16GB (Class 10)

microSD Card - 16GB (Class 10)

COM-15051
$19.95
microSD Card with Adapter - 32GB (Class 10)

microSD Card with Adapter - 32GB (Class 10)

COM-14832
$24.95

Suggested Reading

The SparkFun MicroMod ecosystem is designed to allow users to customize their project to their needs. Do you want to send your weather data via a wireless signal (eg. Bluetooth or WiFi)? There's a MicroMod processor for that. Looking to instead maximize efficiency and processing power? You guessed it, there's a MicroMod processor for that. If you are not familiar with the SparkFun MicroMod system, take a look here:

If you aren't familiar with the MicroMod ecosystem, we recommend reading here for an overview:

MicroMod Logo
MicroMod Ecosystem

We also recommend reading through the following tutorials if you are not familiar with the concepts covered in them:

Serial Communication

Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!

Serial Peripheral Interface (SPI)

SPI is commonly used to connect microcontrollers to peripherals such as sensors, shift registers, and SD cards.

SD Cards and Writing Images

How to upload images to an SD card for Raspberry Pi, PCDuino, or your favorite SBC.
New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

Hardware Overview

In this section we'll cover the components on the MicroMod Data Logging Carrier Board, how a specific MicroMod Processor Board interacts with it and highlight a few unique features on the board.

Common Components

Most SparkFun MicroMod Carrier Boards will have some common components and all MicroMod Carrier Boards will have the keyed M.2 MicroMod Connector to plug your processor into. The photo and list below outline some of the components included on most SparkFun MicroMod Carrier Boards.

  • M.2 MicroMod Connector - This special keyed M.2 connector lets you install your MicroMod Processor Board of choice on your Carrier Board.
  • USB-C Connector - Connect to your computer to program your Processor Board and also can provide power to your MicroMod system.
  • 3.3V Regulator - Provides a regulated 3.3V and sources up to 1A.
  • Qwiic Connector - The standard Qwiic connector so you can add Qwiic devices to your MicroMod system.
  • Boot/Reset Buttons - Push buttons to enter boot mode on Processor Boards and to reset your MicroMod circuit.
  • RTC Backup Battery & Charge Circuit - 1mAh backup battery for the RTC on the Teensy MicroMod Processor. Receives charge voltage from 3.3V.
  • microSD Slot - Insert a µSD card formatted to FAT32(?) here to log your data.

MicroMod Data Logging Carrier Board Common Components Labeled

Power Control Circuit

The Data Logging Carrier Board features two 3.3V/600mA voltage regulators that have their Enable pins tied to I/O pins on an attached MicroMod Processor Board. This allows control of the regulators' output with a few lines of code making it extremely simple to control and conserve power in battery-powered applications. The G1-3V3 line is controlled by G1 on the MicroMod Processor and the G2-3.3V circuit is (as you may suspect) is controlled by G2 on the MicroMod Processor. The G1-3.3V power circuit is tied to several pins highlighted in the below photo for extra flexibility powering external devices. The G2-3V3 output is tied to the 3.3V pin on the Qwiic connector as well as a dedicated PTH pin labeled G2-3V3.

Photo highlighting the power control circuit and affected pins/Qwiic connector.

Battery Charging Circuit

The board also has a MCP73831 Single-Cell Lithium-Ion/Lithium-Polymer Charge IC so you can charge an attached single-cell LiPo battery. The charge IC receives power primarily from USB and can source up to 450mA to charge an attached battery.

Photo highlighting the lipo battery circuit.

Data Logging Connections

Along with the Qwiic connector mentioned in the Common Components, the Data Logging Carrier Board breaks out several other pins to connect UART, SPI and other I/O devices. The primary SPI pins are netted to the µSD slot and a PTH header near the LiPo battery connector. A second Chip Select pin tied to G0 is broken out to that same header.

Note:µSD Chip Select is tied to the SPI_CS chip select pin on the M.2 Connector. Refer to your Processor Board's documentation for information on how to properly define that pin in your code.

A UART PTH header connects to RX1 and TX1 for serial data logging and A0, A1, PWM0, PWM1, D0 and D1 are routed to dedicated PTH pins as well. Lastly, if users prefer a soldered connection instead of Qwiic, the primary I2C bus is broken out to PTH pins.

Photo highlighting the PTH pin connections.

JTAG

An unpopulated JTAG footprint is available for more advanced users who need breakpoint level debugging. We recommend checking out our JTAG section for the compatible male header and a compatible JTAG programmer and debugger.

Photo highlighting JTAG connections

Solder Jumpers

If you have never worked with solder jumpers and PCB traces before or would like a quick refresher, check out our How to Work with Solder Jumpers and PCB Traces tutorial for detailed instructions and tips.

There are seven solder jumpers on the Data Logging Carrier Board labeled I2C, MEAS, BYP, VIN, 3V3, VE, and BATT. In this section we'll detail the functionality and default states of each jumper.

Jumper Name/LabelDescriptionDefault State
I2C Pull-Up / I2CPulls the Qwiic SDA/SCL lines to 3.3V via two 2.2K&ohm; resistorsCLOSED
Measure / MEASOpen this jumper to probe the current draw at the 3.3V output of the regulator. For help measuring current, take a look at our How to Use a Multimeter tutorial.CLOSED
Bypass / BYPThe "penny-in-the-fuse" jumper. Bypasses the 6V/2A fuse and nets VIN and V_USB together to allow >2A current flows. Close only if you know what you are doing!OPEN
VIN / VIN_LEDConnects the 5V/VIN LED to 3.7-6V (typ. 5V from USB) via a 4.1K&ohm; resistor. Open to disable the VIN LED.CLOSED
3V3 / 3V3_LEDConnects the 3.3V LED to 3.3V via a 1K&ohm; resistor. Open to disable the 3.3V LED.CLOSED
Voltage Enable / VEClose this jumper to enable processor control of the 3.3V bus.OPEN
Battery / BATTOpen this jumper to measure current draw from the battery or to switch primary power from USB to battery.CLOSED
Highlighting the solder jumpers on the front of the Data Logging Carrier BoardHighlighting the solder jumpers on the back of the Data Logging Carrier Board

Having trouble viewing the detail in either photo? Click on them for a larger view!

Board Dimensions

The MicroMod Data Logging Carrier Board measures 2.40" x 1.60" (60.96mm x 40.64mm) and has five mounting holes that fit a 4-40 screw. Take note of the mounting hole labeled "Qwiic Mount" above the µSD slot as it can work as single mount for a Qwiic breakout (or other sensor) or you can pair it with the outer mount in the "top-right" corner for a more secure mounting option. We demonstrate using these two mounts for a Qwiic breakout in the following section, Hardware Assembly.

Data Logging Carrier Board Dimensions

Now that we're familiar with the hardware on the MicroMod Data Logging Carrier Board, it's time to plug your Processor Board and peripheral sensors in and start logging some data. Next up we'll cover some assembly tips.

Hardware Assembly

Inserting the Processor Board

With the M.2 MicroMod connector, connecting your processor board is easy. Match up the key on your processor's beveled edge connector to the key on the M.2 connector on your Carrier Board. At a 45° angle, insert the processor board to the M.2 connector. The Processor Board will stick up at an angle as seen here:

Processor Board is inserted into the M.2 connector at a 45 degree angle.

Once the board is in the socket, gently press the Processor Board down, grab the set screw and tighten it with a Phillip's head screwdriver:

Securing the Processor Board into place using the set screw.

Once the Processor Board is secure, your assembled MicroMod system should look similar to the image below!

MicroMod Processor Board secured into place on the Data Logging Carrier Board.
Note: There is technically no way to insert the processor backward since the key prevents it from mating with the M.2 connector. As an extra safeguard to prevent inserting a processor improperly or with a poor connection, the mounting screw will not match up if the Processor Board is not plugged in entirely.

Data Logging Peripherals

As we mentioned previously, the Data Logging Carrier Board offers several ways to connect your sensors or other peripherals you intend to log data from.

If you are using a Qwiic breakout just connect it using a Qwiic cable to the Qwiic connector on the Carrier Board. If your I2C device is not Qwiic-enabled, you can either use a Qwiic adapter cable or connect the peripheral to the Carrier Board using the 0.1"-spaced PTH pins for I2C. Soldering is strongly recommended for this approach but if you just want a temporary connection for prototyping you can use IC Hooks like these or these.

For alternate data inputs using SPI, Serial UART or other inputs (analog, digital, etc.), you will need to connect them to the 0.1"-spaced PTH pins broken out on either side of the Data Logging Carrier Board using one of the methods covered above. Take note of which 3.3V rail you are connecting them to for easy reference when controlling power to your devices after everything is soldered together.

A Qwiic ZOE-M8Q GPS Module is connected to the Data Logging Carrier Board

Before powering everything up, insert your microSD card into the card slot and press it in to lock it into place.

Connecting Everything Up

With your processor inserted and secured it's time to connect your MicroMod Data Logging Carrier Board to your computer using the USB-C connector. Depending on which Processor Board you choose and which drivers you already have installed, you may need to install drivers for your processor board. Refer to your Processor Board's Hookup Guide for detailed instructions on how to install them. At this point you can also connect your battery for charging or to power the circuit once USB power is removed.

A completed GPS logging circuit with USB, Battery and GPS antenna attached.
Note: Make sure that for whichever processor board you choose, you have the correct board definitions installed.

For this particular tutorial, we are using the Artemis MicroMod Processor Board. Board definitions for this processor board can be found in the Software Setup and Programming section of the Artemis MicroMod Processor Board Hookup Guide.

If you are using a different processor board, go to our MicroMod Processor Boards landing page, find your processor board, and head on over to that tutorial for help installing your board definition.

Arduino Examples

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

GPS Demo Circuit Example

We've written a quick example for the demo circuit from the Hardware Assembly section using the SparkFun GPS Breakout - ZEO-M8Q (Qwiic) to showcase how to log data from the GPS module to a µSD card. To assemble the circuit, simply plug in your GPS module to the Data Logging Carrier Board via a Qwiic cable and attach the GPS Antenna to the board using a u.Fl to SMA Adapter. If you've never worked with u.Fl connectors before this tutorial offers a few quick tips for using them.

In order to run this example you will need to have the SparkFun U-blox Arduino library installed. You can install it with the Arduino Library Manager by searching 'SparkFun Ublox' or you can download the zip here from the GitHub repository:

Copy the code below into a blank Arduino sketch, select your Processor Board (for the demo circuit we select, "SparkFun Artemis MicroMod") and the Port your board has enumerated on. If you are not using the MicroMod Artemis Processor, you'll need to adjust the define for Chip Select:

language:c
/*
  MicroMod Data Logging Carrier Board - ZOE-M8Q GPS Example
  This example code is in the public domain.
*/

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "SparkFun_Ublox_Arduino_Library.h"


#define chipSelect = CS //Primary SPI Chip Select is CS for Artemis MicroMod. Adjust for your processor if necessary.
SFE_UBLOX_GPS myGPS;

long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Wire.begin();
  if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
  {
    Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
    while (1);
  }

  myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
  myGPS.saveConfiguration(); //Save the current settings to flash and BBR

  Serial.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1);
  }
  Serial.println("card initialized.");

  myFile = SD.open("data.txt", FILE_WRITE); // Create or open a file called "data.txt" on the SD card
  if(myFile) 
  {
    if(myFile.size() == 0)  // Only create the header if there isn't any data in the file yet
    {
      myFile.println("Date\t\tTime\t\tLatitude\tLongitude\tAlt");
      myFile.println("MM/DD/YYYY\tHH/MM/SS\tdeg\t\tdeg\t\tmm");
      myFile.println("-------------------------------------------------------------------------------------");
    }
    myFile.close(); // Close the file to properly save the data
  }
  else {
    // if the file didn't open, print an error:
    Serial.println("error opening data.txt");
  }

}

void loop() 
{
  char gpsDate[10], gpsTime[10];
  //Query module only every 10 seconds. Adjust this value for more/less frequent GPS logs.
  if (millis() - lastTime > 10000)
  {
    lastTime = millis(); //Update the timer
    long latitude = myGPS.getLatitude();
    long longitude = myGPS.getLongitude();
    long altitude = myGPS.getAltitude();
    uint8_t fixType = myGPS.getFixType();
    if(fixType != 0){
      myFile = SD.open("data.txt", FILE_WRITE); // Open file "data.txt"
      if(myFile)
      {
        // Get date and time
      sprintf(gpsDate,"%d/%d/%d", myGPS.getMonth(),myGPS.getDay(),myGPS.getYear());
      if(myGPS.getSecond() < 10){
        sprintf(gpsTime,"%d/%d/0%d", myGPS.getHour(),myGPS.getMinute(),myGPS.getSecond());
      }
      else
      {
        sprintf(gpsTime,"%d/%d/0%d", myGPS.getHour(),myGPS.getMinute(),myGPS.getSecond());
      }
      // Save data to SD card
      myFile.print(gpsDate);
      myFile.print('\t');
      myFile.print(gpsTime);
      myFile.print('\t');
      myFile.print(latitude);
      myFile.print('\t');
      myFile.print(longitude);
      myFile.print('\t');
      myFile.println(altitude); 
      }

      Serial.print(gpsDate);
      Serial.print('\t');
      Serial.print(gpsTime);
      Serial.print('\t');
      Serial.print(latitude);
      Serial.print('\t');
      Serial.print(longitude);
      Serial.print('\t');
      Serial.println(altitude);

      myFile.close();

    }
    else  // GPS is looking for satellites, waiting on fix
    {
    uint8_t SIV = myGPS.getSIV();
    Serial.print("Satellites in view: ");
    Serial.println(SIV);
    }
  } 
}

With the code adjusted, click the Upload button. For debugging, open your serial monitor and set the baud 115200. The code will print out if the SD card or GPS do not initialize properly. If the SD initialization fails, check that the card is inserted and locked and that it is formatted to FAT32. If the GPS initialization fails, check the connection to your GPS board or verify it is at the default I2C address.

If everything initializes properly, the code will open the "data.txt" file and begin logging data once the GPS has a fix and will also print the same data over serial. If the GPS does not have a lock, the code will print out the number of satellites in view over serial.

Power Control Examples

In addition to this GPS example, we've written two example sketches specifically for the Data Logging Carrier Board demonstrating how to control the 3.3V regulators powering the Qwiic connector/G2-3V3 pin and G1-3V3 rail. They can be found in the MicroMod Data Logging Carrier Board GitHub Repo or you can download the Zip of the repository by clicking the button below

Take note both Qwiic and 3V3 peripheral power are controlled with a P-Channel MOSFET so the logic is reversed (Power ON = LOW and Power OFF = HIGH).

Troubleshooting

Resources and Going Further

Hopefully this guide has got you all set to get started with your own MicroMod logging project using the SparkFun MicroMod Data Logging Carrier Board. For more information about the Carrier Board, check out the resources below:

For more information on the MicroMod ecosystem, check out these resources:

Not sure where to start with your own data logging project? The tutorials below may give you some ideas to get the creative juices flowing:

Vernier Shield Hookup Guide

A guide to using the Vernier Shield

micro:climate Kit Experiment Guide

A weather station kit that is built on top of the inexpensive, easy-to-use micro:bit and Microsoft MakeCode.

GPS Geo-Mapping at the Push of a Button

Let's ramp up our GPS tracking skills with KML files and Google Earth. We'll make a tracker that logs location and allows us to visualize our steps with Google Earth.
New!

MicroMod Data Logging Carrier Board Hookup Guide

Get started with some customizable MicroMod data logging with the Data Logging Carrier Board.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

MicroMod ESP32 Processor Board Hookup Guide

$
0
0

MicroMod ESP32 Processor Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1208

Introduction

Introducing the SparkFun MicroMod ESP32 Processor Board! This bad boy pops an M.2 connector onto the ESP32 so you can take advantage of all that lovely ESP32 power with any of our MicroMod carrier boards. Grab yourself an ESP32 MicroMod Processor Board and let's dive in!

SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$14.95

Required Materials

You'll need a carrier board to get started. Here we use the Input and Display Carrier Board, but there are a number of others you can choose from.

SparkFun MicroMod Machine Learning Carrier Board

SparkFun MicroMod Machine Learning Carrier Board

DEV-16400
$19.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95
SparkFun MicroMod Input and Display Carrier Board

SparkFun MicroMod Input and Display Carrier Board

DEV-16985
$59.95

You'll also need a USB-C cable to connect the Carrier to your computer and if you want to add some Qwiic breakouts to your MicroMod project you'll want at least one Qwiic cable to connect it all together. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Depending on which Carrier Board you choose, you may need a few extra peripherals to take full advantage of them. Refer to the Carrier Boards' respective Hookup Guides for specific peripheral recommendations.

Suggested Reading

The SparkFun MicroMod ecosystem is a unique way to allow users to customize their project to their needs. Do you want to send your weather data via a wireless signal (eg. Bluetooth or WiFi)? There's a MicroMod processor for that. Looking to instead maximize efficiency and processing powere? You guessed it, there's a MicroMod processor for that. If you are not familiar with the MicroMod system, take a look here:

MicroMod Logo
MicroMod Ecosystem

We also recommend taking a look through the following tutorials if you are not familiar with the concepts covered in them:

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

Hardware Overview

In this section we'll cover what's included on the MicroMod ESP32 Processor Board.

M.2 Connector

All of our MicroMod Processor boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor board on your choice of carrier board.


M2 Connector from the FrontM2 Connector from the Back

Espressif ESP32

Ahhh, the Espressif ESP32. It's one of the most unique microcontrollers on the market. In it's native form, it has a laundry list of features. On the MicroMod Processor Board, we include the following:

  • Dual-core Tensilica LX6 microprocessor
  • Up to 240MHz clock frequency
  • 520kB internal SRAM
  • Integrated 802.11 B/G/N WiFi transceiver
  • Integrated dual-mode Bluetooth (classic and BLE)
  • 2.7 to 3.6V operating range
  • 500µA sleep current under hibernation
  • 10-electrode capacitive touch support
  • Hardware accelerated encryption (AES, SHA2, ECC, RSA-4096)
  • 16MB Flash Storage

Espressif chip highlighted

Stat LED

Status LED highlighted

Wireless Antenna

Need wireless? The Espressif chip provides built-in BLE as well as a WiFi transceiver which sends and receives data through a 2.4GHz Antenna.

BlueTooth Antenna highlighted

PinOut Notes

The ESP32 MicroMod has a few quirks. The ESP32's GPIO pins provide a lot of flexibility with what each pin can be used for. Whether it's I2C, I2S, SPI, UART, or PWM, the ESP32 MicroMod can do just about everything! However, with that flexibility and a fixed number of GPIO pins, the ESP32 isn't able to do it all at the same time. Below is a list of protocols the ESP32 supports, but pay close attention to the pins used, because some pins are assigned to two or possibly three functions.

Strapping Pins

One of the unique aspects of the ESP32 is the strapping pins. When the ESP32 comes out of reset, or as power is supplied, there are a few pins which control the behavior of the board. For a detailed description of these pins, check out the ESP32 Boot Mode Selection page on espressif's GitHub page. As a summary the strapping pins are:

GPIO 0

Having GPIO 0 pulled low as the ESP32 comes out of reset will enter the serial bootloader. Otherwise, the board will run the program stored in flash. On the MicroMod Processor, this pin is pulled high externally through a 10k resistor, and is connected to the boot button on the carrier boards, which can pull the pin low.

GPIO 2

Having GPIO 2 pulled high as the ESP32 comes out of reset will prevent the board from entering the serial bootloader. On the MicroMod Processor, this pin is connected to the status LED (active high) and does not interfere with the board from being able to enter the serial bootloader.

GPIO 12

If driven high, the flash voltage (VDD_SDIO) is set to 1.8V. If unconnected or pulled low, VDD_SDIO is set to 3.3V. The flash IC used on the MicroMod Processor has a minimum voltage of 2.7V, which would create a brownout condition and might corrupt the data stored to the flash, or simply prevent the program from running. On the ESP32 MicroMod Processor, this pin is connected to PWM1.

GPIO 15

If driven low, the boot messages printed by the ROM bootloader (at 115200 baud) are silenced. If unconnected or driven high, the messages will be printed as they normally are. On the ESP32 MicroMod Processor, this pin is connected to G0.

I2C

We love us some I2C! We've broken out two I2C buses, which can be used with our Qwiic system. The main I2C bus has dedicated GPIO pins 21/22 connected to MicroMod pads 12/14, along with a dedicated interrupt pin connected to GPIO pin 4, which is connected to pad 16 of the MicroMod connector.

If you need a second I2C bus, the ESP32 uses GPIO pins 25/26 (pads 42/44 on the MicroMod) for SCL1 and SDA1.

Note: The secondary I2C bus is shared with G1 and G2, as well as the I2S bus pins for AUD_LRCLK and AUD_BCLK.

UART

The ESP32 Processor has two UARTs available. The primary UART has dedicated GPIO pins 1 and 3 which can be used for programming as well as printing debug messages to a terminal window. These GPIO pins aren't directly broken out, but instead are converted to USB which is connected to MicroMod pads 3 and 5.

The second UART is connected GPIO pins 16 and 17 (pads 19 and 17 on the MicroMod) for RX1 and TX1.

Note: The secondary UART is shared with G3 and G4, as well as the I2S bus pins for AUD_OUT, and AUD_IN.

GPIO/BUS

The MicroMod connector supports a total of 12 general purpose IO pins, 7 of which are used on the ESP32 Processor, on top of the 6 dedicated pins. The dedicated pins are just that, and are not shared with any other pin, unlike the general purpose pins which may be shared with other pins. The pins used are:

Dedicated Pins

  • A0 - GPIO pin 34, pad 34 on the MicroMod (Input Only!)
  • A1 - GPIO pin 35, pad 38 on the MicroMod (Input Only!)
  • D0 - GPIO pin 14, pad 10 on the MicroMod
  • D1 - GPIO pin 27, pad 18 on the MicroMod
  • PWM0 - GPIO pin 13, pad 32 on the MicroMod
  • PWM1 - GPIO pin 12, pad 47 on the MicroMod

General Purpose IO pins

  • G0 - GPIO pin 15, pad 40 on the MicroMod
  • G1 - GPIO pin 25, pad 42 on the MicroMod - Shared with the I2S bus, and secondary I2C bus.
  • G2 - GPIO pin 26, pad 44 on the MicroMod - Shared with the I2S bus, and secondary I2C bus.
  • G3 - GPIO pin 17, pad 46 on the MicroMod - Shared with the I2S bus, and secondary UART.
  • G4 - GPIO pin 16, pad 48 on the MicroMod - Shared with the I2S bus, and secondary UART.
  • G5 - GPIO pin 32, pad 73 on the MicroMod - Shared with the 32KHz RTC crystal.
  • G6 - GPIO pin 33, pad 71 on the MicroMod - Shared with the 32KHz RTC crystal.

AUDIO

The ESP32 Processor supports audio using the I2S standard. The pins used are:

  • AUD_OUT - GPIO pin 17, pad 56 on the MicroMod, this is the digital audio output.
  • AUD_IN - GPIO pin 16, pad 54 on the MicroMod, this is the digital audio input.
  • AUD_LRCLK - GPIO pin 25, pad 52 on the MicroMod. Officially called "word select", and also known as "frame sync".
  • AUD_BCLK - GPIO pin 26, pad 50 on the MicroMod. Offically called "continuous serial clock, and also known as the "bit clock"
Note: The I2S bus is shared with the secondary UART, secondary I2C bus, and gernal purpose pins G1-G4.

SPI

The MicroMod standard supports two Serial Peripheral Interface (SPI) buses, but because of the limited GPIO pins here, only the primary SPI bus is used. This primary SPI bus is dedicated to the following pins:

  • SCK - This is the clock pin, which is connected to GPIO 18, or MicroMod pad 57.
  • SDO - This is the serial data output of the ESP32, which is connected to GPIO 23, or MicroMod pad 59.
  • SDI - This is the serial data input of the ESP32, which is connected to GPIO 19, or MicroMod pad 61.
  • #CS - This is the chip select pin, which is connected to GPIO 5, or MicroMod pad 55.
Note: You may not recognize the COPI/CIPO labels for SPI pins. SparkFun is working to move away from using MISO/MOSI to describe signals between the controller and the peripheral. Check out this page for more on our reasoning behind this change.

ESP32 MicroMod Processor Pin Functionality

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D-
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0)1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D-
3.3V_EN43USB_D+
3.3V21GND
ESP32 PinAlternate FunctionPrimary FunctionBottom PinTop PinPrimary FunctionAlternate FunctionESP32 Pin
73G5RTC32
71G6RTC33
61SPI_CIPO19
59SPI_COPI23
57SPI_SCK18
17AUD_OUTTX1G35655SPI_CS#5
16AUD_INRX1G45453SCL1G1AUD_LRCLK25
25AUD_LRCLKSCL1G15251SDA1G2AUD_BCLK26
26AUD_BCLKSDA1G25049BATT_VIN339
16AUD_INRX1G44847PWM112
17AUD_OUTTX1G346
26AUD_BCLKSDA1G244
25AUD_LRCLKSCL1G142
15G04039GND
35A138
34A034
13PWM032
19G4RX1AUD_IN16
27CAM_TRIGD11817G3TX1AUD_OUT17
4I2C Interrupt16
22SCL14
21SDA1211BOOT
14D0109USB_VIN
7GND
RESET65USB_D-
3USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board measures 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.

MicroMod Processor Board Dimensions

Hardware Hookup

To get started with the ESP32 Processor Board, you'll need a carrier board. Here we are using the MicroMod Input and Display Carrier Board. Align the top key of the MicroMod ESP32 Processor Board to the screw terminal of the Input and Display Carrier Board and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Note: There is no way to insert the processor backward since the key prevents it from mating with the M.2 connector and as an extra safeguard to prevent inserting a processor that matches the key, the mounting screw is offset so you will not be able to secure an improperly connected processor board.

MicroMod Processor Board inserted into the carrier board

The Processor Board will stick up at an angle, as seen here:

MicroMod Processor Board inserted into the carrier board

Once the board is in the socket, gently hold the MicroMod Processor Board down and tighten the screw with a Phillip's head.

screwing in the machine screw

Once the board is secure, your assembled MicroMod system should look similar to the image below!

Top down image of Input and Display Carrier Board with ESP32 Processor board inserted correctly

Connecting Everything Up

With your processor inserted and secured it's time to connect your carrier board to your computer using the USB-C connector on the Carrier. Depending on which carrier you choose and which drivers you already have installed, you may need to install drivers.

Note: If you've never connected a CP2104 device to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our section on How to Install CP2104 Drivers for help with the installation.

Software Setup and Programming

Note: All of the examples in this tutorial assume you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

To get started with the MicroMod ESP32 Processor Board, you'll need to install the ESP32 Board Definition. Open the Arduino IDE (must be v1.8.13 or later) and navigate to File->Preferences, like so:

Arduino Preferences, under File

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

In the "Additional Board Manager URL" box, make sure you have the following json file included. If you do not have it, add it to your preferences.

    language:c
    https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

If you have more than one json file, you can click on the button outlined in red and add the json link at the end. It'll look something like the following:

Additional Boards Manager URL location in the Preferences Dialog

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


Once you've got your preferences updated, go to Tools ->Board and select the Boards Manager like so:

Arduino Boards Manager Dialog, under Tools

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


Search for "ESP32", and you should find the SparkFun ESP32 Boards board package. Make sure the latest version is selected and click Install.

Board manager showing SparkFun ESP32 Boards install

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


Once the board definitions have been installed, you should see the SparkFun ESP32 MicroMod Board under your Tools -> Board -> SparkFun ESP32 Arduino menu.

DropDown showing tools->Board->SparkFun ESP32 Arduino->SparkFun ESP32 MicroMod


Voila! You're ready to rock your ESP32 MicroMod Processor Board!

With the SparkFun ESP32 Arduino core installed, you're ready to begin programming. Make sure you have the ESP32 MicroMod board definition selected under your Tools>Board menu.

Arduino board select
Having a hard time seeing? Click the image for a closer look.


Then select your serial port under the Tools>Port menu.

Port Selection for the ESP32 MicroMod Processor Board
Having a hard time seeing? Click the image for a closer look.


You can also select the Upload Speed: "921600" baud -- the fastest selectable rate -- will get the code loaded onto your ESP32 the fastest, but may fail to upload once-in-a-while. (It's still way worth it for the speed increase!)

Loading Blink

To make sure your toolchain and board are properly set up, we'll upload the simplest of sketches -- Blink! The STAT LED on the ESP32 Processor Board is perfect for this test. This is also a good time to test out serial communication. Copy and paste the example sketch below into a fresh Arduino sketch:

language:c
int ledPin = 2;

void setup()
{
    pinMode(ledPin, OUTPUT);
    Serial.begin(115200);
}

void loop()
{
    Serial.println("Hello, world!");
    digitalWrite(ledPin, HIGH);
    delay(500);
    digitalWrite(ledPin, LOW);
    delay(500);
}

With everything setup correctly, upload the code! Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. You should see Hello, world!'s begin to fly by. You may also notice that when the ESP32 boots up it prints out a long sequence of debug messages. These are emitted every time the chip resets -- always at 115200 baud.

Example serial port output

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


You should also see some blinking happening on the ESP32 Processor Board! Blink Blink Blink!

Blinking Status LED on the processor board

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


If the blue LED remains off, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the reset button to get your ESP32 MicroMod to run the sketch.

Arduino Example: WiFi

The ESP32 Arduino core includes a handful of WiFi examples, which demonstrate everything from scanning for nearby networks to sending data to a client server. You can find the examples under the File>Examples>WiFi menu.

Here's another example using the WiFi library, which demonstrates how to connect to a nearby WiFi network and poll a remote domain (http://example.com/) as a client.

language:c
#include <WiFi.h>

// WiFi network name and password:
const char * networkName = "YOUR_NETWORK_HERE";
const char * networkPswd = "YOUR_PASSWORD_HERE";

// Internet domain to request from:
const char * hostDomain = "example.com";
const int hostPort = 80;

const int BUTTON_PIN = 0;
const int LED_PIN = LED_BUILTIN;

void setup()
{
  // Initilize hardware:
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);

  // Connect to the WiFi network (see function below loop)
  connectToWiFi(networkName, networkPswd);

  digitalWrite(LED_PIN, LOW); // LED off
  Serial.print("Press the Boot button to connect to ");
  Serial.println(hostDomain);
}

void loop()
{
  if (digitalRead(BUTTON_PIN) == LOW)
  { // Check if button has been pressed
    while (digitalRead(BUTTON_PIN) == LOW)
      ; // Wait for button to be released

    digitalWrite(LED_PIN, HIGH); // Turn on LED
    requestURL(hostDomain, hostPort); // Connect to server
    digitalWrite(LED_PIN, LOW); // Turn off LED
  }
}

void connectToWiFi(const char * ssid, const char * pwd)
{
  int ledState = 0;

  printLine();
  Serial.println("Connecting to WiFi network: " + String(ssid));

  WiFi.begin(ssid, pwd);

  while (WiFi.status() != WL_CONNECTED) 
  {
    // Blink LED while we're connecting:
    digitalWrite(LED_PIN, ledState);
    ledState = (ledState + 1) % 2; // Flip ledState
    delay(500);
    Serial.print(".");
  }

  Serial.println();
  Serial.println("WiFi connected!");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void requestURL(const char * host, uint8_t port)
{
  printLine();
  Serial.println("Connecting to domain: " + String(host));

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  if (!client.connect(host, port))
  {
    Serial.println("connection failed");
    return;
  }
  Serial.println("Connected!");
  printLine();

  // This will send the request to the server
  client.print((String)"GET / HTTP/1.1\r\n" +
               "Host: " + String(host) + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) 
  {
    if (millis() - timeout > 5000) 
    {
      Serial.println(">>> Client Timeout !");
      client.stop();
      return;
    }
  }

  // Read all the lines of the reply from server and print them to Serial
  while (client.available()) 
  {
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }

  Serial.println();
  Serial.println("closing connection");
  client.stop();
}

void printLine()
{
  Serial.println();
  for (int i=0; i<30; i++)
    Serial.print("-");
  Serial.println();
}

Make sure you fill in the networkName and networkPswd variables with the name (or SSID) and password of your WiFi network! Once you've done that and uploaded the code, open your serial monitor.

WiFi example serial terminal output
Having a hard time seeing? Click the image for a closer look.


After your ESP32 connects to the WiFi network, it will wait for you to press the "Boot" button on your carrier board. Tapping that will cause the ESP32 to make an HTTP request to example.com. You should see a string of HTTP headers and HTML similar to the screenshot above.

Arduino Example: ESP32 BLE

Both the Board Manager install and the ESP32 arduino core install come with Bluetooth examples that range from serial to serial to acting as a simple BLE device to functioning as either a Bluetooth server or client. Here we will briefly go over the BLE_write example that can be found in Files>Examples>ESP32 BLE Arduino. This example allows you to write messages on your phone that can then be read in a serial monitor on your computer.

This example works with a BLE scanner on your phone. A good, basic app is the BLE Scanner for iPhone or Android. Make sure to install the app to follow along with this example.

Compile and upload the following code, or if you wish, open the BLE_write example from the Files>Examples>ESP32 BLE Arduino menu. Make sure you have ESP32 MicroMod as your board and the correct port has been selected.

language:c
/*
    Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleWrite.cpp
    Ported to Arduino ESP32 by Evandro Copercini
*/

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"


class MyCallbacks: public BLECharacteristicCallbacks {
    void onWrite(BLECharacteristic *pCharacteristic) {
      std::string value = pCharacteristic->getValue();

      if (value.length() > 0) {
        Serial.println("*********");
        Serial.print("New value: ");
        for (int i = 0; i < value.length(); i++)
          Serial.print(value[i]);

        Serial.println();
        Serial.println("*********");
      }
    }
};

void setup() {
  Serial.begin(115200);

  Serial.println("1- Download and install an BLE scanner app in your phone");
  Serial.println("2- Scan for BLE devices in the app");
  Serial.println("3- Connect to MyESP32");
  Serial.println("4- Go to CUSTOM CHARACTERISTIC in CUSTOM SERVICE and write something");
  Serial.println("5- See the magic =)");

  BLEDevice::init("MyESP32");
  BLEServer *pServer = BLEDevice::createServer();

  BLEService *pService = pServer->createService(SERVICE_UUID);

  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristic->setCallbacks(new MyCallbacks());

  pCharacteristic->setValue("Hello World");
  pService->start();

  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
}

Once you have uploaded your code, open the serial monitor set at 115200 baud so you can see the message that we will write.

Arduino Serial Monitor ESP32
Having a hard time seeing? Click the image for a closer look.


Then open your BLE Scanner app on your phone. You will see multiple options; scroll through these and connect to MyESP32.

Connect to MyESP32

Now we need to drill down to the communication capability we want. Once you are connected to MyESP32, you will be taken to the following page. Select CUSTOM SERVICE.

Choose Custom Service

The next page will show you communications and options for doing so. Select Write,Read.

Choose Write,Read

Finally, we can choose the option that allows us to write a message. Select Write Value.

Choose Write

Now we can write our message. Make sure you choose Text, write yourself a message, and click the Write button.

Write your message!

So now what? Go have a look at your serial monitor. You should see "New value:" with your message.

Received message on the Serial Monitor
Having a hard time seeing? Click the image for a closer look.


This is just a quick walk through of one of the provided examples. We recommend looking through the rest of the provided samples and playing with the code to see what may work for your application. For more information on Bluetooth technology and how it works, check out our Bluetooth Basics Tutorial.

Further Examples

With the MicroMod system, the possibilities for examples with all the processor/carrier board are endless, and we just can't cover them all. You'll notice that in this tutorial, we've selected the Input and Display Carrier Board, but have focused our examples on the Esp32 Processor Board. If you're interested in examples specifically for our carrier board, head on over to our SparkFun MicroMod Input and Display Carrier Board Hookup Guide.

Troubleshooting

With the MicroMod Processors, you can change out the processors with little to no changes in the code. But because each processor board's architecture is different, the way communication protocols are initialized might be a little bit different. For the ESP32 Processor, the two main protocols are the Universal Asynchronous Receiver Transmitter (UART), aka Serial, and I2C, aka Wire.

Secondary Serial/UART Initialization Tips

The UART is initialized with the begin function as:

void begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms)

The primary UART works like any other Arduino board being able to initialize and send messages back to your computer over the USB cable using using Serial.begin(115200) for a baud rate of 115200 as an example. If you wanted to communicate at the same 115200 baud rate on the secondary UART you would initialize Serial1 as:

Serial1.begin(115200, SERIAL_8N1, RX1,TX1);

Or if you want to use the GPIO pin numbers instead, it would be:

Serial1.begin(115200, SERIAL_8N1, 16, 17);

Secondary I2C Initialization Tips

The Wire bus is initialized with the begin function as:

bool begin(int sda, int scl, uint32_t frequency);  // returns true, if successful init of i2c bus

With the primary Wire bus, these pins use the default SCL and SDA pins connected to GPIO pins 22 and 21 and can be initialized by simply calling Wire.begin(). If you plan on using the secondary Wire bus, you need to provide the pins, and possibly the desired frequnecy if the default 400kHz is too fast. For most applications though you can use:

Wire1.begin(SDA1, SCL1);

Or if you wanted to use the GPIO pin numbers, it would be:

Wire1.begin(26, 25);

Resources and Going Further

For more information about the MicroMod ESP32 Processor Board, check out the following links:

For more information about the SparkFun MicroMod Ecosystem, take a look at the links below:

Looking for some project inspiration using your ESP32 Processor Board? The tutorials below can help you get started!

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
New!

Designing with MicroMod

This tutorial will walk you through the specs of the MicroMod processor and carrier board as well as the basics of incorporating the MicroMod form factor into your own PCB designs!
New!

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Designing with MicroMod

$
0
0

Designing with MicroMod a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1206

Introduction

This tutorial will walk you through the specs of the MicroMod processor and carrier board as well as the basics of incorporating the MicroMod form factor into your own PCB designs!

MicroMod Edge Connector and SymbolCarrier Board and Symbol

Suggested Reading

If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.

PCB Basics

What exactly IS a PCB? This tutorial will breakdown what makes up a PCB and some of the common terms used in the PCB world.

Using EAGLE: Board Layout

Part 2 of the Using Eagle tutorials, this one covers how to lay out a board after designing a schematic.
New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

How to Design a MicroMod Processor Board

Instead of starting from scratch, we'll start with a known good development board. In this case, we'll start with a development board and convert it to a MicroMod Processor Board (PB).

Schematic

Start with a known good development board product, the SAMD51 Thing Plus for example, and remove all the bits from the EAGLE design that are not needed from the schematic:

  • USB connector
  • Qwiic connector
  • JST connector
  • Standoffs
  • Headers
  • Power regulation
  • Reset buttons
  • Silk
  • TX/RX LEDs
  • Battery charging

Keep any needed external circuitry such as:

  • Decoupling
  • ADC amplification
  • Crystals for main clock of RTC
  • External memory to enable Python script loading
  • 1 status LED (usually connected to LED_BUILTIN)
  • USB to serial conversion IC and circuitry

Keep anything needed for the device to be programmed by only USB +/-. This means you may need to include a USB to serial IC (CH340E is recommended) for devices that don’t have built-in USB peripherals. Retain any boot control circuitry (Artemis and ESP32 have boot pins that need to be controlled by RTS/DTR).

Remove all LED indicators that will be relocated to the carrier board. This includes TX/RX LEDs, Power LEDs, charge LEDs, etc. The exception to this is every Processor Board shall include one status LED connected to a pin that is not connected to the board edge. This enables the user to immediately test their PB agnostic of the capabilities of the carrier board.

Check with the original designer and the Internet to see if there have been any changes or improvements to the general design using this processor. For a hypothetical example, users and competitors may be populating the SAMD51 boards with a 32mbit flash as opposed to the older 16mbit flash. Roll these improvements into the PB.

Now is your chance to clean up the schematic component for the processor. Combine duplicate GND pins, VDDIO pins, etc into single pins on the schematic component.

alt text

Pull in the MicroMod card edge connector from the SparkFun Eagle library.

alt text

In the schematic, begin connecting the various dedicated hardware pins on the microcontroller to the MM card edge. For example, on the SAMD51:

  • Connect USB +/- on processor to USB +/- on MM edge connector
  • Primary I2C pins on SAMD51 connect to primary I2C pins on MM
  • Flash pins go to onboard flash (no move)
  • SPI pins go to primary SPI pins on MM
  • TX/RX go to TX1/RX1 on MM
  • RX LED, TX LED connections get removed entirely
  • The reset pin on MM is defined as an output open drain. The CB will have a reset button. So be sure to keep the pull up on reset on the PB.
  • Does this processor need special boot pin controls? The Boot pin is input open drain. The carrier board can have a ‘boot’ button that pulls this pin low. Invert this signal and/or add circuitry as needed to work with this processor if needed.
  • Does this processor support SWD? Connect SWDIO and SWCK as needed.
  • Does this processor have differential ADC capabilities? If so, connect the differential ADC pins to ADC+/- (G9/10).
  • Are there any pins on this processor capable of I2S, PDM, CAN, or USB host? * Be sure to connect those and give them priority over the general ADC, PWM, GPIO connections.
  • Dedicate one ADC capable pin to BATT_VIN/3. This pin will read the VIN voltage through a ⅓ voltage divider located on the CB.
  • Dedicate one GPIO to 3.3V_EN. This allows the PB to turn off the main voltage regulator on the CB. This is a dicey pin that needs thinking. Only processors that can sleep and wakeup from RTC / low power battery backup should be able to turn off the main CB voltage regulator.
  • Route any power from RTC_3V on the edge connector to any pins on the processor that need power from a coin cell or mini battery to run the RTC.
  • Does this processor support a Clock Out or special clock generation pin (output)? If so, connect to the AUD_OUT/CAM_MCLK pin.

(below is pulled text from other tutorial)

The connection between the processors pins and the MicroMod board edge follow these rules of thumb:

  • Put a dedicated status LED on the Process Board. This helps users immediately accomplish the 'hello world' blink sketch and verify their PB is working.
  • Give connection priority to A0/1, D0/D1, and PWM0/1. Every processor should be capable of these pins and most carrier boards will guarantee support for these pins.
  • Give unique peripheral connection the next level of priority. For example if a processor supports cool peripherals such as SDIO, audio interfaces, or USB Host consider making these connections available.
  • Give general peripheral connection support the next level of priority. Connect UART1, I2C, and SPI. If a processor supports a 2nd UART, I2C, and/or SPI bus consider connecting it.
  • Give the general pins (G0 to G11) connection support the next level of priority. Often these are any GPIOs remaining unconnected on the processor. In general, put any remaining pins with the most capabilities nearest G0. For example, G0 should support ADC, PWM, and GPIO whereas G6 may not have ADC capabilities.
  • Double routing of nets is permitted. For example: If it makes sense to route the ESP32 pin 26 (SDA capable) to MicroMod pin 51 (SDA1) and MicroMod pin 44 (general purpose pin 2), it is ok to do so.
  • A UART used for serial programming must be unencumbered. Said differently, if your processor is programmed with a serial bootloader, you may not route this UART to UART1 of the MicroMod spec. Said differently again: Don't be like an Uno.

Not all of the pins in the MicroMod spec need to be connected to a pin on your processor. The spec covers a lot of pin capabilities that very few microcontrollers can cover the entirety of.

(/end pull)

Now it’s time to make some architecture decisions:

  • Are there other peripherals that can be exposed on the SAMD51 to the card edge? For example, SAMDs have those evil SERCOM ports. Should we dedicate some unused IO to a 2nd SPI port? 2nd UART? 2nd I2C?
  • Once dedicated hardware is roughed out and connected, find pure analog capable pins. Connect those to A0 and A1.
  • Next, find pins that are purely PWM capable pins. Connect those to PWM0 and PWM1.
  • Next, find pins that are purely GPIO capable pins (no ADC or PWM). Connect those to D0 and D1.
  • Next, find pins that are bus capable, aka ‘fast write’ capable. For example PB00 to PB07 can be accessed with single register read/writes.
  • Any remaining pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc) positions. The intent is to guarantee PWM, ADC, and Digital Pin functionality on those specific pins (A0, D1, PWM1, etc). Whereas Gx pins do not guarantee ADC/PWM function.
  • Any remaining GPIO can be routed to the unused secondary interfaces. For example, if SAMD51 doesn’t have a 2nd I2C port then these pins can be connected to GPIO.

Antennas

The processor board should include any trace or chip antenna to support the functionality of the processor. If the application makes sense, add a U.FL connector.

SDIO and SPI1 Pins

If your processor supports SDIO (aka 4bit SPI) connect it to SDIO pins. If the SPI1 pins are different than the SDIO pins then consider connecting both signals together. For example, on Artemis (shown below) the MOSI0 pin (pin D6) is being used as part of SPI1. Pin D22 is SDIO_DATA0. By connecting both MISO0 and D22 to SDIO_DATA0 on the MicroMod connector the user has the ability to either use SDIO or SPI (one pin D6/D22 will be high impedance). And, the real benefit, the user can route the full SDIO interface/pins to a microSD socket on a carrier board. If the MicroMod processor board does not have library support for SDIO (most don’t) then the user can fall back to using SPI to talk to the microSD card (almost all platforms have support for this)

Artemis with SDIO_DATA0 connected to two pins.

alt text

MicroSD socket on a carrier board wired to support both SDIO and SPI.

alt text

Routing

MicroMod PBs are 4-layer boards, 0.8mm thickness, ENIG finish (for the gold fingers) with a 20° edge bevel.

  • Place components on both sides of the board.
  • In general, the main processor goes on the ‘front’. This is the side that will face up at the user.
  • Use 0402 components liberally. Our catalog of available values has increased significantly with recent designs.

Status LEDs

Place the ‘STAT’ LED in the upper left or upper right corner. If that’s not possible, place near the upper edge.

alt text

Keep Out Layer for M.2 Edge Connector Specification

Heed the top and bottom keepout areas near the edge of the PB. These are part of the M.2 spec and are related to how the card edge interacts with the connector.

alt text

Eagle Layer Setup Commands and Hotkeys

Setup Eagle for four layers with the following command:

Set Used_Layers 1 2 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 91 92 93 94 95 96;  

And if you need it, this is how to go back to 2 layers:

Set Used_Layers 1 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 91 92 93 94 95 96;  

I have edited my eagle.scr to quickly view the internal layers by themselves. This is helpful during routing.

#Used for four layer routing
DISPLAY = VerticalOnly 15 17 18 19 20;
DISPLAY = HorizontalOnly 2 17 18 19 20;
Assign A+0 'display none; display VerticalOnly;'
Assign A+9 'display none; display HorizontalOnly;'

This sets an Alt+0 hotkey that views only layer 15 (vertical routes shown in red above) and Alt+9 that views only layer 2 (horizontal routes shown in blue above). We can add this to the Eagle settings repo if people like it or have a better recommendation.

Trace Width, Trace Spacing, Drill Hits

Routing Processor Boards is tricky. There’s no way around it. Luckily, we can use some very tight tolerances. Use 0.004” traces with 0.0045” space. Use 0.2mm drill hits. Route vertically on layer 15 and horizontally on 2. This will reduce the chance of cross talk on high speed signals. Traces as small as 3.5mil with 3.5mil space ARE allowed and basically free. But going this small increases the chance of cross talk so be wary.

It is recommended to use layer 2 as ground and layer 15 as 3.3V. This will help with PBs that have microstrip RF traces that need a close proximity to a ground plane to minimize the width of a 50 ohm trace.

Microstrip

Does your PB have a microstrip? See Qwiic-GPS-RTK2 hardware repo for an example of 4 layer microstrip and the settings JLCPCB uses for Er and layer stackup. Note: RTK2 was a 1.6mm thick board and PBs are 0.8mm so adjust the numbers as necessary.

alt text

Call the device ‘MicroMod Blarg’, not the reverse.

alt text

Be sure to include special ordering instructions on your design:

  • 0.8mm board thickness
  • 45 degree chamfered edge
  • Four layer design

alt text

Fabrication

The M.2 spec calls for a 20° bevel on the card edge. However, it seems most PCB fab houses are setup for a 45° bevel, and they like to call it a ‘chamfered’ edge. After testing a few runs of boards, 45° chamfer works great. To date, we have not tested a board that does not have a bevel on the card edge. I suspect it will still work, but insertion into the connector may feel different. The text ‘Chamfered Edge’ is automatically added to the panel via the FP.

alt text

We have modified the panelizer to create panels capable of getting the edges beveled.

alt text

Be sure to select ‘Expose Bottom/Card Edge’. Y must be 2.75” or greater, otherwise the fab house cannot v-score. X can be 3” or more. We have found that the price of the PCB doesn’t change much from 3” to 7”. Production can work with panels up to ~9”. The panelizer uses the same DRC settings from the original design.

A panel ready for CAM and then fab.

alt text

Manufacturing

Most orders for 10 panels, 4 layer, 4mil trace/space, gold fingers, ENIG finish, with beveled edge, cost ~$100 with ~$20 in shipping from JLCPCB. Fab times are ~5 days but vary. This is extraordinarily pretty cheap and fast.

If you’re ordering prototypes or short runs, be sure to request a foil stencil be ordered so that the protos can be stenciling on the automatic DEK printers. Hand stenciling is difficult with the scale of PBs’ 0402 components and tight placements.

How to Design a MicroMod Carrier Board

Start with a known good carrier board; the MicroMode Machine Learning Carrier Board is a good example.

If this carrier board would benefit from datalogging, consider adding full SDIO support. The user can always fall back to SPI (SdFat FTW!) if their platform doesn’t have SDIO software support.

alt text

The SMD reflowable standoff is a separate component from the MicroMod connector so that we can track the parts correctly in Sparkle. The connector has a circle where the standoff needs to fall. It needs to be close but not micron perfect. We currently plan to only have 22x22mm MicroMods PBs (note the ‘2222’ text) but this may grow in the future.

alt text

We currently recommend using the common stock 3.3V 1A linear regulator. In addition, please include the zener and pullup on the enable pin. This allows a MicroMod PB to turn off the main power supply when necessary, enabling considerable power savings. The zener protects the MicroMod PB from damage to its GPIO from VIN.

alt text

Note the MEAS jumper below. This allows for cutting and inline current measuring. Note the BYP jumper. This allows the user to bypass the PTC and increase current use beyond 2A if supported by their power supply.

alt text

Interface pins should be grouped together but their location on the board is not specified.

A Qwiic connector with pullups and a logo should be put on every carrier board. Note the thick 0.022” 3.3V trace enabling 2A delivered to the Qwiic bus.

alt text

Components under the MicroModule PB are allowed. Be careful of component height! Any component placed under MicroModule with 4.2mm height connector (the standard connector we stock) must be less than 1.9mm +/-0.1mm tall. No Artemis (too tall), yes SOT-23-5, yes CH340C/E. Double check the height of the components on the bottom of all MicroMod PBs.

alt text

All carrier boards should have a SWD port. Note that this example uses ‘JTAG’ silk. We should probably change to ‘SWD’ since I don’t know of a micro that supports true JTAG, just Serial Wire Debug.

alt text

Add a reset button and consider adding a boot button. Currently, the boot input is not utilized on many PBs but should be considered nearly mandatory. Use the taller 5.2mm switch.

alt text

Consider adding RTC/low power backup to your board. The RTC backup battery configuration shown is pretty well tested. It’s compact, SMD compatible, and provides 1mAh of capacity. Your application may be high power (a motor driver) where RTC doesn’t make sense. It’s ok to leave off.

alt text

Now add anything you may need to your carrier board for your specific application. LiPo charging, DB9, RFID, whatever. The power of MicroMod and the challenge to you is to consider how your added peripherals are going to play with the various MicroMod PBs. Adding a serial device is straightforward, most all PBs will have TX/RX1. Adding a PDM microphone or 4 bit high speed (Quad SPI) display takes more consideration.

Routing is straightforward. Match the length of any high speed traces such as USB D+/D-, USB HOST D+/D-. Consider using 7mil trace/space with 0.012” drills. Ues 0.022” traces for up to 2A power buses. Smaller traces down to 0.0035mil and 0.2mm drills are allowed but highly unlikely we’ll need it. Four layer boards are cheap these days but again, highly unlikely we’ll need it. Carrier boards should be much less complex because all the complexity should be pushed into the Processor Board.

Pull-ups on Chip Select (CS) pins: Pullups live with the peripheral. So if the carrier board has a SPI device on the board (SD, sensor, etc), that device needs to have a pull up on the CS pin. If the CS line is simply brought out to a PTH header, it does not need a pullup (that pullup should live on the peripheral the user adds). Use a 100k where possible but the value can be changed as the peripheral’s datasheet specifies.

Pin Specifications

Signal Group Signal I/O Description Voltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to the USB 2.0 Specification. Connect to any pins on the processor that require 5V for USB functionality. 4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw = 100uA. Connect to pins that maintain an RTC during power loss. Can be left NC. 3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltages above 1V will enable 3.3V power path. Can be left NC. If implemented, carrier board must supply pullup resistor and 3.3V clamping on regulator enable pin. 3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed to enable full 0-3.3V range. 3.3V
ResetResetIInput to processor. Open drain with pull up on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pull up on processor board. Pulling low puts processor into special boot mode. Can be left NC.
USBUSB_D+
USB_D-
I/0USB Data ± Differential serial data interface compliant to the USB 2.0 specification. If a UART is required for programming, USB+/- must be routed to a USB-to-serial conversion IC on the processor board.
USB_HOSTUSBHOST_D+
USBHOST_D-
I/0For processors that support USB Host Mode. USB Data ± differential serial data interface compliant to the USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus Receive Data3.3V
CAN_TXOCAN Bus Transmit Data3.3V
UARTUART_RX1IUART Receive Data3.3V
UART_TX1OUART Transmit Data3.3V
UART RTS1OUART Ready to Send3.3V
UART CTS1IUART Clear to Send3.3V
UART_RX2I2nd UART Receive Data3.3V
UART_TX2O2nd UART Transmit Data3.3V
Note: UART1/2 must be unencumbered (not attached to a USB-to-serial conversion IC).
Note: UART0 is not shown. Primary debug serial is done over USB. Serial.print() should print over USB, not TX1.
I2CI2C_SCLI/OI2C Clock. Open drain with pull up on carrier board.3.3V
I2C_SDAI/OI2C Data. Open drain with pull up on carrier board.3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pull up on carrier board. Active Low. 3.3V
I2C_SCL1I/O2nd I2C Clock. Open drain with pull up on carrier board.3.3V
I2C_SDA1I/O2nd I2C Data. Open drain with pull up on carrier board.3.3V
SPI/SDIOSPI_SCK
SDIO_CLK
OSPI Clock. Secondary use: SDIO Clock. 3.3V
SPI_COPI
SDIO_CMD
IOSPI Controller Out Peripheral In. Secondary use: SDIO Command Interface.3.3V
SPI_CIPO
SDIO_DATA0
I/OSPI Controller In Peripheral Out. Secondary use: SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 13.3V
SDIO_DATA2I/OSDIO data exchange bit 23.3V
SPI_CS
SDIO_DATA3
I/OSPI Chip select. Active low. Secondary use: SDIO data exchange bit 3.3.3V
Note: The carrier board SD socket can fall back to SPI if lines are routed correctly. Connect multiple pins to obtain dual function as necessary. For example, if CIPO1 is a different pin from DATA0 on processor, then route both CIPO1 and DATA0 to SDIO_DATA0 on board edge.
SPI_CIPO1I2nd SPI Controller In, Peripheral Out3.3V
SPI_COPI1O2nd Controller Out, Peripheral In3.3V
SPI_SCK1O2nd SPI clock3.3V
SPI_CS#1O2nd SPI chip select. Active low. Can be routed to GPIO if hardware CS is not used. 3.3V
AUDIOAUD_MCLKOAudio Master Clock3.3V
AUD_OUT
PCM_OUT
I2S_OUT
CAM_MCLK
OAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock. 3.3V
AUD_IN
PCM_IN
I2S_IN
CAM_PCLK
IAudio data input. PCM synchronous data inut/I2S serial data in. Camera peripheral clock. 3.3V
AUD_LRCLK
PCM_SYNC
I2S_WS
PDM_DATA
I/OAudio left/right clock. PCM synchronous data SYNC. I2S word select. PDM data.3.3V
AUD_BLCK
PCM_CLK
I2S_SCK
PDM_CLK
OAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock. 3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor supports SWD. Can be left NC. 3.3V
SWDCKISerial wire debug clock. Connect if processor supports SWD. Can be left NC. 3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range. 3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/OGeneral digital input/output pin.3.3V
D1
CAM_TRIG
I/OGeneral digital input/output pin. Camera trigger. 3.3V
GPIO/BUSG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc) positions. The intent is to guarantee PWM, ADC, and digital pin functionality on ADC/PWM/Digital specific pins. Whereas Gx pins do not guarantee ADC/PWM function. Alternatively, pins can be used to support a fast read/write 8-bit wide or 4-bit wide bus. 3.3V
G1/BUS1I/O33V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin.3.3V
G9
ADC_D-
CAM_HSYNC
I/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10
ADC_D+
CAM_VSYNC
I/ODifferential ADC input if available. Camera vertical sync.3.3V
G11
SWO
I/OGeneral purpose pin. Serial Wire Output. 3.3V

Resources and Going Further

For more information, check out the resources below:

Looking for more MicroMod fun? Check out the following tutorials with MicroMod for more inspiration!

New!

Artemis MicroMod Processor Board Hookup Guide

Get started with the Artemis MicroMod Processor Board in this tutorial!
New!

MicroMod ESP32 Processor Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod ESP32 Processor Board
New!

MicroMod Data Logging Carrier Board Hookup Guide

Get started with some customizable MicroMod data logging with the Data Logging Carrier Board.
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

$
0
0

SparkFun MicroMod Input and Display Carrier Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1230

Introduction

Introducing the SparkFun MicroMod Input and Display Carrier Board! This nifty little board works with all SparkFun MicroMod processors so you can create your own display with one of a multitude of processors.

The carrier board includes 6 APA102 Addressable LEDs, 6 Input Buttons, Onboard Voltage Regulation, 2.4" TFT Display Screen, IO Connector, and a Buzzer. In addition, there's a microSD card slot to store and read data.

Let's dive in and see what we can do!

SparkFun MicroMod Input and Display Carrier Board

SparkFun MicroMod Input and Display Carrier Board

DEV-16985
$59.95

Required Materials

Like all of our MicroMod Carrier Boards, there is no processor included but instead you can plug in a processor board of your choice to the MicroMod M.2 connector on the carrier. Below are a few options to choose for your processor:

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod Teensy Processor

SparkFun MicroMod Teensy Processor

DEV-16402
$19.95
SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$14.95
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95

You'll also need a USB-C cable to connect the Carrier to your computer and if you want to add some Qwiic breakouts to your MicroMod project you'll want at least one Qwiic cable to connect it all together. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Along with a processor and the pertinent cables and accessories, if you want to take full advantage of the features of the Input and Display Carrier Board, you will need a microSD card:

microSD Card - 16GB (Class 10)

microSD Card - 16GB (Class 10)

COM-15051
$19.95

Suggested Reading

The SparkFun MicroMod ecosystem is a unique way to allow users to customize their project to their needs. Do you want to send your data via a wireless signal (eg. Bluetooth or WiFi)? There's a MicroMod processor for that. Looking to instead maximize efficiency and processing power? You guessed it, there's a MicroMod processor for that. If you are not familiar with the MicroMod system, take a look here:

MicroMod Logo
MicroMod Ecosystem

We also recommend taking a look through the following tutorials if you are not familiar with the concepts covered in them:

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

Hardware Overview

In this section we'll cover the various hardware and sensors included on the MicroMod Input & Display Carrier Board.

Common Components

Most SparkFun MicroMod Carriers will have some common components and all MicroMod Carriers will have the keyed M.2 MicroMod Connector to plug your processor into. The photo and list below outline some of the components you can expect on most SparkFun MicroMod Carriers.

  • M.2 MicroMod Connector - This special keyed M.2 connector lets you install your MicroMod Processor of choice on your Input & Display Carrier Board.
  • USB-C Connector - Connect to your computer to program your Processor and also can provide power to your MicroMod system.
  • 3.3V Regulator - Provides a regulated 3.3V and sources up to 1A.
  • Qwiic Connector - The standard Qwiic connector so you can add other Qwiic devices to your MicroMod system.
  • Boot/Reset Buttons - Push buttons to enter Boot Mode on Processor boards and to Reset your MicroMod circuit. More information needed - LAC
  • microSD Slot - Insert a microSD card for reading and writing data.

Annotated Photo of common hardware

Power

The Input and Display Carrier Board takes an input voltage range from 2.7V - 6V via the USB-C connector. We've incorporated a power regulation circuit that caps the voltage for power sensitive circuits and the Qwiic connector.

Input & Display Carrier Board Specific Components

ATTiny84

We've populated this carrier board with Atmel's ATtiny84 with 8kB of programmable flash. This little guy is preprogrammed to communicate with the processor over I2C to read button presses.

ATTiny is highlighted

TFT Display

4DLCD's 24320240-IPS is a color active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). The module display area measures 2.4" and contains 240 x 320 pixels.

Note: IPS displays have higher display quality, better colors, and much better viewing angles than their non-IPS counterparts.

4DLCD screen

LEDs

The Input and Display Carrier Board has 6 Addressable APA102 LEDs.

APA102 LEDs

Input Buttons

Button button, who's got the button? We do! We have two input buttons (A and B), and a 5 way switch that allows you to navigate a UI or play an onboard game.

A Button, B button, and 5 way button

JTAG Debugging

We've populated the JTAG footprint for more advanced users who need breakpoint level debugging. We recommend checking out our JTAG section for the compatible JTAG programmer and debugger.

JTAG debugging pins

Jumpers

Jumpers are highlighted

I2C Jumper

If you are daisy-chaining multiple Qwiic devices, you will want to cut this jumper; if multiple sensors are connected to the bus with the pull-up resistors enabled, the parallel equivalent resistance could create too strong of a pull-up for the bus to operate correctly. As a general rule of thumb, disable all but one pair of pull-up resistors if multiple devices are connected to the bus. To disable the pull up resistors, use an X-acto knife to cut the joint between the two jumper pads highlighted below.

PWR Jumper

Cutting this jumper will disable the "Power" LED on the front of the board.

3V3CTRL Jumper

Many of the MicroMod carrier boards have an RTC backup battery on board and as part of the standardized voltage regulation circuit we include a 3V3 jumper that, when closed, allows you to control the 3V3 control regulator. This shuts down everything on the 3V3 rail but the battery keeps the processor awake. The Input and Display Carrier Board does not have a backup battery, so this jumper should remain open.

BYP Jumper

If you really, really, REALLY need more power, closing this jumper will bypass the 2A fuse. Close at your own risk!

Measure Jumper

Want to measure the juice running through your circuits? Cut the trace between these PTH pads in order to measure the current with a Digital MultiMeter.

PinOuts

Note: You may not recognize the COPI/CIPO labels for SPI pins. SparkFun is working to move away from using MISO/MOSI to describe signals between the controller and the peripheral. Check out this page for more on our reasoning behind this change.
AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D+
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0))1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D+
3.3V_EN43USB_D+
3.3V21GND
NotesPrimary FunctionBottom Pin   Top    PinPrimary FunctionNotes
61SPI_CIPO
59SPI_COPI
57SPI_SCK
55SPI_CS#microSD Chipselect#
47PWM1Buzzer
Display Reset#G2/BUS24443CAN-TX
APA102 DataG1 / BUS14241CAN_RX
APA102 Clock G0 / BUS04039GND
A138
A034
Display Backlight#PWM032
23SWDIO
21SWDCK
19UART_RX1
Display D/CD1/CAM_TRIG1817UART_TX1
I2C_Interrupt16
I2C_SCL14
I2C_SDA1211BOOT
Display Chipselect#D0109USB_VIN
7GND
RESET65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V procided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interfae compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

MicroMod Input and Display Carrier Board Dimensions

Hardware Hookup

To get started with the Input and Display Carrier Board, you'll need a processor board. Here we are using the MicroMod ESP32 Processor Board.

Align the top key of the MicroMod ESP32 Processor Board to the screw terminal of the Input and Display Carrier Board and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Note: There is no way to insert the processor backward since the key prevents it from mating with the M.2 connector and as an extra safeguard to prevent inserting a processor that matches the key, the mounting screw is offset so you will not be able to secure an improperly connected processor board.

MicroMod Processor Board inserted into the carrier board

The Processor Board will stick up at an angle, as seen here:

[[MicroMod Processor Board inserted into the carrier board](https://cdn.sparkfun.com/assets/learn_tutorials/1/2/3/0/16985_MicroMod_InputDisplay_CB_PBAngle.jpg)

Once the board is in the socket, gently hold the MicroMod Processor Board down and tighten the screw with a Phillip's head.

screwing in the machine screw

Once the board is secure, your assembled MicroMod system should look similar to the image below!

Top down image of Input and Display Carrier Board with ESP32 Processor board inserted correctly

Connecting Everything Up

With your processor inserted and secured it's time to connect your carrier board to your computer using the USB-C connector on the Carrier. Depending on which carrier you choose and which drivers you already have installed, you may need to install drivers.

Note: Make sure that for whatever processor board you choose, you have the correct board definitions installed.

For this particular tutorial, we are using the MicroMod ESP32 Processor Board. Board definitions for this processor board can be found in the Software Setup and Programming section of the MicroMod ESP32 Processor Board Hookup Guide.

If you are using a different processor board, go to our MicroMod Processor Boards landing page, find your processor board, and head on over to that tutorial for help installing your board definition.

Software Setup and Programming

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

To get started, you're going to want to get familiar with our HyperDisplay libraries. HyperDisplay is an abstracted library for pretty much any 2D graphics display and has a focus on extensibility. Since the interface is standardized you can write display applications just once and make them work on many different displays with a few small changes. If you want to go more in depth check out this HyperDisplay tutorial.

Everything You Should Know About HyperDisplay

February 20, 2019

This is a tutorial to go in-depth about the SparkFun HyperDisplay Arduino Library.

To use HyperDisplay with this carrier board, you will need to have all three of the following libraries installed in your Arduino IDE. You can head on over to the individual GitHub pages to download or simply click the appropriate link for each of the libraries listed below:

Library NameArduino Library Manager Search TermGitHub LinkDownload Link
HyperDisplaySparkFun HyperDisplayHyperDisplay GitHubHyperDisplay Download
HyperDisplay ILI9341SparkFun HyperDisplay ILI9341 Arduino LibrarySparkFun HyperDisplay ILI9341 Arduino Library GitHubSparkFun HyperDisplay ILI9341 Arduino Library Download
HyperDisplay 4DLCD-320240 Arduino LibrarySparkFun_HyperDisplay_4DLCD-320240_ArduinoLibraryHyperDisplay 4DLCD-320240 Arduino Library GitHubHyperDisplay 4DLCD-320240 Arduino Library Download

Check out this tutorial on how to install an Arduino library if you are unfamiliar.

Each of the libraries above contain some examples, however the ones that will actually make your Input and Display Carrier Board light up are contained in the 'HyperDisplay 4DLCD-320240 Arduino Library' -- in case you are wondering, that name comes from the name of the display module that is used on the board. Once your libraries have been installed move on to the next section and try out a few of the examples.

Example Code

The HyperDisplay library for the Input and Display Carrier Board is named after the LCD module that it uses - the 4DLCD-320240. If you've properly installed the required libraries, you'll notice a number of examples in File->Examples->SparkFun HyperDisplay 4DLCD-320240. If you haven't already, make sure you've got the following three libraries installed:

All of the following examples are explained in depth in the Everything You Should Know About HyperDisplay Tutorial. We'll show you a quick overview of each example here, but if you want more information on how these examples and their code work, head on over to the HyperDisplay Tutorial.

Everything You Should Know About HyperDisplay

February 20, 2019

This is a tutorial to go in-depth about the SparkFun HyperDisplay Arduino Library.

Example 1: Display Test

Example one verifies that your display is working, and gives you some basic code to draw lines and shapes. To start, go to File->Examples->SparkFun HyperDisplay 4DLCD-320240 and load Example1_DisplayTest. In windows, it will look like this:

File Pulldown showing installed library with Example 1 selected
Having a hard time seeing? Click the image for a closer look.


Make sure you have the correct board selected, as well as the correct COM port. Your processor board of choice will dictate which board definition you need to load.

gif showing example 1
Having a hard time seeing? Click the image for a closer look.


Example 2: HyperDisplay Basics

This code walks you through the simplest uses of HyperDisplay so that you can start to write your own code. To start, go to File->Examples->SparkFun HyperDisplay 4DLCD-320240 and load Example2_HyperDisplayBasics.

File Pulldown showing installed library with Example 2 selected
Having a hard time seeing? Click the image for a closer look.


As with Example 1, please make sure you have the correct board selected, as well as the correct COM port. Go ahead and upload your code, and you should see something like the following (note that the gif is sped up):

gif showing example 2
Having a hard time seeing? Click the image for a closer look.


Example 3: Advanced HyperDisplay

Example 3 goes over Color Cycles and the drawing functions currently available in the HyperDisplay drawing functions. For a more in-depth look at the functions available in this example, refer to the Advanced Drawing Functions section of the Everything You Should Know About HyperDisplay tutorial.

To start, go to File->Examples->SparkFun HyperDisplay 4DLCD-320240 and load Example3_AdvancedHyperDisplay.

File Pulldown showing installed library with Example 3 selected
Having a hard time seeing? Click the image for a closer look.


As above, please make sure you have the correct board selected, as well as the correct COM port. Go ahead and upload your code. You should see something like the following (note that the gif is sped up):

gif showing example 3
Having a hard time seeing? Click the image for a closer look.


Example 4: Buffering HyperDisplay

This last example shows you the basics of how to use the buffering abilities of HyperDisplay. You can get more in-depth discussion of this by referring to the Buffering section of the Everything You Should Know About HyperDisplay tutorial.

To start, go to File->Examples->SparkFun HyperDisplay 4DLCD-320240 and load Example4_BufferingHyperDisplay.

File Pulldown showing installed library with Example 4 selected
Having a hard time seeing? Click the image for a closer look.


As above, please make sure you have the correct board selected, as well as the correct COM port. Go ahead and upload your code. You should see something along the lines of the following (note that the gif is sped up):

gif showing example 4
Having a hard time seeing? Click the image for a closer look.


Troubleshooting

Resources and Going Further

For more information about the MicroMod Input and Display Carrier, check out the following links:

For more information about the SparkFun MicroMod Ecosystem, take a look at the links below:

Looking for some project inspiration using your Input and Display Carrier Board? The tutorials below can help you get started!

New!

Designing with MicroMod

This tutorial will walk you through the specs of the MicroMod processor and carrier board as well as the basics of incorporating the MicroMod form factor into your own PCB designs!
New!

MicroMod ESP32 Processor Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod ESP32 Processor Board
New!

MicroMod All The Pins (ATP) Carrier Board

Access All The Pins (ATP) of the MicroMod Processor Board with the Carrier Board!
New!

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

MicroMod All The Pins (ATP) Carrier Board

$
0
0

MicroMod All The Pins (ATP) Carrier Board a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1211

Introduction

Access All The Pins (i.e. ATP) of the MicroMod Processor Board with the MicroMod ATP Carrier Board!

SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.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.

MicroMod Processor Board

You'll need a Processor Board to break out the pins.

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$14.95
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95

Accessories

At a minimum, you will need a USB C cable to power and program the boards. Depending on your application, you may want to grab a Qwiic cable to connect a Qwiic-enabled device.

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2

Tools

You will need a screw driver to tighten the screw between the processor board and carrier board.

SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3

Suggested Reading

If you aren't familiar with the MicroMod ecosystem, we recommend reading here for an overview. We recommend reading here for an overview if you decide to take advantage of the Qwiic connector.

MicroMod Logo
Qwiic Connect System
MicroMod EcosystemQwiic Connect System

If you aren’t familiar with the following concepts, we also recommend checking out these tutorials before continuing.

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

Hardware Overview

MicroMod Processor Board

The MicroMod ATP Carrier Board includes a location for a MicroMod Processor Board. Here is where your chosen Processor Board will reside.

MicroMod M.2 Connector

Power

There are a variety of power and power-related nets broken out to female head pins and its corresponding through hole pads. The image below highlights those female headers and pads. The board can be powered from the VIN pin with a recommended voltage between 3.3V to 6.0V. It can also be powered with 5V from the USB C connector. The voltage is regulated down to 3.3V with the AP7361C voltage regulator to power your devices with up to 1A of current. If your voltage is clean, and regulated, you can also connect 3.3V.

Power Pins

Backup Battery

The board has a built-in backup battery for Processor Boards with an RTC. Depending on the processor, it may not be connected

Backup Battery for the RTC

USB Ports

You have the option of connecting the board to a computer using the USB connectors. The USB Type C connector is used to power, program the processor board, or pass serial data to a serial port. If your processor board has the ability, there is also an option for USB host through the female USB Type A connector. There is a Schottky diode on the USB host's 5V pin but we do not recommend connecting two both the Type C and Type A ports.

USB Ports

All the [GPIO] Pins

Remember our "All the Pins!" nickname? Well, we meant it. On the MicroMod ATP, not only have we broken out all the major pins with female headers, we've added a secondary rail of plated through-holes alongside them to give you the choice of either plug and play or soldering directly to the board. The general hardware pinout v1.0 is broken out on the edge of the board. Your mileage may vary depending on the processor board that you are using.

All The Pins

Qwiic and I2C

There are two locations on the board for your favorite Qwiic-enabled device. IN addition to the Qwiic conenctors, we also have pins that are broken out on the should you need to use jumeper wires or solder wire direction to both boards. There are mounting holes for each standard 1.0"x1.0" Qwiic-enabled device.

Qwiic Connectors and I2C

Reset and Boot Buttons

The reset button will reset the processor. The boot button will put the processor into a special boot mode. Depending on the processor board, this boot pin may not be connected.

Reset and Boot Buttons

SWD Programming Pins

For advanced users, we broke out the SWD programming pins. Note that this is not populated so you will need a compatible header and compatible JTAG programmer to connect.

SWD Programming PIns

Jumper Pads

There are a few jumpers populated on the board:

  • Bypass (BYP) - By default, the BYP is left open. Adding a solder jumper bypasses the 2A resettable fuse on the back of the board should you decide to pull more than 2A from your USB source. Proceed with caution should you decide to bypass the jumper.
  • Enable (EN) - By default, the EN pin is closed. This jumper is connected to a processor board's GPIO pin. The processor board cna control the ATP's voltage regulator. Depending on the processor, this may not be connected.
  • Current Measurement (MEAS) - By default, the MEAs is closed. Cutting the jumper and soldering to the PTH pads will allow you to insert a current meter and precisely monitor the how much current your application is consuming.
  • 3V3 LED - By default, the 3V3 LED is closed. Cutting this jumper will disable the LED there is 3.3V.
  • VIN LED - By default, the VIN LED is closed. Cutting this jumper will disable the LED whenever there is an input voltage.

General MicroMod Pinout

Wondering what the pins are that are broken out on the ATP MicroMod ATP Carrier Board? Check out the table from the Getting Started with MicroMod for more information. Remember to check out the pins against your Processor Board to determine what pins are available.

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D-
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_RX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0))1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V procided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interfae compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board is 3.30"x2.20". There are 4x mounting holes on each corner of the board.

Board Dimensions

Hardware Hookup

If you have not already, make sure to check out the Getting Started with MicroMod: Hardware Hookup for information on inserting your Processor Board to your Carrier Board.

New!

Getting Started with MicroMod

October 21, 2020

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

At a minimum, your setup should look like the image below. In this case, we had the MicroMod SAMD51 Processor Board secured in the M.2 connector. To program and power the microcontroller, we inserted the USB-C cable.

Processor Board inserted into Carrier Board

Depending on your setup you may need hardware (jumper wire, cables, header pins, breadboard, etc.) to connect to the board. In this case, we used jumper wire to connect to another board.

Jumper Wire Connecting Boards

To Qwiic-ly connect 2C devices, simply insert a Qwiic cable between the MicroMod ATP's Qwiic port and your Qwiic device.

Qwiic-Enabled Device Connected to MicroMod ATP Carrier Board with Qwiic Cable

To secure the boards together, you could add standoffs and screws to mount a Qwiic-enabled device that have the standard 1.0"x1.0" sized board. Keep in mind that this will block a few of the header pins below so make sure to plan accordingly.

Qwiic-Enabled Device Mounted with Standoffs

Depending on the location of the mounting holes, you may need to make an adapter to hold the Qwiic-enabled device securely. Below is an example with mounting holes on the same side instead of diagonal. A piece of cardboard was cut out as shown in the image below. Depending on your personal preference, you could also laser cut, CNC, or 3D printer to make a more sturdy panel for those that need a stronger material.

Qwiic-Enabled Device Mounted with Standoffs and Cardboard Adapter

Example

Note: If this is your first time using Arduino IDE or board add-on, please review the following tutorials.

There are quite a lot of peripherals broken out on the MicroMod ATP Carrier Board. Depending on the design of the Processor Board, not all of the pins may be broken out. For simplicity, we will upload a blink sketch to get started.

Blink

Note: Make sure that for whatever processor board you choose, you have the correct board definitions installed. Go to our MicroMod Processor Boards landing page, find your processor board, and head on over to that tutorial for help installing your board definition.

Now that you have a Processor Board secure in the Carrier Board, let's upload a simple blink sketch to the board. Copy and paste the following code in the Arduino IDE. Head to Tools>Board to select the cord board definition (in this case, SparkFun MicroMod SAMD51. Select the correct COM port that the board enumerated to. Hit upload.

language:c
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name
// uncomment the following lines if the macro is not defined for your architecture
//#define LED_BUILTIN 13 //Artemis, SAMD51
//#define LED_BUILTIN 5 //ESP32

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin using the built-in macro as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

After uploading, you should see the Processor Board's LED blink. If not, make sure that to define the pin and check your connections.

What's next? Try building a circuit using the design files and associated tutorial for your Processor Board more information. Keep in mind that while each Processor Board uses the same MicroMod interface pinout, each board may have different specifications, software support, and peripherals available for the architecture.

New!

Artemis MicroMod Processor Board Hookup Guide

Get started with the Artemis MicroMod Processor Board in this tutorial!
New!

MicroMod SAMD51 Processor Board Hookup Guide

This tutorial covers the basic functionality of the MicroMod SAMD51 and highlights the features of the ARM Cortex-M4F development board.
New!

MicroMod ESP32 Processor Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod ESP32 Processor Board

Troubleshooting

Resources and Going Further

Now that you've successfully got your MicroMod ATP Carrier Board up and running with your Processor Board, it's time to incorporate it into your own project! For more information, check out the resources below:

Need some inspiration for your next project? Check out some of these related tutorials with MicroMod:

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
New!

MicroMod ESP32 Processor Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod ESP32 Processor Board
New!

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board
New!

MicroMod Data Logging Carrier Board Hookup Guide

Get started with some customizable MicroMod data logging with the Data Logging Carrier Board.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Artemis MicroMod Processor Board Hookup Guide

$
0
0

Artemis MicroMod Processor Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1191

Introduction

Leveraging the ultra powerful Artemis Module, the SparkFun MicroMod Artemis Processor is the brain board of your dreams. With a Cortex-M4F with BLE 5.0 running up to 96MHz and with as low power as 6uA per MHz (less than 5mW), the M.2 MicroMod connector allows you to plug in a MicroMod Carrier Board with any number of peripherals. Let's have a look at what this processor board has to offer!

Required Materials

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95

You'll need a carrier board to get started. Here we use the Machine Learning Carrier Board, but there are a number of others you can choose from.

SparkFun MicroMod Machine Learning Carrier Board

SparkFun MicroMod Machine Learning Carrier Board

DEV-16400
$19.95
SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$19.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95

You'll also need a USB-C cable to connect the Carrier to your computer and if you want to add some Qwiic breakouts to your MicroMod project you'll want at least one Qwiic cable to connect it all together. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Suggested Reading

We recommend taking a look through the following tutorials if you are not familiar with the concepts covered in them:

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

The SparkFun MicroMod ecosystem is a unique way to allow users to customize their project to their needs. Do you want to send your weather data via a wireless signal (eg. Bluetooth or WiFi)? There's a MicroMod processor for that. Looking to instead maximize efficiency and processing powere? You guessed it, there's a MicroMod processor for that. If you are not familiar with the MicroMod system, take a look here:

MicroMod Logo
MicroMod Ecosystem

Hardware Overview

While the Artemis module is pretty self-contained, let's have a look at a few of the unique features of this MicroMod Processor Board.

Power

Power is supplied by the carrier board, but it should be noted that all pins are 3.3V.

M.2 Connector

All of our MicroMod Processor boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor board on your choice of carrier board. The board measures 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.


M.2 Connector from the FrontM.2 Connector from the Back

Artemis Processor

The SparkFun Artemis Processor provides a Cortex-M4F with BLE 5.0 running up to 96MHz and with as low power as 6uA per MHz (less than 5mW). This module is powerful enough to run TensorFlow, Machine Learning, and all sorts of voice recognition software. A deep dive into all of Artemis's delightful features can be found in the Designing with the SparkFun Artemis tutorial.

Artemis Module on the MicroMod Artemis Processor Board

Op Amp

Incoming analog voltages over 2V will saturate the Artemis's analog to digital converter. We've integrated an OpAmp to scale the incoming 0-3.3V voltages down to the 0-2V range that the Artemis can handle.

Highlighted OpAmp

RTC

An onboard RTC crystal has been integrated.

Highlighted RTC

Status LED

We've also included a Status LED for all your blinky needs.

Highlighted status LED

Artemis MicroMod Processor Pin Functionality

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D+
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0)1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D+
3.3V_EN43USB_D+
3.3V21GND
Alternate FunctionPrimary FunctionBottom Pin   Top    PinPrimary FunctionAlternate Function
73G5
71G6
QSPI3SPI_CS7069G7
QSPI268
QSPI16665TX1ADC_D-
QSPI0SPI_CIPO6463ADC_D+
QSPI_CSSPI_COPI6261SPI_CIPO1
QSPI_SCKSPI_SCK6059SPI_COPI1
CAM_MCLK5857SPI_SCK1
CAM_MCLK5655SPI_CS1
CAM_PCLK5453SCL1
PDM_DATA5251SDA1
PDM_CLK5049BATT_VIN3
G44847PWM1
G346
G244
G142
G04039GND
ADC138
ADC034
PWM032
23SWDIO
21SWDCK
19RX1
D11817TX1ADC_D-
I2C_Interrupt1615CTS1
SCL1413RTS1
SDA1211BOOT
D0109
7GND
RESET65USB_D-
3USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board measures 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.

MicroMod Processor Board Dimensions

Hardware Hookup

To get started with the Artemis MicroMod Processor Board, you'll need a carrier board. Here we are using the Machine Learning Carrier Board. Align the top key of the MicroMod Artemis Processor Board to the screw terminal of the Machine Learning Carrier Board and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Note: There is no way to insert the processor backward since the key prevents it from mating with the M.2 connector and as an extra safeguard to prevent inserting a processor that matches the key, the mounting screw is offset so you will not be able to secure an improperly connected processor board.

MicroMod Processor Board inserted into the carrier board - Top angle

The Processor Board will stick up at an angle, as seen here:

MicroMod Processor Board inserted into the carrier board

Once the board in the socket, gently push the MicroMod Processor Board down and tighten the screw with a Phillip's head.

screwing in the machine screw

Once the board is secure, your assembled MicroMod system should look similar to the image below!

Top down image of Machine Learning Carrier Board with Artemis Processor board inserted correctly

Connecting Everything Up

With your processor inserted and secured it's time to connect your carrier board to your computer using the USB-C connector on the Carrier. Depending on which carrier you choose and which drivers you already have installed, you may need to install drivers.

Note: If you've never connected a CH340 device to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our section on "How to Install CH340 Drivers" for help with the installation.

How to Install CH340 Drivers

August 6, 2019

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

Software Setup

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

Installing the Arduino Core for Apollo3

To get started with the Artemis MicroMod Processor Board, you'll need to install the SparkFun Apollo3 Arduino Core. Open the Arduino IDE (must be v1.8.13 or later) and navigate to File->Preferences, like so:

Arduino Preferences, under File

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

In the "Additional Board Manager URL" box, make sure you have the following json file:

language:c
https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

If you have more than one json file, you can click on the button outlined in red and add the json link at the end. It'll look something like the following:

Additional Boards Manager URL location in the Preferences Dialog

Having a hard time seeing? Click the image for a closer look.
  • Go to Tools ->Board and select the Boards Manager

Arduino Boards Manager Dialog, under Tools

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

Search for "Apollo3", and you should find the SparkFun Apollo3 Boards board package. Make sure the Version 1.2.1 is selected and click Install.

Board manager showing SparkFun Apollo3 Artemis install

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

Installation may take a few minutes -- included in the install are all necessary source files for the Arduino core and Apollo3 libraries, plus all of the compiler and software-upload tools you'll need to use the Artemis with Arduino.

Once the board definitions have been installed, you should see the Artemis MicroMod Processor board under your Tools -> Board -> SparkFun Apollo3 menu.

Artemis MicroMod processor dropdown
Having a hard time seeing? Click the image for a closer look.
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

To get started uploading code and working with your Machine Learning Carrier Board, make sure you have the Artemis MicroMod board definition selected under your Tools>Board menu (or whatever processor you've chosen to use).

Arduino Board Select

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


Then select your serial port under the Tools>Port menu.

Port Selection for the Artemis MicroMod Processor Board

Loading Blink

Let's start with something basic - let's blink an LED. Go to File->Examples->01.Basics->Blink.

Blink Basics Example in the pulldown

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


With everything setup correctly, upload the code! Once the code finishes transferring, you should see the STAT LED on the Artemis Processor Board begin to blink!

If the blue LED remains off, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the reset button to get your Artemis MicroMod to run the sketch.

Look at all the blinks!

blink blink blink

Example 2: PDM

We've built the Arduino core for Artemis from the ground up and a large number of our built-in examples will work out of the box with the Artemis MicroMod Processor Board. You'll find them under File->Examples->'Examples for SparkFun Artemis MicroMod'.

Let's run a quick one from the examples here and take advantage of the two built in microphones on the Machine Learning Carrier Board we're using. Go to File->Examples->PDM->Example1_MicrophoneOutput

Arduino sub menu showing Artemis examples

Click above image for full menu context

Make sure you have the correct board and port selected, and then upload the code. Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. You should see something like the following:

PDM Microphone example serial output

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

Notice that if you hoot and holler, the output changes.

Within the 'Examples for SparkFun Artemis Micromod' menu, we've got examples for setting up multiple I2C ports (it's amazingly easy), writing to EEPROM, using SoftwareSerial (all 48 pins can be serial!), using the the onboard microphone, and using servos (up to 32!). We're adding more all the time so be sure to keep your core up to date.

Further Examples

With the MicroMod system, the possibilities for examples with all the processor/carrier board are endless, and we just can't cover them all. You'll notice that in this tutorial, we've selected the Machine Learning Carrier Board, but have focused our examples on the Artemis Processor Board. If you're interested in examples specifically for our carrier board, head on over to our Machine Learning Carrier Board Hookup Guide.

Troubleshooting

Resources and Going Further

Want more information on the Artemis MicroMod Processor Board? Check out these links!

MicroMod Documentation:

Artemis Documentation:

Looking for some project inspiration using your Artemis Processor Board? The tutorials below can help you get started!

New!

Designing with MicroMod

This tutorial will walk you through the specs of the MicroMod processor and carrier board as well as the basics of incorporating the MicroMod form factor into your own PCB designs!
New!

MicroMod ESP32 Processor Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod ESP32 Processor Board
New!

MicroMod All The Pins (ATP) Carrier Board

Access All The Pins (ATP) of the MicroMod Processor Board with the Carrier Board!
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

MicroMod SAMD51 Processor Board Hookup Guide

$
0
0

MicroMod SAMD51 Processor Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1207

Introduction

With the MicroMod specification, we shrunk down the PCB size for the SAMD51 32-bit ARM Cortex-M4F MCU! This tutorial covers the basic functionality of the MicroMod SAMD51 and highlights its features.

SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.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.

SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95

Suggested Reading

If you aren't familiar with the MicroMod ecosystem, we recommend reading here for an overview.

MicroMod Logo
MicroMod Ecosystem

If you aren’t familiar with the following concepts, we also recommend checking out these tutorials before continuing.

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

Hardware Overview

M.2 Connector

All of our MicroMod Processor Boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor Board on your choice of carrier board. Most of the pins use a common pinout to ensure cross platform compatibility.

M.2 Edge Connector and Mounting

SAMD51 Processor

The brains of the processor board is the ATSAMD51J20 32-bit ARM Cortex M4 processor. An external 32.768kHz crystal is used as the clock for the ATSAMD51. However, the MCU itself has a maximum CPU speed of 120MHz.

SAMD51 Processor

Flash Memory

On the back of the board is the W25Q128JVPIM, which adds 128Mb (16MB) of flash memory externally.

Flash Memory

LED

A STAT LED is added to the top side of the board. This is useful debugging or as a status indicator. Additionally, you can use this to determine if the board is in bootloader mode. Pressing the reset button twice will put the board into bootloader mode causing the LED to fade in/out. This is connected to pin 13.

Status LED

MicroMod SAMD51 Processor Pin Functionality

The complete pin map can be found in the table below or you can refer to the schematic.

Heads up! The pin table below and schematic both include the SAMD51 pin associated with each MicroMod pin and this correlation can be used to identify alternate uses for pins on the SAMD51 Processor Board. For many of the General Purpose I/O pins and other pins with multiple signal options, refer to your Carrier Board's Hookup Guide for information on how those pins are configured what they are used for. Not all pins are used on every Carrier Board.
AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
SAMD51
Pin
Alternate
Function
Primary
Function
Bottom
Pin
   Top    PinPrimary
Function
Alternate
Function
SAMD51
Pin
(Not Connected)75GND
3.3V_IN7473G5D7
3.3V7271G6D8
-7069G7D9
-6867G8D10
-6665G9D11
-6463-
-6261SPI_CIPO47
-6059SPI_COPI45
43I2S_MCLK5857SPI_SCK46
40I2S_SDO5655SPI_CS48
41I2S_SDI5453I2C_SCL1TX236
44I2S_FS5251I2C_SDA1RX237
42I2S_CLK5049A422
D6G44847PWM1A321
D5G34645GND
D4G24443CAN_TX39
D3G14241CAN_RX38
D2G04039GND
18A13837-
GND3635-
17DACA03433GND
19A2PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
36I2C_SCL1UART_TX22221SWDCK
37I2C_SDA1UART_RX22019UART_RX132
D1D11817UART_TX133
D12I2C_INT1615-
34I2C_SCL1413-
35I2C_SDA1211-
D0D0109-
29HOST_ENABLE87GND
RESET# (Open Drain)65USB_D-USBHOST_D-30
3.3V_EN43USB_D+USB_HOST_D+31
3.3V_IN21GND
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1SDIO_DATA37069G7 / BUS7
SDIO_DATA26867G8
SDIO_DATA16665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA06463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD6261SPI_CIPO
SPI SCK1SDIO_SCK6059SPI_COPILED_DAT
AUD_MCLK5857SPI_SCKLED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D+
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX22221SWDCK
UART_RX22019UART_RX1
CAM_TRIGD11817UART_TX1
I2C_INT1615UART_CTS1
I2C_SCL1413UART_RTS1
I2C_SDA1211BOOT (Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (Open Drain)65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V procided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interfae compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board takes advantage of the standard MicroMod form factor.

Board Dimensions

Hardware Assembly

If you have not already, make sure to check out the Getting Started with MicroMod: Hardware Hookup for information on inserting your Processor Board into your Carrier Board.

New!

Getting Started with MicroMod

October 21, 2020

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!

For simplicity, we'll be using the MicroMod ATP Carrier Board to program the board. At a minimum, your setup should look like the image below with the MicroMod SAMD51 inserted into the MicroMod ATP Carrier Board with a USB-C cable.

Processor Board inserted into Carrier Board with USB cable

Qwiic-Enabled Device

If you decide to use a Qwiic device (because why not?!), simply insert a Qwiic cable between the two connectors.

Qwiic-Enabled Device Connected to MicroMod ATP Carrier Board with Qwiic Cable

UF2 Bootloader & Drivers

The SAMD51 Processor Board is easy to program thanks the UF2 bootloader. With the UF2 bootloader, the SAMD51 Thing Plus shows up on your computer as a USB storage device without having to install drivers for Windows 10, Mac, and Linux!

What is UF2?

UF2 stands for USB Flashing Format, which was developed by Microsoft for PXT (now known as MakeCode) for flashing microcontrollers over the Mass Storage Class (MSC), just like a removable flash drive. The file format is unique, so unfortunately, you cannot simply drag and drop a compiled binary or hex file onto the Turbo. Instead, the format of the file has extra information to tell the processor where the data goes, in addition to the data itself.

For Arduino users, the UF2 bootloader is BOSSA compatible, which the Arduino IDE expects on ATSAMD boards. For more information about UF2, you can read more from the MakeCode blog, as well as the UF2 file format specifiation.

Double-Tap to Launch the Bootloader

The bootloader is what allows us to load code over a simple USB interface. To upload code, you will need to manually enter bootloader mode by rapidly double-tapping the reset button (after hitting the reset button once, you have about half a second to hit it again). The board will remain in bootloader mode until power cycles (happens automatically after uploading code) or the reset button is hit again (once).

Hit Reset Button Twice to Enter Bootloader Mode

Double-tapping the reset button to enter bootloader mode.

On the SAMD51, the there are a clues to if it is in bootloader mode:

  • The D13 LED indicator will be slowly fading (may appear to be blinking).
  • Board will show up under a different COM port.
  • The board will appear as a USB mass storage device under the name USB Serial Device.

Driver Verification

To verify that your driver is working, you should see the difference in the following pictures after plugging in your SparkFun SAMD51 Thing Plus. Alternatively, once you have the Arduino IDE installed, you should also see a change in the number of available Serial/COM Ports (you may need to restart the Arduino IDE for the board to populate).

Windows

Check that the board shows up in your device manager. You can click the Start or (Windows) button and type "device" to quickly search for the application. (*On Windows 10, the quick search function is picky on the spelling of the application you are searching for. For example, you may get results using "devi" and none for "device".)

SAMD51 in Windows Device Manager

Screenshot of Window 10 Device Manager with the SAMD51 Processor Board on COM25. Click to enlarge.

Mac OSX

Open the Terminal and run the following command ls /dev/cu.* in the Terminal and check for the following changes (your board may show up under a different device name). To open the Terminal, open your Applications folder, Utilities folder, then double-click on Terminal. Otherwise, press (Command) + space bar (Space Bar) to launch Spotlight and type "Terminal," then double-click the search result.

Mac OSX CLI Command Entry

Screenshot of Mac OSX terminal with the SAMD51 Processor Board on cu.usbmodemFA121. Click to enlarge.
ls /dev/cu.*
Note: If you are still unsure of how to access the Terminal, watch this video or read this Apple support article.

Raspbian

Run the following command ls /dev/ttyACM* in the CLI/Terminal and check for the following changes (your board may show up under a different device name).

Raspbian CLI Command Entry

Screenshot of Raspberry Pi CLI with the SAMD51 Processor Board on ttyACM0. Click to enlarge
ls /dev/ttyACM*

Setting Up the Arduino IDE

Note: If this is your first time using Arduino IDE or board add-on, please review the following tutorials.

Install Arduino SAMD Board Add-Ons

First, you'll need to install a variety of tools, including low-level ARM Cortex libraries full of generic code, arm-gcc to compile your code, and bossa to upload over the bootloader. These tools come packaged along with Arduino's SAMD board definitions for the Arduino Zero.

To install the Arduino SAMD board definitions, navigate to your board manager (Tools>Board>Boards Manager...), then find an entry for Arduino SAMD Boards (32-bits ARM Cortex-M0+) by typing SAMD in the search bar. Select it, and install the latest version (at the time of writing this tutorial, the board definitions work with v1.8.9).

Installing the Arduino SAMD Core  with the Arduino IDE Board Manager

Downloading and installing the tools may take a couple minutes -- arm-gcc in particular will take the longest, it's about 250MB unpacked.

Once installed, Arduino-blue "Installed" text should appear next to the SAMD boards list entry.

Install SparkFun Board Add-On

Now that your ARM tools are installed, one last bit of setup is required to add support for the SparkFun SAMD boards. First, open your Arduino preferences (File>Preferences). Then find the Additional Board Manager URLs text box, and paste the below link in:

https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

Arduino IDE Preferences Additional Moard Manager URLs

Then hit "OK", and travel back to the Board Manager menu. You should (but probably won't) be able to find a new entry for SparkFun SAMD Boards. If you don't see it, close the board manager and open it again. ¯\_(ツ)_/¯.

Installing the SparkFun SAMD Boards

This installation should be much faster; you've already done the heavy lifting in the previous section. When writing this tutorial, the board version used in this tutorial should be v1.7.6. You may have a higher version as the board if there are any updates.

Select the Board and Serial Port

Once the board is installed, you should see a new entry in your Tools>Board list. Select your SparkFun MicroMod SAMD51.

Board and COM Port Selection in the Arduino IDE

Finally, select the SparkFun MicroMod SAMD51's port when the board is connected to your computer. Navigate back up to the Tool>Port menu. The port menu will have the SparkFun MicroMod SAMD51's port, labeled as such here. On a Windows machine, the serial port should come in the form of "COM#". On a Mac or Linux machine, the port will look like "/dev/cu.usbmodem####".

Arduino IDE COM Port Selection

In the picture above my MicroMod SAMD51 is listed under COM25; this is because I've plugged in about as many microcontrollers into my computer, but the one in your port menu should be smaller.

Arduino Examples

The SAMD51 is a powerful microcontroller. Here are a few examples that highlight some of its functionality.

Example 1: Blink and Hello World!

Now that you have a Processor Board secure in the Carrier Board, let's upload a combined sketch to the board. We will combine the blink and Hello World! sketches into one. Copy and paste the following code in the Arduino IDE. Head to Tools>Board to select the correct board definition (in this case, SparkFun MicroMod SAMD51). Select the correct COM port that the board enumerated to. Hit upload.

language:c
/* MicroMod SAMD51 Test Code
   by: Ho Yun "Bobby" Chan
   SparkFun Electronics
   date: October 7, 2020
   license: Public Domain - please use this code however you'd like.
   It's provided as a learning tool.

   This code is provided to show how to control the SparkFun
   MicroMod SAMD51's STAT LED within a sketch. It also serves
   to explain the difference between Serial.print() and
   Serial1.print().

*/

//int LED_BUILTIN = 13;  // The STAT LED has a defined Arduino pin
/* Note: STAT LED is connected to pin 13. This is defined in the
   MicroMod SAMD51 board files already as macros (e.g. PIN_LED, LED_BUILTIN)
   so we can comment this out.
*/


void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);  // Set RX LED as an output
  // TX LED is set as an output behind the scenes

  Serial.begin(9600); //This pipes to the serial monitor
  Serial.println("Initialize Serial Monitor");

  Serial1.begin(9600); //This is the UART, pipes to sensors attached to board
  Serial1.println("Initialize Serial Hardware UART Pins");
}

void loop()
{
  Serial.println("Hello world!");  // Print "Hello World" to the Serial Monitor
  Serial1.println("Hello! Can anybody hear me?");  // Print "Hello!" over hardware UART

  digitalWrite(LED_BUILTIN, LOW);   // set the LED_BUILTIN ON
  delay(1000);              // wait for a second

  digitalWrite(LED_BUILTIN, HIGH);    // set the LED_BUILTIN OFF
  delay(1000);              // wait for a second
}

Check out the MicroMod SAMD51's built-in LED. The LED should blink every second.

MicroMod SAMD51 LED Blink

Open the Arduino IDE's serial monitor set at 9600 baud. You should see every programmer's favorite two-word phrase.

Hello World! with the MicroMod SAMD51 Native Serial

Want to go the extra mile? Grab a 3.3V USB-to-serial converter (in this case, we are using the Serial Basic Breakout CH340). Then connect GND to GND using a M/M jumper wire. Add another M/M jumper wire between TX from the MicroMod ATP Carrier board and the RXI pin of the USB-to-serial converter. Connect the appropriate USB cable to the USB-to-serial converter.

CH340 Connected to SAMD51 via the ATP Carrier Board

Open another serial terminal (in this case, we'll use Tera Term on a Windows) and connect to the USB-to-serial converter at 9600 baud. You should see a different message being sent from the hardware serial pin.

Output from Hardware Serial on Tera Term

Example 2: Qwiic-Enabled Device Qwiic Distance Sensor (VL53L1X)

Note: If you have not previously installed an Arduino library, please check out our installation guide.

There's a plethora of Qwiic-enabled devices available to connect. In this example, we will be using a Qwiic distance sensor to test. If you have not already, head over to the Qwiic Distance Sensor's (VL53L1X) tutorial to install the library.

Qwiic Distance Sensor (VL53L1X) Hookup Guide

June 18, 2018

The Qwiic VL53L1X time of flight sensor is capable of several modes, as well as having a range of 4M. Let's hook it up and find out just how far away that thing over there is.

Connect the distance sensor to the Qwiic connector. Make sure to connect to the one labeled I2C. There is a second port labeled as I2C1. You would need to adjust the code in order to use the second I2C port.

alt text

For simplicity, we'll use the first example just like the tutorial. Open up the first example by heading to File>Examples>SparkFun VL53L1x 4M Laser Distance Sensor>Example1_ReadDistance. If you have not already, head to Tools>Board to select the correct board definition (in this case, SparkFun MicroMod SAMD51). Select the correct COM port that the board enumerated to. Hit upload.

Open a the Arduino Serial Monitor at 9600 baud and start moving your hand over the sensor.

alt text

You should see an output similar to the image below. The values will vary depending on the distance away from the sensor.

VL53L1X Output on the Arduino Serial Monitor

What's next? Try combining the distance sensor example with the HID keyboard/mouse library to wake up a Raspberry Pi from it's screensaver whenever an object is in front of the sensor. Better yet, try adding some buttons and writing code to make a game controller for a computer.

Resources and Going Further

Now that you've successfully got your MicroMod SAMD51 Processor Board up and running, it's time to incorporate it into your own project! For more information, check out the resources below:

Need some inspiration for your next project? Check out some of these related tutorials using HID mouse/keyboard or adding more SERCOM Ports for your SAMD51:

Wireless Joystick Hookup Guide

A hookup guide for the SparkFun Wireless Joystick Kit.

Adding More SERCOM Ports for SAMD Boards

How to setup extra SPI, UART, and I2C serial ports on a SAMD-based boards.

Keyboard Shortcut, Qwiic Keypad

A simple project using the Qwiic Keypad and the RedBoard Turbo to create your own custom hotkey-pad.

Qwiic Pro Micro USB-C (ATmega32U4) Hookup Guide

An overview of the ATmega32U4-based Qwiic Pro Micro USB-C, how to install it, and how to use it with Arduino.

Or check out other tutorials with MicroMod:


learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado


MicroMod Artemis Processor Board Hookup Guide

$
0
0

MicroMod Artemis Processor Board Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1191

Introduction

Leveraging the ultra powerful Artemis Module, the SparkFun MicroMod Artemis Processor is the brain board of your dreams. With a Cortex-M4F with BLE 5.0 running up to 96MHz and with as low power as 6uA per MHz (less than 5mW), the M.2 MicroMod connector allows you to plug in a MicroMod Carrier Board with any number of peripherals. Let's have a look at what this processor board has to offer!

Required Materials

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95

You'll need a carrier board to get started. Here we use the Machine Learning Carrier Board, but there are a number of others you can choose from.

SparkFun MicroMod Machine Learning Carrier Board

SparkFun MicroMod Machine Learning Carrier Board

DEV-16400
$19.95
SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$19.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95

You'll also need a USB-C cable to connect the Carrier to your computer and if you want to add some Qwiic breakouts to your MicroMod project you'll want at least one Qwiic cable to connect it all together. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
6
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Depending on which Carrier Board you choose, you may need a few extra peripherals to take full advantage of them. Refer to the Carrier Boards' respective Hookup Guides for specific peripheral recommendations.

Suggested Reading

The SparkFun MicroMod ecosystem is a unique way to allow users to customize their project to their needs. Do you want to send your weather data via a wireless signal (eg. Bluetooth or WiFi)? There's a MicroMod processor for that. Looking to instead maximize efficiency and processing powere? You guessed it, there's a MicroMod processor for that. If you are not familiar with the MicroMod system, take a look here:

MicroMod Logo
MicroMod Ecosystem

We also recommend taking a look through the following tutorials if you are not familiar with the concepts covered in them:

New!

Getting Started with MicroMod

Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
New!

Designing with MicroMod

This tutorial will walk you through the specs of the MicroMod processor and carrier board as well as the basics of incorporating the MicroMod form factor into your own PCB designs!
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

Hardware Overview

While the Artemis module is pretty self-contained, let's have a look at a few of the unique features of this MicroMod Processor Board.

Power

Power is supplied by the carrier board, but it should be noted that all pins are 3.3V.

M.2 Connector

All of our MicroMod Processor boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor board on your choice of carrier board.


M.2 Connector from the FrontM.2 Connector from the Back

Artemis Processor

The SparkFun Artemis Processor provides a Cortex-M4F with BLE 5.0 running up to 96MHz and with as low power as 6uA per MHz (less than 5mW). This module is powerful enough to run TensorFlow, Machine Learning, and all sorts of voice recognition software. A deep dive into all of Artemis's delightful features can be found in the Designing with the SparkFun Artemis tutorial.

Artemis Module on the MicroMod Artemis Processor Board

Op Amp

Incoming analog voltages over 2V will saturate the Artemis's analog to digital converter. We've integrated an OpAmp to scale the incoming 0-3.3V voltages down to the 0-2V range that the Artemis can handle.

Highlighted OpAmp

RTC

An onboard RTC crystal has been integrated.

Highlighted RTC

Status LED

We've also included a Status LED for all your blinky needs.

Highlighted status LED

Artemis MicroMod Processor Pin Functionality

Note: You may not recognize the COPI/CIPO labels for SPI pins. SparkFun is working to move away from using MISO/MOSI to describe signals between the controller and the peripheral. Check out this page for more on our reasoning behind this change.
AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
NameBottom Pin   Top    PinName
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
PCM_OUT / CAM_MCLKI2S_OUTAUD_OUT5655SPI_CS#
PCM_IN / CAM_PCLKI2S_INAUD_IN5453I2C_SCL1 (I/O)
PCM_SYNC / PDM_DATAI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PCM_CLK / PDM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 / 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D+
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0)1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D+
3.3V_EN43USB_D+
3.3V21GND
Alternate FunctionPrimary FunctionBottom Pin   Top    PinPrimary FunctionAlternate Function
73G5
71G6
QSPI3SPI_CS7069G7
QSPI268
QSPI16665TX1ADC_D-
QSPI0SPI_CIPO6463ADC_D+
QSPI_CSSPI_COPI6261SPI_CIPO1
QSPI_SCKSPI_SCK6059SPI_COPI1
CAM_MCLK5857SPI_SCK1
CAM_MCLK5655SPI_CS1
CAM_PCLK5453SCL1
PDM_DATA5251SDA1
PDM_CLK5049BATT_VIN3
G44847PWM1
G346
G244
G142
G04039GND
ADC138
ADC034
PWM032
23SWDIO
21SWDCK
19RX1
D11817TX1ADC_D-
I2C_Interrupt1615CTS1
SCL1413RTS1
SDA1211BOOT
D0109
7GND
RESET65USB_D-
3USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board measures 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.

MicroMod Processor Board Dimensions

Hardware Hookup

To get started with the Artemis MicroMod Processor Board, you'll need a carrier board. Here we are using the Machine Learning Carrier Board. Align the top key of the MicroMod Artemis Processor Board to the screw terminal of the Machine Learning Carrier Board and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Note: There is no way to insert the processor backward since the key prevents it from mating with the M.2 connector and as an extra safeguard to prevent inserting a processor that matches the key, the mounting screw is offset so you will not be able to secure an improperly connected processor board.

MicroMod Processor Board inserted into the carrier board

The Processor Board will stick up at an angle, as seen here:

MicroMod Processor Board inserted into the carrier board

Once the board in the socket, gently push the MicroMod Processor Board down and tighten the screw with a Phillip's head.

screwing in the machine screw

Once the board is secure, your assembled MicroMod system should look similar to the image below!

Top down image of Machine Learning Carrier Board with Artemis Processor board inserted correctly

Connecting Everything Up

With your processor inserted and secured it's time to connect your carrier board to your computer using the USB-C connector on the Carrier. Depending on which carrier you choose and which drivers you already have installed, you may need to install drivers.

Note: If you've never connected a CH340 device to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our section on "How to Install CH340 Drivers" for help with the installation.

How to Install CH340 Drivers

August 6, 2019

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

Software Setup

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

Installing the Arduino Core for Apollo3

To get started with the Artemis MicroMod Processor Board, you'll need to install the SparkFun Apollo3 Arduino Core. Open the Arduino IDE (must be v1.8.13 or later) and navigate to File->Preferences, like so:

Arduino Preferences, under File

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

In the "Additional Board Manager URL" box, make sure you have the following json file:

language:c
https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

If you have more than one json file, you can click on the button outlined in red and add the json link at the end. It'll look something like the following:

Additional Boards Manager URL location in the Preferences Dialog

Having a hard time seeing? Click the image for a closer look.
  • Go to Tools ->Board and select the Boards Manager

Arduino Boards Manager Dialog, under Tools

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

Search for "Apollo3", and you should find the SparkFun Apollo3 Boards board package. Make sure the Version 1.2.1 is selected and click Install.

Board manager showing SparkFun Apollo3 Artemis install

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

Installation may take a few minutes -- included in the install are all necessary source files for the Arduino core and Apollo3 libraries, plus all of the compiler and software-upload tools you'll need to use the Artemis with Arduino.

Once the board definitions have been installed, you should see the Artemis MicroMod Processor board under your Tools -> Board -> SparkFun Apollo3 menu.

Artemis MicroMod processor dropdown
Having a hard time seeing? Click the image for a closer look.
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

To get started uploading code and working with your Machine Learning Carrier Board, make sure you have the Artemis MicroMod board definition selected under your Tools>Board menu (or whatever processor you've chosen to use).

Arduino Board Select

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


Then select your serial port under the Tools>Port menu.

Port Selection for the Artemis MicroMod Processor Board

Loading Blink

Let's start with something basic - let's blink an LED. Go to File->Examples->01.Basics->Blink.

Blink Basics Example in the pulldown

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


With everything setup correctly, upload the code! Once the code finishes transferring, you should see the STAT LED on the Artemis Processor Board begin to blink!

If the blue LED remains off, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the reset button to get your Artemis MicroMod to run the sketch.

Look at all the blinks!

blink blink blink

Example 2: PDM

We've built the Arduino core for Artemis from the ground up and a large number of our built-in examples will work out of the box with the Artemis MicroMod Processor Board. You'll find them under File->Examples->'Examples for SparkFun Artemis MicroMod'.

Let's run a quick one from the examples here and take advantage of the two built in microphones on the Machine Learning Carrier Board we're using. Go to File->Examples->PDM->Example1_MicrophoneOutput

Arduino sub menu showing Artemis examples

Click above image for full menu context

Make sure you have the correct board and port selected, and then upload the code. Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. You should see something like the following:

PDM Microphone example serial output

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

Notice that if you hoot and holler, the output changes.

Within the 'Examples for SparkFun Artemis Micromod' menu, we've got examples for setting up multiple I2C ports (it's amazingly easy), writing to EEPROM, using SoftwareSerial (all 48 pins can be serial!), using the the onboard microphone, and using servos (up to 32!). We're adding more all the time so be sure to keep your core up to date.

Further Examples

With the MicroMod system, the possibilities for examples with all the processor/carrier board are endless, and we just can't cover them all. You'll notice that in this tutorial, we've selected the Machine Learning Carrier Board, but have focused our examples on the Artemis Processor Board. If you're interested in examples specifically for our carrier board, head on over to our Machine Learning Carrier Board Hookup Guide.

Troubleshooting

Resources and Going Further

Want more information on the Artemis MicroMod Processor Board? Check out these links!

MicroMod Documentation:

Artemis Documentation:

Looking for some project inspiration using your Artemis Processor Board? The tutorials below can help you get started!

New!

MicroMod SAMD51 Processor Board Hookup Guide

This tutorial covers the basic functionality of the MicroMod SAMD51 and highlights the features of the ARM Cortex-M4F development board.
New!

MicroMod All The Pins (ATP) Carrier Board

Access All The Pins (ATP) of the MicroMod Processor Board with the Carrier Board!
New!

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board
New!

MicroMod Machine Learning Carrier Board Hookup Guide

Get hacking with this tutorial on our Machine Learning Carrier Board!

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

SparkFun Qwiic Shield for Teensy Hookup Guide

$
0
0

SparkFun Qwiic Shield for Teensy Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1296

Introduction

The SparkFun Qwiic Shield for Teensy and SparkFun Qwiic Shield for Teensy Extended provide an easy-to-assemble way to add the SparkFun Qwiic ecosystem to Teensy development boards. Both of these shields connect the I2C bus (GND, 3.3V, SDA, and SCL) on your Teensy to four SparkFun Qwiic connectors. The Qwiic ecosystem allows for easy daisy chaining so, as long as your devices are on different addresses, you can connect as many Qwiic devices as you'd like.

SparkFun Qwiic Shield for Teensy

SparkFun Qwiic Shield for Teensy

DEV-17119
$3.95
SparkFun Qwiic Shield for Teensy - Extended

SparkFun Qwiic Shield for Teensy - Extended

DEV-17156
$4.50

Required Materials

To follow along with this tutorial, you will need a Teensy development board with either the "standard" or "extended" form factor. Here are is a collection of the compatible boards. Note, some of them come with headers pre-populated, so keep that in mind when considering which headers to populate on your shield.

Teensy 4.1

Teensy 4.1

DEV-16771
$26.95
2
Teensy 4.0

Teensy 4.0

DEV-15583
$19.95
6
Teensy 4.1 (Headers)

Teensy 4.1 (Headers)

DEV-16996
$30.95
Teensy 4.0 (Headers)

Teensy 4.0 (Headers)

DEV-16997
$22.95

The Qwiic Shield includes a set of stackable headers to fit the Teensy footprint but you may also need some headers to solder to your Teensy. Or if you would prefer to use another header type for your shield assembly we've listed a few options below:

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
Female Headers

Female Headers

PRT-00115
$1.50
7
Teensy Header Kit

Teensy Header Kit

PRT-13925
$1.50
Now you probably would not want the Qwiic Shield for Teensy if you didn't have any Qwiic products to use with it, right? Well, if you don't have any Qwiic products, the following might not be a bad place to start:
SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)

SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)

GPS-15712
$64.95
2
SparkFun 16x2 SerLCD - RGB Text (Qwiic)

SparkFun 16x2 SerLCD - RGB Text (Qwiic)

LCD-16397
$19.95
SparkFun Qwiic Motor Driver

SparkFun Qwiic Motor Driver

ROB-15451
$14.95
1
SparkFun Cryptographic Co-Processor Breakout - ATECC508A (Qwiic)

SparkFun Cryptographic Co-Processor Breakout - ATECC508A (Qwiic)

DEV-15573
$4.95$4.10

You will need some of our Qwiic cables to connect your devices to the shield. Below are a few options:

Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95

Lastly, if you want to use a non-Qwiic I2C device, these adapters help to convert it to a Qwiic connector:

Qwiic Cable - Breadboard Jumper (4-pin)

Qwiic Cable - Breadboard Jumper (4-pin)

PRT-14425
$1.50
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
Qwiic Cable - Female Jumper (4-pin)

Qwiic Cable - Female Jumper (4-pin)

CAB-14988
$1.50

Required Tools

You will need a soldering iron, solder, and general soldering accessories to solder the header pins to the Qwiic shields:

Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.50
2
Soldering Iron - 30W (US, 110V)

Soldering Iron - 30W (US, 110V)

TOL-09507
$9.95
7

Suggested Reading

If you aren't familiar with the Qwiic system, we recommend reading here for an overview:

Qwiic Connect System
Qwiic Connect System

We would also recommend taking a look at the following tutorials if you aren't familiar with them:

How to Solder: Through-Hole Soldering

This tutorial covers everything you need to know about through-hole soldering.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Getting Started with the Teensy

Basic intro to the Teensy line of products, with soldering and programming suggestions.

Arduino Shields v2

An update to our classic Arduino Shields Tutorial! All things Arduino shields. What they are and how to assemble them.

Hardware Overview

Qwiic Connectors

The Qwiic Shields for Teensy each have four Qwiic connectors on them. The two on the edges are the standard horizontal connectors and the two in the middle are vertical connectors.

Note, the horizontal Qwiic connector on the "top" (aka North end) of the non-extended version is positioned slightly downward to allow space for proper cable insertion, and to avoid any conflicts with the nearby 6-pin header on the edge of the board.

Teensy Qwiic ConnectorsTeensy Extended Qwiic Connectors

Program Button

Each of these shields have a "PROG" button. This is to allow easier access to a programming button for each time you want to upload to the Teensy. Note, it is electrically in parallel with the "PROG" button on the Teensy boards themselves. This means that you can choose to use either the button on your Teensy or the button on the shield. If your shield is located on top of your Teensy (using stack-able headers), then it will be much more accessible to use the button on the shield, rather than trying to reach under the shield.

Teensy Program ButtonTeensy Extended Program Button

I2C Jumper

This jumper is a little different than our normal I2C pull up jumpers as it is open by default. The jumper only needs to be closed if your attached I2C device does not have pull up resistors. Essentially all SparkFun I2C breakouts come with pull up resistors on them so if you are using a Qwiic I2C device or another SparkFun I2C device, you can most likely leave it open. When closed, the SDA and SCL lines are pulled to 3.3V by 4.7K&ohm; resistors. If you have never worked with solder jumpers before, check out this tutorial for some tips and tricks for working with them.

Teensy I2C JumperTeensy Extended I2C Jumper

External Power Input

These shields include an optional 3.3V power input. The 3.3V pin off of the Teensy is rated to supply 250mA. If your project requires more than that on the Qwiic 3.3V power rail, then you should consider supplying a separate power source and soldering it into the header pins labeled "ALT 3V3". Note, you must also cut the jumper labeled "ISO" to properly isolate the Teensy's 3.3V power rail from your external.

Optional External Power InputExtended Optional External Power Input

Note, when using the external power input header, you may notice a slight voltage drop. This is because we have included a protective diode in the circuit. For most applications, this will be fine to leave in place. For more advanced users, we have included a bypass jumper to easily bypass this jumper and have a direct connection to the 3.3V power net.

Schematic highlightExternal power input header and bypass jumper

Board Dimensions

The Qwiic Shield for Teensy measures 0.70in x 1.40in (17.78mm x 35.56mm). The extended version measures 0.70in x 2.40in (17.78mm x 60.96mm). Note, because these are such small form factor boards, they do not have any standoff holes. They simply rely on the headers for both electrical connections and "mounting hardware".

Qwiic Shield for Teensy DimensionsQwiic Shield for Teensy Extended Dimensions

Hardware Assembly

To get started using the Qwiic Shield for Teensy, solder the headers onto your Teensy board and your Qwiic Shield. You may choose to use the included stackable header kit or any combination of male/female breakaway headers. Below we show a couple options using standard breakaway headers. Note, for best access to the program button on the shield and the two vertical Qwiic connectors, it is best to have it be the top of your stack.

Teensy 4.0 and shield with M/F headers soldered into place.Teensy 4.1 and extended shield with M/F headers soldered into place.

Once you have soldered headers to your shield and connected it to your Teensy, it's time to start connecting Qwiic devices! Below you can see an example of each shield connected to the appropriate Teensy (4.0 or 4.1). Here we used our standard breakaway headers along with a couple of Qwiic Devices chained to it.

Teensy Example HookupTeensy Extended Example Hookup

If you are using the upper-most qwiic connector on the Qwiic Shield for Teensy, please check out the following tips. It helps to bend/curl your Qwiic cable a bit before inserting it into the right-angle connector on the sheild.

Qwiic Cable

Qwiic Cable with a bend.

With the bend in place, you can better align it before inserting it all the way.

Qwiic Cable Being Inserted

Initial alignment.

To avoid stressing the cable wires, it is best to push the Qwiic connector using your fingernails on the sides of the connector plastic. Tweezers can also do the trick.

Qwiic Cable Inserted with Fingernails

Pressing on the sides of the plastic is ideal.

Resources and Going Further

That's a wrap! Your Qwiic Shield for Teensy/Teensy Extended is now ready to connect to any of a host of Qwiic devices SparkFun offers. For more information, take a look at the resources below.

Qwiic Shield for Teensy

Qwiic Shield for Teensy Extended

Even More Resources

If you are having trouble getting your Qwiic devices to connect using your newly assembled Qwiic Shield, you may want to take a look at these tutorials for help troubleshooting and reworking your shield.

Now that you have your Qwiic Shield ready to go, it's time to check out some Qwiic products. Below are a few to get started.

SparkFun Triple Axis Magnetometer Breakout - MLX90393 (Qwiic)

SparkFun Triple Axis Magnetometer Breakout - MLX90393 (Qwiic)

SEN-14571
$14.95
SparkFun Servo pHAT for Raspberry Pi

SparkFun Servo pHAT for Raspberry Pi

DEV-15316
$10.95
2
SparkFun RED-V Thing Plus - SiFive RISC-V FE310 SoC

SparkFun RED-V Thing Plus - SiFive RISC-V FE310 SoC

DEV-15799
$29.95
Alchitry Au FPGA Development Board (Xilinx Artix 7)

Alchitry Au FPGA Development Board (Xilinx Artix 7)

DEV-16527
$99.95
2

Before you go, here are some other tutorials using the Qwiic Connect System you may want to look through:

Capacitive Touch Slider (CAP1203) Hookup Guide

An easy and Qwiic way to add capacitive touch to any of your projects using the CAP1203! In this guide, we go over how to connect and set up your Capacitive Touch Slider so you can start playing with it right away.

SparkFun Qwiic Button Hookup Guide

A Hookup Guide for the SparkFun Qwiic Button (Red) and SparkFun Qwiic Button Breakout. Goes over connecting the Qwiic Button to an Arduino microcontroller and using it with the Qwiic Button Arduino library.

SparkFun Clock Generator 5P49V60 (Qwiic) Hookup Guide

The SparkFun Clock Generator 5P49V60 (Qwiic) breakout board offers a wide range of customizable frequencies in a wide range of different signal types using a single reference clock. This hookup guide will go over all of the many available functions and gives the hardware rundown on what exactly is on this board.

Artemis Development with the Arduino IDE

This is an in-depth guide on developing in the Arduino IDE for the Artemis module and any Artemis microcontroller development board. Inside, users will find setup instructions and simple examples from blinking an LED and taking ADC measurements; to more complex features like BLE and I2C.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

SparkFun Qwiic 3-Axis Accelerometer (ADXL313) Hookup Guide

$
0
0

SparkFun Qwiic 3-Axis Accelerometer (ADXL313) Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1396

Introduction

The SparkFun 3-Axis Digital Accelerometer Breakout - ADXL313 (Qwiic) is a Qwiic sensor that utilizes the ADXL313 accelerometer from Analog Devices. The ADXL313 is a low cost, low power, up to 13-bit resolution, 3-axis accelerometer with a 32-level FIFO stack capable of measuring up to &PlusMinus;4g.

SparkFun Triple Axis Digital Accelerometer Breakout - ADXL313 (Qwiic)

SparkFun Triple Axis Digital Accelerometer Breakout - ADXL313 (Qwiic)

SEN-17241
$14.95

The ADXL313 can be used in applications like car alarms, hill start aid (HSA) systems, electronic parking brakes, and (black box) data recorders. Some of the specific features of the ADXL313 include:

  • Embedded, patent pending FIFO technology minimizes host processor load
  • Low noise performance
  • Fixed 10-bit resolution for any g-range
  • 10,000g survival rating
  • Two configurable interrupt pins
    • Including, built-in motion detection functions for activity/inactivity monitoring
  • Self-test capability

Required Materials

The Qwiic 3-Axis Accelerometer does need a few additional items for you to get started. The RedBoard Qwiic will be used for the Arduino examples. A single board computer and the Qwiic pHAT are required for the Python examples (see note below). You may already have a few of these items, including the required Qwiic cable, so feel free to modify your cart based on your needs. Additionally, there are also options that are available as well (click button below to toggle options).

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
7
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
5
USB micro-B Cable - 6 Foot

USB micro-B Cable - 6 Foot

CAB-10215
$4.95
13
SparkFun Qwiic pHAT v2.0 for Raspberry Pi

SparkFun Qwiic pHAT v2.0 for Raspberry Pi

DEV-15945
$5.95
2
Qwiic Compatible Microcontrollers:
SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
5
SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

DEV-15795
$19.95
1
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
4
SparkFun Thing Plus - SAMD51

SparkFun Thing Plus - SAMD51

DEV-14713
$19.95
1
In addition we also offer, Qwiic compatible stackable shields for microcontrollers and pHATs for single board computers (like the Raspberry Pi boards) that don't include a Qwiic connector.
SparkFun Qwiic Shield for Thing Plus

SparkFun Qwiic Shield for Thing Plus

DEV-16790
$3.95
SparkFun Qwiic Shield for Teensy

SparkFun Qwiic Shield for Teensy

DEV-17119
$3.95
1
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic Shield for Arduino Nano

SparkFun Qwiic Shield for Arduino Nano

DEV-16789
$3.95
SparkFun Qwiic HAT for Raspberry Pi

SparkFun Qwiic HAT for Raspberry Pi

DEV-14459
$5.95
4
SparkFun Auto pHAT for Raspberry Pi

SparkFun Auto pHAT for Raspberry Pi

ROB-16328
$29.95
SparkFun Qwiic pHAT v2.0 for Raspberry Pi

SparkFun Qwiic pHAT v2.0 for Raspberry Pi

DEV-15945
$5.95
2
SparkFun Servo pHAT for Raspberry Pi

SparkFun Servo pHAT for Raspberry Pi

DEV-15316
$10.95
2
SparkFun Top pHAT for Raspberry Pi

SparkFun Top pHAT for Raspberry Pi

DEV-16301
$49.95
SparkFun Qwiic SHIM for Raspberry Pi

SparkFun Qwiic SHIM for Raspberry Pi

DEV-15794
$0.95
7
You will also need a Qwiic cable to connect to your Qwiic ADXL313 accelerometer, choose a length that suits your needs.
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95

Python Example: If you don't already have them, you will need an SBC (single board computer) such as a Raspberry Pi and standard peripherals or Jetson Nano and standard peripherals. An example setup is listed below.
NVIDIA Jetson Nano Developer Kit (V3)

NVIDIA Jetson Nano Developer Kit (V3)

DEV-16271
$99.00
10
SparkFun DLI Kit (without Jetson Nano)

SparkFun DLI Kit (without Jetson Nano)

KIT-16389
$74.95
SparkFun Raspberry Pi 4 Basic Kit - 8GB

SparkFun Raspberry Pi 4 Basic Kit - 8GB

KIT-16831
$114.95
pi-topCEED (Green)

pi-topCEED (Green)

KIT-14035
$114.95
4
Multimedia Wireless Keyboard

Multimedia Wireless Keyboard

WIG-14271
$29.95
3
NVIDIA Jetson Nano 2GB Developer Kit

NVIDIA Jetson Nano 2GB Developer Kit

DEV-17244
$59.00
SparkFun DLI Kit for Jetson Nano 2GB

SparkFun DLI Kit for Jetson Nano 2GB

KIT-17245
$139.95

Suggested Reading

If you're unfamiliar with serial terminals, jumper pads, or I2C be sure to checkout some of these foundational tutorials.

Installing an Arduino Library

How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Serial Terminal Basics

This tutorial will show you how to communicate with your serial devices using a variety of terminal emulator applications.

How to Work with Jumper Pads and PCB Traces

Handling PCB jumper pads and traces is an essential skill. Learn how to cut a PCB trace, add a solder jumper between pads to reroute connections, and repair a trace with the green wire method if a trace is damaged.

RedBoard Qwiic Hookup Guide

This tutorial covers the basic functionality of the RedBoard Qwiic. This tutorial also covers how to get started blinking an LED and using the Qwiic system.

Qwiic pHAT for Raspberry Pi Hookup Guide

Get started interfacing your Qwiic enabled boards with your Raspberry Pi. The Qwiic pHAT connects the I2C bus (GND, 3.3V, SDA, and SCL) on your Raspberry Pi to an array of Qwiic connectors.

Arduino Shields v2

An update to our classic Arduino Shields Tutorial! All things Arduino shields. What they are and how to assemble them.

Raspberry Pi SPI and I2C Tutorial

Learn how to use serial I2C and SPI buses on your Raspberry Pi using the wiringPi I/O library for C/C++ and spidev/smbus for Python.

Python Programming Tutorial: Getting Started with the Raspberry Pi

This guide will show you how to write programs on your Raspberry Pi using Python to control hardware.

Working with Qwiic on a Jetson Nano through Jupyter Notebooks

We created a few Jupyter Notebooks to make using our Qwiic boards with your Jetson Nano even easier!

Qwiic Connect System

The Qwiic ADXL313 Accelerometer utilizes the Qwiic connect system. We recommend familiarizing yourself with the Logic Levels and I2C tutorials (above) before using it. Click on the banner above to learn more about our Qwiic products.

Note: First time Raspberry Pi users should also head over to the Raspberry Pi Foundation website and check out their quickstart guides:

We have also listed a few additional resources for users to familiarize themselves with the Raspberry Pi:

Hardware Overview

Board Dimensions

The SparkFun 3-Axis Digital Accelerometer Breakout - ADXL313 (Qwiic) is laid out on the standardized 1" x 1" (2.54 x 2.54 cm) Qwiic breakout board and includes the standard four 0.13" mounting holes, which are compatible with M3 screws.

board dimensions
Board dimensions. (Click to enlarge)

Power

There is a power status LED to help make sure that your Qwiic ADXL313 Accelerometer is getting power. You can power the board either through the polarizedQwiic connector system or the breakout pins (3.3V and GND) provided. The Qwiic system is meant to run on 3.3V, be sure that you are NOT using another voltage when using the Qwiic system. A jumper is available on the back of the board to remove power to the LED for low-power applications (see Jumpers section below).

power
Power LED and power breakout pins. (Click to enlarge)

ADXL313 Accelerometer

The ADXL313 accelerometer from Analog Devices is a low cost, low power, up to 13-bit resolution, 3-axis accelerometer with a 32-level FIFO stack capable of measuring up to &PlusMinus;4g. The shock rating for the sensor (IC only, not board) is up to 10,000g, which is great for data loggers like black boxes. The sensor also has automotive applications including car alarms, hill start aid (HSA) systems, and electronic parking brakes.

accelerometer
Analog Devices ADXL313 accelerometer. (Click to enlarge)

Theory of Operation

The sensor mechanism contains a polysilicon structure built above a silicon wafer. The polysilicon structure includes a central mass with springs to suspend it over the surface of the wafer. An acceleration creates a deflection of the structure, which is measured with differential capacitors, resulting in a sensor output whose amplitude is proportional to acceleration. Phase-sensitive demodulation is used to determine the magnitude and polarity of the acceleration.

For more details, check out these articles from Analog Devices:

Sensor Characteristics

Below, is a table of the characteristics of the accelerometer. For more details, please refer to the datasheet.

CharacteristicDescription
Power Supply Voltage: 2.0 - 3.6V
Supply Cuurent:
  • Data Rate > 100Hz: 100 - 300µA
  • Data Rate < 10Hz: 30 - 110µA
Measurement Range&PlusMinus;.5g, &PlusMinus;1g, &PlusMinus;2g, &PlusMinus;4g
Resolution All Ranges: 10 bits (Default)
&PlusMinus;.5g Range: 10 bits (Full Resolution)
&PlusMinus;1g Range: 11 bits (Full Resolution)
&PlusMinus;2g Range: 12 bits (Full Resolution)
&PlusMinus;4g Range: 13 bits (Full Resolution)
FIFO Stack32 levels
Data Rate6.25 - 3200Hz
I2C Address (7-bit)0x1D (Default), 0x53
SPI Configuration3-wire or 4-wire Operation

Power Modes

By default, with standard operation, the ADXL313 automatically modulates its power consumption based on the output data rate. For increased power savings, an optional low power mode is available for data rates below 400 Hz. The available power savings for the low power mode (VS = 3.3V) is detailed in the table below. In addition, there are two power configurations for minimal power consumption. For more details, please refer to the datasheet.

Output Data Rate (Hz)Bandwidth (Hz)Current Consumption (at VS = 3.3V): IDD (µA)
Std. OperationLow Power Mode
32001600170---
1600800115---
800400170---
400200170115
20010017082
1005017065
502511557
2512.58250
12.56.256543
6.253.12557---
Autosleep Mode

Autosleep mode provides additional power savings by automatically switching the ADXl313 into sleep mode during periods of inactivity. The inactivity level is determined by two factors, a threshold value and a time period. Based upon their configuration, if the sensor doesn't detect an acceleration in excess of the threshold value for the specified time period, the ADXL313 will automatically transition into sleep mode.

Standby Mode

Placing the ADXL313 into standby mode discontinues any measurements, preserves the contents of the FIFO stack, and reduces current consumption down to 0.1 µA.

FIFO Operation

The ADXL313 includes a 32-level FIFO stack management system that is utilized to minimize the burden on the host microcontroller. The buffer has four different modes of operation: Bypass, FIFO, Stream, and Trigger. For more details, please refer to the datasheet.

Note: For users unfamiliar with how a FIFO typically operates, check out this example from the Qwiic Keypad hookup guide.

FIFO operation
Demonstration of the FIFO: (1) Filling the FIFO stack with inputs, (2) overwriting old inputs, and (3) incrementing & reading the FIFO.
Bypass Mode

The FIFO is bypassed and no values are stored.

FIFO Mode

The FIFO collects up to 32 values and then stops collecting data and triggers the watermark interrupt, collecting new data only when FIFO is not full. The accelerometer will continue to operate after the FIFO is full, so that features such as activity detection can still be utilized. The watermark interrupt will continue to trigger until the number of samples in FIFO is less than the threshold.

Stream Mode

The FIFO holds the latest 32 data values. When FIFO is full, the oldest data is overwritten with newer data and the watermark interrupt will trigger. The watermark interrupt will continue to trigger until the number of samples in FIFO is less than the threshold.

Trigger Mode

When triggered by the trigger bit, FIFO holds the last data samples before the trigger event and then continues to collect data until full. New data is collected only when FIFO is not full. Additional trigger events will not function in this mode until the trigger mode is cleared.

Self Test Operation

A unique feature of the ADXL313 is the self test operation, which can test the sensor's mechanical and electronic systems simultaneously. When enabled, an electrostatic force is exerted on the mechanical sensor and moves the mechanical sensing element in the same manner as an acceleration would. This creates an additive acceleration that is proportional to VS2. For more details, please refer to the datasheet.

Qwiic and I2C

I2C Address

The Qwiic ADXL313 Accelerometer’s I2C address, 0x1D (7-bit), is factory set. An alternate I2C address of 0x53 (7-bit) can be configured by modifying the ADDR jumper or by pulling the ADR pin low.

Qwiic Connectors

The simplest way to use the Qwiic ADXL313 Accelerometer is through the Qwiic connect system. The connectors are polarized for the I2C connection and power. (*They are tied to the corresponding power and I2C breakout pins.)

Qwiic connectors
Qwiic connectors. (Click to enlarge)

Breakout Pins

The board also provides eight labeled breakout pins.

Breakout pins
Breakout pins. (Click to enlarge)

I2C

You can connect these lines to the I2C bus of your microcontroller and power pins (3.3V and GND), if it doesn't have a Qwiic connector. The interrupt pins are also broken out to use for triggered events.

I2C Pins
I2C Connections- The pins are tied to the Qwiic connectors.

SPI

You can connect these lines to the SPI bus of your microcontroller and power pins (3.3V and GND); the sensor can operate in either a 3-wire or 4-wire configuration. The interrupt pins are also broken out to use for triggered events.

SPI pins
SPI breakout pins. (Click to enlarge)

Interrupt Pins

The interrupt pins (active high) are used to indicate various states of the ADXL313, depending on how they are configured and if they are enabled. The interrupt pins can be configured for the following modes:

  • Activity - Triggers when the acceleration is greater than a stored threshold.
  • Inactivity - Triggers when the acceleration is lower than a store threshold for a specified amount of time (up to 255 seconds).
  • Watermark - Triggers when the number of samples stored in the FIFO reaches a specific value.
  • Overrun - Triggers when the FIFO is overrun (new data replaces unread data in the stack).

Additionally, the interrupts can be used to trigger measurements into the FIFO, when the FIFO is configured for Trigger Mode.

Interrupt pins
Interrupt breakout pins. (Click to enlarge)

Jumpers

There are three jumpers on the board. Not sure how to cut or modify a jumper? Read here!

Power LED

Cutting the LED jumper will remove the 1kΩ resistors and PWR LED from the 3.3V power. This is useful for low power applications.

power LED jumper
Power LED jumper. (Click to enlarge)

I2C Pull-Up

Cutting the I2C jumper will remove the 4.7kΩ pull-up resistors from the I2C bus. If you have many devices on your I2C bus you may want to remove these jumpers.

I2C jumper
I2C pull-up resistor jumper. (Click to enlarge)

Address Pull-up

Soldering the ADR jumper connect a 10kΩ pull-up resistor to the SDO/ADR pin. This can be used to configure the default I2C address of the device to 0x53 (7-bit) on power up.

interrupt jumper
Address jumper. (Click to enlarge)

Hardware Assembly

Arduino Examples

With the Qwiic connector system, assembling the hardware is simple. All you need to do is connect your SparkFun 3-Axis Digital Accelerometer Breakout - ADXL313 (Qwiic) to the RedBoard Qwiic with a Qwiic cable. Otherwise, you can use the I2C pins of your microcontroller; just be aware of logic levels.

Hardware assembly with RedBoard Qwiic
RedBoard Qwiic connected the Qwiic ADXL313 Accelerometer with a Qwiic cable.

Note: This tutorial assumes users are familiar with Arduino products and are using the latest stable version of the Arduino IDE on your desktop. If this is your first time using the Arduino IDE, please review our tutorial on installing the Arduino IDE.

Python Examples

With the Qwiic connector system, assembling the hardware is simple. In addition to the SparkFun 3-Axis Digital Accelerometer Breakout - ADXL313 (Qwiic), you will need: a Qwiic cable, a SparkFun Qwiic pHAT for Raspberry Pi, single board computer, monitor, and standard peripherals. (*If you are unfamiliar with the Qwiic pHAT, you can find the Hookup Guide here.)

There are two single board computer (SBC) options that we have tested on:

Hardware assembly with Raspberry Pi 4 with Qwiic pHAT
Raspberry Pi 4 (with Qwiic pHAT) connected the Qwiic ADXL313 Accelerometer.
Hardware assembly with Jetson with Qwiic pHATJetson connected to the Qwiic ADXL313 Accelerometer.

Note:Don't forget to connect any necessary peripherals, such as a monitor, keyboard and mouse, and power supply to the single board computer.

Note: This tutorial assumes users are familiar with using a Raspberry Pi and have the latest version of Raspbian OS (full... with recommended software) your Raspberry Pi. You can download the latest version of the Raspbian OS from the Raspberry Pi Foundation website.

If this is your first time using a Raspberry Pi, please head over to the Raspberry Pi Foundation website to use their quickstart guides. We have listed a few of them here:

  1. Setting up your Raspberry Pi
  2. Using your Raspberry Pi
  3. Documentation:
  4. Setup Documentation
    Installation Documentation
    Raspbian Documentation
    SD card Documentation

Note: This tutorial assumes users are familiar with using a Jetson Nano and you have the latest version of L4T OS your Jetson Nano. You can download the latest version of the L4T OS from the Jetson Download Center on Nvidia's website.

If this is your first time using a Jetson Nano, please head over to the Nvidia website to use their quickstart guides. We have listed a few of them here:

  1. Getting Started With Jetson Nano Developer Kit
  2. Jetson Nano Developer Kit User Guide
  3. Documentation:
  4. Jetson Nano Getting Started Guide
    Jetson Download Center
    Wiki: Jetson Nano
    Jetpack Software Documentation
    Nvidia Jetson Tutorials

Arduino Library

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

We've written a library to easily get setup and take readings from the SparkFun 3-Axis Digital Accelerometer Breakout - ADXL313 (Qwiic). However, before we jump into getting data from the sensor, let's take a closer look at the available functions in the library. You can install this library through the Arduino Library Manager. Search for SparkFun ADXL313 Arduino Library and you should be able to install the latest version. If you prefer manually downloading the libraries from the GitHub repository, you can grab them here:

Let's get started by looking at the functions that set up the Qwiic Atmospheric Sensor:

Class

In the global scope, construct your sensor object (such as mySensor) without arguments.

ADXL313 mySensor;

Object Parameters and setup()

Rather that passing a bunch of data to the constructor, configuration is accomplished by setting the values of the ADXL313 type in the setup() function. They are exposed by being public: so use the myName.aVariable = someValue; syntax.

  • Initialize Sensor
    • .begin() or .begin(i2caddr, Wire) - Initializes the sensor with basic settings and returns false if sensor is not detected.
      • .isConnected() - Returns true if I2C device ack's
    • .beginSPI(CS_pin) - Initializes the sensor with basic settings via SPI and returns false if sensor is not detected.
    • .checkPartId() - Returns true if device's part ID register is correct.
    • .dataReady() - Checks the dataReady bit
    • .updateIntSourceStatuses()
    • .standby() - Clears the measure bit, putting decive in standby mode, ready for configuration
    • .measureModeOn() - Sets the measure bit, putting decive in measure mode, ready for reading data
    • .softReset() - Soft reset clears all settings, and puts it in standby mode
    • .printAllRegister() - Print Register Values to Serial Output.
      • Can be used to Manually Check the Current Configuration of Device
  • Reading Acceleration
    • .readAccel() - Reads acceleration data from ADXL313 into three class variables: x, y, and z.
  • Sensor Configuration
    • Range Setting
      • .setRange(range)
        • 0.5g, 1g, 2g, or 4g
      • .getRange()
    • Autosleep Bit
      • .autosleepOn() - Sets the autosleep bit
        • Note, prior to calling this, you will need to set THRESH_INACT and TIME_INACT.
      • .autosleepOff() - Clears the autosleep bit
    • Self-Test Bit
      • .setSelfTestBit(selfTestBit)
        • 1 - Self-Test Applied. Electrostatic Force exerted on the sensor causing a shift in the output data.
        • 0 - Self-Test Disabled.
      • .getSelfTestBit()
    • SPI Bit State
      • .setSpiBit(spiBit)
        • 1 - Puts Device in 3-wire Mode
        • 0 - Puts Device in 4-wire SPI Mode
      • .getSpiBit()
    • INT_INVERT Bit State
      • .setInterruptLevelBit(interruptLevelBit)
        • 0 - Sets the Interrupts to Active HIGH
        • 1 - Sets the Interrupts to Active LOW
      • .getInterruptLevelBit()
    • FULL_RES Bit State
      • .setFullResBit(fullResBit)
        • 1 - Device is in Full Resolution Mode: Output Resolution Increase with G Range set by the Range Bits to Maintain a 4mg/LSB Scale Factor
        • 0 - Device is in 10-bit Mode: Range Bits Determine Maximum G Range and Scale Factor
      • .getFullResBit()
    • JUSTIFY Bit State
      • .setJustifyBit(justifyBit)
        • 1 - Selects the Left Justified Mode
        • 0 - Selects Right Justified Mode with Sign Extension
      • .getJustifyBit()
    • Gain -Gains for each axis in g's/count
      • .setAxisGains(_gains)
      • .getAxisGains(_gains)
    • OFSX, OFSY, and OFSZ Bytes - User Offset Adjustments in Twos Complement Format. Scale Factor of 15.6mg/LSB.
      • .setAxisOffset(x, y, z)
      • .getAxisOffset(x, y, z)
    • THRESH_ACT Register - Holds the Threshold Value for Detecting Activity.
      • .setActivityThreshold(activityThreshold)
        • Data Format is Unsigned, so the Magnitude of the Activity Event is compared with the Value is Compared with the Value in the THRESH_ACT Register.
        • The Scale Factor is 62.5mg/LSB.
        • Value of 0 may Result in Undesirable Behavior if the Activity Interrupt Enabled.
        • It Accepts a Maximum Value of 255.
      • .getActivityThreshold() - Gets the THRESH_ACT byte
    • THRESH_INACT Register - Holds the Threshold Value for Detecting Inactivity.
      • .setInactivityThreshold(inactivityThreshold)
        • The Data Format is Unsigned, so the Magnitude of the Inactivity Event is compared with the value in the THRESH_INACT Register.
        • Scale Factor is 62.5mg/LSB.
        • Value of 0 May Result in Undesirable Behavior if the Inactivity Interrupt Enabled.
        • It Accepts a Maximum Value of 255.
      • .getInactivityThreshold()
    • TIME_INACT Register
      • .setTimeInactivity(timeInactivity)
        • Contains an Unsigned Time Value Representing the Amount of Time that Acceleration must be Less Than the Value in the THRESH_INACT Register for Inactivity to be Declared.
        • Uses Filtered Output Data unlike other Interrupt Functions
        • Scale Factor is 1sec/LSB.
        • Value Must Be Between 0 and 255.
      • .getTimeInactivity()
  • Activity Bits
    • Enabled
      • .isActivityXEnabled()
      • .isActivityYEnabled()
      • .isActivityZEnabled()
      • .isInactivityXEnabled()
      • .isInactivityYEnabled()
      • .isInactivityZEnabled()
    • State
      • .setActivityX(state)
      • .setActivityY(state)
      • .setActivityZ(state)
      • .setActivityXYZ(stateX, stateY, stateZ)
      • .setInactivityX(state)
      • .setInactivityY(state)
      • .setInactivityZ(state)
      • .setInactivityXYZ(stateX, stateY, stateZ)
    • Active
      • .isActivityAc()
      • .isInactivityAc()
      • .setActivityAc(state)
      • .setInactivityAc(state)
  • Low Power Bit
    • .isLowPower()
    • .lowPowerOn()
    • .lowPowerOff()
  • Rate Bits
    • .getRate()
    • .setRate(rate)
  • Bandwidth
    • .setBandwidth(bw)
    • .getBandwidth()
  • Trigger Check - Check if Action was Triggered in Interrupts
    • .triggered(interrupts, mask)
    • .getInterruptSource()
    • .getInterruptSource(interruptBit)
    • .getInterruptMapping(interruptBit)
  • Interrupt Mapping - Set the Mapping of an Interrupt to pin1 or pin2
    • .setInterruptMapping(interruptBit, interruptPin)
    • .isInterruptEnabled(interruptBit)
    • .setInterrupt(interruptBit, state)
    • .ActivityINT(status)
    • .InactivityINT(status)
    • .DataReadyINT(status)
    • .WatermarkINT(status)
    • .OverrunINT(status)
  • FIFO Mode Setting
    • .getFifoMode()
    • .setFifoMode(mode)
    • .getFifoSamplesThreshhold()
    • .setFifoSamplesThreshhold(samples)
    • .getFifoEntriesAmount()
    • .clearFifo()

Arduino Examples

Example 1: Basic Readings

Once you've got the library installed, open the Example1 Basic Readings sketch. You can find it under

File > Examples > SparkFun ADXL313 Arduino Library > Examples

Then load it onto your RedBoard or Uno. Open your favorite Serial Terminal to see the printed values.

streaming raw data
Raw data readings for ADXL313. (Click to enlarge)

This example outputs the raw acceleration values read by the sensor. To convert the values, use the following equation.

In this example, g-range = 2 and the resolution = 10-bits = 1024; therefore the measured acceleration (g's):

Example 3: Auto. Sleep

Open the Example3 Autosleep sketch, and load it onto your RedBoard or Uno.

device entering sleep mode
Raw data readings with indicators for when the sensor detects inactivity and enters auto-sleep. (Click to enlarge)

After the sensor detects inactivity for more than 5 seconds, it will automatically enter sleep mode and stop recording data into the FIFO. This conserves power to the accelerometer.

Note: The senor has to be relatively flat on the x-axis in order for it to enter sleep mode. Therefore, users may need to play with a level if their desk isn't level or flat.

Otherwise, users can change the threshold on line 73: myAdxl.setActivityThreshold(10); // 0-255 (62.5mg/LSB) to a higher value, like `40` to increase the inactivity threshold. This means the sensor doesn't have to lie precisely flat, but also means that the sensor requires more acceleration to wake up as well.

Example 6: Interrupt

Note: For this example to work, the microcontroller's interrupt pin needs to be connected to the Qwiic ADXL313. Make sure that this pin is also designated in the code. For the RedBoard Qwiic, Pin 2 can operate as an interrupt and is coded by default in the example.

interrupt example wiring
Wiring between ADXL313 and microcontroller for the interrupt functionality. (Click to enlarge)

close up of microcontroller wiring
Close up of the wiring at the microcontroller. (Click to enlarge)
close up of interrupt pin wiring
Close up of the wiring at the ADXL313 interrupt pin. (Click to enlarge)

Once the interrupt pin has been wired up, open the Example6 Interrupt sketch, and load it onto your RedBoard or Uno.

Let the sensor sit still, flat on a table to enter sleep mode. While, shaking the accelerometer will trigger the interrupt on the microcontroller for start reading data. Lying the accelerometer flat and still, will discontinue the sensor readings and put it into sleep mode again.

waking the microcontroller
Waking the microcontroller.

Python Package

Note: The link to the ReadtheDocs documentation for this Python package is currently broken. We are working to resolve the issue.

Note: This tutorial assumes you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi, please checkout our tutorial on Python Programming with the Raspberry Pi and the Raspberry Pi SPI and I2C Tutorial. Jetson Nano users can check out this tutorial on Working with Qwiic on a Jetson Nano through Jupyter Notebooks.

We've written a Python package to easily get setup and take readings from the ADXL313 accelerometer. There are two methods for installing the Python package for the ADXl313.

  1. Install the all inclusive SparkFun Qwiic Python package.
  2. Independently install the SparkFun ADXL313 Python package.

The all inclusive SparkFun Qwiic Python package, is recommended as is also installs the required I2C driver as well.

Note: Don't forget to double check that the hardware I2C connection is enabled on your single board computer.

SparkFun Qwiic Package

This repository is hosted on PyPi as the sparkfun-qwiic package. On systems that support PyPi installation via pip3 (use pip for Python 2) is simple, using the following commands:

For all users (note: the user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic

For the current user:

language:bash
pip3 install sparkfun-qwiic

Independent Installation

You can install the sparkfun-qwiic-adxl313 Python package independently, which is hosted by PyPi. However, if you prefer to manually download and install the package from the GitHub repository, you can grab them here (*Please be aware of any package dependencies. You can also check out the repository documentation page, hosted on ReadtheDocs.):

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-adxl313 package. On systems that support PyPi installation via pip3 (use pip for Python 2) is simple, using the following commands:

For all users (note: the user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic-adxl313

For the current user:

language:bash
pip3 install sparkfun-qwiic-adxl313

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line (use python for Python 2):

language:bash
python3 setup.py install

To build a package for use with pip3:

language:bash
python3 setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip3.

language:bash
cd dist
pip3 install sparkfun_qwic_adxl313-<version>.tar.gz

Python Package Operation

Before we jump into getting readings, let's take a closer look at the available functions in the Python package. Below, is a description of the basic functionality of the Python package. This includes the package organization, built-in methods, and their inputs and/or outputs. For more details on how the Python package works, check out the source code and package documentation.

Dependencies

This Python package has a very few dependencies in the code, listed below:

language:python
import qwiic_i2c
import time

Default Variables

The default variables, in the code, for this Python package are listed below:

language:python
# qwiic_adxl313 GLOBAL VARIABLES
#----------------------------------------------------------------------------------------------------
# Define the device name and I2C addresses. These are set in the class defintion 
# as class variables, making them avilable without having to create a class instance.
# This allows higher level logic to rapidly create a index of qwiic devices at 
# runtine
#
# The name of this device 
_DEFAULT_NAME = "Qwiic ADXL313"

# Some devices have multiple availabele addresses - this is a list of these addresses.
# NOTE: The first address in this list is considered the default I2C address for the 
# device.
_AVAILABLE_I2C_ADDRESS = [0x53, 0x1D]

# define our valid chip IDs
_validChipIDs = [0xCB]
Note: This package is different from previous packages as the register variables are declared in the object class.
language:python
# QwiicAdxl313 CLASS VARIABLES
#----------------------------------------------------------------------------------------------------

ADXL313_TO_READ = 6      # Number of Bytes Read - Two Bytes Per Axis

#/////////////////////////////////////////
## ADXL313 Registers //
#/////////////////////////////////////////
ADXL313_DEVID_0 = 0x00
ADXL313_DEVID_1 = 0x01
ADXL313_PARTID = 0x02
ADXL313_REVID = 0x03
ADXL313_XID = 0x04
ADXL313_SOFT_RESET = 0x18
ADXL313_OFSX = 0x1E
ADXL313_OFSY = 0x1F
ADXL313_OFSZ = 0x20
ADXL313_THRESH_ACT = 0x24
ADXL313_THRESH_INACT = 0x25
ADXL313_TIME_INACT = 0x26
ADXL313_ACT_INACT_CTL = 0x27
ADXL313_BW_RATE = 0x2C
ADXL313_POWER_CTL = 0x2D
ADXL313_INT_ENABLE = 0x2E
ADXL313_INT_MAP = 0x2F
ADXL313_INT_SOURCE = 0x30
ADXL313_DATA_FORMAT = 0x31
ADXL313_DATA_X0 = 0x32
ADXL313_DATA_X1 = 0x33
ADXL313_DATA_Y0 = 0x34
ADXL313_DATA_Y1 = 0x35
ADXL313_DATA_Z0 = 0x36
ADXL313_DATA_Z1 = 0x37
ADXL313_FIFO_CTL = 0x38
ADXL313_FIFO_STATUS = 0x39

#////////////////////////////////
## ADXL313 Responses //
#////////////////////////////////
ADXL313_DEVID_0_RSP_EXPECTED = 0xAD
ADXL313_DEVID_1_RSP_EXPECTED = 0x1D
ADXL313_PARTID_RSP_EXPECTED = 0xCB

ADXL313_I2C_ADDRESS_DEFAULT = 0x1D
ADXL313_I2C_ADDRESS_ALT = 0x53
ADXL313_CS_PIN_DEFAULT = 10

#/************************** INTERRUPT PINS **************************/
ADXL313_INT1_PIN = 0x00     # INT1: 0
ADXL313_INT2_PIN = 0x01     # INT2: 1


#/********************** INTERRUPT BIT POSITION **********************/
ADXL313_INT_DATA_READY_BIT = 0x07
ADXL313_INT_ACTIVITY_BIT = 0x04
ADXL313_INT_INACTIVITY_BIT = 0x03
ADXL313_INT_WATERMARK_BIT = 0x01
ADXL313_INT_OVERRUN_BIT = 0x00

ADXL313_DATA_READY = 0x07
ADXL313_ACTIVITY = 0x04
ADXL313_INACTIVITY = 0x03
ADXL313_WATERMARK = 0x01
ADXL313_OVERRUN = 0x00

#/********************** RANGE SETTINGS OPTIONS **********************/
ADXL313_RANGE_05_G = 0x00 # 0-0.5G
ADXL313_RANGE_1_G = 0x01 # 0-1G
ADXL313_RANGE_2_G = 0x02 # 0-2G
ADXL313_RANGE_4_G = 0x03 # 0-4G

#/********************** POWER_CTL BIT POSITION **********************/
ADXL313_I2C_DISABLE_BIT = 0x06
ADXL313_LINK_BIT = 0x05
ADXL313_AUTOSLEEP_BIT = 0x04
ADXL313_MEASURE_BIT = 0x03
ADXL313_SLEEP_BIT = 0x02

#/********************** BANDWIDTH RATE CODES (HZ) *******************/
ADXL313_BW_1600 = 0xF           # 1111      IDD = 170uA
ADXL313_BW_800 = 0xE            # 1110      IDD = 115uA
ADXL313_BW_400 = 0xD            # 1101      IDD = 170uA
ADXL313_BW_200 = 0xC            # 1100      IDD = 170uA (115 low power)
ADXL313_BW_100 = 0xB            # 1011      IDD = 170uA (82 low power)
ADXL313_BW_50 = 0xA         # 1010      IDD = 170uA (64 in low power)
ADXL313_BW_25 = 0x9         # 1001      IDD = 115uA (57 in low power)
ADXL313_BW_12_5 = 0x8           # 1000      IDD = 82uA (50 in low power)
ADXL313_BW_6_25 = 0x7           # 0111      IDD = 65uA (43 in low power)
ADXL313_BW_3_125 = 0x6          # 0110      IDD = 57uA

#/********************** FIFO MODE OPTIONS ***************************/
ADXL313_FIFO_MODE_BYPASS = 0x00
ADXL313_FIFO_MODE_FIFO = 0x01
ADXL313_FIFO_MODE_STREAM = 0x02
ADXL313_FIFO_MODE_TRIGGER = 0x03

#/****************************** ERRORS ******************************/
ADXL313_OK = 1      # No Error
ADXL313_ERROR = 0       # Error Exists

ADXL313_NO_ERROR = 0        # Initial State
ADXL313_READ_ERROR = 1      # Accelerometer Reading Error
ADXL313_BAD_ARG = 2     # Bad Argument

#/********************** INTERRUPT STATUSES **************************/
ADXL313_INTSOURCE_DATAREADY = 0
ADXL313_INTSOURCE_ACTIVITY = 0
ADXL313_INTSOURCE_INACTIVITY = 0
ADXL313_INTSOURCE_WATERMARK = 0
ADXL313_INTSOURCE_OVERRUN = 0

#/***************** x,y,z variables (raw values) *********************/
x = 0
y = 0
z = 0

Class

QwiicAdxl313() or QwiicAdxl313(address)
This Python package operates as a class object, allowing new instances of that type to be made. An __init__() constructor is used that creates a connection to an I2C device over the I2C bus using the default or specified I2C address.

The Constructor

A constructor is a special kind of method used to initialize (assign values to) the data members needed by the object when it is created.

__init__(address=None, i2c_driver=None):

Input: value
The value of the device address. If not defined, the Python package will use the default I2C address (0x71) stored under _AVAILABLE_I2C_ADDRESS variable.
Input: i2c_driver
Loads the specified I2C driver; by default the Qwiic I2C driver is used: qwiic_i2c.getI2CDriver(). Users should use the default I2C driver and leave this field blank.

Functions

A function is an attribute of the class, which defines a method for instances of that class. In simple terms, they are objects for the operations (or methods) of the class. A list of all the available functions are detailed on the API Reference page of ReadtheDocs for the Qwiic_ADXL313_Py Python package.

Upgrading the Python Package

In the future, changes to the Python package might be made. Updating the installed packages has to be done individually for each package (i.e. sub-modules and dependencies won't update automatically and must be updated manually). For the sparkfun-qwiic-adxl313 Python package, use the following command (use pip for Python 2):

For all users (note: the user must have sudo privileges):

language:bash
sudo pip3 install --upgrade sparkfun-qwiic-adxl313

For the current user:

language:bash
pip3 install --upgrade sparkfun-qwiic-adxl313

Python Examples

Note: The link to the ReadtheDocs documentation for the Python package is currently broken. We are working to resolve the issue.

There are several examples written for the Qwiic_ADXL313_Py Python package. They can be found in the Examples folder of the GitHub repository or view on the repository documentation page, hosted on ReadtheDocs. Users can also grab them here, using the link below. (*Please be aware of any package dependencies.):

Example 1 - Basic Readings

This example is hosted on ReadtheDocs: Example 1.

reading raw data
Raw data readings for ADXL313. (Click to enlarge)

This example outputs the raw acceleration values read by the sensor. To convert the values, use the following equation.

In this example, g-range = 2 and the resolution = 10-bits = 1024; therefore the measured acceleration (g's):

Example 3 - Auto. Sleep

This example is hosted on ReadtheDocs: Example 3.

sensor entering sleep mode and waking up
Raw data readings with indicators for when the sensor detects inactivity and enters auto-sleep. (Click to enlarge)

After the sensor detects inactivity for more than 5 seconds, it will automatically enter sleep mode and stop recording data into the FIFO. This conserves power to the accelerometer.

Note: The senor has to be relatively flat on the x-axis in order for it to enter sleep mode. Therefore, users may need to play with a level if their desk isn't level or flat.

Otherwise, users can change the threshold on line 74: myAdxl.setActivityThreshold(10) # 0-255 (62.5mg/LSB) to a higher value, like `40` to increase the inactivity threshold. This means the sensor doesn't have to lie precisely flat, but also means that the sensor requires more acceleration to wake up as well.

Troubleshooting

Below, we have also included some troubleshooting tips for issues that you may come across.

  1. One of our employees compiled a great list of troubleshooting tips based on the most common customer issues. This is the perfect place to start.
  2. For any Arduino IDE specific issues, we recommend starting with their troubleshooting guide.

If neither of the troubleshooting guides above were able to help, here are some resources you might have missed. (Most of this material is summarized from the tutorial.):

Raspberry Pi

For comprehensive information or troubleshooting issues, on the Raspberry Pi, users should check out the Raspberry Pi Foundation website and their forum.

As a general guideline, users should use the following resources when looking for technical information or assistance that is specifically related to the Raspberry Pi itself:

  1. Raspberry Pi FAQ
  2. Raspberry Pi Beginner's Subforum
  3. Raspberry Pi Documentation and Help Guides
  4. Raspberry Pi Forum

Nvidia Jetson Nano

For comprehensive information or troubleshooting issues, on the Nvidia Jetson, users should check out the Nvidia website and their forum.

As a general guideline, users should use the following resources when looking for technical information or assistance that is specifically related to the Jetson Nano itself:

  1. Jetson Support Resources
  2. Jetson Nano Getting Started Guide
  3. Developer Kit User Manual
  4. Jetson Nano Wiki
  5. Nvidia FAQ
  6. Jetson Forum
  7. Jetpack Documentation

For users looking for technical assistance, click on the link. There you will find, basic troubleshooting tips and instructions to get started with posting a topic in our forum. Our technical support team will do their best to assist you.

Resources and Going Further

For more information on the SparkFun 3-Axis Digital Accelerometer Breakout - ADXL313 (Qwiic), check out the links below:

For more sensor action, check out these other great SparkFun tutorials.

MAG3110 Magnetometer Hookup Guide

Get started with the MAG3110 3-Axis Magnetometer and learn how to make your own digital compass that senses the Earth's magnetic fields.

The Uncertain 7-Cube

The Uncertain 7-Cube is a non-committal, less-than-helpful, but also entirely honest fortune teller. Simply ask it a yes or no question, give it a nudge, and the 7-Cube will dutifully inform you that it doesn’t have all the facts and doesn’t feel comfortable making a guess.

INA169 Breakout Board Hookup Guide

How to interface with the INA169 Breakout Board to measure current.

LSM9DS0 Hookup Guide

How to assemble, connect to, and use the LSM9DS0 -- an accelerometer, gyroscope, and magnetometer all-in-one.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Getting Started with the 8BitDo Bluetooth GamePads

$
0
0

Getting Started with the 8BitDo Bluetooth GamePads a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1428

Introduction

One of the best things about this job is that I get to play with all the new products that come in. If you have a gamer in your family, listen up. The SN30 Pro Bluetooth Gamepad and the Lite Bluetooth Gamepad (which also comes in yellow) from 8BitDo are REALLY cool. They are after market game controllers that work on a variety of platforms, including the Switch, Windows, Linux, Raspberry Pi and possibly even on the iOS. Let's check 'em out!

8BitDo Lite Bluetooth Gamepad - Blue

8BitDo Lite Bluetooth Gamepad - Blue

WIG-17266
$24.95
8BitDo Lite Bluetooth Gamepad - Yellow

8BitDo Lite Bluetooth Gamepad - Yellow

WIG-17265
$24.95
8BitDo SN30 Pro Bluetooth Gamepad

8BitDo SN30 Pro Bluetooth Gamepad

WIG-17264
$44.95

Suggested Reading

MetaWatch Teardown and Arduino Hookup

Tearing down the nifty Bluetooth-enabled MetaWatch. Then building an Arduino sketch to control it.

Bluetooth Basics

An overview of the Bluetooth wireless technology.

Connectivity of the Internet of Things

An overview of the different protocols that can be used for the development of Internet of Things (IoT)-based projects.

Lite Hardware Overview

8BitDo's Lite Controller is a D-pad extravaganza. Who needs extra D-pads? I mean, who doesn't? They do have the "push button" functionality of the joystick but you have to press all four direction buttons down at the same time and it's hit or miss. That said, this controller is great for my kiddos - it extremely low profile, so it fits better into their smaller hands and thus it's easier for them to maneuver on. Let's have a look at some of the specs:

  • Compatibility: Windows, Steam, Switch
  • Dimension / Weight: 12066.216.2mm / 84g
  • Special Features:
    • Dual D-pads
    • Mode switch
    • Customizable turbo functionality ( X-input )
  • Connectivity:
    • Wireless Bluetooth®
    • USB-C
  • Battery Type / Battery Life:
    • 480mAh Li-on battery, rechargeable
    • 18 play hours with 1-2 hour charging time
  • Includes:
    • 8BitDo Lite Bluetooth gamepad
    • USB cable
    • Instruction manual

Diagram of 8bitdo Lite buttons

Battery and Charging

The Lite Controller comes with a standard USB-C cable and takes a couple hours to charge up. 8BitDo's documentation boasts about 18 hours of play once charged and while I haven't done any actual benchmarking on that, I will say that my kids have been playing on this thing for a week and I have yet to need to charge it. So it ain't too shabby.

Cons

All this low profile and portability comes at a bit of a cost. The 8BitDo Lite controller does not have an accelerometer or rumble feature, and there is no NFC reader. But! If you're a retro gamer who loves old school Zelda, Mario, etc, this is the controller for you.

Lite Hardware Pairing

Switch

The 8BitDo Lite is designed to work with the Nintendo Switch Lite. In fact, the colors of these controllers match the yellow and turquoise versions of the Switch Lite. If you're not color coordinated, do you even game, bro?

Let's pair. From your main screen, navigate to "Controllers".

Controllers option from the main screen of the switch

Select Change Grip/Order:

Change Grip screen

You'll see the following screen:

Pairing screen

Make sure the S/X button is moved to the "S" position like so:

S and X switch is in the top middle of the controller

Then press the Home button to turn the controller on:

Home button is on the lower right of the controller

On the bottom of the controller, you'll see LEDs turn on. Once the LEDs are lit up, press and hold the Pair button at the top of the controller for 3 seconds to enter pairing mode.

The Pair button is on the top of the controller to the right of the USB C input

The LEDs will run back and forth while pairing. Once pairing is complete, a single LED will light up and you'll see the following screen:

Screen showing controller paired

WOO GAME!

Gif playing Zelda on the Switch Lite with the Lite Controller

Windows

To pair your 8BitDo Lite Controller with Windows, start by navigating to your Bluetooth Settings from your Windows Start menu.

alt text

Click on Add Bluetooth or other device:

alt text

Within this dialog, select Bluetooth:

On windows, search for Bluetooth

Make sure you have the Select switch on the 8BitDo Lite Controller is set to "X".

Select switch is pushed to the right, selecting the X functionality

Press the Home button on the Lite Controller:

Home button on the Lite controller is highlighted

The LEDs on the bottom of the Lite controller will light up. Once you see this, press the "Pair" button on the top of the Lite Controller.

Pair button at the top of the controller is highlighted

In Windows, you should see the 8BitDo Lite show up. Go ahead and click on that.

Once paired, game on.

Playing Legend of Zelda, yo

WOOOOOO

SN30 Pro Hardware Overview

Got drift? The 8BitDo SN30 Pro Controller Gamepad is, in essence, a pro controller for the Nintendo Switch. Instead of going out and buying a new joycon, feel free to pick one of these bad boys up instead. Let's look at all the features!

  • Compatibility: Windows, Android, macOS, Steam, Switch, Raspberry Pi
  • Controller Mode: X-input, D-input, Mac mode, Switch mode
  • Special Features:
    • Rumble vibration
    • Motion controls
    • Turbo function
    • USB-C
  • Dimension / Weight: 14463.533mm / 114g
  • Connectivity:
    • Wireless Bluetooth®4.0
    • USB-C
  • Includes:
    • SN30 Pro G Classic
    • USB-C cable
    • Instruction manual

SN30 Pro Diagram

Battery and Charging

Like all of 8BitDo's controllers, this one uses a Universal USB-C and charges up in a couple of hours. 8BitDo mentions that a single charge can play for 16 hours, but I haven't tested that out. Uh... I'll do that now. BRB...

SN30 Pro Hardware Pairing

We're focused primarily on the Switch and Windows here, but we'll eventually add Linux/iOS/Raspberry Pi/etc as we suss those processes out. Let's get to pairing!

Switch

Like it's Lite brethren, the 8BitDo SN30 Pro is designed to work with the Nintendo Switch system. And just as similarly, the pairing process is fairly straightforward.

From your main screen, navigate to "Controllers".

Nintendo Main Screen

Select Change Grip/Order like so:

Change Grip Order screen

On the SN30 Pro Controller, press Y and Start simultaneously.

The Y button and the start button are highlighted

Once the LEDs are lit up, press and hold the Pair button at the top of the controller for 3 seconds to enter pairing mode.

Highlighted pair button

The LEDs will run back and forth while pairing. Once pairing is complete, the LED will light up.

Paired LED

Playtime!

alt text

If you're used to the Nintendo Switch Pro Wireless Controller, the SN30 Pro takes a hot minute to get used to. That said, all the functionality is there, and the price is pretty sweet.

Windows

Got Windoz gamez? Let's pair.

Go to the Start menu and navigate to your "Bluetooth" dialog.

From Start Menu, search up Bluetooth

Once your Bluetooth Dialog is open, click on Add Bluetooth or Other Device.

Windows add bluetooth menu

Choose your Bluetooth Type (top option):

windows add bluetooth dialog

On the SN30 Pro Controller, press X and Start simultaneously

X button and Start button are highlighted

Once the LEDs are lit up, press and hold the Pair button at the top of the controller for 3 seconds to enter pairing mode.

Highlighted pair button

In Windows, you should see the 8BitDo show up. Go ahead and click on that.

Connecting the 8BitDo Pro controller

The LEDs will run back and forth while pairing. Once pairing is complete, the LED will light up.

Paired LED

GAME ON.

Playing Amanita Design's Machinarum

Resources and Going Further

We've covered some of the basics here and we'll add more as we can, but these little controllers have so much potential. Is it feasible to connect them to your other bluetooth devices? Can you drive around a robot? What else can you hack?

8BitDo resources:

Need inspiration for your next project? Check out some of these Bluetooth tutorials!

MetaWatch Teardown and Arduino Hookup

Tearing down the nifty Bluetooth-enabled MetaWatch. Then building an Arduino sketch to control it.

Using the BlueSMiRF

How to get started using the BlueSMiRF and Bluetooth Mate Silvers.

ESP32 Thing Hookup Guide

An introduction to the ESP32 Thing's hardware features, and a primer on using the WiFi/Bluetooth system-on-chip in Arduino.

Nintendo Switch Macro Recording on the Raspberry Pi

Learn how to record and playback controller 'macros' for your Nintendo Switch using a Raspberry Pi, SparkFun Top pHAT, and Joycontrol.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

SparkFun RTK Surveyor Hookup Guide

$
0
0

SparkFun RTK Surveyor Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1463

Introduction

The RTK Surveyor from SparkFun is your one stop shop for high precision geolocation and surveying needs. For basic users, it’s incredibly easy to get up and running and for advanced users, the RTK Surveyor is a flexible and powerful tool.

SparkFun RTK Surveyor

SparkFun RTK Surveyor

SPX-17369
$399.95

With just a few minutes of setup, the RTK Surveyor is one of the fastest ways to take centimeter grade measurements.

RTK Fix in SW Maps

An RTK Fix in SW Maps

By connecting your phone to the RTK Surveyor over Bluetooth, your phone can act as the radio link to provide correction data as well as receive the NMEA output from the device. It’s how $10,000 surveying devices have been operating for the past decade - we just made it easier, smaller, and a lot cheaper.

Required Materials

While the RTK Surveyor is nicely enclosed you will need a few cables and antennas to make everything work. We'll go into the specifics of how to hook things together but in general you will need to get a good quality L1/L2 antenna:

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GPS-15192
$64.95
1
GNSS Multi-Band L1/L2 Surveying Antenna (TNC) BT-147

GNSS Multi-Band L1/L2 Surveying Antenna (TNC) BT-147

SPX-17382
$124.95
GPS Antenna Ground Plate

GPS Antenna Ground Plate

GPS-15004
$4.95
1/4" to 5/8" Antenna Thread Adapter

1/4" to 5/8" Antenna Thread Adapter

PRT-17546
$4.95

Depending on your setup you may want to use your phone for RTCM correction data. If a source is not available online, you will need a 2nd RTK Surveyor setup in base mode and a radio link connecting the Base to the Rover. Again, we'll go into details but we designed RTK Surveyor to work with these 500mW 915MHz telemetry radios out of the box:

Serial Telemetry Radio Kit - 915MHz, 500mW

Serial Telemetry Radio Kit - 915MHz, 500mW

WRL-17255
$44.95

To charge the RTK Surveyor you will need a USB C cable and a power supply. SparkFun carries a few options:

USB 2.0 Cable A to C - 3 Foot

USB 2.0 Cable A to C - 3 Foot

CAB-15092
$3.95
USB 2.0 Type-C Cable - 1 Meter

USB 2.0 Type-C Cable - 1 Meter

CAB-16905
$4.50
Reversible USB A to C Cable - 0.8m

Reversible USB A to C Cable - 0.8m

CAB-15425
$4.95
1
USB Wall Charger - 5V, 2A

USB Wall Charger - 5V, 2A

TOL-16893
$5.95
USB-C Wall Adapter - 5.1V, 3A (Black)

USB-C Wall Adapter - 5.1V, 3A (Black)

TOL-16272
$4.95

Suggested Reading

GNSS RTK is an incredible feat of engineering that has been made easy to use by powerful GNSS receivers such as the ZED-F9P by u-blox (the receiver inside RTK Surveyor). The process of setting up an RTK system will be covered in this tutorial but if you want to know more about RTK here are some good tutorials to brush up on:

What is GPS RTK?

Learn about the latest generation of GPS and GNSS receivers to get 14mm positional accuracy!

Getting Started with U-Center for u-blox

Learn the tips and tricks to use the u-blox software tool to configure your GPS receiver.

GPS-RTK2 Hookup Guide

Get precision down to the diameter of a dime with the new ZED-F9P from Ublox.

Setting up a Rover Base RTK System

Getting GNSS RTCM correction data from a base to a rover is easy with a serial telemetry radio! We'll show you how to get your high precision RTK GNSS system setup and running.

How to Build a DIY GNSS Reference Station

Learn how to affix a GNSS antenna, use PPP to get its ECEF coordinates and then broadcast your own RTCM data over the internet and cellular using NTRIP to increase rover reception to 10km!

Hardware Overview

The RTK Surveyor is a fully enclosed, preprogrammed device. There are very few things to worry about or configure but we will cover the basics.

Switches

RTK Surveyor Switches

Setup

This device can be used in three modes:

  • GNSS Positioning (~30cm accuracy)
  • GNSS Positioning with RTK (1.4cm accuracy)
  • GNSS Base Station

When the SETUP switch is set to Rover the device will enter Position mode. RTK Surveyor will receive L1 and L2 GNSS signals from the four constellations (GPS, GLONASS, Galileo, and BeiDou) and calculate the position based on these signals. Similar to a standard grade GPS receiver, the RTK Surveyor will output industry standard NMEA sentences at 4Hz and broadcast them over any paired Bluetooth device at 115200bps. The end user will need to parse the NMEA sentences using commonly available mobile apps, GIS products, or embedded devices (there are many open source libraries). Unlike standard grade GPS receivers that have 2500m accuracy, the accuracy in this mode is approximately 300mm horizontal positional accuracy with a good grade L1/L2 antenna.

When the SETUP switch is set to Rover and RTCM correction data is sent into the radio port or over Bluetooth, the device will automatically enter Positioning with RTK mode. In this mode RTK Surveyor will receive L1/L2 signals from the antenna and correction data from a base station. The receiver will quickly (within a few seconds) obtain RTK float, then fix. The NMEA sentences will have increased accuracy of 14mm horizontal and 10mm vertical accuracy. The RTCM correction data can be obtained from a cellular link to online correction sources or over a radio link to a 2nd RTK Surveyor setup as a base station.

When the SETUP switch is set to Base the device will enter Base Station mode. This is used when the device is mounted to a fixed position (like a tripod or roof). The RTK Surveyor will initiate a survey. After 60 to 120 seconds the survey will complete and the RTK Surveyor will begin transmitting RTCM correction data out the radio port. A base is often used in conjunction with a second unit set to 'Rover' to obtain the 14mm accuracy. Said differently, if you’ve got a radio attached to the base and the rover, you’ll create an RTK system without any other setup and the Rover will output super accurate readings.

Power

The Power switch is self explanatory. When turned on the LED will turn Green, Yellow, or Red indicating battery level. The RTK Surveyor has a built-in 1000mAh lithium polymer battery that will enable up to 4 hours of field use between charging. If more time is needed a common USB power bank can be attached boosting the field time to 40 hours.

LEDs

RTK Surveyor LEDs

There are a variety of LEDs:

  • Power - Blue when attached to power and charging / off when fully charged. Green/Yellow/Red when the Power switch is turned on indicating the state of charge of the internal battery.
  • RTK - This white LED will be off when no RTCM correction data is received. Blinking indicates RTK Float is achieved. Solid when RTK Fix is achieved.
  • PPS - Pulse per second. This yellow LED will blink at 1Hz when GNSS fix is achieved. You’ll see this LED begin blinking anytime the receiver detects enough satellites to obtain a rough location.
  • PAIR - Blinks blue when waiting to be paired with over Bluetooth. Solid when a connection is active.
  • Horizontal Accuracy 100cm/10cm/1cm - These green LEDs illuminate as the horizontal positional accuracy increases. 100cm will often be achieved in normal positioning mode with a good L1/L2 antenna. 10cm will often be achieved as the first few seconds of RTCM correction data is received, and 1cm will be achieved when a full RTK fix is calculated.
  • BASE - This LED will blink red when the SETUP switch is set to Base and a survey is being conducted. It will turn solid red once the survey is complete and the unit begins broadcasting RTCM correction data.

Connectors

RTK Surveyor Connectors and label

The SparkFun RTK Surveyor has a variety of connectors

Antenna:

This SMA connector is used to connect an L1/L2 type GNSS antenna to the RTK Surveyor. Please realize that a standard GPS antenna does not receive the L2 band signals and will greatly impede the performance of the RTK Surveyor (RTK fixes are nearly impossible). Be sure to use a proper L1/L2 antenna.

RTK Surveyor SMA connector

Configure u-blox:

This USB C connector is used for charging the device and/or directly configuring and inspecting the ZED-F9P GNSS receiver using u-center. It’s not necessary in normal operation but is handy for tailoring the receiver to specific applications. As an added perk, the ZED-F9P can be detected automatically by some mobile phones and tablets. If desired, the receiver can be directly connected to a compatible phone or tablet removing the need for a Bluetooth connection.

RTK Surveyor u-blox connector

USB Configure ESP32:

This USB C connector is used for charging the device, configuring the device, and reprogramming the ESP32. Various debug messages are printed to this port at 115200bps and a serial menu can be opened to configure advanced settings.

RTK Surveyor ESP32 connector

Radio:

This 4-pin JST connector is used to allow RTCM correction data to flow into the device when it is acting as a rover or out of the device when it is acting as a base. You will most likely connect this port to one of our Serial Telemetry Radios if you don’t have access to a correction source on the internet. The pinout is 3.5-5.5V / TX / RX / GND. The connector is a 4-pin locking 1.25mm JST SMD connector (part#: SM04B-GHS-TB, mating connector part#: GHR-04V-S). 3.5V to 5.5V is provided by this connector to power a radio with a voltage that depends on the power source. If USB is connected to the RTK Surveyor then voltage on this port will be 5V (+/-10%). If running off of the internal battery then voltage on this port will vary with the battery voltage (3.5V to 4.2V depending on the state of charge). While the port is capable of sourcing up to 2 amps, we do not recommend more than 500mA. This port should not be connected to a power source.

RTK Surveyor Radio connector

Data:

This 4-pin JST connector is used to output NMEA sentences over 115200bps serial. Most applications will send the NMEA position data over Bluetooth. Alternatively, this port can be useful for sending position data to an embedded microcontroller or single board computer. The pinout is 3.3V / TX / RX / GND. The connector is a 4-pin locking 1.25mm JST SMD connector (part#: SM04B-GHS-TB, mating connector part#: GHR-04V-S). 3.3V is provided by this connector to power a remote device if needed. While the port is capable of sourcing up to 600mA, we do not recommend more than 300mA. This port should not be connected to a power source.

RTK Surveyor Data connector

microSD:

This slot accepts standard microSD cards up to 32GB. Currently, there is no firmware support for reading or writing to files but support may be added in the future.

RTK Surveyor microSD connector

Qwiic:

This 4-pin Qwiic connector exposes the I2C bus of the ESP32 WROOM module. Currently, there is no firmware support for adding I2C devices to the RTK Surveyor but support may be added in the future.

RTK Surveyor Qwiic connector

Power

The RTK Surveyor has a built in 1000mAh battery and consumes approximately 240mA worst case with Bluetooth connection active, GNSS fully tracking, and a 500mW radio broadcasting. This will allow for 4 hours of use in the field. If more time is needed in the field a standard USB power bank can be attached. If a 10,000mAh bank is attached one can estimate 30 hours of run time assuming 25% is lost to efficiencies of the power bank and charge circuit within RTK Surveyor.

The RTK Surveyor can be charged from any USB port or adapter. The charge circuit is rated for 1000mA so USB 2.0 ports will charge at 500mA and USB 3.0+ ports will charge at 1A.

To quickly view the state of charge, turn on the unit. A green LED indicates > 50% charge remaining. A yellow LED indicates > 10% charge remaining. A red LED indicates less than 10% charge remaining.

Hardware Overview - Advanced Features

The RTK Surveyor is a hacker’s delight. Under the hood of the RTK Surveyor is an ESP32 WROOM connected to a ZED-F9P as well as some peripheral hardware (LiPo fuel gauge, microSD, etc). It is programmed in Arduino and can be tailored by the end user to fit their needs.

RTK Survayor Schematic

Click on the image to get a closer look at the Schematic!

ZED-F9P GNSS Receiver

The ZED-F9P GNSS receiver is configured over I2C and uses two UARTs to output NMEA (UART1) and input/output RTCM (UART2).

ZED-F9P GNSS Receiver

Two internal slide switches control the flow of NMEA and RTCM traffic between the external connectors and the internal BT UART used on the ESP32. Ostensibly the Bluetooth Broadcast switch can be set to pipe RTCM data to the ESP32’s UART (instead of NMEA) so that correction data can be transmitted over Bluetooth. Point to point Bluetooth radio support is not supported because the useful range of Bluetooth is too short for most RTK applications but may be helpful in some advanced applications.

Communication switches

ESP32

The ESP32 uses a standard USB to serial conversion IC (CH340) to program the device. You can use the ESP32 core for Arduino or Espressif’s IoT Development Framework (IDF).

The CH340 automatically resets and puts the ESP32 into bootload mode as needed. However, the reset pin of the ESP32 is brought out to an external 2-pin 0.1” footprint if an external reset button is needed.

ESP32 on SparkFun RTK Surveyor

Measurement Jumpers

To facilitate the measurement of run, charge, and quiescent currents, two measurement jumpers are included. These are normally closed jumpers combined with a 2-pin 0.1” footprint. To take a measurement, cut the jumper and install a 2-pin header and use banana to IC hook cables to a DMM.

Measurement Jumpers on SparkFun RTK Surveyor

LiPo and Charging

The RTK Surveyor houses a standard 1000mAh 3.7V LiPo. The charge circuit is set to 1A so with an appropriate power source, charging an empty battery should take roughly one hour. USB C on the RTK Surveyor is configured for 2A draw so if the user attaches to a USB 3.0 port, the charge circuit should operate near the 1A max. If a user attaches to a USB 2.0 port, the charge circuit will operate at 500mA.

LiPo and Charging on SparkFun RTK Surveyor

MAX17048 Fuel Gauge

The MAX17048 is a simple to use fuel gauge IC that gives the user a statement of charge (SOC) that is basically a 0 to 100% report. The MAX17048 has a sophisticated algorithm to figure out what the SOC is based on cell voltage that is beyond the scope of this tutorial but for our purposes, allows us to control the color of the power LED.

MAX17048 Fuel Gauge on SparkFun RTK Surveyor

Qwiic

A Qwiic connector is exposed on the end of the unit. This allows connection to the I2C bus on the ESP32. Currently the stock RTK Surveyor does not support any additional Qwiic sensors or display but users may add support for their own application.

Qwiic Connector on SparkFun RTK Surveyor

microSD

A microSD socket is situated on the ESP32 SPI bus. The current RTK Surveyor firmware does not have any microSD features, but data logging has been electrically tested and confirmed. Future planned features include logging of RAW sentences to a file for later PPP processing. Any microSD up to 32GB is supported.

microSD socket on SparkFun RTK Surveyor

Hardware Assembly

The RTK Surveyor was designed to work with low-cost, off the shelf equipment. Here we’ll describe how to assemble a Rover and Base.

Rover

Shown here is the most common RTK Rover setup. A monopole designed for cameras is used. A cell phone holder is clamped to the monopod and the RTK Surveyor is mounted. The ¼” camera thread of the monopole is adapted to ⅝” 11-TPI and a L1/L2 antenna is attached. A TNC-RP to SMA cable connects the antenna to the RTK Surveyor. No radio is needed because RTCM correction data is provided by a phone over Bluetooth.

Basic RTK Surveyor setup

Basic RTK Surveyor Rover setup with RTCM over Bluetooth

We have done lots of testing with the u-blox L1/L2 antenna and it's very good for the price and size. Mounted to a ground plate you will get very good results. It's just a bit ungainly when mounted to the top of a monopole. We recommend the 'ufo' style L1/L2 antennas because they have a larger antenna element and a slightly larger ground plane than the u-blox antenna.

u-blox L1/L2 antenna with ground plate

u-blox L1/L2 antenna with ground plate

If you’re shopping for a monopole (aka monopod), get one that is 65” in length or greater to ensure that the antenna will be above your head. We’ve had good luck with the Amazon Basics brand.

Monopole with antenna above head height

If you’re shopping for a cell phone clamp be sure to get one that is compatible with the diameter of your monopole and has a knob to increase clamp pressure. Our monopole is 27mm in diameter and we’ve had a good experience with this clamp and this clamp. Your mileage may vary.

RTK Surveyor mounted in clamp

If you are receiving RTCM correction data over a radio link it’s recommended that you attach a radio to the back of the RTK Surveyor.

RTK Surveyor Rover setup with radio

2nd most common setup with a 915MHz Radio providing RTCM

Picture hanging strips from 3M make a nice semi-permanent mount. Plug the 4-pin to 6-pin JST cable included with the RTK Surveyor from the Radio port to either of the Serial Telemetry Radios (shipped in pairs). We really love these radios because they are paired out of the box, either can send or receive (so it doesn't matter which radio is attached to base or rover) and they have remarkable range. We achieved over a mile range (nearly 1.5 miles or 2.4km) with the 500mW radios and a big 915MHz antenna on the base (see this tutorial for more info).

Serial Telemetry Radio mounted to the back of RTK Surveyor

Temporary Base

A temporary or mobile base setup is needed when you are in the field too far away from a correction source and/or cellular reception. A 2nd RTK Surveyor is mounted to a tripod and it is configured to complete a survey-in (aka, locate itself), then begin broadcasting RTCM correction data. This data (~1000 bytes a second) is sent to the user's connected radio of choice. For our purposes, the 915MHz 500mW telemetry radios are used because they provide what is basically a serial cable between our base and rover.

RTK Surveyor Base setup

Temporary RTK Surveyor Base setup

Any tripod with a ¼” camera thread will work. A cell phone holder is clamped to the tripod and the RTK Surveyor is held in the clamp. The ¼” camera thread is adapted to ⅝” 11-TPI and a L1/L2 antenna is attached. A TNC-RP to SMA cable connects the antenna to the RTK Surveyor.

Once the base has been setup with a clear view of the sky, move the Setup switch to "Base" and turn the unit on. The red LED will blink for 60-120 seconds. Once the survey is complete the red LED will be constantly illuminated and RTCM data will begin to be broadcast. You can verify this by viewing the LEDs on the telemetry radio (a small red LED will blink when serial data is received from the RTK Surveyor). The RTK Surveyor is designed to follow the u-blox recommended survey-in of 60s and a mean 3D standard deviation of 5m of all fixes. If a survey fails to achieve these requirements it will auto-restart after 10 minutes.

More expensive surveyor bases have a ⅝” 11-TPI thread but the top of the surveyor base will often interfere with the antenna’s TNC connector. If you chose to use a surveyor’s ‘stick’ be sure to obtain a ⅝” extender plate to raise the antenna at least an inch.

If you’re shopping for a cell phone clamp be sure to get one that is compatible with the diameter of your tripod and has a knob to increase clamp pressure. Our tripod is 18mm in diameter and we’ve had a good experience with this clamp. Your mileage may vary.

Cell phone clamp on the side of a tripod with RTK Surveyor

Note: A mobile base station works well for quick trips to the field. However, the survey-in method is not recommended for the highest accuracy measurements because the positional accuracy of the base will directly translate to the accuracy of the rover. Said differently, if your base's calulcated position is off by 100cm, so will every reading your rover makes. If you’re looking for maximum accuracy consider installing a static base with fixed antenna. We were able to pinpoint the antenna on the top of SparkFun with an incredible accuracy +/-8mm of accuracy using PPP!

Bluetooth and NTRIP

The RTK Surveyor transmits full NMEA sentences over Bluetooth serial port profile (SPP) at 4Hz and 115200bps. This means that nearly any GIS application that can receive NMEA data over serial port (almost all do) can be used with the RTK Surveyor. As long as your device can open a serial port over Bluetooth (also known as SPP) your device can retrieve industry standard NMEA positional data. The following steps show how to use SW Maps but the same steps can be followed to connect any serial port based GIS application.

The best mobile app that we’ve found is the powerful, free, and easy to use SW Maps by Softwel. You’ll need an Android phone or tablet with Bluetooth. What makes SW Maps truly powerful is its built-in NTRIP client. This is a fancy way of saying that we’ll be showing you how to get RTCM correction data over the cellular network. If you’re using a serial radio for your correction data, you can skip this part.

SW Maps with RTK Fix

SW Maps with RTK Fix

When powered on, the RTK Surveyor will broadcast itself as either 'Surveyor Rover-BC41' or 'Surveyor Base-BC41' depending on the position of the SETUP switch. Discover and pair with this device from your phone or tablet. Once paired, open SW Maps.

Pairing with the RTK Surveyor over Bluetooth

Pairing with the RTK Surveyor over Bluetooth

From SW Map's main menu, select Bluetooth GNSS. This will display a list of available Bluetooth devices. Select the Rover or Base you just paired with. Select 'u-blox RTK' (rather than just 'u-blox') from the Instrument Model dropdown. This is important and will enable the use of NTRIP. If your are taking height measurements (altitude) in addition to position (lat/long) be sure to enter the height of your antenna off the ground including any ARP offsets of your antenna (should be printed on the side).

Click on 'CONNECT' to open a Bluetooth connection. Assuming this process takes a few seconds, you should immediately have a location fix.

List of BT Devices in SW Maps

List of available Bluetooth devices

Next we need to send RTCM correction data from the phone back to the RTK Surveyor so that it can improve its fix accuracy. This is the amazing power of RTK Surveyor and SW Maps. Your phone can be the radio link! From the main SW Maps menu select NTRIP Client. Not there? Be sure to select 'u-blox RTK' instrument when connecting. Disconnect and change the instrument choice to enable the NTRIP Connection option.

SW Maps NTRIP Connection menu

NTRIP Connection - Not there? Be sure to select 'u-blox RTK' instrument

Enter your NTRIP caster credentials and click connect. You will see bytes begin to transfer from your phone to the RTK Surveyor. Within a few seconds the RTK Surveyor will go from ~300mm accuracy to 14mm. Pretty nifty, no?

SW Maps NTRIP client

Connecting to an NTRIP caster

What's an NTRIP caster? In a nut shell it's a server that is sending out correction data every second. There are thousands of sites around the globe that calculate the perturbations in the ionosphere and troposphere that decrease the accuracy of GNSS accuracy. Once the inaccuracies are known, correction values are encoded into data packets in the RTCM format. You, the user, don't need to know how to decode or deal with RTCM, you simply need to get RTCM from a source within 10km of your location into the RTK Surveyor. The NTRIP client logs into the server (also known as the NTRIP caster) and grabs that data, every second, and sends it over Bluetooth to the RTK Surveyor.

Don't have access to an NTRIP caster? We have a tutorial for that! Checkout How to Build a DIY GNSS Reference Station. Remember, you can always use a 2nd RTK Surveyor in Base mode to provide RTCM correction data but it will less accurate than a fixed position caster.

Once you have a full RTK fix you'll notice the location bubble in SW Maps turns to green. Just for fun, rock your rover monopole back and forth on a fixed point. You'll see your location accurately reflected in SW Maps. Millimeter location precision is a truly staggering thing.

Output to an Embedded System

Many applications using the RTK Surveyor will use a 3rd party GIS application or mobile app like SW Maps and receive the data over Bluetooth. Alternatively, for embedded applications a user can obtain the NMEA data over serial directly.

For this example we will connect the output from the DATA port to a USB to Serial adapter so that we can view the serial data.

Connect the included 4-pin JST to breadboard cable to the DATA port. The cable has the following pinout:

  • Red - 3.3V
  • Green - TX (output from RTK Surveyor)
  • Orange - RX (input to RTK Surveyor)
  • Black - GND

Wires connected to a SparkFun USB C to Serial adapter

Click on the image for a closer view!

Open a terminal at 115200bps and you should see NMEA sentences:

NMEA output from the RTK Surveyor

The Data connector on the RTK Surveyor is a 4-pin locking 1.25mm JST SMD connector (part#: SM04B-GHS-TB, mating connector part#: GHR-04V-S). 3.3V is provided by this connector to power a remote device if needed. While the port is capable of sourcing up to 600mA, we do not recommend more than 300mA. This port should not be connected to a power source, so if your embedded device has its own power do not connect the red wire.

The parsing of NMEA sentences is straightforward and left to the reader. There are ample NMEA parsing libraries available in C++, Arduino, python, and many more languages.

Troubleshooting

Resources and Going Further

We hope you enjoy using the RTK Surveyor as much as we have!

Here are the pertinent technical documents for the RTK Surveyor:

Check out these additional tutorials for your perusal:

Mini GPS Shield Hookup Guide

A hookup guide for the SparkFun Mini GPS Shield.

LS20031 5Hz (66 Channel) GPS Receiver Hookup Guide

In this tutorial, we will solder headers to the surface mount pads of the LS20031 GPS receiver and read the output using an Arduino!

SparkFun GPS Breakout - XA1110 (Qwiic) Hookup Guide

Figure out where in the world you are with the Qwiic SparkFun GPS Breakout - XA1110.

RFID Beginners Tutorial

In this tutorial we'll revisit some RFID basics and practice by making a remote work logger using an RFID reader and a GPS module. You'll scan a card and get ID, location, and time. All the perfect data to punch in and punch out from the middle of Nowhere!

ESP32 Thing Plus Hookup Guide

Hookup guide for the ESP32 Thing Plus using the ESP32 WROOM's WiFi/Bluetooth system-on-chip in Arduino.

How to Install CH340 Drivers

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Viewing all 1123 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>