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

Qwiic Ultrasonic Distance Sensor (HC-SR04) Hookup Guide

$
0
0

Qwiic Ultrasonic Distance Sensor (HC-SR04) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Qwiic Ultrasonic Distance Sensor is great for providing non-contact distance readings from 2cm to 400cm. It improves on the classic HC-SR04 distance sensor by adding a pair of Qwiic connectors to it, so now you can communicate over I2C and daisy chain any other Qwiic product of your choosing.

If you prefer to bypass the Qwiic connector and I2C you can also access the VCC, Trigger, Echo, and Ground pins broken out on the edge of the board. Please be aware that this ultrasonic sensor comes uncalibrated and you will need manipulate the raw output for your specific application. Let's have a look at this fun board!

SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04

SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04

SEN-17777
$12.95

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Suggested Reading

If you aren't familiar with the 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.

Serial Terminal Basics

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

Hardware Overview

Overall Features:

  • Operating Voltage 3.3V
  • Detecting Angle: 15 degrees
  • Sensor range: 2cm to 400cm
  • Accuracy: 3mm
  • MCU on board: STM8L051
  • Default I2C Address: 0x00
  • Dimensions: 21.5 x 45.5mm
  • Weight 9.2g

STM8L051 MCU

The 8-bit ultra-low power STM8 MCU Core provides increased processing power (up to 16 MIPS at 16 MHz) while maintaining the advantages of a CISC architecture with improved code density, a 24-bit linear addressing space and an optimized architecture for low power operations. It also features embedded data EEPROM and low power, low-voltage, single-supply program Flash memory. The device incorporates an extensive range of enhanced I/Os and peripherals, a 12-bit ADC, a real-time clock, two 16-bit timers, one 8-bit timer, as well as standard communication interfaces such as an SPI, an I2C interface, and one USART. For more information, refer to the datasheet.

Sensor with core highlighted

Qwiic Connectors

Our Qwiic Ecosystem makes sensors pretty much plug and play. There are two Qwiic connectors on the side of the Qwiic Distance Sensor board to provide power and I2C connectivity simultaneously.

Sensor with the Qwiic connectors highlighted

Power

Ideally, power will be supplied via the Qwiic connectors on either side of the board. Alternatively, power can be supplied through the pins along the bottom side of the board labeled 3V3 and GND. The input voltage range should be between 1.8-3.6V.

Sensor with 3.3V and GND pins highlighted

Trigger and Echo Pins

If you (for some crazy reason) don't want to utilize the Qwiic connectors, we've broken out the Trigger and Echo pins as PTH. We've included headers that can be soldered in place.

Sensor with Trigger and Echo Pins Highlighted

I2C Jumpers

The Qwiic Ultrasonic Distance Sensor has built-in 2.2k pull-up resistors on the SDA and SCL lines. These are needed for normal I2C communication. The I2C jumper has two small traces connecting the pull-ups to 3.3V. For general use you can leave this jumper unmodified. If you have many (over 7) devices on the I2C bus, each with their own pull up resistors, then you may want to cut the I2C jumpers to disconnect the 2.2k resistors on each Qwiic board.

Sensor with I2C jumpers highlighted

Board Dimensions

Units below are in mm.

Board measures 45.06mm by 21.51mm

Hardware Hookup

Using the Qwiic system, assembling the hardware is simple. Connect the RedBoard to one of the Ultrasonic Distance Sensor Qwiic ports and the Qwiic OLED Display on the other Qwiic port using your Qwiic cables. Then connect the RedBoard to your computer via the MicroUSB cable and voila! You're ready to rock!

Image of all three boards hooked up via Qwiic cables

Software Setup and Programming

Note: Make sure you are using the latest stable version of the Arduino IDE on your desktop. If this is your first time using Arduino IDE, library, or board add-on, please review the following tutorials.

Our friends over at Zio have provided an example to get you started with this Ultrasonic Distance Sensor. In order to do so, you'll need to install a few libraries first.

To display the sensor readings on the connected Qwiic OLED, we will use three Adafruit libraries:

Adafruit BusIO Library

You can install this library to automatically in the Arduino IDE's Library Manager by searching for "Adafruit BusIO". Or you can manually download it from the GitHub repository.

Adafruit GFX Library

You can install this library to automatically in the Arduino IDE's Library Manager by searching for "Adafruit GFX". Or you can manually download it from the GitHub repository.

Adafruit SSD1306 Library

You can install this library to automatically in the Arduino IDE's Library Manager by searching for "Adafruit SSD1306 Library". Or you can manually download it from the GitHub repository.


Example 1

This example lives in the GitHub Repo in the Arduino folder. Feel free to download the code, alternatively you can copy the code below into a blank Arduino sketch. Select your board (for this example we'd select "SparkFun RedBoard") and the port your board has enumerated on. Go ahead and upload your code.

language:c
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SLAVE_BROADCAST_ADDR 0x00  //default address
#define SLAVE_ADDR 0x00       //SLAVE_ADDR 0xA0-0xAF
uint8_t distance_H = 0;
uint8_t distance_L = 0;
uint16_t distance = 0;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


void setup() {
  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
  Serial.println("IIC testing......");
  display.clearDisplay();
  //  Wire.beginTransmission(SLAVE_BROADCAST_ADDR); // transmit to device SLAVE_BROADCAST_ADDR
  //  Wire.write(SLAVE_ADDR);              // Change the SLAVE_ADDR
  //  Wire.endTransmission();    // stop transmitting
}



void loop() {
  Wire.beginTransmission(SLAVE_ADDR); // transmit to device #8
  Wire.write(1);              // measure command: 0x01
  Wire.endTransmission();    // stop transmitting

  Wire.requestFrom(SLAVE_ADDR, 2);    // request 6 bytes from slave device #8
  while (Wire.available()) { // slave may send less than requested
    distance_H = Wire.read(); // receive a byte as character
    distance_L = Wire.read();
    distance = (uint16_t)distance_H << 8;
    distance = distance | distance_L;
    Serial.print(distance);         // print the character
    Serial.println("mm");
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(10, 0);
    display.clearDisplay();
    display.print(distance);
    display.print("mm");
    display.display();
    delay(1);

    delay(100);
  }
}

Try moving an object (like your hand or a dinosaur) closer to the sensor - notice the output of the OLED shows you how close the object is! Grr. Rawr!

Oh no! A dinosaur is approaching distance sensor and now it's only 61mm away!

Curse your sudden but inevitable betrayal!

Troubleshooting

Resources and Going Further

For more information on the Qwiic Ultrasonic Distance Sensor, check out the following links:

Need some inspiration for your next project? Check out some of these other Qwiic product tutorials:

Qwiic Magnetometer (MLX90393) Hookup Guide

Figure out how magnetic fields are oriented, all without having to solder a thing.

TFMini - Micro LiDAR Module (Qwiic) Hookup Guide

The TFMini is a ToF (Time of Flight) LiDAR sensor capable of measuring the distance to an object as close as 30 cm and as far as 12 meters! The TFMini allows you to easily integrate LiDAR into applications traditionally reserved for smaller sensors such as the SHARP GP-series infrared rangefinders. With the added Qwiic feature, you can quickly connect to the sensor via I2C!

Hookup Guide for the SparkFun RedBoard Artemis Nano

Get started with the powerful RedBoard Artemis Nano

Advanced Autonomous Kit for Sphero RVR Assembly Guide

Get your Advanced Autonomous Kit for the Sphero RVR built up with this hookup guide!

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


How to Upgrade Firmware of a u-blox GNSS Receiver

$
0
0

How to Upgrade Firmware of a u-blox GNSS Receiver a learn.sparkfun.com tutorial

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

Introduction

For GNSS positioning, u-blox has some of the most incredible receivers available. Over time they will release new versions of the firmware running on those receivers. This tutorial will demonstrate how to upgrade the firmware on the ZED-F9P but can be used for nearly all u-blox receivers including:

Connecting

If you have not already installed u-center, do so now. If this is your first time using u-center, you should be fine, but just now we have a Getting started with u-center tutorial that can be helpful.

Connecting the ZED-F9P over USB

Connecting the RTK Surveyor over USB

For many modules like the ZED-F9P (shown inside the RTK Surveyor above) or NEO-M8P, a USB connection is as simple as plugging in a USB cable.

SAM-M8Q connected to USB

A USB adapter providing the serial connection

For modules that do not have USB built in, you will need to use a serial to USB adapter and solder in a 6-pin right angle header. Note how the GRN and BLK labels align on both the serial adapter and the SAM-M8Q evaluation board.

COM power menu list

Open u-center and connect to the appropriate COM port. Not sure what COM port to use? The easiest method is to view the listed COM ports, then unplug your device from USB. Now re-open the list. Which COM disappeared? That’s the one you want.

Alternatively, you can Open Device Manager (press the Windows button then type ‘device’).

Device Manager list of COM ports

In the image above COM3 is a COM port on my computer that never goes away. COM11 disappears when I unplug my ZED-F9P so COM11 is the port I need to connect to from u-center.

Backup Device Settings

Updating the firmware will overwrite the device configuration. If you use stock settings or tweak just a few features then you can skip this step. If you have a highly configured receiver that you don’t want to manually configure again, read on.

Receiver configuration sub menu

Open the Receiver Configuration window. It’s under Tools.

Receiver configuration tool

We want to transfer from the receiver to a file. Give the configuration file an easy to remember name. Once complete, the receiver’s settings will be committed to the file.

Loading a configuration to a u-blox receiver

And just as easily, you can load a configuration file back onto the receiver. This is a handy tool for having a handful of different configurations or if you have a batch of receivers that all need to have the same settings applied.

Identifying Current Firmware Version

This is perhaps the most difficult step of the process! Click on the Messages window button.

Messages window

Within the Messages window, you will see a tremendous number of subtrees. Close them all so you only see NMEA, RTCM3, and UBX

All subtress collapsed

Now expand UBX. We need to locate and expand MON, and finally locate VER.

VER message located

Your device’s firmware will be listed in the right window pane. In this example the Firmware Version is 1.13 and the module is the ZED-F9P.

Getting Latest Firmware

Now that you know your current firmware, it’s time to find out if there is anything more recent. SparkFun will generally not host the binary files that u-blox releases. This is because we want you to have the latest and greatest version directly from u-blox. You can usually find the firmware for a given product under the ‘Documents and resources’ tab for that given product. Here’s the ZED-F9P as an example.

Documents tab

Scroll or search this page for ‘firmware’

Download firmware link

Download this binary to a folder where you can easily find it.

Upgrading Firmware

Firmware update sub-menu

Select Firmware Update from the Tools menu. Note that while the menu says that Ctrl+U is the shortcut, it is not! Ctrl+U will open the legacy firmware update tool. Be careful and use your mouse.

Firmware update tool window

Press the button with three dots '...' and locate the firmware image you just downloaded. When you’re ready, press the green dot button labeled ‘GO’ in the lower left corner.

Loading new firmware

Sit back and wait. This upgrade took about 60s but your mileage may vary.

Firmware update success

Upon completion, you should see the ‘Firmware Update Success’ message. The GNSS receiver will reset and re-enumerate over USB (if it has USB built-in). On the ZED-F9P all device settings and configurations were overwritten so if you previously saved your device’s configuration now is a good time to reload them.

Further Reading

Thanks for reading! We hope this makes the firmware upgrade process a bit less daunting. If you're unsure about the changes and advantages to each firmware release, be sure to checkout the 'Release Notes' listed on a given u-blox receiver's documents page.

Want more GNSS goodness? Checkout some of these great tutorials:

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 u-blox.

SparkFun GPS Breakout (ZOE-M8Q and SAM-M8Q) Hookup Guide

The SparkFun ZOE-M8Q and SAM-M8Q are two similarly powerful GPS units but with different project applications. We'll compare both chips before getting each up and running.

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!

MicroMod Asset Tracker Carrier Board Hookup Guide

Get started with the SparkFun MicroMod Asset Tracker Carrier Board following this Hookup Guide. The Asset Tracker uses the u-blox SARA-R510M8S LTE-M / NB-IoT module to provide a host of data communication options.

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

SparkFun QwiicBus Hookup Guide

$
0
0

SparkFun QwiicBus Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Introducing the SparkFun QwiicBus system! The QwiicBus is a fast and easy way to extend the range of your I2C bus. The QwiicBus system features two boards: the SparkFun QwiicBus EndPoint and the SparkFun QwiicBus MidPoint. SparkFun also offers the QwiicBus Kit that includes two EndPoints, one MidPoint and two Ethernet cables to get you started with the QwiicBus.

SparkFun QwiicBus Kit

SparkFun QwiicBus Kit

KIT-17250
$39.95
SparkFun QwiicBus - EndPoint

SparkFun QwiicBus - EndPoint

COM-16988
$10.95
SparkFun QwiicBus - MidPoint

SparkFun QwiicBus - MidPoint

COM-18000
$20.95

Using NXP's PCA9615 differential I2C bus buffer IC, the QwiicBus converts the two default I2C signals into four differential signals (two for SCL and two for SDA). The differential signals are sent over an Ethernet cable, which attaches to the EndPoint or MidPoint through the on-board RJ-45 connectors. Differential signaling allows the I2C signals to reach distances of over 100 feet while still maintaining their signal integrity. In our testing using two EndPoints, four MidPoints, at least one Qwiic device on each node and over 200 feet of Ethernet cable, we were able to use all devices with nearly no signal integrity loss!

The EndPoint acts as the starting and ending points of the QwiicBus and the MidPoint allows you to add a drop-in I2C connection to your long-distance differential I2C chain wherever you would like.

These boards grew out of a collaboration with FarmHand Automation. While developing autonomous micro-tractors to help small farmers grow their business, Farmhand realized they needed a low cost, open source CAN/Modbus alternative. Read more about their story here. FarmHand founder, Alex Jones said, "We knew the sensors we wanted to use, but as soon as you need to communicate over long distances in noisy environments things get complicated. The Qwiic Midpoint is going to solve a lot of that headache." The QwiicBus MidPoint and QwiicBus EndPoint are ideal for applications that require long-range communication over Ethernet, such as agricultural technology or data collection/monitoring in rural/remote areas.

Whether you have a robot with multiple I2C devices throughout it like FarmHand, a sensor network project with multiple sensors over a large area or other I2C projects you can think of that require a wired signal transmission over long distances, the QwiicBus makes that communication a breeze!

Required Materials

If you are using the QwiicBus Kit, you'll have the required boards and Ethernet cables to assemble your QwiicBus circuit. Otherwise, you'll want to pick up two EndPoints and however many MidPoints your project needs.

Along with the QwiicBus boards, you will need the following materials to follow along with this tutorial. 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.

A microcontroller is needed to control any I2C devices attached to your QwiicBus. 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 Qwiic Pro Micro - USB-C (ATmega32U4)

SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

DEV-15795
$19.95
2
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
8

If you would prefer to use a single-board computer (SBC) like a Raspberry Pi or Jetson Nano as your controller, the products below will also work with the QwiicBus:

NVIDIA Jetson Nano Developer Kit (V3)

NVIDIA Jetson Nano Developer Kit (V3)

DEV-16271
$99.00
10
SparkFun DLI Kit for Jetson Nano

SparkFun DLI Kit for Jetson Nano

KIT-16308
$174.95
3
Raspberry Pi 4 Model B (2 GB)

Raspberry Pi 4 Model B (2 GB)

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

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

KIT-16386
$159.95

If your favorite microcontroller or single board computer is not already Qwiic-enabled, you can add that functionality with one or more of the following items:

SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic SHIM for Raspberry Pi

SparkFun Qwiic SHIM for Raspberry Pi

DEV-15794
$0.95
8
SparkFun Qwiic Shield for Arduino

SparkFun Qwiic Shield for Arduino

DEV-14352
$6.95
6
SparkFun Qwiic pHAT v2.0 for Raspberry Pi

SparkFun Qwiic pHAT v2.0 for Raspberry Pi

DEV-15945
$5.95
2

You will also probably want a few Qwiic cables to connect your devices on your I2C bus:

Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50

Finally, if you are not using the QwiicBus Kit you'll need at least one straight through Ethernet cable.

Optional Extras for Alternate QwiicBus Power Configurations

The QwiicBus offers multiple power configurations intended for applications where many devices need to be powered over the QwiicBus. We cover these configurations in more detail in the Hardware Overview and Hardware Assembly. To use these configurations you will need some extra hardware and tools. Click the button below to view some recommended products for alternate power configurations.

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 the topics they cover.

Logic Levels

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

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.

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

The simplicity of the QwiicBus is one of its biggest appeals as all you really need to get started is the QwiicBus boards, Ethernet and Qwiic cables and a controller (either development board or SBC). Other I2C communication methods require packetizing I2C communication into another protocol, be it RS-485 or 1-Wire. However, the PCA9615 keeps the I2C protocol by utilizing a differential transceiver. In this section, we'll take a closer look at the QwiicBus boards and the hardware present on them to better understand how they work.

PCA9615 Bus Buffer IC

Let's take a quick look at the PCA9615 IC at the heart of the MidPoint and EndPoint. The PCA9615 acts as a bridge that translates a standard two-wire I2C bus to a four-wire differential I2C bus. Translating to a differential bus helps prevent signal disruption in noisy environments as well as extending the signal over long-distance transmissions. For detailed information about the full functionality and feature set of the PCA9615 review the datasheet.

Photo of QwiicBus EndPoint highlighting PCA9615Photo of QwiicBus MidPoint highlighting PCA9615

The PCA9615 has two supply voltage rails: VDDA and VDDB. VDDA acts primarily as the I2C-bus side power supply and VDDB primarily is used for the differential side power supply. While the two power supplies have slightly different operating ranges (VDDA supply voltage range: 2.3-5.5V. VDDB supply voltage range: 3.0-5.5V), both the EndPoint and MidPoint default to net both voltages together at 3.3V.

The PCA9615 supports I2C clock speeds up to 1MHz though the maximum cable length is inversely related to the clock speed. At max speed, the max rated cable length is listed at 3m but can be increased at lower clock speeds. For example, in our testing of the QwiicBus with over 200 feet of Ethernet cable we observed no significant signal loss while running at the standard clock speed for the Arduino Wire Library (100KHz).

We've designed the QwiicBus MidPoint and EndPoint to have multiple configuration options for powering your QwiicBus so there is a bit to take note of before powering everything up. We cover the different power configurations further down in the Solder Jumpers sub section as well as in the Hardware Assembly section so read on for more information.

The QwiicBus boards also break out the Enable (EN) pin to a PTH header if you would like to control the PCA9615 manually. By default, it is pulled to VDDA via an internal resistor. Refer to section 7.3 of the PCA9615 datasheet for more information on using this pin.

Qwiic and I2C Interface

As a large portion of you readers have come to expect, the I2C pins are broken out to two Qwiic connectors so you can easily connect your QwiicBus boards to other Qwiic devices. We've also broken out the four I2C pins to standard 0.1"-spaced PTH header pins for users who prefer the standard plated through-hole connection.

Photo of QwiicBus EndPoint highlighting Qwiic and I2C PinsPhoto of QwiicBus MidPoint highlighting Qwiic and I2C Pins

Differential Output and RJ-45 Connectors

The EndPoint has a single RJ-45 to send the differential signal out to another EndPoint or to your MidPoint nodes. The MidPoint comes with two RJ-45 connectors so you can easily integrate it into your existing bus.

Photo of QwiicBus EndPoint highlighting RJ-45 ConnectorsPhoto of QwiicBus MidPoint highlighting RJ-45 Connectors

Depending on your project's power needs, the unused Green and Blue twisted pairs in the Ethernet cable can be used to send 5V over the Blue pair (Ethernet pins 4 and 5) or 3.8V to 36V over the Green pair (Ethernet pins 3 and 6). On the EndPoint, the Blue pair is broken out to PTH pins labeled VCC1 and GND and the Green pair is broken out to PTH pins labeled VCC2 and GND2.

We've also broken out the VCC2 and GND2 lines to a pair of PTH pins on the MidPoint if users would like to use them for powering peripherals or running the voltage over the QwiicBus chain on separate wires.

Photo of QwiicBus EndPoint highlighting the voltage PTH pinsPhoto of QwiicBus MidPoint highlighting the VCC2 and GND2 PTH pins.

VCC1 is tied to both VDDA and VDDB on the PCA9615 so long as the 0-1 jumper is CLOSED (more on that in the following sections). VCC2 and GND2 are connected to the Ethernet Green pair intended for powering the buck regulator on any attached MidPoint(s). If users are powering the QwiicBus through either of these voltage inputs, the Bypass jumper on all MidPoints must be OPENED. Using the Green or Blue pair to provide voltage to the QwiicBus requires the proper power configuration covered in the Hardware Assembly section.

Lastly, you may notice the VCC2 and GND2 PTH pins on the EndPoint are labeled GRN and GRNW when viewed from the top. The Green pair can be used as an isolated signal line by opening the VDDA and GND jumpers on the EndPoint. Note, when using the Green pair in this way, make sure the GND2 jumper(s) on any attached MidPoints are opened.

Buck Regulator - MidPoint Only

The MidPoint includes the LMR33630 Simple Switcher® variable buck regulator from Texas Instruments®. The regulator accepts an input voltage between 3.8V to 36V so you can send higher voltages over the Ethernet cable to render any voltage drop over long cables negligable and the 3A@3.3V output provides a larger current source for any devices attached to the MidPoint. The LMR33630 has a variable voltage output that the MidPoint design sets to 3.3V.

Photo of QwiicBus MidPoint highlighting LMR33630 regulator circuit.

The buck regulator is not powered by default but the design features a dual jumper labeled PSEL users can adjust to enable the buck regulator to power the MidPoint(s) from a higher voltage (5V or 3.8V to 36V) via the Blue and Green pair pins broken out on the EndPoint and MidPoint. Read on to the Solder Jumpers sub-section below and the Hardware Assembly section for more information on how to use these alternate power configurations.

Note: While the buck regulator is rated for 3A, sourcing max current through the regulator continuously will cause it to heat up and decrease its efficiency. Running max current through the regulator for an extended period of time can also damage the IC and is not recommended.

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.

In this section we'll cover the jumpers found on both QwiicBus boards and their functionality, default state and a few things to take note of prior to adjusting them.

Since this guide covers both QwiicBus boards (EndPoint and MidPoint) we'll denote which jumpers are found on both boards as well as board-specific jumpers. The EndPoint's five jumpers are labeled: I2C, PWR, VDDA, GND and 0-1. The six MidPoint jumpers are labeled: I2C, PWR, BP, PSEL, GND1 and GND2.

Photo of QwiicBus MidPoint highlighting solder jumpers on the top of the boardPhoto of QwiicBus EndPoint highlighting solder jumpers on the bottom of the board
QwiicBus EndPoint Solder Jumpers - TopQwiicBus EndPoint Solder Jumpers - Bottom
Photo of QwiicBus MidPoint highlighting solder jumpers on the top of the boardPhoto of QwiicBus MidPoint highlighting solder jumpers on the bottom of the board
QwiicBus MidPoint Solder Jumpers - TopQwiicBus MidPoint Solder Jumpers - Bottom

I2C Pull-Up Jumper - EndPoint and MidPoint

This jumper connects the SDA and SCL lines to VDDA of the PCA9615 (normally 3.3V) via a pair of 4.7k&ohm; resistors. The jumper's default state is CLOSED. To disable the pull-up resistors open the jumper by severing the trace between the three pads.

Note:Each MidPoint will need its own set of pull-up resistors on the I2C side of the PCA9615. We recommend disabling any pull-up resistors on devices connected to the MidPoint's Qwiic connectors or the SDA/SCL pins since if multiple devices have their pull-up resistors enabled, the parallel equivalent resistance can create too strong of a pull-up for the bus to operate correctly.

Power (PWR) LED Jumper - EndPoint and MidPoint

This jumper connects the Power LED's cathode to 3.3V via a 1k&ohm; resistor. The jumper is CLOSED by default. Open the jumper by severing the trace between the two pads to disable the power LED on either QwiicBus board.

VDDA and GND Jumpers - EndPoint

The VDDA and GND jumpers connect VDDA (if the 0-1 jumper is closed) and Ground to the Green twisted pair on the RJ-45 jacks and Ethernet cable. Their default state is CLOSED. If users do not need the Green pair for a power input, these jumpers can be opened so that pair is avaiable for other data lines or redundant power connections. Most users will want to leave these jumpers alone. If using the Green pair as an independent signal, make sure the GND2 jumper on any MidPoints is OPEN.

0-1 Jumper - EndPoint

The 0-1 jumper nets VDDA and VDDB on the PCA9615 together. By default this jumper is CLOSED to power both VDDA and VDDB with the same supply voltage (3.3V in the default power configuration). Open this jumper if using two separate voltages for VDDA (VCC) and VDDB (VCC1). If using separate voltages, make sure they fall within the voltage ranges for VDDA (2.3V-5.5V) and VDDB (3.0V-5.5V).

Heads Up! When using any of the alternate power configurations, the 0-1 jumper on the primary / first EndPoint should be OPEN but the 0-1 jumper on the terminating / last should be CLOSED to avoid leaving VDDB on the terminating EndPoint floating. Take note that with the 0-1 jumper CLOSED, 5V is sent to the Qwiic connectors and 3.3V PTH pin on the terminating EndPoint.

Bypass (BP) Jumper - MidPoint

The Bypass jumper (labeled BP on the board) nets VCC1 with the 3.3V rail on the MidPoint. By default, this jumper is CLOSED. When the QwiicBus system is powered at 3.3V, this jumper can remain closed but if the PSEL jumper is adjusted to use anything over 3.3V to power the QwiicBus, this jumper must be OPEN.

Power Select (PSEL) Jumper - MidPoint

This dual jumper selects which voltage supplies the input voltage for the MidPoint buck regulator. The Power Select jumper defaults to all open and the buck regulator is unpowered. In this default setting, power for each EndPoint is 3.3V and provided over the Blue pair of the Ethernet cable from the microcontroller/SBC or dedicated 3.3V power supply.

If using the 5V power configuration, this jumper should be closed to set it to the "1" side. When set to "1", the input voltage is still provided over the Blue pair of the Ethernet cable but at 5V.

If using the 3.8V-36V power configuration, close the jumper to set it to the "2" side. When set to "2", input voltage is provided over the Green pair of the Ethernet cable.

Important! If either alternate setting of the PSEL Jumper is used, the Bypass Jumper must beOPEN.

GND1 and GND2 Jumpers - MidPoint

The GND1 and GND2 jumpers net both input voltages to a common ground. Both jumpers are CLOSED by default. In advanced-use cases, users can open one or both of these jumpers to reduce noise and/or prevent ground loops on QwiicBus boards further down the chain. Most users will want to leave these jumpers alone.

Board Dimensions

The QwiicBus EndPoint PCB measures identically to the Differential I2C Breakout at 1.75in x 1.00in (44.45mm x 25.40mm). The MidPoint measures 1.80in x 1in (45.72mm x 25.40mm) and is flared to 1.10in (27.94mm) wide at the RJ-45 end. The RJ-45 connectors extend roughly 0.30in (7.62mm)from the edge of the PCB on both boards.

EndPoint Dimensional Drawing

MidPoint Dimensional Drawing

Hardware Assembly

In this section we'll go over configuring your QwiicBus EndPoint and MidPoint as how to assemble the QwiicBus circuit. Before we start connecting anything there are a couple of things to take note of.

Ethernet Cables

Make sure your Ethernet cables are straight-through (i.e. Pin 1 on one end of the cable is connected to Pin 1 on the other end) and not crossover. Most Ethernet cables sold are straight-through so you probably have nothing to worry about here. If you're not sure what type of Ethernet cable you have, you can test for pin continuity with a digital multimeter.

Also take the voltage drop over the Ethernet cables into account. For longer chains or for circuits with many devices on multiple MidPoints, consider using one of the alternate power configurations so the voltage drop is negligible. The formula below can help you calculate the voltage drop at different lengths of CAT-6/Ethernet cable and whether or not you will need to consider one of the alternate power options:

In this formula, I is the current through the object in Amperes and R is the resistance of the wires in Ohms. Most CAT-6/Ethernet cable will have 24AWG internal wires and depending on the quality of the cable will be either copper or aluminum. Refer to a table like this one from PowerStream to determine the resistance in &ohm;/1000ft or &ohm;/km to help calculate the approximate voltage drop.

I2C Pull-Up Resistors

Take time to note which devices you will have connected to your EndPoint and MidPoint's I2C bus side have their pull-up resistors enabled and what voltage they are tied to. Almost all Qwiic products have pull-up resistors enabled by default that pull the SDA/SCL lines connected directly to the I2C bus to 3.3V.

The PCA9615 requires pull-up resistors on the two-wire I2C bus so each EndPoint and MidPoint must have at least one pair of pull-up resistors enabled on the two-wire side. The pull-up resistors do not translate through to the differential side of the PCA9615. To help make things a bit simpler, each QwiicBus EndPoint and MidPoint come with pull-up resistors on both SDA and SCL lines tied to VDDA. Normally, VDDA is 3.3V but can be as high as 5V on the EndPoint depending on the power configuration settings.

Note: If multiple devices are connected and you have a single device with pull-up resistors, make sure the voltage they are netted to is within the operating voltage range of all other I2C devices on the bus (normally 3.3V for Qwiic devices). If needed, you can shift the voltage to safe levels with a level shifter or voltage divider. If you're not familiar with logic levels and how to shift them, take a read through this tutorial.

Power Configuration Settings

As we mentioned in the Hardware Overview section of this guide, both QwiicBus boards feature a plethora of jumpers as well as two pairs of dedicated power PTH pins to configure how to power your QwiicBus circuit. Let's take a closer look at the three options available for powering the QwiicBus.

Important! When using alternate power configurations make sure to double check the jumpers on all EndPoints and MidPoints on your QwiicBus are set properly per the instructions below. Any QwiicBus boards or other Qwiic devices on your bus can be damaged if the circuit is assembled improperly.

Default - Entire System at 3.3V

In this configuration, the entire system is powered at 3.3V and the buck regulator(s) on the MidPoint(s) are unpowered. On the MidPoint(s), the Bypass jumper is CLOSED and both sides of the PSEL jumper are OPEN. 3.3V is provided either from your development board or single-board computer through the Qwiic connector or the 3.3V pin on the primary EndPoint.

Take note, in this configuration where all power is provided over the CAT-6/Ethernet cables, your total current draw will for attached devices will be limited to ~550mA with standard CAT-6/Ethernet cables due to the physical constraints of the wires inside. Anything beyond 550mA runs the risk of damaging the wires and can create a fire hazard.

The 3.3V supply voltage is then transferred from the initial EndPoint over the CAT-6/Ethernet cables in your QwiicBus system. Note that over long lengths of wire, you will see voltage drop and devices further down your QwiicBus chain may misbehave if the voltage drops below their operating range. Refer to the formula and links in the Ethernet Cables subsection above for calculating the voltage drop in your circuit.

Alternate 1 - VCC1 at 5V

While the default 3.3V configuration should work just fine for shorter QwiicBus chains, we found the PCA9615 functions better when powered with 5V. Powering VCC1 with 5V also allows us to also use the buck regulator on the MidPoint to source up to 3A@3.3V to devices connected to the MidPoint. Using this configuration requires adjusting both the EndPoint and MidPoint as well as multiple power supplies.

First and most importantly, the Bypass jumper on each MidPoint must beOPEN. On each MidPoint, adjust the PSEL jumper to the "1" side (see image below).

Photo of a MidPoint with PSEL and Bypass Jumpers adjusted properly for Alternate 1 power configuration

It is also strongly recommended to OPEN the 0-1 jumper on the primary / first EndPoint to isolate VCC (VDDA) from VCC1 (VDDB) but leave the 0-1 jumper on the terminating EndPoint CLOSED. Leaving the 0-1 jumper closed will send 5V to any Qwiic devices attached to your terminating / last EndPoint.

Photo of an EndPoint with the 0-1 jumper opened.

With the jumpers adjusted and your QwiicBus circuit assembled including any peripheral devices attached to your MidPoint(s), connect your 5V source to the VCC1 and GND PTH pins on the primary EndPoint. If the 0-1 jumper is opened, 3.3V should be provided over the Qwiic connectors or through the 3.3V PTH pin to power VCC (VDDA) on the primary EndPoint.

Alternate 2 - VCC2 at 3.8V to 36V

For this configuration, we use two separate voltages to power the EndPoints and MidPoint(s). First and most importantly, the Bypass jumper on each MidPoint must beOPEN. Adjust the PSEL jumper to the "2" position on each MidPoint.

Photo of a MidPoint with the PSEL and Bypass Jumpers adjusted for Alternate 2 power configuration

If you plan to power VCC1 with 5V it is recommended to OPEN the 0-1 jumper on the primary EndPoint to isolate VCC from VCC1. As covered above, we recommend leaving the 0-1 jumper CLOSED on the terminating EndPoint.

After adjusting the jumpers and assembling your QwiicBus circuit including any peripheral devices attached to your MidPoint(s), connect 3.8V to 36V to the VCC2 and GND2 PTH pins on the primary EndPoint. 3.3V for the first EndPoint should be provided from the microcontroller/SBC via the Qwiic connectors or a dedicated source through the 3.3V PTH pin.

Alternate 3 - VCC1 at 5V and VCC2 at 6V to 36V

This advanced configuration uses multiple power supply to allow for optimal performance of the QwiicBus over very long distances with multiple MidPoints. As mentioned above, we have found the QwiicBus operates best over long distances at 5V (particularly VDDB @5V). In this configuration, VCC1 is powered with 5V and VCC2 is powered with 6V-36V. Before connecting power supplies, a few jumpers must be adjusted.

First, the Bypass jumper on each MidPoint must beOPEN. Set the PSEL jumper on all MidPoints to the "2" position. The 0-1 jumper on the primary EndPoint is OPEN and the 0-1 jumper on the terminating EndPoint is CLOSED. This isolates VDDA and VDDB on the first EndPoint so the Qwiic connectors on the first EndPoint are at 3.3V. As we mentioned before, the Qwiic connectors and 3.3V PTH pin on the terminating EndPoint will be at 5V so be careful what is connected to that EndPoint.

After adjusting jumpers on all the QwiicBus boards and assembling the rest of your circuit (including connecting any Qwiic devices to MidPoints/EndPoints), connect the 5V power supply to the VCC1 and GND PTH pins and the power supply sourcing 6V to 36V to the VCC2 and GND2 PTH pins to the primary EndPoint.

Assembling the QwiicBus Circuit

Important! Make sure your QwiicBus circuit is not powered when adding or removing devices to your MidPoint(s) and EndPoint. Connecting and disconnecting devices while your QwiicBus is powered can cause voltage spikes and damage the PCA9615.

After taking into consideration how you intend to configure your QwiicBus circuit it's time to assemble it. Adjust the appropriate jumpers (if necessary), connect any Qwiic/I2C devices to the EndPoints and MidPoint(s) and connect the QwiicBus boards to each other with Ethernet cable plugged into the RJ-45 connectors on each board. Once the devices are all connected together, power up the circuit. The photo below shows the QwiicBus assembled in the default configuration (all boards powered with 3.3V) so your circuit may differ.

Photo of a completed QwiicBus Kit circuit in default power configuration
A completed QwiicBus Kit circuit using a SparkFun RedBoard Qwiic and operating at 3.3V

With everything adjusted and connected properly, that's all you need to assemble your QwiicBus circuit. Go forth and build ridiculously long, wired I2C circuits to your heart's content!

Troubleshooting

Here a few troubleshooting tips for the SparkFun QwiicBus.

I2C Communication

The PCA9615 supports I2C clock speeds up to 1MHz at short distances but as the cable length increases, high clock speeds can become more unreliable. If you find you are losing data or having unreliable communication on your QwiicBus, try reducing the clock speed as a quick software fix. Switching to one of the alternate power configurations can also help boost the reliability over long distances at high clock speeds.

Voltage Drop

Over long distances of cable the voltage may drop below the operating voltage range of the PCA9615 or attached devices. The formula below can help you calculate the voltage drop at different lengths of CAT-5/Ethernet cable and whether or not you will need to use one of the alternate power options:

I is the current through the object in Amperes and R is the resistance of the wires in Ohms. Most CAT-5/Ethernet cable will have 24AWG internal wires and depending on the quality of the cable will be either copper or aluminum. Refer to a table like this one from PowerStream to determine the resistance in Ω/1000ft or Ω/km to help calculate the approximate voltage drop over your QwiicBus circuit.

Recommended Power-Up/Power-Down Procedure

Remember to power down the QwiicBus circuit before connecting or disconnecting any devices to the chain. Connecting or disconnecting devices to the QwiicBus can damage the PCA9615 on the QwiicBus boards if it is powered on.

Floating VDDB on the Terminating EndPoint

Reminder, when using any of the alternate power configurations, the 0-1 jumper on the primary / first EndPoint should be OPEN but the 0-1 jumper on the terminating / last should be CLOSED to avoid leaving VDDB on the terminating EndPoint floating. Take note that with the 0-1 jumper CLOSED, 5V is sent to the Qwiic connectors and 3.3V PTH pin on the terminating EndPoint.

General Troubleshooting

Resources and Going Further

Now that you have your QwiicBus set up and configured to your liking, it's time to start creating some I2C device networks! For more information, take a look at the following links:

QwiicBus EndPoint Links

QwiicBus MidPoint Links

For inspiration for your I2C project using the QwiicBus, check out the following tutorials:

ESP32 Thing Plus Hookup Guide

Hookup guide for the ESP32 Thing Plus using the ESP32 WROOM's WiFi/Bluetooth system-on-chip in Arduino.

SparkFun Qwiic Micro (SAMD21E) Hookup Guide

An introduction to the Qwiic Micro SAMD21E. Level up your Arduino-skills with the powerful SAMD21 ARM Cortex M0+ processor!

Assembly Guide for SparkFun JetBot AI Kit V2.0

Assembly Guide for the SparkFun JetBot AI Kit v2.0. This tutorial includes photos & comments to assemble the two-layer chassis & additional components unique to the JetBot kit.

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!

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

Qwiic MultiPort Hookup Guide

$
0
0

Qwiic MultiPort Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Qwiic Multiport adds additional ports to boards that have only one Qwiic port on their I2C bus. Once added, you can use it as a hub to add as many I2C devices to the bus as you need [1] ! You can also use the board as an alternative to a daisy chained configuration.

SparkFun Qwiic MultiPort

SparkFun Qwiic MultiPort

BOB-18012
$1.95

Required Materials

To follow along with this tutorial, you will need a microcontroller or single board computer with a Qwiic connector. You will also need a Qwiic cable and a way to power the board. 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.

Besides having the Qwiic MultiPort in your cart, here are the parts if you decide to go with a microcontroller. You can easily swap out the microcontroller depending on your project's needs with MicroMod. Make sure to include the Qwiic-enabled device in your cart as well!

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
10
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
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2

Here are the parts if you decide to go with a single board computer. The Qwiic SHIM kit is a great starting point if you do not have a Qwiic-enabled device in mind.

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

KIT-16386
$159.95
SparkFun Qwiic SHIM Kit for Raspberry Pi

SparkFun Qwiic SHIM Kit for Raspberry Pi

KIT-16987
$29.95

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 LogoQwiic Connect System
MicroMod EcosystemQwiic Connect System

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

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.

Raspberry Pi 4 Kit Hookup Guide

Guide for hooking up your Raspberry Pi 4 Model B basic, desktop, or hardware starter kit together.

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

The board is a simple design that allows you to connect devices to the I2C bus easily with the Qwiic Connect System. Power and logic levels are set to 3.3V. Make sure to use a logic level converter if your board uses a voltage higher than 3.3V.

Wire Color Signal
Black GND
Red 3.3V
Blue SDA
Yellow SCL

Qwiic Connectors

There are 4x Qwiic connectors populated on the board.

alt text

LED and Jumper

In addition to the connectors, there is an LED to indicate when power is available on the I2C bus. On the back, there is a jumper in case you would like to disable the LED.

Front of BoardBack of Board

Mounting Holes

There are 2x mounting holes included on the board.

Mounting Holes

Board Dimensions

Below are the board dimensions. The overall size of the board is 1.00" x 1.00". Each connector extending from the center has a width of about 0.30". As stated earlier, this board has 2x mounting holes located around the center.

Board Dimensions

Hardware Assembly

Expanding on Boards with One Qwiic Connector

Depending on the design, there may only be enough room for one Qwiic connector. Below are a few of these boards from the SparkFun catalog

SparkFun 16x2 SerLCD - RGB Backlight (Qwiic)

SparkFun 16x2 SerLCD - RGB Backlight (Qwiic)

LCD-16396
$19.95
SparkFun GPS Breakout - ZOE-M8Q (Qwiic)

SparkFun GPS Breakout - ZOE-M8Q (Qwiic)

GPS-15193
$44.95
5
SparkFun Power Delivery Board - USB-C (Qwiic)

SparkFun Power Delivery Board - USB-C (Qwiic)

DEV-15801
$24.95
2
SparkFun 16x2 SerLCD - RGB Text (Qwiic)

SparkFun 16x2 SerLCD - RGB Text (Qwiic)

LCD-16397
$19.95
1
SparkFun 20x4 SerLCD - RGB Backlight (Qwiic)

SparkFun 20x4 SerLCD - RGB Backlight (Qwiic)

LCD-16398
$24.95
4
SparkFun Qwiic Soil Moisture Sensor

SparkFun Qwiic Soil Moisture Sensor

SEN-17731
$8.50

If you are looking to connect more than one device with one Qwiic connector to your development board, you will just need a Qwiic MultiPort board and an additional Qwiic cable for each device.

Qwiic MultiPort Connecting Several I2C Devices with One Qwiic Connector on the Qwiic MicroMod Breakout

Alternative to a Daisy Chained Configuration

The Qwiic MultiPort can also be used as a hub so that you do not have to place the board with one Qwiic connector at the end of the daisy chain. Below is an example with the Qwiic SHIM Kit for Raspberry Pi. Instead of having the Qwiic 9DoF between the Pi and Qwiic SerLCD,

Raspberry Pi Connecting to the Qwiic SHIM Kit

Mounting with Standoffs

The two boards can be mounted with standoffs for a secure connection. Below is the Qwiic Micro (SAMD21), Qwiic MultiPort, Qwiic GPS (ZOE-M8Q), and a GPS antenna (W3062A) connected stacked on top of each other. They are all connected to the Qwiic SerLCD connect using Qwiic cables (with the exception of the antenna).

Qwiic MultiPort Mounted to the Board

Resources and Going Further

Now that you've connected your Qwiic MultiPort, it's time to incorporate it into your own project! For more information, check out the resources below:

Looking for inspiration? Check out any of the tutorials tagged with Qwiic for ideas on what to connect to your Qwiic system!

Qwiic Flex Glove Controller Hookup Guide

Is your finger bent? Is your finger straight? The Qwiic Flex Glove controller board will answer this age old question for you with the flex sensor!

Pi Servo pHAT (v2) Hookup Guide

This hookup guide will get you started with connecting and using the Pi Servo pHAT on a Raspberry Pi.

Real Time Clock Module - RV-8803 (Qwiic) Hookup Guide

A Hookup Guide for the SparkFun Real Time Clock Module - RV-8803 (Qwiic). Learn how to integrate the RV-8803 into your next time-keeping project.

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.

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

ESP32-S2 Thing Plus Hookup Guide

$
0
0

ESP32-S2 Thing Plus Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The ESP32-S2 Thing Plus is a feather form-factor development board with the improved ESP32-S2 module, from Espressif. The new ESP32-S2 module addresses the security flaws in the original ESP32. While the ESP32-S2 does include improved security features, it lacks the Bluetooth capabilities of the original ESP32 module.

SparkFun Thing Plus - ESP32-S2 WROOM

SparkFun Thing Plus - ESP32-S2 WROOM

WRL-17743
$19.95

Required Materials

To get started, users will need a few items. Now some users may have a few of these items, feel free to modify your cart accordingly.

  • ESP32-S2 Thing Plus
  • USB 3.1 Cable A to C - 3 Foot - The USB interface serves two purposes: it powers the board and allows you to upload programs to it. (*If your computer doesn't provide a USB-A slot, then you will need to choose an appropriate cable or purchase an adapter as well.)
  • Computer with the an operating system (OS) that is compatible with all the software installation requirements.
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
SparkFun Thing Plus - ESP32-S2 WROOM

SparkFun Thing Plus - ESP32-S2 WROOM

WRL-17743
$19.95

Click the buttons above to toggle the additional materials based on the options you
wish to use. Feel free to modify the items in your cart to fit your needs.

Li-Po Battery

For mobile applications, users will want to pick up a single-cell LiPo battery from our catalog. Below, are a few available options:

Lithium Ion Battery - 400mAh

Lithium Ion Battery - 400mAh

PRT-13851
$4.95
9
Lithium Ion Battery - 2Ah

Lithium Ion Battery - 2Ah

PRT-13855
$12.95
7
Lithium Ion Battery - 1Ah

Lithium Ion Battery - 1Ah

PRT-13813
$9.95
7
Lithium Ion Battery - 110mAh

Lithium Ion Battery - 110mAh

PRT-13853
$4.95
2

Jumper Modification

To modify the jumpers, users will need soldering equipment and/or a knife.

Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$8.95
7
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$7.95
3
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$44.95
2
Hobby Knife

Hobby Knife

TOL-09200
$2.95
2

Headers & Accessories

Headers are great for development purposes, letting users swap parts with just a set of jumper wires. If you would like to add headers to your board, check out some of the options for the Thing Plus or Feather form factor boards below. For a full selection of our available Headers or Soldering Tools, click on the associated links.

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
SparkFun Beginner Tool Kit

SparkFun Beginner Tool Kit

TOL-14681
$57.95
Feather Stackable Header Kit

Feather Stackable Header Kit

PRT-15187
$1.50
Photon Header - 12 Pin Female

Photon Header - 12 Pin Female

PRT-14321
$0.50
Header - 8-pin Female (PTH, 0.1")

Header - 8-pin Female (PTH, 0.1")

PRT-11895
$0.50

New to soldering? Check out our Through-Hole Soldering Tutorial for a quick introduction!

How to Work with Jumper Pads and PCB Traces

April 2, 2018

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.

JTAG Functionality

Users interested in JTAG applications (i.e. programming and debugging the ESP32) will need an JTAG Programmer and need to solder on a JTAG header. We recommend these programmers from our catalog:

J-Link EDU Base Programmer

J-Link EDU Base Programmer

PGM-15346
$60.00
1
J-Link BASE Compact Programmer

J-Link BASE Compact Programmer

PGM-15347
$378.00
Header - 2x5 Pin (Male, 1.27mm)

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.50

Suggested Reading

As a more professionally oriented product, we will skip over the more fundamental tutorials (i.e. Ohm's Law and What is Electricity?). However, below are a few tutorials that may help users familiarize themselves with various aspects of the board.

How to Solder: Through-Hole Soldering

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

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.

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.

Analog vs. Digital

This tutorial covers the concept of analog and digital signals, as they relate to electronics.

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.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

ESP32 Thing Plus Hookup Guide

Hookup guide for the ESP32 Thing Plus using the ESP32 WROOM's WiFi/Bluetooth system-on-chip in Arduino.

Installing Board Definitions in the Arduino IDE

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Qwiic Connect System

One of the new, advanced features of the board is that it takes advantage of the Qwiic connect system. We recommend familiarizing yourself with the Logic Levels and I2C tutorials. Click on the banner above to learn more about Qwiic products.

Hardware Overview

Board Dimensions

The board dimensions are illustrated in the drawing below. The listed measurements are in inches and the two mounting holes are compatible with 4-40 standoff screws.

Board Dimensions
[Board dimensions (PDF)]( for the ESP32-S2 Thing Plus, in inches. (Click to enlarge)

USB-C Connector

The USB connector is provided to power and program the board. For most users, it will be the primary programing interface for the ESP32-S2.

USB-C Connector
USB-C connector on the ESP32-S2 Thing Plus. (Click to enlarge)

TC7USB40MU USB Switch

The TC7USB40MU is used to switch the data lines for the USB-C connection, between the ESP32-S2 module's native USB pins or its UART pins, through a CP2102 Serial-to-UART bridge. There is a jumper on the back of the board to control the USB switch; by default, the data lines from the USB-C connector are tied to the CP2102 Serial-to-UART bridge.

USB Switch
Functional block diagram for the TC7USB40MU USB switch. (Click to enlarge)

CP2102 Serial-to-UART

The CP2102 allows the ESP32-S2 to communicate with a computer/host device through its USB-C connection. This allows the board to show up as a device on the serial (or COM) port of the computer. Users will need to install the latest drivers for the computer to recognize the board (see Software Overview section).

Power

The ESP32-S2 Thing Plus only requires 3.3V to power the board. However, the simplest method to power the board is with the USB-C connector. There are additional power pins available on the board:

  • 3.3V - A regulated 3.3V voltage source.
    • Regulated from the USB 5V power and/or battery connection.
    • Used to power the ESP32-S2 module and Qwiic I2C bus.
  • USB - The voltage from the USB-C connector, usually 5V.
  • VBAT - The voltage from the JST battery connector; meant for single cell LiPo batteries.
  • GND - The common ground or the 0V reference for the voltage supplies.

Power connections
ESP32-S2 Thing Plus power connections. (Click to enlarge)

Charging Circuit

The charging circuit utilizes the MCP73831 linear charge management controller and is powered directly from the USB-C connector or USB. The controller is configured for a 500mA charge rate by default; there is a jumper on the back of the boards for users to lower the charge rate to 100mA. Battery charging is indicated when the yellow, CHG LED. If the charge controller is shutdown or charging is complete, the CHG LED will turn off. For more information, please refer to the MCP73831 datasheet.

ESP32-S2 Module

The ESP32-S2 WROOM module from Espressif is the brains of the ESP32-S2 Thing Plus. While the new ESP32-S2 module does include improved security features to addresses the security flaws in the original ESP32, it lacks the Bluetooth capabilities of the original module. For more details check out the datasheets for the ESP32-S2 chipset and the ESP32-S2 WROOM module.

  • Xtensa® Single-Core 32-bit LX7 Microprocessor (up to 240MHz)
    • RISC-V ULP Coprocessor
    • 128KB ROM and 320KB SRAM
    • 4MB of Embedded SPI Flash Storage
  • Cryptographic Hardware Accelerators
    • AES, ECB/CBC/OFB/CFB/CTR, GCM, SHA, RSA, and ECC (Digital Signature)
  • Physical Security Features
    • Transparent external flash and RAM encryption (AES-XTS)
    • Secure Boot feature ensures only signed firmware (with RSA-PSS signature) is booted
    • HMAC and Digital Signature modules use software inaccessible keys to generate SHA-MAC and MAC signatures
  • Integrated 802.11 b/g/n WiFi 2.4GHz Transceiver (up to 150Mbps)
  • Integrated Temperature Sensor (-20°C to 110°C)
  • 34 GPIO (excluding strapping pins)
    • 1x USB OTG Interface
    • 1x DVP Camera Interface
    • 1x LCD Interface
  • Operating Voltage: 3.0 to 3.6V
    • WiFi: 310mA (peak)
    • Light-Sleep: 550µA
    • Deep-Sleep: 20-235µA
ESP32-S2
ESP32-S2 module on the ESP32-S2 Thing Plus. (Click to enlarge)

Note: Users should be aware of the following nuances and details of this board

Note: While most users will utilize the USB connection for serial programming, the ESP32-S2 can also be programmed through its JTAG or SWD pins. This might is useful for individuals developing and debugging firmware that would be flashed directly onto the module, such as in production for commercial applications.

ESP32-S2 Thing Plus's JATG pins
The JTAG pins on the ESP32-S2 Thing Plus. (Click to enlarge)

Peripherals and I/O

Note: Users should be aware of the following nuances of this board

The pins from the ESP32-S2 module are broken out into a feather form factor layout. There are 21 I/O pins broken out on this board, with 8 I/O pads on the back of the board. All of the ESP32-S2 Thing Plus pins are broken out with .1" pitch spacing for headers. With the ESP32's pin multiplexing, various pins will be capable of several functionalities. For more technical specifications on the I/O pins, you can refer to the ESP32-S2 datasheet.

  • 16x 12-bit ADC Channels
  • 2x 8-bit DAC
  • 14x Capacitive Touch Sensing
  • 4x SPI (only one is configured by default in the Arduino IDE)
  • 1x I2S
  • 2x I2C (only one is configured by default in the Arduino IDE)
  • 2x UART (only two are configured by default in the Arduino IDE, one UART is used for bootloading/debug)
  • 8x PWM Channels
  • 1x DVP Camera Interface
  • 1x LCD Interface

Graphical datasheet
Graphical datasheet for the ESP32-S2 Thing Plus. (Click to enlarge)

Note: Users should be aware of the following limitations for the board in the Arduino IDE.

  • Not all of the features, listed above, are available in the Arduino IDE. For the full capabilities of the ESP32-S2, the Espressif IDF should be utilized.
  • Only one I2C bus is defined.
  • Only two UART interfaces are available.
    • UART (USB):Serial
    • RX1/TX1 Pins:Serial1
  • Only one SPI bus is defined.
  • The bit-width for the ADC2 channels needs to be set when reading ADC values.
    • Setting the bit-width before taking any ADC readings doesn’t work; the bit-width must be set, when the making ADC readings.

Buttons

There are two buttons on ESP32-S2 Thing Plus; a Reset and IO0 button.

Reset Button

The reset (RST) button allows users to reset the program running on the ESP32-S2 module without unplugging the board.

Reset Button
Reset button on the ESP32-S2 Thing Plus. (Click to enlarge)

User Button

Note: In order to utilize the user button, connected to IO 0, the pin mode will need to be configured as an input with an internal pullup (i.e. INPUT_PULLUP); see an example below.

pinMode(D0, INPUT_PULLUP);

The user (0 ) button allows users to short IO 0 to ground (GND).

IO 0 Button
IO 0 button on the ESP32-S2 Thing Plus. (Click to enlarge)

Indicator LEDs

There are two indicator LEDs on the ESP32-S2 Thing Plus:

  • Status/Pin 13 (Blue)
  • Battery Charging (Yellow)

Battery Charging LED

The yellow, CHG LED will light while a battery is being charged through the charging circuit. The LED will be off when no battery is present (*dimmed), when the charge management controller is in standby (after the battery charging has been completed), or when the charge management controller is shutdown. The LED will be on when the charge management controller is in the process of charging the battery. For more information, please refer to the MCP73831 datasheet.

Charge LED
The battery charging (CHG) LED indicator on the ESP32-S2 Thing Plus. (Click to enlarge)
Charge Cycle StateSTAT1
Shutdown
  • Thermal Shutdown
  • VDD< VBAT
Off (High Z)
No Battery PresentDimmed (High Z)
Charge Complete – StandbyOff (H)
PreconditioningOn (L)
Constant-Current Fast ChargeOn (L)
Constant VoltageOn (L)

STAT LED

The blue, status (13) LED is typically used as a test or status LED to make sure that a board is working or for basic debugging. This indicator is connected to GPIO 18.

Status LED
The status (13) LED indicator on the ESP32-S2 Thing Plus. (Click to enlarge)

Jumpers

There are three jumpers on the back of the board that can be used to easily modify the hardware connections on the board.

  • USB - This jumper can be used to control the USB-C data line connections through the TC7USB40MU USB switch.
    • By default, the data lines are connected to the CP2102 Serial-to-UART bridge; and therefore, tied to the ESP32-S2's UART pins.
  • CHG - This jumper can be used to modify the charging rate to the LiPo JST connector.
    • By default, the charge rate is configured to 500mA.
  • GPIO18PU - This jumper can be used to disconnect the pull-up resistor on GPIO18.
Jumpers
The jumpers on the back of the ESP32-S2 Thing Plus. (Click to enlarge)

Never modified a jumper before? Check out our Jumper Pads and PCB Traces tutorial for a quick introduction!

How to Work with Jumper Pads and PCB Traces

April 2, 2018

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.

Primary I2C Bus

The Qwiic connector is attached to the primary I2C bus. The primary I2C bus for this board utilizes the pin connections, detailed in the table below:

Connection VDDGNDSCLSDA
Pad Number
(ESP32-S2 module)
3.3VGNDIO1IO2
Qwiic Connector

A Qwiic connector is provided for users to seamlessly integrate with SparkFun's Qwiic Ecosystem.

qwiic connector
Qwiic connector and I2C pins on the ESP32-S2 Thing Plus. (Click to enlarge)

What is Qwiic?

The Qwiic system is intended a quick, hassle-free cabling/connector system for I2C devices. Qwiic is actually a play on words between "quick" and I2C or "iic".

Features of the Qwiic System

Keep your soldering iron at bay.

Cables plug easily between boards making quick work of setting up a new prototype. We currently offer three different lengths of Qwiic cables as well as a breadboard friendly cable to connect any Qwiic enabled board to anything else. Initially you may need to solder headers onto the shield to connect your platform to the Qwiic system but once that’s done it’s plug and go!

Qwiic Cable and Board

Qwiic cables connected to Spectral Sensor Breakout

Minimize your mistakes.

How many times have you swapped the SDA and SCL wires on your breadboard hoping the sensor will start working? The Qwiic connector is polarized so you know you’ll have it wired correctly, every time, from the start.

The PCB connector is part number SM04B-SRSS (Datasheet) or equivalent. The mating connector used on cables is part number SHR04V-S-B or equivalent. This is a common and low cost connector.

JST Connector

1mm pitch, 4-pin JST connector

Expand with ease.

It’s time to leverage the power of the I2C bus! Most Qwiic boards will have two or more connectors on them allowing multiple devices to be connected.

Software Overview

Installing the CP2104 USB Driver

Note: Make sure to manually install the driver for the CP210X with the following instructions. The driver that Windows auto-installs will not work with the auto-reset circuit on the board and cause serial uploads to fail.

Users will need to install the SiLabs CP2104 Driver, which can be found here: USB to UART Bridge VCP Driver

Note: If applicable, make sure you are using the proper driver files for your CPU architecture. This is usually indicated by a folder or file name with "x86" for 32-bit processors or "x64" for 64-bit processors.

Arduino IDE

Note: For first-time users, who have never programmed before and are looking to use the Arduino IDE, we recommend beginning with the SparkFun Inventor's Kit (SIK), which includes a simpler board like the Arduino Uno or SparkFun RedBoard and is designed to help users get started programming with the Arduino IDE.

Most users may already be familiar with the Arduino IDE and it's use. However, for those of you who have never heard the name Arduino before, feel free to check out the Arduino website. To get started with using the Arduino IDE, check out our tutorials below:

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.

What is an Arduino?

What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Installing Board Definitions in the Arduino IDE

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Install Board Definition

Installing Development Arduino Core:

Currently, the ESP32 Arduino core hasn't been updated to include support for the ESP32-S2. However, there is a branch in development that users can use to get a head start on their development in the Arduino IDE. For more information, please refer to the Installation Instructions from the GitHub repository. (*User will need to have Git installed and be familiar with utilizing the command prompt.)

  1. Install the latest ESP32 Arduino core, through the Ardiuno IDE Boards Manager.
  2. Locate the hardware folder for the Espressif ESP32 Arduino core. Depending on your operating system, IDE version, and IDE type (i.e. store App, .zip file installation, or .exe installation), the folder location may vary. For our computers, the folder for the Arduino IDE was located in the Documents folder. From there, depending on how the Arduino IDE was installed, the folder for the ESP32 Arduino core was in one of the following locations:
    • Arduino\hardware\espressif\esp32
    • ArduinoData\packages\esp32\hardware\esp32\<version_number>
  3. Delete the file contents.
    hardware folder contents
    Example of file contents. (Click to enlarge)
  4. Using the command prompt (or terminal), clone the master branch of the ESP32 Arduino core from the GitHub repository with the following command: git clone https://github.com/espressif/arduino-esp32.git
    cloning GItHub repo into folder
    Cloning GiHub repository. (Click to enlarge)
  5. Using the command prompt (or terminal), change directories into the arduino-esp32 folder. Then, update the submodules with the following command: git submodule update --init --recursive
    changing directory and updating submodule
    Updating submodules. (Click to enlarge)
  6. Move the contents from the arduino-esp folder up a directory (i.e. into the folder the arduino-esp folder resides in).
    moving file contents
    Moving the file contents back into the appropriate directory. (Click to enlarge)

    *In step 4, users could also have modified the command to clone the GitHub repository into the current directory, but the command varies by system:
    • git clone https://github.com/espressif/arduino-esp32.git .\
    • git clone https://github.com/espressif/arduino-esp32.git && \
  7. Using the command prompt (or terminal), change directories into the tools folder. Then, execute the get.py(or get.exe) file (depending on your operating system) to install the required tools. Using the command prompt, this is done with the command: python get.py. For more details, please refer to the Installation Instructions from the GitHub repository.
    install tools
    Installing required tools. (Click to enlarge)

Users should now, be able to open the Arduino IDE and select the ESP32-S2 Thing Plus board and upload code.

board selection
ESP32-S2 Thing Plus is available in the board options. (Click to enlarge)
code upload
Successfully uploading code to the ESP32-S2 Thing Plus. (Click to enlarge)

Note: Once Espressif releases a new Arduino core supporting the ESP32-S2, users will need to uninstall (and possibly manually delete the installed files), from the instructions above; before re-installing the latest board definitions.

Install the latest ESP32 board definitions in the Arduino IDE.

Installing Board Definitions in the Arduino IDE

September 9, 2020

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Note: For more instructions, users can follow this tutorial on Installing Additional Cores provided by Arduino. Users will also need the .json file for the Espressif Arduino Core:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Hardware Assembly

USB Programming

The USB connection is utilized for programming and serial communication. Users only need to plug their ESP32-S2 Thing Plus into a computer using a USB-C cable.

ESP32-S2 Thing Plus USB connection
The ESP32-S2 Thing Plus with USB-C cable attached. (Click to enlarge)

Battery

For remote IoT applications, a Li-Po battery can be connected. Additionally, users may be interested in utilizing a solar panel and USB-C cable to recharge their battery.

Battery connected to the ESP32-S2 Thing Plus
The ESP32-S2 Thing Plus with a battery connected. (Click to enlarge)
Solar Panel Charger - 10W

Solar Panel Charger - 10W

PRT-16835
$18.95
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2

Qwiic Devices

The Qwiic system allows users to effortlessly prototype with a Qwiic compatible I2C device without soldering. Users can attach any Qwiic compatible sensor or board, with just a Qwiic cable. (*The example below, is for demonstration purposes and is not pertinent to the board functionality or this tutorial.)

Qwiic devices connected to ESP32-S2 Thing Plus
The Qwiic XA110 GPS breakout board and Micro OLED board connected to the ESP32-S2 Thing Plus.

Arduino Examples

Blink

To verify the toolchain and board are properly set up on their computer, users can upload the simplest of sketches -- Blink! The LED attached to GPIO 13 is perfect for this test. Plus, with the ESP32 attached to your computer, this is a good time to test out serial communication. Copy and paste the example sketch below into a fresh Arduino sketch:

language:c
int ledPin = 13;

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. Users should see Hello, world!'s begin to fly by.

If the blue LED remains dimly lit, it's probably still sitting in the bootloader. After uploading a sketch, users may need to tap the RESET button to get your ESP32-S2 Thing Plus to begin running the sketch.

Example serial port output

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.

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. Users 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 = 13;

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 button 0 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 to fill in the networkName and networkPswd variables with the name (or SSID) and password of your WiFi network! Then upload the code, open the Serial Monitor.

WiFi example serial terminal output

After the ESP32-S2 connects to the WiFi network, it will wait for users to press the 0 button. 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.

Troubleshooting

Resources and Going Further

For more inspiration, check out these other ESP32 tutorials:

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.

ESP32 Environment Sensor Shield Hookup Guide

SparkFun's ESP32 Environment Sensor Shield provides sensors and hookups for monitoring environmental conditions. This tutorial will show you how to connect your sensor suite to the Internet and post weather data online.

MicroPython Programming Tutorial: Getting Started with the ESP32 Thing

MicroPython is an implementation and subset of the Python 3 programming language that can be used on microcontrollers. This guide will walk you through writing MicroPython programs for the ESP32 Thing development board.

LuMini 8x8 Matrix Hookup Guide

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

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

Garmin LIDAR-Lite v4 (Qwiic) Hookup Guide

$
0
0

Garmin LIDAR-Lite v4 (Qwiic) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The new Garmin® LIDAR sensor is now easier to use, as a Qwiic device. The Garmin® LIDAR-Lite v4 (Qwiic), fuses the advanced measurement technology of Garmin®'s LIDAR-Lite v4 sensor with the simplicity of SparkFun's Qwiic connect system, for rapid prototyping.

Garmin LIDAR-Lite v4 LED - Distance Measurement Sensor (Qwiic)

Garmin LIDAR-Lite v4 LED - Distance Measurement Sensor (Qwiic)

SEN-18009
$69.95

The LIDAR sensor is ideal for drone, robot, IoT, or unmanned vehicle operations, with a range up to 10 meters and 1 cm resolution. Check out the video below for an overview of the product features.

Required Materials

The Qwiic LIDAR-Lite v4 does need a few additional items for you to get started. The RedBoard Qwiic will be used for the Arduino examples. 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
10
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
USB micro-B Cable - 6 Foot

USB micro-B Cable - 6 Foot

CAB-10215
$4.95
13
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
2
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
8
SparkFun Thing Plus - SAMD51

SparkFun Thing Plus - SAMD51

DEV-14713
$19.95
1
In addition we also offer, Qwiic compatible stackable shields for microcontrollers that don't include a Qwiic connector.
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic Shield for Thing Plus

SparkFun Qwiic Shield for Thing Plus

DEV-16790
$4.25
SparkFun Qwiic Shield for Teensy

SparkFun Qwiic Shield for Teensy

DEV-17119
$4.25
1
SparkFun Qwiic Shield for Arduino Nano

SparkFun Qwiic Shield for Arduino Nano

DEV-16789
$4.25
You will also need a Qwiic cable to connect to your Qwiic device, choose a length that suits your needs.
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50

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.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

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.

Arduino Shields v2

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

Qwiic Connect System

The Garmin LIDAR-Lite v4 (Qwiic) 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.

Hardware Overview

Board Dimensions

The Garmin LIDAR-Lite v4 (Qwiic) has an attached 1" x 1" Qwiic board for ease of use. The overall product dimensions are approximately 2.8" x 1.0" x 0.9" (L x W x H), with more detailed measurements in the drawing below.

Board Dimensions
Board dimensions (PDF) for the Garmin LIDAR-Lite v4 (Qwiic), in inches. (Click to enlarge)

Mounting Options

The Garmin LIDAR-Lite v4 operation manual lists zipties and double-sided tape as attachment methods. There are notches on the sensor housing that appear to be meant for a ziptie.

Mounting hole locations
Screw holes and zip-tie notches on the Qwiic LIDAR-Lite v4. (Click to enlarge)

With our Qwiic version, we provide two screw holes on the Qwiic board as an additional mounting option. The holes are compatible with 4-40 screws and hardware.

Power

There is a power status LED to indicate when the Garmin LIDAR-Lite v4 (Qwiic) sensor is powered. Either the polarizedQwiic connector system or the breakout pins (3.3V or 5V 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 pins and LED
Power LED and power breakout pins on the Qwiic LIDAR-Lite v4. (Click to enlarge)

DC-DC Converter

The Garmin LIDAR-Lite v4 sensor requires 5V to operate. In order to provide 5V to the sensor from the 3.3V line of the Qwiic connector, a DC-to-DC voltage converter is utilized. This can also be referred to as the buck/boost converter/circuit. For more details, check out the XC9140 datasheet.

boost converter
Boost converter on the Qwiic LIDAR-Lite v4. (Click to enlarge)

Garmin LIDAR-Lite v4

The Garmin® LIDAR-Lite v4 is a distance measurement sensor. For more details on the sensor, please refer to the operation manual and technical specifications.

LIDAR sensor
Garming® LIDAR-Lite v4 sensor. (Click to enlarge)
Note: For the sensor's compliance and safety information, please refer to the safety and product information documentation.

Sensor Characteristics

⚡ Note:

The power and current consumption characteristics listed below are from the operation manual and technical specifications. However, these specifications are for the sensor itself.

To prevent brown outs, users should be wary when attaching several Qwiic LIDAR-Lite v4s to the Qwiic connect system. Users can easily surpass the current (supply) limitation of their Qwiic microcontroller board. The Qwiic LIDAR-Lite v4 operates at 3.3V and we have measured the current consumption from the 3.3V line to be approximately:

  • 120mA (idle)
  • 165mA (during an acquisition)

Below, are the LIDAR sensor's electrical and performance characteristics, as listed in the operation manual and technical specifications datasheet.

CharacteristicDescription
Power (operating voltage)4.75 to 5.25 Vdc
Current Consumption2 mA idle
85 mA during an acquisition
I/O Voltage3.3 V Max Range5 cm to 10 m (1.97 in. to 32.8 ft.)Resolution1 cm (0.4 in.)Beam divergence4.77 degreesLED Wavelengtd940 nmOptical Aperture14.9 mmMeasurement Repeatability*± 1 cm up to 2 m
± 2 cm up to 4 m
± 5 cm up to 10m
I2C Address0x62 (Default)
Software configurable

*NOTE: As measured indoors to a 90% reflective target; 1 cm is equivalent to 1 standard deviation. Measurements were obtained using high accuracy mode.

Qwiic and I2C

I2C Address

The Garmin LIDAR-Lite v4 (Qwiic)’s I2C address, 0x62 (7-bit), is factory set. However, this address is software configurable.

Qwiic Connectors

The simplest way to use the Garmin LIDAR-Lite v4 (Qwiic) 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 on the Qwiic LIDAR-Lite v4. (Click to enlarge)

Breakout Pins

⚡ Note: Excluding the 5V pin, the rest are 3.3V pins.

The board also provides eleven labeled breakout pins. Besides the 5V (and GND) pin, the rest of the pins are only 3.3V tolerant.

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.

J-Link Debug and I/O Pins

DANGER!

Reprogramming the nRF52840 System on Chip (SoC) removes all pre-programmed factory software. SparkFun is NOT able to help you recover the software once it has been removed.

Before attempting to mess with the the nRF52840 System on Chip (SoC), we highly recommend users refer to the operation manual and technical specifications for other considerations and notices from the manufacturer.

The J-Link and I/O pins are also broken out for users, in case they wish to interface with the RF52840 SoC.

other pins
Other breakout pins on the Qwiic LIDAR-Lite v4. (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 lowering power consumption.
  • 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.
  • 5V Disconnect - Cutting the 5V jumper on the board will disconnect the buck converter from the 5V power trace. This is useful when users power the board through the 5V breakout pin.

Jumpers
The power LED, I2C pull-up resistor, and 5V disconnect jumpers on the Qwiic LIDAR-Lite v4. (Click to enlarge)

Hardware Assembly

With the Qwiic connector system, assembling the hardware is simple. All you need to do is connect your Garmin LIDAR-Lite v4 (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 LIDAR-Lite v4 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.

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 Garmin LIDAR-Lite v4 (Qwiic). However, before we jump into retrieving measurements 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 Garmin LIDAR-Lite v4 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:

Note: Users may also notice another Arduino for the Garmin LIDAR-Lite. This library is provided and maintained by Garmin®, for all their LIDAR sensors. For more details, check out the GitHub repository.

garmin arduino library
Garmin and SparkFun Arduino libraries for the Garmin LIDAR-Lite v4. (click to enlarge)

Arduino Examples

Note: This section is in progress and will be up shortly... we apologize for the delay.

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.

Resources and Going Further

Looking for other distance sensors? Check out some of these tutorials:

Qwiic Distance Sensor (RFD77402) Hookup Guide

The RFD77402 uses an infrared VCSEL (Vertical Cavity Surface Emitting Laser) TOF (Time of Flight) module capable of millimeter precision distance readings up to 2 meters. It’s also part of SparkFun’s Qwiic system, so you won’t have to do any soldering to figure out how far away things are.

Qwiic Distance Sensor (VL53L1X) Hookup Guide

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.

Getting Started with the A111 Pulsed Radar Sensor

Get started with the Acconeer A111 SDK with a Raspberry Pi! The tiny A111 pulsed coherent radar (PCR) adds high-precision, cutting-edge distance measurement for speed-, material-, motion-,or gesture-sensing projects! We’re not talking about simple ultrasonic, or even infrared sensors here, but 60GHz radar!
New!

Qwiic Ultrasonic Distance Sensor (HC-SR04) Hookup Guide

Get started with the Qwiic Ultrasonic Distance Sensor!

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

Qwiic Haptic Driver DA7280

$
0
0

Qwiic Haptic Driver DA7280 a learn.sparkfun.com tutorial

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

Introduction

The Qwiic Haptic Driver includes an itty-bitty, Linear Resonant Actuator (LRA) vibration motor and Dialog Semiconductor's DA7280 motor driver IC for applications that require haptic feedback. There is also a kit for those that would like the motor mounted separately from the board. Note that you will need to manually solder the wires and motor to the board.

SparkFun Qwiic Haptic Driver - DA7280

SparkFun Qwiic Haptic Driver - DA7280

ROB-17590
$14.95
SparkFun Qwiic Haptic Driver Kit - DA7280

SparkFun Qwiic Haptic Driver Kit - DA7280

ROB-18247
$15.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 RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Reversible USB A to Reversible Micro-B Cable - 0.8m

Reversible USB A to Reversible Micro-B Cable - 0.8m

CAB-15428
$3.95
SparkFun Qwiic Haptic Driver - DA7280

SparkFun Qwiic Haptic Driver - DA7280

ROB-17590
$14.95

Suggested Reading

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

Qwiic Connect System
Qwiic Connect System

If you aren’t familiar with the following concepts, we also recommend checking out a few of these tutorials before continuing. While the Haptic Motor Driver hookup guide linked below uses a different IC on the board, there is some useful information about different motors available in the tutorial.

Pulse Width Modulation

An introduction to the concept of Pulse Width Modulation.

I2C

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

Haptic Motor Driver Hook-Up Guide

Good vibes only. Getting started with the Haptic Motor Driver.

Hardware Overview

Power and Logic Levels

We recommend powering the board through the Qwiic connector when quickly prototyping. For a more secure connection, you can always solder to the PTH pads labeled 3V3/VDD and GND. The recommended input voltage when using the board with a microcontroller is 3.3V. However, you could potentially power the board between 2.8V to 5.5V as explained in the datasheet. Note that the 3V3/VDD is connected to VDDIO. There is a jumper on the back of the board to disconnect the input voltage and the logic levels if you decide to use different voltages. If you decide to adjust the logic level, this is typically 1.8V. However, you can set the logic levels between 1.35V and 5.5V as long as VDDIOVDD and if GPI0, GPI1, and GPI2 are not grounded as it is recommended in the datasheet.

Power Rails Highlighted on Qwiic Haptic Driver  DA7280

I2C

The main method of controlling the DA7280 and the vibe motor is through the I2C bus. The board includes two Qwiic connectors for fast prototyping and removes the need for soldering. All you need to do is plug a Qwiic cable into the Qwiic connector and voila! You can also solder to the PTHs labeled as SDA and SCL as an alternative. The address for the DA7280 is 0x4A.

Qwiic Connectors and I2C Port Highlighted for the Qwiic Haptic Driver DA7280

Interrupt

The interrupt is active low and notifies the host microcontroller when the DA7280 has finished driving the motor. This connection is optional and available for those that decide to include an interrupt for their application.

Interrupt Pin Highlighted on Qwiic Haptic Driver DA7280

PWM Pin

The second method of controlling the DA7280 is to send a PWM signal to the GPI0 pin. Once the DA7280 is configured to PWM mode via I2C, the duty cycle of the PWM signal will be reflected on the DA7280's output drive to the vibration motor. The DA7280 requires that the PWM signal is at least 10kHz. The top of the board only labels the PTH as GPI0 due to the space available around the pin while the back of the board labels the pin as GPI0/PWM.

GPI0/PWM Pin Highlighted on Qwiic Haptic Driver DA7280

GPI Pins

The third method of controlling DA7280 and the motor is through the general purpose input (GPI) pins. These can be configured to edge trigger based on the the combination of the pins and waveforms that are stored in the DA7280's memory.

GPI Pins Highlighted on Qwiic Haptic Driver DA7280

LED

The board includes an LED indicator that lights up when there is power available.

LED Highlighted on Qwiic Haptic Driver DA7280

Jumpers

There are four jumpers on the back of the board. For more information, check out our tutorial on working with jumper pads and PCB traces should you decide to cut the traces with a hobby knife.

  • LED - This is connected to the PWR LED on the top of the board. Cutting this disables the LED.
  • I2C - The I2C jumper is connected to the 4.7k&ohm; pull-up resistors for the I2C bus. Most of the time you can leave these alone unless your project requires you to disconnect the pull-up resistors.
  • QISO - The QISO jumper is connected to the Qwiic bus power line (i.e. 3.3V). Cut this trace to separate power from the Qwiic ports if you decide to power the board with a different voltage on 3V3/VDD. Note that the I2C lines are still pulled up to 3.3V.
  • IO - The IO jumper connects 3.3V/VDD to VDDIO for the DA7280. Cut this trace and supply VDDIO with a different voltage to adjust the DA7280's logic levels. This is typically 1.8V. However, you can set the logic levels between 1.35V and 5.5V as long as VDDIOVDD and if GPI0, GPI1, and GPI2 are not grounded as it is recommended in the datasheet

LED, I2C Pullup Resistor, QISO, IO, Jumpers Highlighted on Qwiic Haptic Driver DA7280

Board Dimensions

The board dimension is 1.00" x 1.15" and includes 3x mounting holes. The mounting holes are spaced using the Qwiic standard for 1.0"x1.0" sized boards. Note that the board is longer on one side to accommodate the SMD vibe motor.

Board Dimensions

Hardware Assembly

There are three modes (I2C, PWM, and stande-alone with the GPI) available for the DA7280. For the scope of this tutorial and Arduino Library, we will be using the I2C and PWM modes. If you are using the PTHs, we recommend soldering header pins or wires to the board for a secure connection.

I2C Mode

The main method to control the DA7280 is through an I2C bus. You'll need the RedBoard Qwiic and a USB cable to program the microcontroller. Insert the USB cable into the RedBoard. Then insert a Qwiic cable between the RedBoard Qwiic and Qwiic Haptic Driver. Depending on your application, you can also solder to the plated through holes for a secure connection.

RedBoard Qwiic Connected to Qwiic Haptic Driver for I2C Mode

PWM Mode

The second method of controlling the DA7280 is via PWM. The Haptic Driver IC requires that the PWM signal frequency given to GPI0/PWM pin is at least 10kHz. The default PWM methods of analogWrite() does not provide a method of controlling the frequency of the PWM signal. To use with the RedBoard with ATmega328P, you will need to use the TimerOne Arduino Library by Paul Stoffregen as explained later in this tutorial. Note that this library is limited to certain boards. For the Arduino Uno (e.g. the RedBoard with ATmega328P) the pins that are reserved for PWM are on pins 9 and 10.

In this case, we will connect the Qwiic Haptic's GPIO0/PWM pin to the RedBoard's pin 9. We also still need to control the DA7280. Make sure to include a Qwiic cable between the boards as well.

PWM Mode

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 DA7280 Haptic Driver Arduino library can be downloaded with the Arduino library manager by searching 'SparkFun Qwiic Haptic Driver DA7280' or you can manually install the library by downloading the zip here from the GitHub repository:

Example 1: I2C Mode

We're just going to look the I2C_Mode.ino example. Open the File>Examples>SparkFun Haptic Driver Arduino Library>I2C_Mode. Select your board (in this case Arduino Uno) and COM port. Then hit the upload button.

Once uploaded, the Qwiic Haptic Driver should begin vibrating every half a second. Note that the value for hapDrive.setVibrate() range from 0 to 127. A value of 0 turns the motor off while a value of 127 turns the motor fully on. Try adjusting the value to

Example 2: PWM Mode

We're just going to look the PWM_Mode_Timer1.ino example. Open the File>Examples>SparkFun Haptic Driver Arduino Library>PWM_Mode_Timer1.ino. Select your board (in this case Arduino Uno) and COM port. Then hit the upload button.

Once uploaded, the Qwiic Haptic Driver will first clear a flag that shuts the motor off if the PWM signal is cut off suddenly without being set into inactive mode. The motor will begin vibrating based on the PWM signal in the for loop. In this case, the PWM signal is dependent on the value for power and we slowly increase the intensity.

Resources and Going Further

For more information about the Qwiic Haptic Driver DA7280, check out the resources below.

Looking for more information about haptic motors project ideas? Check out the following tutorials.

Haptic Motor Driver Hook-Up Guide

Good vibes only. Getting started with the Haptic Motor Driver.

LilyPad Vibe Board Hookup Guide

The LilyPad Vibe Board is a small vibration motor that can be sewn into projects with conductive thread and controlled by a LilyPad Arduino. The board can be used as a physical indicator on clothing and costumes for haptic feedback.

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

nRF9160 Thing Plus Hookup Guide

$
0
0

nRF9160 Thing Plus Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

SparkFun has paired up with CircuitDojo to bring you the SparkFun nRF9160 Thing Plus, which features the powerful Nordic nRF9160 microcontroller in a feather-compatible footprint. This little chip is capable of both CAT M1 LTE and NB-IoT cellular communication and is designed to work with Zephyr, the go-to RTOS for embedded development.

Not only can you take advantage of Nordic’s advanced power states, but you can also put the device into a low power standby state. Laboratory measurements are putting that mode at about 2µA of current. 2µA! It also features a 3.3V Buck-Boost which helps get every mWh from your batteries as possible.

No batteries? No problem! You can plug or power your nRF9160 Thing Plus externally for AC/DC powered operation. Keep it on at all times for high availability scenarios. Power it via the 5V pin or insert a USB C cable to keep things going.

Want to persist data? The nRF9160 Thing Plus has a 4MB external flash for storing data while offline. Using external flash with a filesystem like LitteFS and you’ll have a project to recon with!

SparkFun Thing Plus - nRF9160

SparkFun Thing Plus - nRF9160

WRL-17354
$129.95

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Suggested Reading

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

Serial Peripheral Interface (SPI)

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

I2C

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

Bluetooth Basics

An overview of the Bluetooth wireless technology.

Three Quick Tips About Using U.FL

Quick tips regarding how to connect, protect, and disconnect U.FL connectors.

Hardware Overview

nRF9160

The nRF9160 from Nordic Semiconductor has some amazing capabilities. Some of the more prominent features are listed below. See the datasheet for more information.

  • Microcontroller
    • ARM Cortex M33
    • 1MB Flash
    • 256kB RAM
    • ARM® TrustZone®
    • ARM® Cryptocell 310
    • Up to 4x SPI, I2C and UART with Easy DMA
    • I2S w/ EasyDMA
    • 4x PWM with EasyDMA
    • 12bit SADC with EasyDMA
    • 2x RTC
    • PPI (Programmable peripheral interconnect) interface
  • Radio
    • Transceiver and baseband
    • 3GPP LTE release 13 Category M1 and NB1 compliant
    • 3GPP release 14 NB2 compliant
    • GPS receiver (GPS L1 C/A supported) - Active antenna only.
    • RF Transceiver for global coverage supporting bands:
      • Cat-M1: B1, B2, B3, B4, B5, B8, B12, B13, B14, B17, B18, B19, B20, B25, B26, B28, B66
      • Cat-NB1/NB2: B1, B2, B3, B4, B5, B8, B12, B13, B17, B18, B20, B25, B26, B28, B66
    • Supports 4FF Nano SIM

The Nordic nRF9160 is highlighted on the board

Power

The nRF9160 Thing Plus has an operating range of 2.8V to 5.5V and can be powered several ways. The most popular way to power Thing Plus boards is by using the USB C port on the bottom of the board. Alternatively, the board can be powered by a LiPo battery plugged into the 2 pin JST connector on the left side.

NOTE: The nRF9160 shouldn't be used with a battery less than 300mAH.

The board is designed from the ground up to be power efficient at the most used power state: standby. As of this writing the estimated current draw in this state should be about 2µA.

In addition, the nRF9160 Thing Plus also has a fully fledged DC/DC Buck Boost. That way, whether your input voltage is 5.5 or 2.8V you'll get a nice stable 3.3V at the output.

Both the USB C and the LiPoly jack are highlighted

JTAG

If you choose to use an external programmer, the JTAG pins highlighted here will allow you to connect. We recommend the nRF5340DK or, for non-commercial use, we recommend the J-Link EDU Mini Programmer.

JTAG pins are highlighted

Sim Card

In order to use the LTE functionality, you'll need to activate and insert the included Hologram Sim Card. Head over to Hologram's Start Page and follow the instructions to activate your card. In this tutorial, we are using the most basic license, which is free (up to a point).

Sim Card slot is highlighted

Qwiic Connector

Our Qwiic Ecosystem makes using qwiic sensors pretty much plug and play. Use this port to attach your sensor of choice!

Qwiic port is highlighted

Buttons

In order to upload code to the nRF9160 Thing Plus, you'll need to put the board in Bootloader mode. To do so, do the following:

  • Press the Mode button (MD)
  • While holding down the Mode button, press and release the Reset (RST) button.
  • When the LED lights up, release the Mode button

Mode and Reset are highlighted

Antenna Connections

There are two antenna connectors - one U.FL for the LTE with matching network, one U.FL for active GPS antennas (active only). The connectors are labelled on the back of the board to help you remember which is which.

  • Antenna supply voltage: 3.3V± 0.3V
  • Antenna current rating: 15mA

Connectors are highlighted and labelled

Jumpers

There are two jumpers on the board.

JMP1 is used to disable the accelerometer interrupt on Pin 2. By default, the interrupt is push/pull and is always enabled. To disable, cut the trace.
JMP2 is used to disable PS_EN's connection to the power supply, which allows you to use PS_EN as a GPIO pin. You can turn this functionality to "Always on" operation by shorting the middle and right pads on JMP2 and cutting the existing short.

Jumpers are highlighted

Board Dimensions

The nRF9160 Thing Plus measures 2.10 inches by 0.9 inches.

Board measures 2.10 inches by 0.9 inches

SDK Setup - Windows

This page is all about getting your Windows machine compiling code for the nRF9160 Thing Plus. Run into trouble during the process? Post your questions on the community forum.

IDE Setup

Install or use the code editor of your choice. I personally use Microsoft Visual Studio Code. The download link is here, or you can download by clicking the button below. If you decide to use Visual Studio Code, make sure you install the C/C++ and Cortex-Debug extentions using the built in extension marketplace.

Visual Studio Code extensions for C/C++ and  Cortex-Debug

SDK Install

nRF Connect For Desktop is the utility that you can use to manipulate your nRF9160 Thing Plus. Download and install nRF Connect For Desktop.

Image showing the download page for nRF connect for desktop

Once downloaded, run the installer:

Installer is installing

Open up the app and install the Toolchain Manager:

Image showing the "Install" button of the Toolchain Manager

Open up the Toolchain Manager after installing. Scroll to the bottom and click Install package from other source

Teeny tiny text at the bottom right saying Install package from other source

Then paste this url into the box and click ok:

language:c
http://developer.nordicsemi.com/.pc-tools/toolchain/ncs-toolchain-v1.4.1-20201215-7ecf886-minimal.zip

Paste the above link into the Install toolchain package popup window and click ok

The download and install will take a few minutes. Hang out, take a walk, sing a song, and come back later.

Once installed you'll have a dropdown that you can access. Click on it and then the Open Bash or Open Command Prompt option. (I prefer bash since I use *nix a lot)

nRF Connect SDK dropdown showing options for what to open or update

To get the nRF9160 Thing Plus examples we'll update C:\Users\<your username>\ncs\v1.4.1\nrf\west.yml. First in the remotes section add:

language:c
name: circuitdojo
url-base: https://github.com/circuitdojo

Then in the projects section add at the bottom:

language:c
name: nfed
repo-path: nrf9160-feather-examples-and-drivers
revision: v1.4.x
path: nfed
remote: circuitdojo

Then run west update in your freshly created bash/command prompt session. This will fetch the nRF9160 Thing Plus examples.

Installing newtmgr

newtmgr is required for the MCU bootloader to work. You can download the binary file here or by clicking the button below:


Extract it and move it into your C:\Users\<your username>\ncs\v1.4.1\toolchain\bin directory.

Add the path to your newtmgr.exe to your system $PATH. If you're unfamiliar with the process check out this guide. Also remember to restart your bash window after updating the system $PATH.


Setting your connection configuration (one time only)

In order to easily work with newtmgr you'll need to make a one-time connection profile. Make sure that the COM port matches the one attached to the nRF9160 Thing Plus. An easy way to check is to remove and add the device to see which COM port shows up in device manager.

language:c
newtmgr conn add serial type=serial connstring="dev=COM3,baud=1000000"
Having trouble? You may have to install the Silabs VCP driver. Download and install the CP210x VCP Windows option.

You've now created a connection called serial. We'll be using that when issuing commands to the nRF9160 Thing Plus.

SDK Setup - Mac

This page is all about getting your Mac compiling code for the nRF9160 Thing Plus. Run into trouble during the process? Post your questions on the community forum.

IDE Setup

Install or use the code editor of your choice. I personally use Microsoft Visual Studio Code. The download link is here or you can download by clicking the button below. If you decide to use Visual Studio Code, make sure you install the C/C++ and Cortex-Debug extentions using the built in extension marketplace.

Installing SDK

Installing the latest SDK is a snap and only takes a few steps. Let's walk through them here.

nRF Connect For Desktop is the utility that you can use to manipulate your nRF9160 Thing Plus. Download and install nRF Connect For Desktop.

Mac download highlighted

Copy the app to your Applications folder

nrf copy dialog

Open up the app and install the Toolchain Manager

Dialog to install toolchain manager

Then open it up.

Click on the small arrow to the right of the "Open" button

Scroll to the bottom and click Install package from other source:

Small text all the way at the bottom of the dialog

Then paste this url into the box and click OK:

language:c
http://developer.nordicsemi.com/.pc-tools/toolchain/ncs-toolchain-v1.5.0-20210225-607a0e0-minimal.dmg

Install toolchain package dialog - paste the above into the dialog and click okay

The download and install will take a few minutes. Hang out, take a walk, sing a song, and come back later.

Finally, once installed you'll have a dropdown that you can access. Click on it and then the Open Terminal option.

To get the nRF9160 Thing Plus examples we'll update /opt/nordic/ncs/v1.4.1/nrf/west.yml.

First in the remotes section add:

language:c
name: circuitdojo
url-base: https://github.com/circuitdojo

Then in the projects section add at the bottom:

language:c
name: nfed
repo-path: nrf9160-feather-examples-and-drivers
revision: v1.4.x
path: nfed
remote: circuitdojo

Then run west update in your freshly created terminal session. This will fetch the nRF9160 Thing Plus examples.

Installing newtmgr

If you're on a newer version of OSX you'll need to install the drivers.

For loading code to your nRF9160 Thing Plus, you'll need to download and copy a custom version of newtmgr. Open a terminal window and run:

language:c
cd ~/Downloads
wget "https://docs.jaredwolff.com/files/newtmgr/darwin/newtmgr.zip"
unzip newtmgr.zip
mv newtmgr /opt/nordic/ncs/v1.4.1/toolchain/bin
rm newtmgr.zip

Then you'll need to add your serial profile to make it easier to download/update your device:

language:c
newtmgr conn add serial type=serial connstring='dev=/dev/tty.SLAB_USBtoUART,baud=1000000'

If you have multiple Silicon Labs CP2102 connected to your machine your serial port may be named differently. I recommend you unplug all devices that could be named tty.SLAB_USBtoUART to ensure you're targeting the correct device during programming.

For more info in using newtmgr checkout the programming section.

Now you can get to playing around with some of the nRF9160 Thing Plus example code! Remember you'll always have to open a terminal using the Toolchain Manager to build code!

SDK Setup - Linux/Ubuntu

This page is all about getting your Linux machine compiling code for the nRF9160 Thing Plus. Run into trouble during the process? Post your questions on the community forum.

Installing IDE

Install or use the code editor of your choice. I personally use Microsoft Visual Studio Code. You can download directly from the Ubuntu Software Install utility.

Linux VSC install

If you decide to use Visual Studio Code, make sure you install the C/C++ and Cortex-Debug extentions using the built in extension marketplace.

Installing SDK

Install dependencies using apt-get

language:bash
sudo apt install --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc gcc-multilib g++-multilib libsdl2-dev

Check your cmake version:

language:bash
cmake --version

If it's older than 3.13.3, you'll have to install a newer version using the instructions here.

Install west. West is the most important utility for using nRF Connect SDK & Zephyr.

language:bash
pip3 install --user -U west

Then make sure that ~/.local/bin is added to your path:

language:bash
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
source ~/.bashrc

Now create a folder on your machine and call it nfed (short for nRF9160 Feather Examples and Drivers). Open a terminal to this folder and initialize nRF Connect SDK using west:

language:bash
cd ~
mkdir nfed
cd nfed
west init -m https://github.com/circuitdojo/nrf9160-feather-examples-and-drivers --mr main

Once your nRF Connect SDK compontents are downloaded, you'll need to fetch the remaining SDK:

language:bash
west update

You'll see a bunch of output go by as west downloads dependencies using Git.

Here's what your nfed folder should look like:

❯ tree -L 1
.
├── bootloader
├── build
├── latest
├── mbedtls
├── modules
├── nrf
├── nrf9160-feather
├── nrfxlib
├── test
├── tools
└── zephyr

Installing the remaining SDK requirements using pip3:

language:bash
pip3 install --user -r zephyr/scripts/requirements.txt
pip3 install --user -r nrf/scripts/requirements.txt
pip3 install --user -r bootloader/mcuboot/scripts/requirements.txt

Note: there may be an error during the first pip3 install. You can safely ignore them.

Note: nRF Connect for Desktop is distributed as an appimage. Right click and enable running as an executable. Then you can double click and run as any other app. nRF Desktop AppImagenRF Desktop Allow as Executable

The ARM Embedded Toolchain

First download the latest Zephyr SDK installer:

language:bash
cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.4/zephyr-sdk-0.11.4-setup.run

Then run it:

language:bash
chmod +x zephyr-sdk-0.11.4-setup.run
./zephyr-sdk-0.11.4-setup.run -- -d ~/zephyr-sdk-0.11.4

Finally install the udev rules which allows you to flash boards using a programmer.

language:bash
sudo cp ~/zephyr-sdk-0.11.4/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload

Installing newtmgr

For loading code to your nRF9160 Thing Plus, you'll need to download and copy a custom version of newtmgr to a folder in your PATH.

language:bash
cd ~/Downloads
wget "https://docs.jaredwolff.com/files/newtmgr/linux/newtmgr.zip"
unzip newtmgr.zip
mv newtmgr ~/.local/bin
rm newtmgr.zip

If you're not sure, ~/.local/bin is always a good spot for these types of binaries.

Then you'll need to add your serial profile to make it easier to download/update your device:

language:bash
newtmgr conn add serial type=serial connstring='dev=/dev/ttyUSB0,baud=1000000'
newtmgr -c serial reset

If you have multiple Silicon Labs CP2102 connected to your machine your serial port may be named differently. I recommend you unplug all devices that could be named ttyUSB0 to ensure you're targeting the correct device during programming.

Note if you get a Error: open /dev/ttyUSB0: permission denied error. You'll have to fix permissions for the serial device for all users. Here are the steps:

Open this .rules file in vi (or your editor of choice):

language:bash
sudo vi /etc/udev/rules.d/50-myusb.rules

Then within the editor hit i, paste this:

language:bash
KERNEL=="ttyUSB[0-9]*",MODE="0666"
KERNEL=="ttyACM[0-9]*",MODE="0666"

Hit the esc button and then type :wq!.

For more info in using newtmgr checkout the programming section of CircuitDojo's documentation.

Programming and Debugging

There are currently two ways of programming the nRF9160 Thing Plus. You can use the built-in bootloader or use an external programmer.

Bootloader

Currently the nRF9160 Thing Plus uses the MCUBoot bootloader which comes standard with the nRF Connect SDK. It is the recommended way to load new firmware onto your nRF9160 Thing Plus.

In order to utilize the bootloader, you'll need to make sure you have newtmgr (AKA mcumgr) installed. Instructions for your platform can be found in the SDK Setup sections of this tutorial.

Pre-check: MCUBoot needs to be enabled in your project before you can use it! Make sure that you have CONFIG_BOOTLOADER_MCUBOOT=y in your prj.conf.

Put your nRF9160 Thing Plus into DFU mode.

  • Press the Mode button (MD)
  • While holding down the Mode button, press and release the Reset (RST) button.
  • When the LED lights up, release the Mode button

Build your application if you haven't already with west build. It will create a folder called build. The file we care about is build/zephyr/app_update.bin

Load the file using newtmgr

  • Load the binary file using: newtmgr -c serial image upload build/zephyr/app_update.bin
  • Reset your board using newtmgr -c serial reset or hit the RST button. Full process below:

Resetting the board in newtmgr
Note: The transfer process is limited to 1M BAUD. In most cases it takes about 8 seconds to transfer application code. The nRF9160 Thing Plus does not respond to newtmgr commands unless it's in DFU mode. (See the above to get it into DFU mode.)

External Programming and Debugging

You can also use external programmers with the nRF9160 Thing Plus. Here are the current supported external programmers:

Note: Most commercial J-Link programmers *should* work with the nRF9160 Thing Plus. In particular the J-Link EDU Mini is a great choice if you're building non-commercial products. (Supports Cortex M33 processors. Untested at this time.)
Important: The nRF52 and nRF51 based development kits do not work with the nRF9160 Thing Plus!

Installing programmer software

The nRF5340-DK is the programmer of choice. These steps should not be different from other J-Link supported boards.

Download your version of the nRF Command Line Tools.

  • Windows
    • Then, run the .exe that was downloaded. It will do all the heavy lifting for you.
    • Run nrfjprog in a cmd window to make sure your install is working.
    • You may also have to add JLink.exe to your path. It's the exact same procedure as adding newtmgr except the path you're adding is C:\Program Files (x86)\SEGGER\JLink.
      Update the JLInk path
    • Close/restart VSCode and your Command Prompt
    • Run jlink.exe and make sure it opens.
  • Mac:
    • First run nRF-Command-Line-Tools_10_9_0_OSX.pkg
    • Once that install is done, run JLink_MacOSX_V680a.pkg
    • Open a fresh terminal window and run nrfjprog and jlinkexe to make sure your install is complete.

Setting up the nRF5340-DK

Here are a couple of close up shots of how to connect the nRF5340-DK:

The JTAG cable is directional and has a tab on the side that will keep you from inserting it incorrectly

Showing the cable next to the nRF9160 Thing Plus

Showing the cable plugged into the nRF9160 Thing Plus

I highly recommend you jump SB47 on your nRF5340-DK with some solder. This forces the debugger to think an external devices is permanently connected. If you're only doing external debugging, this is very useful.

SB47 Jumper is highlighted

After hooking things up, It's time to do a quick smoke test. Running nrfjprog -r in a terminal should show this result:

language:bash
$ nrfjprog -r
Applying system reset.
Run.

Success!

Programming with the nRF5340-DK

Programming with the nRF5340-DK is straight forward in Zephyr using west. Here's what it looks like:

language:bash
west build -b circuitdojo_feather_nrf9160ns -p
west flash --runner nrfjprog
nrfjprog -r

In the above, I'm:

  • Doing a pristine build of my application with the nRF9160 Thing Plus as the target.
  • Then flashing using the nrfjprog runner option. This is preferred for all J-Link boards.
  • Resetting the board using nrfjprog -r. As of this writing, west does not reset the board after programming.

Getting a Modem Trace

Sometimes, you may be requested to get a modem trace of your device. This section will focus on helping you get one for your nRF9160 Thing Plus.

In order to get a modem trace, the TX and RX pins on your board need to be free. You'll also need a UART to USB adapter of some type. I used an FTDI one that has each of the lines broken out.

First, set your prj.conf to include the following lines:

language:bash
# Enable modem trace
CONFIG_BSD_LIBRARY_TRACE_ENABLED=y


# AT host library
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_AT_HOST_LIBRARY=y
Note: Version v1.5.x and newer uses this flag to enable modem tracing: CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=y

Then, create a folder in your project/sample called boards and add a new file called circuitdojo_feather_nrf9160ns.overlay We'll want to enable the UART1 interface on pins 23 and 24 like below:

language:bash
/*
* Copyright (c) 2020 Circuit Dojo LLC
*
* SPDX-License-Identifier: Apache-2.0
*/

&uart1 {
status = "okay";
current-speed = <115200>;
tx-pin = <24>;
rx-pin = <23>;
};

Connect your USB to UART adapter. I've used clips from my logic analyzer to hold the wires in place. Connect the yellow wire to the TX on the board. Connect the orange wire to the RX on the board.

Image showing the 6 way header

Image courtesy of CircuitDojo

Then open the serial port in the modem trace app and click start.

Opening the serial trace port

Click on the image for a closer view

Then run your app as normal. You should see the Trace size go up little by little as connections are made, etc.

Watch the trace size go up

Click on the image for a closer view

Then grab the file according to the log output. For example: Tracefile created: /Users/jaredwolff/Library/Application Support/nrfconnect/pc-nrfconnect-tracecollector/trace-2020-09-16T20-47-19.741Z.bin

For more information, check out Nordic's original article on the subject.

Debugging in Visual Studio Code

Debugging your application is possible with Visual Code. If you get a J-Link programmer such as the J-Link EDU Mini Programmer, it will include the necessary cabling. Programmers that are possible include the nRF9160 DK, nRF532 DK, J-Link EDU (if your project is non-profit) and the standard commercial J-Link programmers.

Here's the process:

Download and install your version of the nRF Command Line Tools.

Install the C/C++ Extension and the Cortex-Debug extensions. They're both very handy in development and debugging of Zephyr based projects.

Dialog showing c/c++ extension

Dialog showing Cortex debug extension

If you don't have one already, create a .vscode folder in the root of your project.

Under NCS, create the .vscode

Create a file called launch.json. This is where we'll set up the configuration for debugging.

Here's a real example of a config I was using to debug a project in OSX:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Cortex Debug",
      "cwd": "${workspaceRoot}",
      "executable": "${workspaceRoot}/pyrinas/applications/dreamstars/build/zephyr/zephyr.elf",
      "request": "launch",
      "type": "cortex-debug",
      "servertype": "jlink",
      "device": "nrf9160_xxAA",
      "interface": "swd",
      "armToolchainPath": "/Users/jaredwolff/gcc-arm-none-eabi-9-2019-q4-major/bin"
    }
  ]
}

For folks on Windows you'll have to modify appropriately:

{
 // Use IntelliSense to learn about possible attributes.
 // Hover to view descriptions of existing attributes.
 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 "version": "0.2.0",
 "configurations": [
    {
        "name": "Cortex Debug",
        "cwd": "${workspaceRoot}",
        "executable": "${workspaceRoot}\\nrf9160-feather\\samples\\blinky\\build\\zephyr\\zephyr.elf",
        "request": "launch",
        "type": "cortex-debug",
        "servertype": "jlink",
        "device": "nrf9160_xxAA",
        "interface": "swd",
        "armToolchainPath": "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\9 2019-q4-major\\bin"
    }
 ]
}

Remember that workspaceRoot refers to the folder you have opened in VSCode. This will most likely be /opt/nordic/ncs/v1.4.1/nfed or c:\users\<user name>\ncs\v1.4.1\nfed. You will have to modify the "executable" entry to match the path of your zephyr.elf file.

Change the executable path and the armToolchainPath to reflect your system. Make sure you point the executable option to the .elf file that gets produced during the compilation process.

Next, go to your projects prj.conf and disable the bootloader by commenting outCONFIG_BOOTLOADER_MCUBOOT=y or changing the y to a n. As of this writing, disabling the bootloader is required as it prevents the debugging process from occuring.

In prj.conf you'll also want to enable the CONFIG_DEBUG option. This disables compiler optimizations which make the debug process hairy and/or impossible.

Finally, program your project using west build&& west flash.

At this point, if you've ever done any debugging in Visual Code, you should be able to follow the final steps to debug your application!

Set some breakpoints in your code by pressing the line number you want. A red dot will appear where the breakpoint is set.

Little red dot in the margin will be your breakpoint

Start debugging by clicking the debug icon on the left. Then click the play button in the top left.

Click the debug button on the left side

Click the play button at the top of the menu

You can use the popup menu on the right to control traversal through your code.

Step over, step into, etc are in the popout menus in the upper right

Compiling an Application

Prerequisites/SDK Setup

If you haven't already, make sure you've set up the SDK:

General Build Commands

Generally speaking, as long as you have all the requirements from the guide above, compiling for the nRF9160 Thing Plus should be as simple as running the following:

language:bash
west build -b circuitdojo_feather_nrf9160ns

If you would like to "clean" your project before building add the -p parameter.

language:bash
west build -b circuitdojo_feather_nrf9160ns -p
Note: Having trouble building? Make sure you check out the troubleshooting page.

The output assets are placed in the build/zephyr folder. If you're programming from scratch, you'll want the merged.hex. If you're using newtmgr then you'll want the app_update.bin. More info on different programming methods can be found in the Programming and Debugging section.

For subsequent builds you don't need -b circuitdojo_feather_nrf9160ns if you're not using the -p param.

language:bash
west build

west uses the last board that was indicated for the re-build.

Common errors and warnings

CMake complains about your MCUBoot key:

CMake Warning at /Users/jaredwolff/Git/nrf-connect/ncs/v1.4.1/nrf/cmake/mcuboot.cmake:115 (message):


        ---------------------------------------------------------
        --- WARNING: Using default MCUBoot key, it should not ---
        --- be used for production.                           ---
        ---------------------------------------------------------

The default bootloader uses the default MCUBoot key. Before you compile your project, make sure that the following lines are added to the prj.conf:

language:bash
# Enable Zephyr application to be booted by MCUboot
CONFIG_BOOTLOADER_MCUBOOT=y

This will enable support for the bootloader.

Example - Blinky

Let's start with a basic example and move up from there!

Note: Pre-built binary can be downloaded here: blinky-v1.3.2.bin

Change directories to ncs/v1.4.1/zephyr/samples/basic/blinky.

Make sure you've enabled support for the bootloader by verifying that the following lines are added to the prj.conf:

language:bash
# Enable Zephyr application to be booted by MCUboot
CONFIG_BOOTLOADER_MCUBOOT=y

Then, build using the build command:

language:bash
west build -b circuitdojo_feather_nrf9160ns

You should see towards the end of the output that both the application and the bootloader have been built and merged.

Uploading Code

Make sure that you have set your connection configuration (this should only need to be done once) and put your nRF9160 into Boot mode.

  • Press the Mode button (MD)
  • While holding down the Mode button, press and release the Reset (RST) button.
  • When the LED lights up, release the Mode button

Programming can then be completed with newtmgr by pasting the following into your bash/terminal window:

language:bash
newtmgr -c serial image upload build/zephyr/app_update.bin
newtmgr -c serial reset

LED on the board is blinking

Notes:

The transfer process is limited to 1M BAUD. In most cases it takes about 8 seconds to transfer application code.

Example - AT Client Sample

Note: Pre-built binary can be downloaded here: at-client-v1.3.2.bin

Change directories to ncs/v1.4.1/nrf/samples/nrf9160/at_client.

Make sure that the following lines are added to the prj.conf:

language:bash
# Enable Zephyr application to be booted by MCUboot
CONFIG_BOOTLOADER_MCUBOOT=y

This will enable support for the bootloader. Then, build using the build command:

language:bash
west build -b circuitdojo_feather_nrf9160ns
Note: Having trouble building? Make sure you check out the troubleshooting page.

You can see towards the end of this output that both the application and the bootloader have been built and merged.

Uploading Code

Make sure that you have set your connection configuration (this should only need to be done once) and put your nRF9160 into Boot mode.

  • Press the Mode button (MD)
  • While holding down the Mode button, press and release the Reset (RST) button.
  • When the LED lights up, release the Mode button

Programming can then be completed with newtmgr by pasting the following into your bash/terminal window:

language:bash
newtmgr -c serial image upload build/zephyr/app_update.bin
newtmgr -c serial reset

LTE Link Monitor

The best way to debug anything cellular-related is to use the LTE Link Monitor. To install:

  • (for OSX folks) If you haven't already, install the Si2102 USB-to-Serial drivers.
  • Make sure you have nRF Connect For Desktop installed as outlined in the SDK sections of this tutorial
  • Open up nRF Connect and in the list of apps, find LTE Link Monitor
  • Click install
  • Once installed click open and let the fun begin!

Install LTE monitor from nRFConnect for Desktop

For more information check out Nordic's Documentation.

Sim Card

Your purchase of the Sparkfun nRF9160 Thing Plus should have included a SIM card for use with LTE applications. In this instance, we have the Hologram SIM card:

Hologram eUICC SIM Card

Hologram eUICC SIM Card

CEL-17117
$4.95

In order to use the SIM card, you'll need to activate it. Go to Hologram's Start Page and follow the instructions. In this tutorial, we are using the most basic license, which is free (up to a point).

Using the LTE Link Monitor

Almost any code example can be used with the AT Host Library. Generally all that is needed is adding these lines to your prj.conf:

language:bash
# AT host library
CONFIG_AT_HOST_LIBRARY=y
CONFIG_UART_INTERRUPT_DRIVEN=y

Alternatively, for a quick start, simply program the at_client example to your nRF9160 Thing Plus. Then follow these quick steps to get up an running:

  • Insert your SIM into the nRF9160 Thing Plus.
  • Attach your LTE antenna.
  • Plug your nRF9160 Thing Plus into your computer's USB port.
  • Ensure that Flow Control is turned off, and Auto device/port filter is also unchecked.

image showing the unchecked flow control box

Connect to it using the Device dropdown in the top left hand corner of the LTE Link Monitor. On *nix based systems, the port will show up like /dev/tty.SLAB_USBtoUART. On Windows, you'll have to determine which COM port is associated by using the device manager.

Top left side of the LTE dialog showing the dropdown with devices listed

With Automatic requests turned on and the nRF9160 Thing Plus connected, press the AT+CFUN=1 button followed by the AT+CFUN? button. This will cause a few important commands to be automatically sent to your nRF9160 Thing Plus. Additionally, your nRF9160 Thing Plus will attempt to connect to the closest compatible tower possible.

Review the LTE Link Monitor for connection information.

LTE Monitor output of aforementioned commands

Yes, the LTE Link Monitor provides some great information. Consider it your go-to tool when debugging cellular or board related issues.

Example - nRF Cloud AGPS Sample

The nrf_cloud_agps sample is the easiest way to get started with generating GPS coordinates with your nRF9160 Thing Plus.

Note: Pre-built binary can be downloaded here: nrf_cloud_agps

Programming nrf_cloud_apgs Sample

Change directories to ncs/v1.4.1/nrf (Make sure you're using NCS v1.4.0 or newer). Then change directories to /nrf/samples/nrf9160/agps/. Add the following to prj.conf:

language:bash
# Cloud prefix for nRF9160 Thing Plus
CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX="thing-plus-"

# Enable Zephyr application to be booted by MCUboot
CONFIG_BOOTLOADER_MCUBOOT=y

# COEX0 is used to enable the GPS LNA, but it has to be configured to do so.
CONFIG_NRF9160_GPS_SET_COEX0=y
CONFIG_NRF9160_GPS_COEX0_STRING="AT%XCOEX0=1,1,1565,1586"

Then compile as normal:

language:bash
west build -b circuitdojo_feather_nrf9160ns

Uploading Code

Make sure that you have set your connection configuration (this should only need to be done once) and put your nRF9160 into Boot mode.

  • Press the Mode button (MD)
  • While holding down the Mode button, press and release the Reset (RST) button.
  • When the LED lights up, release the Mode button

Programming can then be completed with newtmgr by pasting the following into your bash/terminal window:

language:bash
newtmgr -c serial image upload build/zephyr/app_update.bin
newtmgr -c serial reset

Setting Up nRF Connect for Cloud

Note: Some of these steps take time to complete and/or register with the cloud devices. Be patient!

During factory test, your nRF9160 Thing Plus is added to nRF Connect for Cloud for your immediate use. The boards are registered with an nRF cloud key of 7753 (SPKF). You'll use this, along with your nRF9160 Thing Plus, SIM and antenna to connect to the nRF Connect for Cloud and get GPS readings.

Every nRF9160 Thing Plus has a device ID generated based on the IMEI. Your full device ID will look something like:

thing-plus-<IMEI> where <IMEI> is the IMEI tied to your specific device. You'll need this in a moment.

Above you should have compiled and programmed your device with the nrf_cloud_agps sample. Power up and confirm that the device can connect to the cloud. Then pop on over to your favorite internet browser, go to nrfcloud.com, and create an nRF Connect for Cloud Account.

Once created, go to the top left and click the big + icon.

Big plus circle is in the upper left corner of the screen

Add new:

Add New LTE Device is the second option down

Then skip the iBasis setup since we're using Hologram.

The Skip option is located directly under the Activate SIM button

Enter the Device ID and the PIN.

Device ID and Pin options are pointed out

Once you press Add Device, nRF Connect for Cloud should notify you that your device has been added. Navigate to Devices and click on the device you're working with!

The newly registered device will show up in your dashboard

That's it! Your device screen will adapt to whatever example code that you're using.

Troubleshooting

There are some things that can go wrong here. They're usually related to your nRF Cloud certs.

Reloading the certs can be done using the tutorial here.

Debug Serial Usage

The nRF9160 Thing Plus comes with an on-board Silicon Labs CP2102 USB-to-UART chip. You can use it with most serial terminal viewers. If you have an older version of Windows you will have to install the driver. The download is located here.

Here are some recommendations for software to communicate with the nRF9160 Thing Plus. No matter what program you use, the standard baud rate for the console is 115200. All other options are standard/default (8 bits, oon-parity, 1 stop bit).

Multi-Platform

nRF Connect For Desktop - LTE Link Monitor

If you haven't already, make sure you check out the LTE Link Monitor. It's a great multi-purpose tool for using and debugging the nRF9160 Thing Plus.

CoolTerm

CoolTerm has been my go-to for testing and debugging. Fortunately it's also multi-platform! The download is located here.

Mac OSX & Linux

screen

You can use screen to view your debug output. Here's a typical command:

language:bash
screen /dev/tty.SLAB_USBtoUART 115200

The major drawback of using screen is that it does not save your history. It's better to use other utilities for that purpose.

Note: depending on your system your serial port may be named something different from /dev/tty.SLAB_USBtoUART. You can check your dev folder like this to check which one may be it:

language:bash
ls -l /dev | grep SLAB

cu

You can also use cu to display your debug output. Here's an example:

language:bash
sudo cu -l /dev/tty.SLAB_USBtoUART -s 115200

If you notice, it requires super user permissions. (This is the only drawback to it IMHO)

To escape from your session type ~.

Troubleshooting

Resources and Going Further

For more information, check out the resources below:

Circuit Dojo information:

Nordic Semiconductor:

Check out these related tutorials:

Using the BlueSMiRF

How to get started using the BlueSMiRF and Bluetooth Mate Silvers.

ESP32 LoRa 1-CH Gateway, LoRaWAN, and the Things Network

Using the ESP32 LoRa 1-CH Gateway as a gateway and device, and pushing data to The Things Network.

GNSS Chip Antenna Hookup Guide

You've always wanted to experiment with those tiny GPS antennas. Now you can!

Assembly Guide for SparkFun JetBot AI Kit V2.0

Assembly Guide for the SparkFun JetBot AI Kit v2.0. This tutorial includes photos & comments to assemble the two-layer chassis & additional components unique to the JetBot kit.

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


Triple Axis Accelerometer Breakout - KX13x (Qwiic) Hookup Guide

$
0
0

Triple Axis Accelerometer Breakout - KX13x (Qwiic) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Triple Axis Accelerometer Breakout - KX134 (Qwiic) and Triple Axis Accelerometer Breakout - KX132 (Qwiic) offer two high-speed additions to SparkFun's accelerometer selection featuring the KX134-1211 and KX132-1211 3-axis digital accelerometers from Kionix. The KX134 and KX132 both include a host of accelerometer features including Freefall detection, Directional Tap and Double-Tap detection, tilt orientation detection and more. The breakouts can interface with controllers using both I2C and SPI at high speeds so you can use it in either an existing Qwiic/I2C chain or SPI bus.

SparkFun Triple Axis Accelerometer Breakout - KX134 (Qwiic)

SparkFun Triple Axis Accelerometer Breakout - KX134 (Qwiic)

SEN-17589
$19.95
SparkFun Triple Axis Accelerometer Breakout - KX132 (Qwiic)

SparkFun Triple Axis Accelerometer Breakout - KX132 (Qwiic)

SEN-17871
$13.95

The KX134 is a low-power, 16-bit resolution 3-axis accelerometer capable of measuring ±8g/16g/32g/64g (user selectable) and has up to a 10kHz (max) output data rate making it ideal for high-g measurements as well as high-speed applications such as vibration sensing. The KX132 offers nearly the same data specifications at smaller acceleration (±2g/4g/8g/16g) ranges. At lower ranges the sensitivity can be set as high as 17367 counts/g (@±2g), so it's a great for applications looking for both high-speed data rates and high-sensitivity measurements at lower acceleration ranges.

Note: Any reference in this guide specific to either version of these breakouts will denote the version (KX132 or KX134) discussed. We'll use the terms "KX13x Breakout(s)" or "KX13x" when discussing subjects or specifications pertaining to both boards or both accelerometers.

Required Materials

In order to follow along with this tutorial you'll need a few items along with your KX13x Breakout. First, you will need a microcontroller or single-board computer (SBC) like a Raspberry Pi to communicate with the board. Click the button below to toggle to recommended Raspberry Pi and Qwiic Pi products.

Below are a few Arduino development boards that come Qwiic-enabled out of the box:
SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
6
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

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

SparkFun Qwiic Micro - SAMD21 Development Board

DEV-15423
$20.95
5
If your preferred microcontroller does not have a Qwiic connector, you can add one using one of the following products:
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic Shield for Arduino

SparkFun Qwiic Shield for Arduino

DEV-14352
$6.95
6
SparkFun Qwiic Shield for Thing Plus

SparkFun Qwiic Shield for Thing Plus

DEV-16790
$4.25
SparkFun Qwiic Shield for Arduino Nano

SparkFun Qwiic Shield for Arduino Nano

DEV-16789
$4.25
If you would prefer to use the SparkFun Qwiic KX13x Python package with either board you'll instead want a single-board computer like the products listed below:
Raspberry Pi 4 Model B (4 GB)

Raspberry Pi 4 Model B (4 GB)

DEV-15447
$55.00
16
SparkFun Raspberry Pi 4 Desktop Kit - 2GB

SparkFun Raspberry Pi 4 Desktop Kit - 2GB

KIT-16385
SparkFun DLI Kit for Jetson Nano 2GB

SparkFun DLI Kit for Jetson Nano 2GB

KIT-17245
$139.95
NVIDIA Jetson Nano 2GB Developer Kit

NVIDIA Jetson Nano 2GB Developer Kit

DEV-17244
$59.00
1
SparkFun offers several options to add Qwiic connectors to single-board computers using the Raspberry Pi's 2x20 header:
SparkFun Qwiic HAT for Raspberry Pi

SparkFun Qwiic HAT for Raspberry Pi

DEV-14459
$6.50
4
SparkFun Qwiic SHIM for Raspberry Pi

SparkFun Qwiic SHIM for Raspberry Pi

DEV-15794
$0.95
8
SparkFun Servo pHAT for Raspberry Pi

SparkFun Servo pHAT for Raspberry Pi

DEV-15316
$11.95
3
SparkFun Qwiic pHAT v2.0 for Raspberry Pi

SparkFun Qwiic pHAT v2.0 for Raspberry Pi

DEV-15945
$6.95
2

At least one Qwiic cable is recommended to connect your KX13x Breakout to your microcontroller/SBC:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
10
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50

For users who wish to communicate with the KX13x Breakout using SPI, some through-hole soldering will be necessary. You may already have a few of these items but if not the tools and products below will help with that assembly:

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
Hook-Up Wire - Assortment (Stranded, 22 AWG)

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

PRT-11375
$16.95
18
Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

TOL-14456
$14.95
11
Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.50
2

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:

Serial Peripheral Interface (SPI)

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

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.

Hardware Overview

In this section we'll cover the unique aspects of the KX134 and KX132 accelerometers along with other components found on the Triple Axis Accelerometer Breakout - KX13x (Qwiic).

KX132 & KX134 3-Axis Accelerometers

First up let's examine the two accelerometers on the boards, highlight their specifications and how they differ. The KX134-1211 and KX132-1211 offer the following features:

  • Four User-Selectable Measurement Ranges
    • KX134: ±8 / 16 / 32 / 64g
    • KX132: ±2 / 4 / 8 / 16g
  • User-configurable 3-stage Advanced Data Path (ADP) with low-pass filter, low-pass/high-pass filter and RMS calculation engine
  • User-selectable Low Power or High-Performance Modes
  • Configurable Output Data Rate (ODR) up to 25,600Hz
  • High resolution Wake-Up / Back-to-Sleep functions with configurable thresholds (as low as 15.6mg on the KX134 & 39mg on the KX132)
  • Free fall detection
  • Directional-Tap/Double-Tap
  • Device Orientation algorithms
  • Embedded 512-byte FIFO buffer (continues to record while being read)
  • Digital I2C up to 3.4MHz and Digital SPI up to 10MHz

Photo highlighting KX134 IC and KX13x version jumpers
Note: As these boards both share the same PCB design, a closed solder jumper located below the "right" side Qwiic connector indicates the version (KX132 or KX134). The photo above highlights this solder jumper.

The KX13x also includes an integrated voltage regulator to maintain consistent performance across its entire supply voltage range (1.7 to 3.6V). The table below outlines some of the electrical and functional characteristics of the KX134-1211 and KX132-1211 from the sensors' datasheets. All values in the table apply to both accelerometers unless specifically noted in the table or notes below it. Refer to the accelerometers' datasheets for a full overview: KX132-1211& KX134-1211.

ParameterUnitsMinTypicalMax
Supply Voltage (VDD)V1.72.5 (3.3 for use with Qwiic)3.6
Current Consumption (Accelerometer Only)High Performance w/Wake-up Detection (ODR=800Hz)µA148
Low Power w/Wake-up Detection (ODR=0.781Hz, 2 samples averaged)0.53
Standby0.50
Operating Temperature Range°C-40-105
Output Data RateHz0.7815025600
Sensitivity (16 bit)±2g[1]counts/g145011638417367
±4g[1]770081928684
±8g376840964424
±16g188420482212
±32g[2]94210241106
±64g[2]471512553
Noise[3]RMSmgKX134: 1.9
KX132: 0.7
Densityµg/√HzKX134: 300
KX132: 150
I2C Address0x1E (0x1F alternate)
1. Reminder: ±2/4g ranges are only available on the KX132.
2. Reminder: ±32/64g ranges are only availabe on the KX134.
3. Acceleration data noise varies depending on ODR, power mode & Average Filter Control settings. Noise measuring settings: High-Performance Mode (RES=1), ODR=50Hz, IIR Filter Enabled and IIR filter corner frequency set to ODR/2. Refer to Table 1 in the sensors' Datasheets as well as the Technical Reference Manuals for more information.

Pinout

The KX13x Breakouts' I2C and SPI interface share the same pins so users must select the interface mode by altering the state of the ADR/SDO pin. The ADR jumper sets the state of the ADR/SDO pin (more on that in the Solder Jumpers section). Both breakouts operate in I2C mode by default. We've labeled these shared pins so I2C labels are visible from the front and SPI labels are visible when viewed from the back.

Photo highlighting the pinout as viewed from the top.Photo highlighting the pinout as viewed from the bottom.

Qwiic and I2C Interface

As you would expect on a Qwiic breakout, the boards break out the KX134's I2C pins to a pair of Qwiic connectors to easily integrate the board into a Qwiic system. The I2C pins are also routed to a standard 0.1" spaced header for PTH soldering.

Photo highlighting the Qwiic connectors and I2C PTH pins.
Note: The Qwiic interface is great for general use cases on the lower acceleration ranges and for testing the higher acceleration settings but we recommended to solder the connections for long-term and high-acceleration projects to avoid communication issues.

SPI Interface

Communicating via SPI on the Qwiic KX13x is ideal for taking advantage of the maximum Output Data Rate as the Digital SPI interface on the KX13x-1211 can operate at speeds up to 10MHz.

The Qwiic KX13x breaks out the SPI interface to the same standard 0.1" spaced header as the I2C pins. As mentioned above, the board ships with the I2C interface enabled by default so to switch to the SPI interface users need to open the ADR jumper by severing the trace in between the "Center" and "Left" pads.

Photo highlighting the SPI PTH pins

Interrupt and Trigger Pins

The KX13x has two physical interrupt pins as well as a trigger pin for FIFO buffer control. Both of the physical interrupts operate as push-pull, enter a high-impedence (high-Z) state during the Power-On-Reset (POR) procedure and are driven LOW after POR. Connect these pins to external interrupt-capable pins on your microcontroller to use the interrupt functionalities. Refer to the Interrupt and Buffer examples in the Qwiic KX13x Arduino and Python libraries for a demonstration of using the interrupt pins.

The Trigger pin controls the FIFO buffer. By default, the Qwiic KX13x ties this pin to ground through the TRIG jumper. Users who wish to use the Trigger pin must open that jumper before tying it to a pin on their microcontroller. Refer to the Datasheets (KX132& KX134) and either Technical Reference Manuals (KX132 or KX134) for more information on using this pin to control the FIFO buffer.

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 KX13x has four jumpers labeled ADR, I2C, TRIG and PWR. In this section we'll cover each jumper's purpose, their default states and how to configure them to alter the functionality of the KX13x Breakouts.

Photo highlighting the Power LED solder jumper.Photo highlighting the solder jumpers on the bottom of the board.

Address (ADR) Jumper

This 3-way jumper selects the I2C address of the KX13x and also selects the communication interface for the chip by pulling the ADR/SDO pin to either 3.3V, 0V/Ground or No Connect. By default, the ADR/SDO is pulled to 3.3V via a 4.7k&ohm; resistor to set the KX134 to operate in I2C mode with the I2C address as 0x1E.

To change the I2C address to 0x1F, sever the trace between the "Center" and "Left" pads and then connect the "Center" and "Right" pads together to pull the ADR/SDO pin to 0V/Ground.

Finally, to set the Qwiic KX13x to SPI mode, sever the trace between the "Center" and "Left" pads of the ADR jumper (default setting) to leave the ADR/SDO pin Floating/No Connect. After adjusting the jumper, connect the SDO pin to your controller's SDI/COPI pin.

I2C Jumper

The I2C jumper on the Qwiic KX13x pulls the SDA and SCL lines to 3.3V via a pair of 4.7k&ohm; resistors. The default state of this jumper is CLOSED. Open the jumper by severing the traces between the three pads to disable the pullups on these lines.

If you have more than one device on a single I2C bus, best practices recommend to only maintain a single pair of pullup resistors to avoid creating too strong of a parallel resistance. A strong parallel resistance can lead to communication issues on the bus. Take note that if you are using a single set of pull-up resistors on your I2C bus, make sure all devices operate at the same logic level or are properly shifted to avoid damage to the device(s).

Trigger (TRIG) Jumper

The Trigger jumper ties the TRIG pin on the KX13x-1211 to 0V/Ground. The default state of this jumper is CLOSED. To use the Trigger pin for FIFO control, open the jumper and connect the TRIG PTH pin to a digital I/O pin on your microcontroller. Refer to section 2.5 in the Technical Reference Manuals (KX132 or KX134) for more information on using Trigger Mode.

Power LED (PWR) Jumper

The Power LED jumper (labeled PWR on the board) completes the power LED circuit on the board by tying the anode of the LED to 3.3V via a 1k&ohm; resistor. The jumper is CLOSED by default. Disable the power LED by severing the trace between the two pads. Disabling the LED helps reduce the total current draw of the board and is particularly helpful for low-power or battery-powered applications.

Board Dimensions

The Triple Axis Accelerometer Breakout - KX13x (Qwiic) matches the standard 1x1" (25.4mm x 25.4mm) dimensions for Qwiic breakouts and has four mounting holes that fit a 4-40 screw.

Board Dimensions

Hardware Assembly

Now that we're familiar with the KX13x and the other hardware present on the KX13x Breakouts we can start assembling our circuit. Depending on your preferred use of the accelerometer, you'll want to connect either using I2C using the Qwiic connector (or the PTH header) or via SPI using the PTH header on the board.

Qwiic/I2C Assembly

The fastest and easiest way to get started using the breakout is using either of the Qwiic connectors, a Qwiic cable and a Qwiic-enabled development board like the SparkFun RedBoard Qwiic. If you are using a Raspberry Pi instead for our Python Package, you'll need a Pi, Qwiic cable and an adapter like the Qwiic Shim or another of our Qwiic-enabled pHATs.

Photo showing assembled Qwiic KX13x circuit with RedBoard Qwiic

If you would prefer a more secure and permanent connection, you can solder headers or wire to the PTH header on the board. This method is recommended for permanent installations as well as high-g and vibration sensing applications.

SPI Assembly

If you'd prefer to take advantage of the max output data rate of the KX13x, you'll want to use the SPI interface instead of the I2C interface. Assembling the KX13x Breakout in SPI mode requires some through-hole soldering. If you are not familiar with through-hole soldering, take a read through this tutorial:

How to Solder: Through-Hole Soldering

September 19, 2013

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

Along with tools for soldering, you'll need either some hookup wire or headers and jumper wires. Also, the Address (ADR) Jumper must be opened by severing the trace between the "Center" and "Left" pads to switch to SPI mode. After opening this jumper, connect the SDO pin to your controller's SDI/COPI pin.

Photo highlighting the ADR jumper on the KX13x Breakout

With the KX13x Breakout set to SPI mode, solder headers or wire to the PTH header on the board and make the SPI connections with your controller. Remember the KX13x operates at 3.3V logic so make sure to connect to a board running at the same logic level or use a level shifter to adjust it to a safe voltage.

KX13x 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 KX13x Arudino library makes it easy to get started measuring acceleration data from the sensor. You can install this library through the Arduino Library Manager. Search for "SparkFun KX13x Arduino Library" and install the latest version. If you prefer manually downloading the library from the GitHub repository, you can grab it here:

Library Functions

The list below outlines all of the functions available in the SparkFun Qwiic KX13x Arduino Library along with quick descriptions of what they do. The examples cover many of the functions on this list so refer to them to get started or to demonstrate how to integrate them into your own code.

Class

In the global scope, construct your KX13x object (such as accel or myKX13x) without arguments.

  • QwiicKX13X accel;

The KX13x Arduino Library has a class for each version of the KX13x. Construct the object (such as kxAccel or myKX13x) without arguments:

  • QwiicKX132 kxAccel;

or

  • QwiicKX134 kxAccel;

The examples default to using the KX132 so adjust the object to KX134 if needed.

The library also uses an object for the accelerometer data. Construct the object (such as myData or accelData) in the global class:

  • outputData myData;

Device Setup & Configuration

  • bool begin(uint8_t deviceAddress = KX13X_DEFAULT_ADDRESS, TwoWire &wirePort = Wire); - Start communication with the KX13x via I2C.
  • bool beginSPI(uint*_t, uint32_t spiPortSpeed = 10000000, SPIClass &spiPort = SPI); - Start communication with the KX13x via SPI.
  • bool initialize(uint8_t settings = DEFAULT_SETTINGS); - Initialize the KX13x at the specified settings. These settings are specified according to the AN092 Getting Started App Note and can be adjusted to have additional presets. The available settings in the library are:
    • DEFAULT_SETTINGS - Initialize the KX13x with no alternate settings active.
    • INT_SETTINGS - Initialize the KX13x with the Data Ready Engine enabled (CNTL1 register, bit 5), the KX13x Interrupt 1 pin enabled and configured to trigger on Data Ready.
    • SOFT_INT_SETTINGS - Initialize the KX13x with the Data Ready Engine enabled (CNTL1 register, bit 5), no hardware interrupt pin enabled.
    • BUFFER_SETTINGS - Initialize the KX13x with the Data Ready Engine enabled (CNTL1 register, bit 5), the KX13x Interrupt 1 pin enabled and configured to trigger when the buffer is full. Buffer enabled and settings configured to FIFO mode and 16 bit samples.
  • bool accelControl(bool); - Sets the operating mode of the KX13x to stand-by mode or High-Performance/Low Power mode.
  • uint8_t readAccelSate(); - Reads whether the operating state of the KX13x (Stand By or Active Mode).
  • bool setRange(uint8_t range); - Set the range of the KX13x. Split into dedicated values for either the KX132 or KX134 to avoid errors in data conversion handling. Valid options for this setting are:
    • KX132_RANGE2G
    • KX132_RANGE4G
    • KX132_RANGE8G
    • KX132_RANGE16G
    • KX134_RANGE8G
    • KX134_RANGE16G
    • KX134_RANGE32G
    • KX134_RANGE64G
  • bool setOutputDataRate(uint8_t rate) - Set the refresh rate of the KX13x's output data in Hz. The default value is 50Hz (0b0110). Refer to the table on page 26 of the Technical Reference Manual (KX132& KX134 for valid entries.
  • float readOutputDataRate(); - Reads the value set for the Output Data Rate.
  • bool setInterruptPin(bool enable, uint8_t polarity = 0, uint8_t pulseWidth = 0, bool latchControl = false); - Configure the Interrupt pin settings. Note: settings just one sets all others to their default.
  • bool routeHardwareInterrupt(uint8_t, uint8_t pin = 1); - Route any of the interrupt pin settings to either interrupt pin 1 or 2.
  • bool clearInterrupt(); - Clear the interrupt register by reading the interrupt latch release register.
  • bool dataTrigger(); - Triggers collection of data by the KX13X.
  • bool setBufferThreshold(uint8_t); - Sets the number of samples (not bytes) held in the buffer. Minimum value is two, maximum depends on the buffer resolution (8 or 16bit).
  • bool setBufferOperation(uint8_t, uint8_t); - Sets the resolution and operation mode of the buffer. Resolution can be 8 or 16 bit. Operation modes are FIFO, Stream & Trigger. More information on the buffer modes found on Table 16 of the Technical Reference Manual.
  • bool enableBuffer(bool, bool); - Enables the buffer and sets whether the buffer triggers an interrupt event when full.
  • bool runCommandTest(); - Checks the integrity of the IC. Primarily for manufacturing use.

Acceleration Data

  • bool getRawAccelData(rawOutputData*); - Pull raw acceleration data values for X, Y and Z axes from either the buffer or output registers depending on if buffer usage is specified by the user.
  • bool convAccelData(outputData*, rawOutputData*); - Convert the acceleration data into g using the value stored for setRange();.
  • outputData getAccelData(); - Pull converted acceleration data for X, Y and Z axes. Call data for the specific axis by using myData.xData (or yData/zData) where myData is the definition of outputData class. Refer to the examples in the Arduino library for more information.

Arduino Examples

The SparkFun Qwiic KX13x Arduino Library includes four examples to get started with both KX13x boards.

Example 1 - Basic Readings

Example 1 is a basic example to demonstrate how to read data from the accelerometer. Open the example by navigating to "File > Examples > SparkFun Qwiic KX13x Library > Example1BasicReadings". Next, open the Tools menu and select your board (in this case, Arduino Uno) and correct Port your board enumerated on. Upload the code, open the serial monitor and set the baud rate to 115200.

Code to note:

language:c
QwiicKX132 kxAccel;
outputData myData;

The setup starts the accelerometer and initializes it to the Default Settings. The code freezes if either process fails.

language:c
if( !kxAccel.begin() ){
    Serial.println("Could not communicate with the the KX13X. Freezing.");
    while(1);
  }
  else
    Serial.println("Ready.");



if( !kxAccel.initialize(DEFAULT_SETTINGS)){
    Serial.println("Could not initialize the chip.");
    while(1);
}
else
    Serial.println("Initialized...");

After initializing the IC, the code prints out data for all three axes every 20ms. The delay here is important as it should be 1/ODR (Output Data Rate) and the default setting is 50Hz.

language:c
void loop() {

  myData = kxAccel.getAccelData();
  Serial.print("X: ");
  Serial.print(myData.xData, 4);
  Serial.print("g ");
  Serial.print(" Y: ");
  Serial.print(myData.zData, 4);
  Serial.print("g ");
  Serial.print(" Z: ");
  Serial.print(myData.zData, 4);
  Serial.println("g ");

  delay(20); // Delay should be 1/ODR (Output Data Rate), default is 50Hz

}

Example 2 - Interrupts

Example 2 shows how to use the hardware interrupt pin(s) on the accelerometer. In order to use this example, connect the INT1 pin on the KX13x breakout to an interrupt-capable pin. This example assumes a SparkFun RedBoard Qwiic/Arduino Uno is used so adjust the code as necessary. To follow along with this example (as well as the Buffer Example), assemble your circuit with INT1 connected to D1 on your RedBoard/Uno similar to the photo below:

Interrupt circuit assembled.

Along with creating the KX13x and data objects, the code sets the physical interrupt pin as D1.

language:c
int dataReadyPin = D1;

The code sets the dataReadyPin as an input:

language:c
pinMode(dataReadyPin, INPUT);   

and initializes the accelerometer in the Interrupt Settings mode. By default, this mode enables INT1 and sets it to go HIGH when data is ready to be read:

language:c
if( !kxAccel.initialize(INT_SETTINGS)){
    Serial.println("Could not initialize the chip.");
    while(1);
}
else
    Serial.println("Initialized...");

After initializing the sensor, the main loop monitors the dataReadyPin (D1) and if it is HIGH, prints out data for all three axes:

language:c
void loop() {

  if( digitalRead(dataReadyPin) == HIGH ){ // Wait for new data to be ready.

    myData = kxAccel.getAccelData();
    Serial.print("X: ");
    Serial.print(myData.xData, 4);
    Serial.print("g ");
    Serial.print(" Y: ");
    Serial.print(myData.zData, 4);
    Serial.print("g ");
    Serial.print(" Z: ");
    Serial.print(myData.zData, 4);
    Serial.println("g ");

     //kxAccel.clearInterrupt();// Because the data is being read in "burst"
     //mode, meaning that all the acceleration data is being read at once, we don't
     //need to clear the interrupt.
  }
  delay(20); // Delay should be 1/ODR (Output Data Rate), default is 50Hz
}

Example 3 - Software Interrupts

The third example demonstrates how to use the KX13x to trigger software interrupts. The code initializes the KX13x in Software Interrupt mode. The primary difference between Example 3 and Example 2 is, as you may expect, the software interrupt does not use any of the interrupt pins on the KX13x.

The code initializes the KX13x in software interrupt mode:

language:c
if( !kxAccel.initialize(SOFTWARE_INT_SETTINGS)){
    Serial.println("Could not initialize the chip.");
    while(1);
}
else
    Serial.println("Initialized...");

The main loop waits for available data by polling the data ready bit and prints out acceleration data for all three axes whenever data is ready.

Example 4 - Buffer

The fourth example shows how to use the KX13x in the default buffer settings to trigger hardware interrupts when the buffer is full. Just like Example 2 , the code sets the physical interrupt/data ready pin as D1 which is driven HIGH when the buffer is full. Just like with Example 2, in order to use this example, connect the INT1 pin on the KX13x breakout to an interrupt-capable pin. This example assumes a SparkFun RedBoard Qwiic/Arduino Uno is used so adjust the code as necessary.:

language:c
int dataReadyPin = D1;

In the setup, the dataReadyPin is defined as an input:

language:c
pinMode(dataReadyPin, INPUT);

and the KX13x is initialized with default buffer settings (FIFO mode and 16 bit samples):

if( !kxAccel.initialize(BUFFER_SETTINGS)){
    Serial.println("Could not initialize the chip.");
    while(1);
}
else
    Serial.println("Initialized...");

After setting everything up, the main loop waits for the buffer to fill and drive the data ready pin HIGH. Once the pin goes HIGH, the code prints out acceleration data for all three axes just like the other examples.

Qwiic KX13x 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, these tutorial can help you get started:

We've written a Python package to control the KX13x Breakouts for users who prefer a Raspberry Pi or other Python-specific development environment. You can install the sparkfun-qwiic-kx13x 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-kx13x 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-kx13x

For the current user:

language:bash
pip3 install sparkfun-qwiic-kx13x

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_kx13x-<version>.tar.gz

Qwiic KX13x Python Package Operation

For a full overview of all the functions included with the Qwiic KX13x Py package and how it works, take a look at the source code and package documentation hosted on ReadtheDocs page.

Upgrading the Python Package

If needed, the Python package can be upgraded using the following commands (use pip for Python 2):

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

language:bash
sudo pip3 install --upgrade sparkfun-qwiic-kx13x

For the current user:

language:bash
pip3 install --upgrade sparkfun-qwiic-kx13x

Python Examples

The Qwiic KX13X Python Package includes four examples to get users started with either Qwiic KX13x board using Python. In this section we'll go over the examples and highlight how they work.

To use the examples, open them from the Qwiic KX13X Py location or copy the code into your preferred Python interpreter.

Note, the examples default to using the Qwiic KX132 so if a Qwiic KX1334 is used, adjust the code by un-commenting this line:

language:python
myKX = qwiic_kx13x.QwiicKX134()

And replace any instance of kx132 with kx134. The acceleration range can also be adjusted by uncommenting this line and adjusting the value set for the range:

language:python
myKx.set_range(myKx.KX132_RANGE8G)

Example 1 - Simple Example

The first example is a basic example demonstrating how to initialize a Qwiic KX13x board on the I2C bus using its default settings. The full example code can be found below if you would prefer to copy it into your preferred Python interpreter:

language:python
from __future__ import print_function
import qwiic_kx13x
import time
import sys
import RPi.GPIO

def run_example():

    print("\nSparkFun KX13X Accelerometer Example 1\n")
    # myKx = qwiic_kx13x.QwiicKX134() # If using the KX134 un-comment this line and replace other instances of "kx132" with "kx134"
    myKx = qwiic_kx13x.QwiicKX132()

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

    if myKx.begin():
        print("Ready.")
    else:
        print("Make sure you're using the KX132 and not the KX134")

    # myKx.set_range(myKx.KX132_RANGE8G) # Update the range of the data output.
    myKx.initialize(myKx.BASIC_SETTINGS) # Load basic settings 

while True:

    myKx.get_accel_data()
    print("X: {0}g Y: {1}g Z: {2}g".format(myKx.kx132_accel.x,
                                           myKx.kx132_accel.y,
                                           myKx.kx132_accel.z))
    time.sleep(.02) #Set delay to 1/Output Data Rate which is by default 50Hz 1/50 = .02


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

Example 2 -

The second example shows how to enable Hardware Interrupt Pin 1 on the KX13x and fires it whenever data is ready. The complete example code can be found below if you prefer to copy/paste it into your prefered Python interpreter:

language:python
from __future__ import print_function
import qwiic_kx13x
import time
import sys
import RPi.GPIO

def runExample():

    print("\nSparkFun KX13X Accelerometer Example 1\n")
    # myKx = qwiic_kx13x.QwiicKX134() # If using the KX134 un-comment this line and replace other instances of "kx132" with "kx134"
    myKx = qwiic_kx13x.QwiicKX132()

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

    if myKx.begin():
        print("Ready.")
    else:
        print("Make sure you're using the KX132 and not the KX134")

    # myKx.set_range(myKx.KX132_RANGE8G) # Update the range of the data output.
    myKx.initialize(myKx.INT_SETTINGS) # Load basic settings 

    dataReadyPin = 5
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(dataReadyPin, GPIO.IN)

    while True:

        if GPIO.INPUT(dataReadyPin) == 1:

            myKx.get_accel_data()
            print("X: {0}g Y: {1}g Z: {2}g".format(myKx.kx132_accel.x,
                                                   myKx.kx132_accel.y,
                                                   myKx.kx132_accel.z))

        time.sleep(.02) #Set delay to 1/Output Data Rate which is by default 50Hz 1/50 = .02

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

Example 3 - Software Interrupts

Example 3 shows how to use software interrupts to signal when accelerometer data is ready. The primary difference between this and the hardware interrupts is none of the KX13x Hardware Interrupt Pins are enabled. The full example is below for users who prefer to copy/paste it into their Python interpreter:

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

def runExample():

    print("\nSparkFun KX13X Accelerometer Example 1\n")
    # myKx = qwiic_kx13x.QwiicKX134() # If using the KX134 un-comment this line and replace other instances of "kx132" with "kx134"
    myKx = qwiic_kx13x.QwiicKX132()

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

    if myKx.begin():
        print("Ready.")
    else:
        print("Make sure you're using the KX132 and not the KX134")

    # myKx.set_range(myKx.KX132_RANGE8G) # Update the range of the data output.
    myKx.initialize(myKx.SOFT_INT_SETTINGS) # Load basic settings 

    while True:

        if myKx.data_trigger():

            myKx.get_accel_data()
            print("X: {0}g Y: {1}g Z: {2}g".format(myKx.kx132_accel.x,
                                                   myKx.kx132_accel.y,
                                                   myKx.kx132_accel.z))

        time.sleep(.02) #Set delay to 1/Output Data Rate which is by default 50Hz 1/50 = .02

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

Example 4 - Buffer Interrupt

The fourth and final example builds on the hardware interrupt example and uses the Hardware Interrupt Pins to indicate when a buffer is full and ready to be read. Copy/paste the code below into your preferred Python interpreter:

language:python
from __future__ import print_function
import qwiic_kx13x
import time
import sys
import RPi.GPIO

def runExample():

    print("\nSparkFun KX13X Accelerometer Example 1\n")
    # myKx = qwiic_kx13x.QwiicKX134() # If using the KX134 un-comment this line and replace other instances of "kx132" with "kx134"
    myKx = qwiic_kx13x.QwiicKX132()

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

    if myKx.begin():
        print("Ready.")
    else:
        print("Make sure you're using the KX132 and not the KX134")

    # myKx.set_range(myKx.KX132_RANGE8G) # Update the range of the data output.
    myKx.initialize(myKx.BUFFER_SETTINGS) # Load basic settings 

    dataReadyPin = 5
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(dataReadyPin, GPIO.IN)

    while True:

        if GPIO.INPUT(dataReadyPin) == 1: # When the buffer is full, the pin will go high

            myKx.get_accel_data()
            print("X: {0}g Y: {1}g Z: {2}g".format(myKx.kx132_accel.x,
                                                   myKx.kx132_accel.y,
                                                   myKx.kx132_accel.z))

        time.sleep(.02) #Set delay to 1/Output Data Rate which is by default 50Hz 1/50 = .02

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

Troubleshooting

Switching to SPI

As we've covered before in this tutorial, using either KX13x Breakout in SPI mode requires a slight modification to the board. The ADR Jumper must be completely opened so the ADR/SDO pin is floating prior to being connected to the SPI controller's SDI/COPI pin. Also, make sure the controller the KX13x Breakout connects to runs at 3.3V logic to avoid damaging the IC. Using either accelerometer breakout with a 5V controller requires level shifting the signal.

General Troubleshooting and Technical Support

Resources and Going Further

For more information on the SparkFun Triple-Axis Accelerometer Breakout - KX13x (Qwiic), take a look at the following recources:

For some inspiration on motion-based projects using your KX13x Breakout, take a look at these tutorials:

Sensor Kit Resource Hub

An overview of each component in the SparkFun Sensor Kit, plus links to tutorials and other resources you'll need to hook them up.

Getting Started with the micro:bit

The BBC micro:bit is a compact, powerful programming tool that requires no software installation. Read on to learn how to use it YOUR way!

SparkFun Inventor's Kit Experiment Guide - v4.0

The SparkFun Inventor's Kit (SIK) Experiment Guide contains all of the information needed to build all five projects, encompassing 16 circuits, in the latest version of the kit, v4.0a.

Hookup Guide for the Qwiic Motor Driver

Drive things "qwiic"-ly with the SparkFun Qwiic Motor Driver!

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

Qwiic Haptic Driver DA7280 Hookup Guide

$
0
0

Qwiic Haptic Driver DA7280 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The Qwiic Haptic Driver includes an itty-bitty, Linear Resonant Actuator (LRA) vibration motor and Dialog Semiconductor's DA7280 motor driver IC for applications that require haptic feedback. There is also a kit for those that would like the motor mounted separately from the board. Note that you will need to manually solder the wires and motor to the board.

SparkFun Qwiic Haptic Driver - DA7280

SparkFun Qwiic Haptic Driver - DA7280

ROB-17590
$14.95
SparkFun Qwiic Haptic Driver Kit - DA7280

SparkFun Qwiic Haptic Driver Kit - DA7280

ROB-18247
$15.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 Qwiic Haptic Driver - DA7280

SparkFun Qwiic Haptic Driver - DA7280

ROB-17590
$14.95
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Reversible USB A to Reversible Micro-B Cable - 0.8m

Reversible USB A to Reversible Micro-B Cable - 0.8m

CAB-15428
$3.95

Suggested Reading

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

Qwiic Connect System
Qwiic Connect System

If you aren’t familiar with the following concepts, we also recommend checking out a few of these tutorials before continuing. While the Haptic Motor Driver hookup guide linked below uses a different IC on the board, there is some useful information about different motors available in the tutorial.

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.

Haptic Motor Driver Hook-Up Guide

Good vibes only. Getting started with the Haptic Motor Driver.

Hardware Overview

Haptic Driver and LRA Motor

The haptic driver IC rotated at 45° with respect to the board while the circular disk is the LRA motor. If you received the kit version, the motor will need to be soldered to the board using the wires. Note that the Arduino library used in this tutorial configures the DA7280's settings based on the LRA motor's specifications.

DA7280 Haptic Driver and LRA Motor

Power and Logic Levels

We recommend powering the board through the Qwiic connector when quickly prototyping. For a more secure connection, you can always solder to the PTHs labeled 3V3/VDD and GND. The recommended input voltage when using the board with a microcontroller is 3.3V. However, you could potentially power the board between 2.8V to 5.5V as explained in the datasheet. Note that the 3V3/VDD is connected to VDDIO. There is a jumper on the back of the board to disconnect the input voltage and the logic levels if you decide to use different voltages. If you decide to adjust the logic level, this is typically 1.8V. However, you can set the logic levels between 1.35V and 5.5V as long as VDDIOVDD and if GPI0, GPI1, and GPI2 are not grounded as it is recommended in the datasheet.

Power Rails Highlighted on Qwiic Haptic Driver  DA7280

I2C

The main method of controlling the DA7280 and the vibe motor is through the I2C bus. The board includes two Qwiic connectors for fast prototyping and removes the need for soldering. All you need to do is plug a Qwiic cable into the Qwiic connector and voila! You can also solder to the PTHs labeled as SDA and SCL as an alternative. The address for the DA7280 is 0x4A.

Qwiic Connectors and I2C Port Highlighted for the Qwiic Haptic Driver DA7280

Interrupt

The interrupt is active low and notifies the host microcontroller when the DA7280 has finished driving the motor. This connection is optional and available for those that decide to include an interrupt for their application.

Interrupt Pin Highlighted on Qwiic Haptic Driver DA7280

PWM Pin

The second method of controlling the DA7280 is to send a PWM signal to the GPI0 pin. Once the DA7280 is configured to PWM mode via I2C, the duty cycle of the PWM signal will be reflected on the DA7280's output drive to the vibration motor. The DA7280 requires that the PWM signal is at least 10kHz. The top of the board only labels the PTH as GPI0 due to the space available around the pin while the back of the board labels the pin as GPI0/PWM.

GPI0/PWM Pin Highlighted on Qwiic Haptic Driver DA7280

GPI Pins

The third method of controlling DA7280 and the motor is through the general purpose input (GPI) pins. These can be configured to edge trigger based on the the combination of the pins and waveforms that are stored in the DA7280's memory.

GPI Pins Highlighted on Qwiic Haptic Driver DA7280

LED

The board includes an LED indicator that lights up when there is power available.

LED Highlighted on Qwiic Haptic Driver DA7280

Jumpers

There are four jumpers on the back of the board. For more information, check out our tutorial on working with jumper pads and PCB traces should you decide to cut the traces with a hobby knife.

  • LED - This is connected to the PWR LED on the top of the board. Cutting this disables the LED.
  • I2C - The I2C jumper is connected to the 4.7k&ohm; pull-up resistors for the I2C bus. Most of the time you can leave these alone unless your project requires you to disconnect the pull-up resistors.
  • QISO - The QISO jumper is connected to the Qwiic bus power line (i.e. 3.3V). Cut this trace to separate power from the Qwiic ports if you decide to power the board with a different voltage on 3V3/VDD. Note that the I2C lines are still pulled up to 3.3V.
  • IO - The IO jumper connects 3.3V/VDD to VDDIO for the DA7280. Cut this trace and supply VDDIO with a different voltage to adjust the DA7280's logic levels. This is typically 1.8V. However, you can set the logic levels between 1.35V and 5.5V as long as VDDIOVDD and if GPI0, GPI1, and GPI2 are not grounded as it is recommended in the datasheet

LED, I2C Pullup Resistor, QISO, IO, Jumpers Highlighted on Qwiic Haptic Driver DA7280

Board Dimensions

The board dimension is 1.00" x 1.15" and includes 3x mounting holes. The mounting holes are spaced using the Qwiic standard for 1.0"x1.0" sized boards. Note that the board is longer on one side to accommodate the SMD vibe motor.

Board Dimensions

Hardware Assembly

There are three modes (I2C, PWM, and stande-alone with the GPI) available for the DA7280. For the scope of this tutorial and Arduino Library, we will be using the I2C and PWM modes. If you are using the PTHs, we recommend soldering header pins or wires to the board for a secure connection.

I2C Mode

The main method to control the DA7280 is through an I2C bus. You'll need the RedBoard Qwiic and a USB cable to program the microcontroller. Insert the USB cable into the RedBoard. Then insert a Qwiic cable between the RedBoard Qwiic and Qwiic Haptic Driver. Depending on your application, you can also solder to the plated through holes for a secure connection.

RedBoard Qwiic Connected to Qwiic Haptic Driver for I2C Mode

PWM Mode

The second method of controlling the DA7280 is via PWM. The Haptic Driver IC requires that the PWM signal frequency given to GPI0/PWM pin is at least 10kHz. The default PWM methods of analogWrite() does not provide a method of controlling the frequency of the PWM signal. To use with the RedBoard with ATmega328P, you will need to use the TimerOne Arduino Library by Paul Stoffregen as explained later in this tutorial. Note that this library is limited to certain boards. For the Arduino Uno (e.g. the RedBoard with ATmega328P) the pins that are reserved for PWM are on pins 9 and 10.

In this case, we will connect the Qwiic Haptic's GPIO0/PWM pin to the RedBoard's pin 9. We also still need to control the DA7280. Make sure to include a Qwiic cable between the boards as well.

PWM Mode

Before powering up, you will also need to ensure that you cut the trace for the RedBoard Qwiic's I/O and add a solder jumper to the 3.3V pin.

Cut Jumper and Add Solder Jumper

Soldering Wires

For those that want to attach the LRA motor separately from the board, you will need to solder wires between the Qwiic Haptic Driver board's castellated pins. For a flush connection, we recommend cutting the male header pins and stripping the wire. Solder the black wire to the castellated pin (which is connected to DA7280's OUTN pin) that is the closest to the PWR LED. Then solder the red wire to the other castellated pin (which is connected to the DA7280's OUTP pin).

Solder Wires to Qwiic Haptic Driver Board

Cut and strip the wire on the other ends. With the LRA motor's SMD pads facing you (as shown in the image below), solder the black wire on the left pad. Then solder the red wire on the right pad.

Solder Wires to LRA Vibration Motor

If you decide to leave the header pins on the wires, your setup will look similar the image on the left. With the header pins removed, your setup will look similar to the image on the right. For a secure connection, you may want to add some hot glue to the terminals for strain relief. Once soldered, simply attach a Qwiic cable between the Qwiic connectors or solder wire to your connections as explained above. Remember, you will need to adjust the RedBoard Qwiic's logic level to 3.3V if you decide to use the PWM mode.

M/M jumper wires solderedM/M jumper pins cut and wire soldered
M/M jumper wires solderedM/M jumper pins cut and wire soldered

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 DA7280 Haptic Driver Arduino library can be downloaded with the Arduino library manager by searching 'SparkFun Qwiic Haptic Driver DA7280' or you can manually install the library by downloading the zip here from the GitHub repository:

Example 1: I2C Mode

We're just going to look the I2C_Mode.ino example. Open the File>Examples>SparkFun Qwiic Haptic Driver DA7280 Arduino Library>I2C_Mode. Select your board (in this case Arduino Uno) and COM port. Then hit the upload button.

Once uploaded, the Qwiic Haptic Driver should begin vibrating every half a second. Note that the value for hapDrive.setVibrate() range from 0 to 127. A value of 0 turns the motor off while a value of 127 turns the motor fully on. Try adjusting the value to a higher intensity. If the motor does not vibrate, try uncommenting the code to clear the interrupt.

Example 2: PWM Mode

We're just going to look the PWM_Mode_Timer1.ino example. Open the File>Examples>SparkFun Qwiic Haptic Driver DA7280 Arduino Library>PWM_Mode_Timer1.ino. Select your board (in this case Arduino Uno) and COM port. Then hit the upload button.

Once uploaded, the Qwiic Haptic Driver will first clear a flag that shuts the motor off if the PWM signal is cut off suddenly without being set into inactive mode. The motor will begin vibrating based on the PWM signal in the for loop. In this case, the PWM signal is dependent on the value for power and we slowly increase the intensity.

Resources and Going Further

For more information about the Qwiic Haptic Driver DA7280, check out the resources below.

Looking for more information about haptic motors project ideas? Check out the following tutorials.

Haptic Motor Driver Hook-Up Guide

Good vibes only. Getting started with the Haptic Motor Driver.

LilyPad Vibe Board Hookup Guide

The LilyPad Vibe Board is a small vibration motor that can be sewn into projects with conductive thread and controlled by a LilyPad Arduino. The board can be used as a physical indicator on clothing and costumes for haptic feedback.

Or check out this blog post for ideas.


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

MicroMod STM32 Processor Hookup Guide

$
0
0

MicroMod STM32 Processor Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

We've brought the power and precision of the STM32 Processor to the MicroMod ecosystem! Please welcome the MicroMod STM32 Processor Board! With the high-performance Arm® Cortex®-M4 32-bit RISC core, Flash memory up to 1 Mbyte, up to 192 Kbytes of SRAM, a memory protection unit (MPU), high-speed embedded memories, up to 4 Kbytes of backup SRAM, and an extensive range of enhanced I/Os and peripherals, this board is ready to rock your MicroMod world. Let's dive in!

SparkFun MicroMod STM32 Processor

SparkFun MicroMod STM32 Processor

DEV-17713
$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.

Suggested Reading

The SparkFun MicroMod ecosystem offers 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 (e.g. Bluetooth or WiFi)? There's a MicroMod Processor Board for that. Looking to instead maximize efficiency and processing power? You guessed it, there's a MicroMod Processor Board for that. If you are not familiar with the MicroMod ecosystem, 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!

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.


M.2 Connector from the FrontM.2 Connector from the Back

STM32F405

There is so much packed into this chip! As stated in the introduction, STMicroelectronics' STM32F405RG family is based on the ARM Cortex M4 RISC core. At 168MHz, it provides very high performance, floating point single precision, a full set of DSP instructions, and a memory protection unit that enhances application security. For more information, refer to the Datasheet.

STM32 Arm Cortex is Highlighted

Power

Power is supplied by the carrier board, but it should be noted that all pins are 3.3V.

Boot and Reset Buttons

In order to upload code to the STM32 MicroMod Processor Board, you'll need these two buttons to put the board into Boot mode. Hold the Boot button down, press the Reset button (while still holding the Boot button), and then release the Boot button.

These pins will be on the carrier board. For this tutorial, we will show you the these pins on the MicroMod ATP Carrier board.

Boot and Reset buttons highlighted on ATP Carrier Board

Flash

To complement the STM32F405 processor, we've added an additional 128Mb (16MB) serial flash memory chip.

Flash chip is highlighted

Status LED

Status LED is highlighted

MicroMod STM32F405 Processor Pin Functionality

Graphical Datasheet

Click on image for a closer view of the graphical datasheet.

The complete pin map can be found in the table below or you can refer to the schematic.

AUDIOUARTGPIO/BUSI2CSDIOSPIDedicated
FunctionBottom
Pin
   Top   
Pin
Function
(Not Connected)75GND
3.3V7473G5 / BUS5
7271G6 / BUS6
7069
6867
6665
6463G10/HOST_VBUS
6261SPI_CIPO (I)
6059SPI_COPI (O)
5857SPI_SCK (O)
AUD_OUT5655SPI_CS#
AUD_IN5453I2C_SCL1 (I/O)
AUD_LRCLK5251I2C_SDA1 (I/O)
AUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 to 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
2221SWDCK
2019UART_RX1 (I)
D11817UART_TX1 (0)
I2C_INT#1615
I2C_SCL (I/0)1413
I2C_SDA (I/0)1211BOOT# (I - Open Drain)
D0109
G11/HOST_ID87GND
RESET# (I - Open Drain)65USB_D-
43USB_D+
3.3V21GND
FunctionBottom
Pin
   Top   
Pin
Function
(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 (I)
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
CAM_MCLKPCM_OUTI2S_OUTAUD_OUT5655SPI_CS#
CAM_PCLKPCM_INI2S_INAUD_IN5453I2C_SCL1 (I/O)
PDM_DATAPCM_SYNCI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PDM_CLKPCM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 to 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
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 Outline

The board takes advantage of the standard MicroMod form factor.

Board outline and measurements

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.

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!

After inserting the MicroMod STM32 processor board into a carrier board, your setup may look like the following:

alt text

Go ahead and secure the Processor Board by gently pressing it down and tightening the screw (not too much though).

Gently tightening the screw on the micromod carrier board to secure the processor

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.

Arduino Board Definition

Installation for the STM32 MicroMod Processor is relatively straight-forward. You will want to install the board definitions via the Arduino Boards manager. Search for SparkFun STM32 and you should see the option for the STM32 MicroMod Processor show up.

Boards Manager with SparkFun STM32 boards

For more information on installing boards via the Arduino Board Manager, check out the add-ons section of our Installing Arduino IDE tutorial.

Installing Arduino IDE

March 26, 2013

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Install STM32Cube Programmer Software

In order to work with the STM32 MicroMod Processor, you'll need to install the STM32Cube Programmer. This is an all-in-one multi-OS software tool for programming STM32 products. It primarily provides the driver we need, but you can also program your board using this GUI.

DFU Bootloader

As of this writing, SparkFun is using the DFU bootloader to upload code to the STM32 MicroMod Processor. In order to do so, you need to do the following:

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Keep pressing the Boot button until the code is uploaded

Examples

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.


Once you've plugged your MicroMod Carrier Board with your MicroMod STM32 Processor into your computer, you'll need to go to your Tools menu and set up your options to look like the following:

Tools menu with STM32 Options

With everything setup correctly, you'll need to put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

Once the code finishes transferring, you should see the STAT LED on the STM32 Processor Board begin to blink!

Status LED on the STM32 MicroMod Processor Board is blinking
If the blue LED remains dimly lit, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the RST button to get your STM32 MicroMod Processor Board to begin running the sketch.

I2C Scanner

The Qwiic Connect Ecosystem makes attaching sensors a breeze. That said, sometimes it's nice to be able to scan your I2C connections to find out the address of your sensor. That's what we'll do here!

Grab your MicroMod STM32 Processor Board and your Carrier Board, and attach a Qwiic Sensor to the Qwiic port on the Carrier like so:

STM32 Processor Board, Carrier Board, and Qwiic sensor attached

Copy and paste the code below into a new Arduino sketch.

language:c
// --------------------------------------
// I2C Scanner example using Wire1
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

TwoWire Wire1(SDA1,SCL1); //Intialize Wire1 class

void setup()
{
  Wire1.begin();

  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

Make sure your options are all set up correctly in the Tools menu, and make sure you put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

After uploading, open the serial monitor and set the baud to 115200. You should see a similar printout to the one shown below.

GIF of screen monitor showing that the qwiic sensor has been found and address 0x48

UART Example

Let's have a quick look at an example using UART. If you're unfamiliar with Serial Output, go ahead and have a look at our Serial Basic Tutorial.

Grab your MicroMod STM32 Processor Board and your Carrier Board, and attach the Serial Basic Rx and Tx pins like so:

MicroMod ATP board with Serial Basic RX and TXX pins hooked up

Click on the image for a closer view

Copy and paste the code below into a new Arduino sketch.

language:c
// --------------------------------------
// UART example using Serial1
//
//
// This sketch prints "Hello World!" every second
// using the secondary UART pins RX1 and TX1.
//



HardwareSerial Serial1(RX1, TX1); //Attach Serial1 to RX1 and TX1

void setup() {
  Serial1.begin(115200);
  while (!Serial1) {
    ; // wait for serial port to connect. Needed for Native USB only
  }
  Serial1.println("Goodnight moon!");

}

void loop() {
  Serial1.println("Hello World!");
  delay(1000);
}

Make sure your options are all set up correctly in the Tools menu, and make sure you put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

Once your code is uploaded, open up the Serial Monitor attached to your Serial Basic with the baud rate set to 115200 to see your output!

Gif of the serial output printing "Hello World" every second

Troubleshooting

Resources and Going Further

Need some inspiration for your next project? Check out some of these related tutorials using STM32:

New!

STM32 Thing Plus Hookup Guide

Get started with the STM32 Thing Plus!

Or check out other tutorials with MicroMod:

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!

MicroMod Artemis Processor Board Hookup Guide

Get started with the Artemis MicroMod Processor Board in this tutorial!

MicroMod All The Pins (ATP) Carrier Board

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

Qwiic Carrier Board Hookup Guide

The Qwiic carrier board is the latest way to rapid prototype with the included M.2 socket to swap processor boards and Qwiic connectors to easily connect I2C devices.

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

STM32 Thing Plus Hookup Guide

$
0
0

STM32 Thing Plus Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

What incorporates a high-performance Arm® Cortex®-M4 32-bit RISC core, a full set of DSP instructions, memory protection unit (MPU), high-speed embedded memories, up to 4 Kbytes of backup SRAM, and an extensive range of enhanced I/Os and peripherals? The new SparkFun STM32 Thing Plus has all this and more in the popular, Feather-compatible Thing Plus form factor.

Let's have a look at the details!

SparkFun Thing Plus - STM32

SparkFun Thing Plus - STM32

DEV-17712
$29.95

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Suggested Reading

If you aren't familiar with the 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.

Serial Communication

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

I2C

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

ARM Programming

How to program SAMD21 or SAMD51 boards (or other ARM processors).

Hardware Overview

STM32F405

The STM32 Thing Plus exploits the vast capabilities of STMicroElectronics' STM32F405 series. This family of ICs uses the ARM 32-bit Cortex M4 CPU to provide high performance, floating point single precision, a full set of DSP instructions, and a memory protection unit that enhances application security. For more information, refer to the Datasheet.

Features

  • Core: ARM® 32-bit Cortex®-M4 CPU with FPU
  • Adaptive real-time accelerator (ART Accelerator™) allowing 0-wait state execution from Flash memory
  • Frequency up to 168 MHz
  • Memory protection unit
  • 210 DMIPS/1.25 DMIPS/MHz (Dhrystone 2.1)
  • DSP instructions

STM32 Arm Cortex is highlighted

Power

Power to the STM32 Thing Plus can be supplied either by a single-cell LiPo battery or by USB-C. The STM32 Thing Plus has an onboard 3.3V regulator, as well as a LiPo battery charging circuit.

USBC connector and LiPo battery connector highlighted

Qwiic Connector

Our Qwiic Ecosystem makes sensors pretty much plug and play. The Qwiic connector provides power and I2C connectivity simultaneously. In addition, the Thing Plus form factor breaks out the I2C functionality to PTH.

Qwiic connector is highlighted

Boot and Reset Buttons

In order to upload code to the STM32 Thing Plus, you'll need these two buttons to put the board into Boot mode. To enter Boot mode, hold the Boot button down, press the Reset button (while still holding the Boot button), and then release the Boot button.

Boot and Reset Buttons are highlighted

MicroSD

Want extra storage space? Add a MicroSD card using the slot on the back of the board.

MicroSD slot is highlighted

Flash

In addition to the STM32's internal Flash memory, we've provided an additional (128M-bit) Serial Flash memory.

Flash chip is highlighted

Board Dimensions

Board Outline and Measurements

Assembly Tips

Headers

The STM32 Thing Plus ships without anything soldered into the header pins -- ensuring that you can mold the board to best fit your project. To use the chip's pins you'll need to solder something to the I/O and power rail vias broken out to either side of the board.

New to soldering? Check out our Through-Hole Soldering Tutorial for a quick introduction!

What you solder to the STM32 Thing Plus's I/O pins is completely up to you. The header rows are breadboard-compatible, so you may want to solder male headers in.

STM32 Thing with male headers soldered

STM32 Thing Plus with soldered male headers.

Then plug it into the breadboard, hanging the USB and LiPo connectors off the end, and start wiring!

Alternatively, female headers (you may need two separate strips to solder all the pins), right-angle headers, or stranded wire are all good options, depending on your project's needs.

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.

Arduino Board Definition

Installation for the STM32 Thing Plus is relatively straight-forward. You will want to install the board definitions via the Arduino Boards manager. Search for SparkFun STM32 and you should see the option for the STM32 Thing Plus show up.

Boards Manager with SparkFun STM32 boards

For more information on installing boards via the Arduino Board Manager, check out the add-ons section of our Installing Arduino IDE tutorial.

Installing Arduino IDE

March 26, 2013

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Install STM32Cube Programmer Software

In order to work with the STM32 Thing Plus, you'll need to install the STM32Cube Programmer. This is an all-in-one multi-OS software tool for programming STM32 products. It primarily provides the driver we need, but you can also program your board using this GUI.

DFU Bootloader

As of this writing, SparkFun is using the DFU bootloader to upload code to the STM32 Thing Plus. In order to do so, you need to do the following:

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Keep pressing the Boot button until the code is uploaded

Example - Blinky

With the STM32 Arduino core installed, you're ready to begin programming. If you haven't already, plug the STM32 Thing Plus into your computer using a USB-C cable.

Once the board is plugged in, it should be assigned a unique port identifier. On Windows machines, this will be something like COM#, and on Macs or Linux computers it will come in the form of /dev/tty.usbserial-XXXXXX.

Select the Board and Port

You'll notice that there are quite a few options. Make sure you have the Generic STM32F4 Series board and SparkFun Thing Plus STM32F405 board part number selected under your Tools menus.

The other options are more variable. For this example, you'll want to set your selections as you see below.

Tools Menu with options selected

Loading Blink

To make sure your toolchain and board are properly set up, we'll upload the simplest of sketches -- Blink! The builtin LED is perfect for this test. Copy and paste the example sketch below into a fresh Arduino sketch:

language:c

void setup()
{
    pinMode(LED_BUILTIN, OUTPUT);
    Serial.begin(115200);
}

void loop()
{
    Serial.println("Hello, world!");
    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
}

With everything setup correctly, hit the upload button.

IMPORTANT In order to upload code via the DFU Bootloader, you will need to press and hold the Boot Button, then press the Reset Button, then release the Reset Button, then release the Boot Button.

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.

Note: If the blue LED remains dimly lit, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the RST button to get your STM32 Thing Plus to begin running the sketch.

Example serial port output

You may also notice that when the STM32 boots up it prints out a long sequence of debug messages. These are emitted every time the chip resets -- always at 115200 baud.

STM32 Thing Plus with blinking LED!

Example - I2C Scanner

The Qwiic Connect Ecosystem makes attaching sensors a breeze. That said, sometimes it's nice to be able to scan your I2C connections to find out the address of your sensor. That's what we'll do here!

Grab your STM32 Thing Plus and attach a Qwiic Sensor to the Qwiic port on the Thing Plus like so:

Image of STM32 TP and Qwiic sensor attached

Copy and paste the code below into a new Arduino sketch.

language:c
// --------------------------------------
// I2C Scanner example using Wire1
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

TwoWire Wire1(SDA1,SCL1); //Intialize Wire1 class

void setup()
{
  Wire1.begin();

  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

Make sure your options are all set up correctly in the Tools menu, and make sure you put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

After uploading, open the Serial Monitor and set the baud to 115200. You should see something similar to the printout below.

GIF of screen monitor showing that the qwiic sensor has been found and address 0x48

Example - Serial UART

Let's have a quick look at an example using UART. If you're unfamiliar with Serial Output, go ahead and have a look at our Serial Basic Tutorial.

Grab your MicroMod STM32 Thing Plus board and attach the Serial Basic Rx and Tx pins like so:

Hookup image showing Rx connected to Tx and Tx connected to Rx

Click on the image for a closer view

Note that the RX pin functionality is D0 and the TX pin functionality is D1.

Copy and paste the code below into a new Arduino sketch.

language:c
// --------------------------------------
// UART example using Serial1
//
//
// This sketch prints "Hello World!" every second
// using the secondary UART pins D0 and D1.
//



HardwareSerial Serial1(D0, D1); //Attach Serial1 to D0 and D1

void setup() {
  Serial1.begin(115200);
  while (!Serial1) {
    ; // wait for serial port to connect. Needed for Native USB only
  }
  Serial1.println("Goodnight moon!");

}

void loop() {
  Serial1.println("Hello World!");
  delay(1000);
}

Make sure your options are all set up correctly in the Tools menu, and make sure you put your board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

Once your code is uploaded, open up the Serial Monitor attached to your Serial Basic with the baud set to 115200 to see your output!

Gif of the serial output printing "Hello World" every second

Troubleshooting

Resources and Going Further

This should get you started with the STM32 Thing Plus. Need more information? Check out some of the links below:

Check out these other great Thing Plus tutorials from SparkFun:

XBee3 Thing Plus Hookup Guide

Get started with SparkFun's XBee3 Thing Plus - both the u.FL as well as the PCB antenna versions.

SAMD51 Thing Plus Hookup Guide

This tutorial covers the basic functionality of the SAMD51 Thing Plus and highlights the features of the new ARM Cortex-M4F development board.

Hookup Guide for the SparkFun Artemis Thing Plus

Get started with our SparkFun Artemis Thing Plus - our popular Thing Plus footprint with the powerful Artemis module for ultimate functionality.

RP2040 Thing Plus Hookup Guide

Want to take a stab at advancing your programming skills? Check out the Thing Plus - RP2040, with the first microcontroller from the Raspberry Pi Foundation. This guide will get you started working with the RP2040 and programming in MicroPython and C/C++.

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

Qwiic 6DoF (LSM6DSO) Breakout Hookup Guide

$
0
0

Qwiic 6DoF (LSM6DSO) Breakout Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Note: This tutorial is for the LSM6DSO. It is important to note that last designation for the IC is the letter O as opposed to the number 0. There is also the LSM6DS0 that was released by STMicroelectronics but it is EOL.

The LSM6DSO is an accelerometer and gyroscope sensor with a giant 9 kbyte buffer and embedded processing interrupt functions, specifically targeted at the cellphone market. The sensor is super-flexible and can be configured specifically for an application. We've put together a driver and slew of examples to help you explore the possibilities.

SparkFun 6 Degrees of Freedom Breakout - LSM6DSO (Qwiic)

SparkFun 6 Degrees of Freedom Breakout - LSM6DSO (Qwiic)

SEN-18020
$11.95

Some of the things the LSM6DSO can do:

  • Read accelerometer data up to 6.66 kilosamples per second, for super accurate movement sensing
  • Read gyroscope data up to 6.66 kilosamples per second
  • Operates at 0.55mA for up to 6.66 ksps modes
  • Read temperature
  • Buffer up to 9 kbytes of data between reads (built-in FIFO)
  • Count steps (Pedometer)
  • Detect shocks, tilt, motion, taps, double-taps
  • Host other sensors into its FIFO
  • Drive interrupt pins by embedded functions or by FIFO low-capacity/overflow warning.

Covered In This Tutorial

This tutorial gives you all you need to get going with the LSM6DSO. We'll introduce you to the chip itself, then the breakout board. Then we'll switch over to example code and show you how to interface with the board using an Arduino and our SparkFun LSM6DSO Arduino library.

The tutorial is split into the following pages:

  • Introduction - Basic information
  • Hardware Overview - Hardware connections
  • Hardware Assembly - Connect to the LSM6DSO by I2C or SPI
  • Installing the Arduino Library - Includes overview of the examples
  • Using the Arduino Library - Explains the user API
  • Resources and Going Further - Links to the datasheet and application notes, plus inspirational projects

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 RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Reversible USB A to Reversible Micro-B Cable - 0.8m

Reversible USB A to Reversible Micro-B Cable - 0.8m

CAB-15428
$3.95
SparkFun 6 Degrees of Freedom Breakout - LSM6DSO (Qwiic)

SparkFun 6 Degrees of Freedom Breakout - LSM6DSO (Qwiic)

SEN-18020
$11.95
Warning! The LSM6DSO is a 3.3V device! Supplying voltages greater than ~3.6V can permanently damage the IC. As long as your Arduino has a 3.3V supply output, and you're ok with using I2C, you shouldn't need any extra level shifting. If you want to use SPI, you may need a level shifter.

SparkFun Logic Level Converter - Bi-Directional

SparkFun Logic Level Converter - Bi-Directional

BOB-12009
$2.95
108
SparkFun Level Translator Breakout - PCA9306

SparkFun Level Translator Breakout - PCA9306

BOB-15439
$4.25
A logic level shifter is required for any 5V-operating Arduino (Uno, RedBoard, Leonardo, etc). If you use a 3.3V-based 'duino -- like the Arduino Pro 3.3V or 3.3V Pro Mini -- there is no need for level shifting.

The RedBoard Qwiic has two level shifters on the I2C lines so you do not need to worry about the logic levels when using the board in I2C mode. You could also adjust the system voltage by cutting the jumper and adding solder to the 3.3V side when using the board in SPI.

Suggested Reading

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

Qwiic Connect System
Qwiic Connect System

If you aren’t familiar with the following concepts, we also recommend checking out a few of 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.

Gyroscope

Gyroscopes measure the speed of rotation around an axis and are an essential part in determines ones orientation in space.

Logic Levels

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

Accelerometer Basics

A quick introduction to accelerometers, how they work, and why they're used.

I2C

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

Hardware Overview

In this section, we'll highlight the features of the board. We recommend looking at the datasheet and application notes linked in the Resources and Going Further for more information on the LSM6DSO. Open them in a non-browser viewer that can display the index/table of contents in a pane. There is so much information, paned viewing is a must!

Power and Logic Levels

We recommend powering the board through the Qwiic connector when quickly prototyping. For a more secure connection, you can always solder to the PTH labeled 3V3 and GND. The recommended input voltage when using the board with a microcontroller is 3.3V if you are using the Qwiic connector. However, you can use a regulated supply voltage between 1.71V and 3.6V to power the sensor. The logic levels will match the input voltage (e.g. if the sensor is powered at 3.3V, the logic level will be 3.3V as well).

Power Net

I2C

The main method of reading the LSM6DSO is through the I2C bus. The board includes two Qwiic connectors for fast prototyping and removes the need for soldering. All you need to do is plug a Qwiic cable into the Qwiic conenctor and voila! You can also solder to the PTHs labeled as SDA and SCL as an alternative. The default address for the IC is 0x6B. However, you can adjust the jumper on the back of the board to change the address to 0x6A.

I2C Pins and Qwiic Connectors

SPI

If you decide to use a SPI bus, you will need to solder header pins or wires to the board.

  • SDA/SDI - Device data in. Note that the SDA pin used for I2C is also the SDI pin used for SPI. Flipping the board to the bottom side will show the label for the SPI pin.
  • SCL - Serial clock for either I2C or SPI.
  • SDO - Device data out. By default, the SDO pin is connected to power to set the I2C address. Make sure to cut the trace as explained below if you decide to use this sensor in SPI mode.
  • CS - Chip select.
Top of Board for SPIBottom of Board for SPI
Top of Board for SPIBottom of Board for SPI

When using the board in SPI mode, you will need to cut the I2C jumper for the default address (e.g. 0x6B) on the back and leave the jumper pads unconnected when using SPI.

Cut Jumper for SPI Mode

Interrupt Pins

INT1 and INT2 are programmable interrupts for the accelerometer and gyroscope. They can be set to alert on over/under thresholds, data ready, or FIFO overruns. Make sure these are connected to an INPUT pin to prevent driving 5v back into the LSM6DSO.

Interrupt Pins

There are a variety of interrupts on the LSM6DSO. While connecting these is not as critical as the communication or power supply pins, using them will help you get the most out of the chip.

The interrupt pins are INT1 and INT2. One or both pins can be software configured and mapped to the following conditions:

  • Step detected
  • Step detected after delta time
  • Step counter overflowed
  • Significant motion (shock, drop)
  • FIFO full
  • FIFO overrun
  • FIFO threshold reached (Datasheet calls this the "watermark")
  • Boot status
  • Gyroscope data ready
  • Accelerometer data ready
  • Inactivity
  • Single tap
  • Wake-up
  • Free-fall
  • Double tap
  • 6D (orientation)
  • Tilt
  • Timer
  • Ironing interrupt

Only a few interrupt examples are provided. See the datasheet and application guide for using the advanced interrupt features.

Auxiliary Pins

The auxiliary serial data output pins are used to attach slave I2C and auxiliary SPI 3/4-wire devices for FIFO data collection. This function is not covered in this tutorial.

  • OCS - aux chip select
  • SCX - aux serial clock
  • SDIX - aux serial data input
  • SDOX - aux serial data output

Auxiliary Pins

Reference Axis

For easy reference, we've documented the 6DoF's vectors with 3D Cartesian coordinate axes on the top and bottom side of the board. Make sure to orient and mount the board correctly for your application. Remember, it's all relative.

6DoF Reference (Top)6DoF Reference (Bottom)
6DoF Reference (Top)6DoF Reference (Bottom)

LED

The board includes an LED indicator that lights up when there is power available.

LED

Jumper Pins

There are five jumpers on the back of the board. For more information, check out our tutorial on working with jumper pads and PCB traces should you decide to cut the traces with a hobby knife.

  • LED - This is connected to the PWR LED on the top of the board. Cutting this disables the LED.
  • I2C - The I2C jumper is connected to the 4.7k&ohm; pull-up resistors for the I2C bus. Most of the time you can leave these alone unless your project requires you to disconnect the pull-up resistors. SPI works with these connected but really should be cut apart for better signal shape at high speeds and to lower power consumption.
  • 0x6B/0x6A - These jumpers are used to select the address 0x6B (default) or 0x6A for I2C communication. This jumper must be opened for SPI mode or the SDO line will not supply data.
  • SCX - By default, this pin is connected to GND since ST recommends pulling the unused SCX to power or ground when not in use. For most users, you can leave this jumper alone. If your project requires connecting slave devices to the auxiliary pin, cut this trace.
  • SDIX - By default, this pin is connected to GND since ST recommends pulling the unused SDIX to power or ground when not in use. For most users, you can leave this jumper alone. If your project requires connecting slave devices to the auxiliary pin, cut this trace.

Jumpers

Board Dimensions

The board uses the standard Qwiic size 1.0"x1.0" with four mounting holes by each corner.

Board Dimensions

Hardware Assembly

I2C Mode

For this example, we'll use a RedBoard Qwiic and associated USB cable. With that and a Qwiic cable, the assembly is very simple. Plug a Qwiic cable between the RedBoard Qwiic and the Qwiic 6DoF LSM6DSO. If you're going to be soldering to the through hole pins, then just attach lines to power, ground, and the I2C data lines to the microcontroller of your choice. Just make sure to match to use a logic level converter to match the 3.3V logic on the Qwiic 6DoF.

Qwiic Cable Connecting Arduino and LSM6DSO

SPI Mode

Here's how to connect the SPI lines to a 5V system like the RedBoard Qwiic using a SparkFun Logic Level Converter. Be sure to orient the converter's low side to the LSM6DSO. If using a Teensy or other 3.3V microcontroller, the SPI lines can be connected directly!

Fritzing Diagram of LSM6DSO in SPI Mode with an Arduino and Logic Level Converter

Installing the 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 an Arduino library to help make interfacing with the LSM6DSO's gyro, accelerometer, and temperature sensor as easy-as-possible. Download using the Arduino library manager by searching for 'SparkFun Qwiic 6DoF LSM6DSO Arduino Library' or you can manually install the library by downloading the zip here from the GitHub repository:

Note: The LSM6DSO library is based on the LSM6DS3's Arduino Library. While the libraries are similar, the LSM6DS3's library will not work with the LSM6DSO. Make sure to download the correct library for your IC!

Resources and Going Further

There are a gazillion ways to use an IMU, from simple gravity sensing to advanced motion tracking. There are so many ways to configure the LSM6DSO! After you've used your Arduino and the examples to get the hang of things, use this process:

  1. Read the datasheet and application note!
  2. Design an experiment to try an idea
  3. Measure the results

Only this, is the way to improve.

Need a little inspiration? Check out some of these tutorials!

Dungeons and Dragons Dice Gauntlet

A playful, geeky tutorial for a leather bracer that uses a LilyPad Arduino, LilyPad accelerometer, and seven segment display to roll virtual 4, 6, 8, 10, 12, 20, and 100 side dice for gaming.

Lessons in Algorithms

Learn techniques on how to use Finite Impulse Response (FIR) filters and other data-processing tools to turn data into information.

Pi Servo Hat Hookup Guide

This hookup guide will show you how to connect and use the Pi Servo Hat in a project.
New!

Qwiic 6DoF (LSM6DSO) Breakout Hookup Guide

A hookup guide for the Qwiic 6DoF (LSM6DSO), which features a 3-axis accelerometer, 3-axis gyroscope, temperature sensor, and FIFO buffer.

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

2D Barcode Scanner Breakout Hookup Guide

$
0
0

2D Barcode Scanner Breakout Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun 2D Barcode Scanner Breakout is a nifty little breakout board featuring the DE2120 barcode scanner module from DYScan. The DE2120 reads 20 different barcode symbologies (both 1D and 2D) using a camera coupled with on-board image processing to identify and decode everything from UPC codes to QR codes. The module also features two LEDs: one for illumination and one to project the red line for "aiming" that you're used to seeing from laser-based scanners.

SparkFun 2D Barcode Scanner Breakout

SparkFun 2D Barcode Scanner Breakout

SEN-18088
$49.95

The breakout makes it easy to use the scanner module by connecting the scanner's USB serial output to a USB-C connector. The breakout also includes a standard 0.1"-spaced PTH header for the power, serial UART, trigger and status output connections. On top of that, we've added a trigger button, buzzer and status LED connected to the appropriate drive circuits to easily initialize scans and receive feedback from scanning barcodes.

Required Materials

You'll need a few things along with the 2D Barcode Scanner Breakout to follow this tutorial. You may not need everything though depending on what you have already so add anything you need from the items below to your cart.

The 2D Barcode Scanner Breakout can work as a USB device connected to a computer (PC or Single-Board like the Pi) with a USB Type-C cable.

USB 2.0 Cable A to C - 3 Foot

USB 2.0 Cable A to C - 3 Foot

CAB-15092
$3.95
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
USB 2.0 C to C Cable - 1m

USB 2.0 C to C Cable - 1m

CAB-16395

If you want to use the 2D Barcode Scanner Breakout with a Pi, the options below can get you started:

Raspberry Pi 4 Model B (2 GB)

Raspberry Pi 4 Model B (2 GB)

DEV-15446
$35.00
4
Raspberry Pi 4 Model B (8 GB)

Raspberry Pi 4 Model B (8 GB)

DEV-16811
$75.00
5
Raspberry Pi 3 B+

Raspberry Pi 3 B+

DEV-14643
$35.00
34
SparkFun Raspberry Pi 4 Basic Kit - 8GB

SparkFun Raspberry Pi 4 Basic Kit - 8GB

KIT-17980
$114.95

The breakout can also communicate with a microcontroller like an Arduino through the serial UART pins and other dedicated pins on the breakout's PTH header.

Arduino Uno - R3

Arduino Uno - R3

DEV-11021
$22.95
136
SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

DEV-15795
$19.95
4
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
8

Using the breakout's PTH header requires some assembly and soldering. You may already have a few of these items but if not, the tools and hardware below will help with that assembly:

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
Hook-Up Wire - Assortment (Stranded, 22 AWG)

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

PRT-11375
$16.95
18
Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

TOL-14456
$14.95
12
Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.50
2

Recommended Reading

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

Serial Communication

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

Logic Levels

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

Serial Terminal Basics

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

Hardware Overview

Let's take a closer look at the DYScan DE2120 scanner module as well as the other hardware present on this breakout.

DE2120 Barcode Scanner Module

The DE2120 barcode scanner module from DYScan combines a CMOS camera with on-board image processing to identify and decode 20 different barcode symbologies in both 1D and 2D on a variety of mediums (paper, screen, etc.). The DE2120 also includes two user-configurable LEDs. One super bright white LED to help illuminate the scanning area and one red LED to project the red line like those found on laser-based scanners.

Highlighting the DE2120 Barcode Scanner Module

The DE2120 interfaces over USB Serial and TTL UART and can operate in several modes including USB Keyboard (default), USB COM, USB HID and TTL. Configure the communication modes and other settings by scanning barcodes or sending serial commands from the Scan Settings Manual.

When in USB Keyboard mode, the scanner behaves as a keyboard input (think your typical scanner on a Point of Sale system) and "types" the scanned barcode data followed by a carriage return. In USB-COM mode, the scanner behaves as a USB COM device and in TTL mode, the scanner operates as a TTL UART device to interface with a controller.

The module's two LEDs are also fully configurable to set behavior, brightness and simple on/off settings.

As mentioned above, the DE2120 can recognize and scan many different 1D and 2D symbologies. The list below outlines all the barcode symbologies the module recognizes:

1D Symbologies

  • UPC-A
  • UPC-E
  • EAN-8
  • EAN-13
  • Code 128
  • GS1-128
  • Code 39
  • Code 93
  • Code 11
  • Interleaved 2-of-5
  • Matrix 2-of-5
  • Industrial 2-of-5
  • Codabar
  • MSI
  • GS1 DataBar
  • Datalogic 2-of-5

2D Symbologies

  • QR Code
  • Data Matrix
  • PDF 417
  • Micro PDF 417
  • Aztec Code

Pinout and USB-C Connection

The scanner module receives power either via the USB-C connector or from a regulated 3.3V source through the 3.3 pin. 5V from USB is regulated to 3.3V through an on-board 3.3V/600mA regulator.

Highlighting the USB-C connector and PTH header.

The breakout routes the power input pins (3.3V and Ground), Serial UART (RX/TX) pins as well as the Trigger Input and Status Output pins to a standard 0.1"-spaced PTH header to easily interface with them when integrating the module breakout in an installation.

Buzzer, Status LED and Trigger Button

We've routed the trigger pin to a pushbutton labeled SCAN, the status LED pin to a green LED and buzzer pin to a Piezo buzzer. Configure the Trigger and Buzzer just like everything else on the DE2120 using serial commands or barcodes from the Scan Settings Manual.

Highlighting the Buzzer, STAT LED and Trigger Button.

Use the Trigger Button (or pin) to initiate a scan when the DE2120 is in Trigger Mode (default). The buzzer defaults to play a tone on power-up and on a successful decode. The STAT LED illuminates on power-up and on a successful scan. The STAT LED is not configurable through software but can be disabled through the STAT LED Jumper.

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 2D Barcode Scanner Breakout has three jumpers labeled PWR, STAT_LED and BUZZ. These three jumpers all complete their respective circuits and are CLOSED by default.

Highlighting the STAT and BUZZ Jumpers. Not pictured: PWR Jumper.
The PWR jumper is covered by the DE2120 ribbon cable in this photo but we promise it' there. Check the Eagle Files for the specific location.

The Power LED Jumper connects the anode of the power LED to 3.3V through a 1k&ohm; resistor. Open the jumper by severing the trace between the two pads to disable the Power LED.

The STAT LED Jumper connects the anode of the status LED to a transistor via a 1k&ohm; resistor so it can be controlled by the barcode module. Open the jumper to permanently disable the Status LED on the breakout. Disabling this LED is recommended if you are using an external LED connected to the STAT PTH pin.

The Buzzer Jumper completes the buzzer driver circuit and connects the voltage input (positive) pin of the buzzer to 3.3V via a 10&ohm; resistor. Open the jumper to disable the on board buzzer. Similar to the STAT LED, opening this jumper is particularly useful when an external buzzer is connected to the buzzer driver PTH pin.

Board Dimensions

The 2D Barcode Scanner Breakout measures 1.75in x 1.00in (44.45mm x 25.4mm) with two mounting holes that fit a 4-40 screw.

2D Barcode Scanner Breakout Dimensions.

Hardware Assembly

Now that we're familiar with the DE2120 and other hardware present on the 2D Barcode Scanner Breakout, let's get it connected and start scanning codes.

USB Assembly

The easiest way to get started with the barcode scanner breakout is to plug it in to a computer (PC or SBC) via a USB-C cable. Simply connect the breakout to your computer using a USB-C cable and scan the USB-COM mode barcode from the Scan Setting Manual (the DE2120 defaults to USB-Keyboard mode) on page 23 or you can scan directly it below:

USB-COM Mode barcode from the Scan Settings Manual

Once the device is in USB-COM Mode your computer should automatically search for and install the necessary drivers. After drivers are installed and the device has enumerated, select the correct port and open up a terminal window with the baud to 115200.

The DE2120 defaults to trigger mode to scan barcodes so the Trigger Button must be pressed to start a scan. Find some barcodes to scan or if you don't have any readily available, you can generate custom codes from all types of symbologies on this website to quickly test the barcode scanner.

Completed USB Assembly with Raspberry Pi

Serial UART Assembly

Interacting with the 2D Barcode Scanner Breakout via TTL UART either through direct commands from the Scan Setting Manual or with the Arduino library requires a bit of soldering and wiring. As covered in the previous seciton, the breakout routes the required TTL UART pins to a 0.1"-spaced header for users to solder to. If you are not familiar with through-hole soldering, take a read through this tutorial:

How to Solder: Through-Hole Soldering

September 19, 2013

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

For easy prototyping in this tutorial we're going to solder a set of male headers to the breakout to easily prototype circuits using either a breadboard or jumper wires like the photo below:

Headers soldered to 2D Barcode Scanner Breakout PTH Header

After soldering to the breakout, we make the necessary connections to the controller. In this case we'll use a SparkFun RedBoard to demonstrate the Arduino library so make the following connections or match the photo below:

2D Barcode Scanner Breakout → SparkFun RedBoard

  • 3.3V3.3V
  • GNDGround
  • TXD2
  • RXD3

Completed TTL UART circuit with SparkFun RedBoard
Click on the image for a closer look at this circuit.

After assembling the circuit, make sure to set the 2D Barcode Scanner Breakout to operate in TTL mode by scanning the proper barcode from the Scan Setting Manual on page 24 or you can scan it below:

DE2120 TTL Mode barcode

DE2120 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 DE2120 Arduino Library helps to interface an Arduino microcontroller with the barcode scanner to configure common settings as well as poll the device for scanned codes. Note, the library does not cover all of the codes from the Scan Settings Manual; just the ones we found particularly useful.

Install the Arduino Library Manager by searching for "SparkFun DE2120 Arduino Library" and clicking the "Install" button to download and install the latest version. Users who prefer to manually install the library can get it from the GitHub Repository or you can download the repo by clicking the button below:

Library Functions

The list below goes over all the available functions in the DE2120 Library along with short descriptions of what they do. The examples use many of the functions so refer to them for demonstrations of how to use the common functions in your own code.

Class

In the global scope, construct the DE2120 object (scanner is used in the examples) without arguments:

language:c
DE2120 scanner;

Sketches should also create a character for the serial buffer and define its length for the scan data from the DE2120:

language:c
#define BUFFER_LEN 40
char scanBuffer[BUFFER_LEN];

Device Settings and Setup

The following functions control most of the settings for the DE2120 over TTL serial.

  • bool begin(HardwareSerial &serialPort); - Initialize communication over the hardware serial port.
  • bool begin(SoftwareSerial &serialPort); - Initialize communication using the Software Serial.
  • bool isConnected(); - Returns true if device's ID is what it should be.
  • uint8_t getVersion(); - Queries device for its version number.
  • bool factoryDefault(); - Sets the DE2120 to factory default settings.
  • bool sendCommand(const char *cmd, const char *arg = "", uint32_t maxWaitInms = 3000); - Send a specific command to the DE2120. The function takes two strings as arguments, links them, adds the command prefix "^^" and the command suffix "." and then transmits the command to the module. For example, to enable Matrix 2 of 5 scanning, which is done using the command '^^M25ENA1.' you would make the call 'scanner.sendCommand("M25ENA", "1")'
  • bool readBarcode(char *resultBuffer, uint8_t size); - Check the receive buffer for serial data. If data is present, check the result for a Carriage Return (CR). CR marks a completed scan so if found, the function overwrites the result buffer until it is full or a CR is reached in the receive buffer. Refer to Example 1 for a demonstration of this function.
  • bool available(); - Returns the number of characters in the serial buffer ready to be read.
  • int read(); - Read the data present in the serial buffer.
  • bool changeBaudRate(uint32_t baud); - Adjust the baud rate. Default is 115200.
  • bool changeBuzzerTone(uint8_t tone); - Adjust the buzzer's frequency between LOW, MED and HIGH.
  • bool enableDecodeBeep(); - Enable the buzzer to beep on a barcode decode.
  • bool disableDecodeBeep(); - Disable the buzzer on barcode decode.
  • bool enableBootBeep(); - Enable the buzzer to beep on startup.
  • bool disableBootBeep(); - Disable the startup buzzer beep.
  • bool lightOn(); - Turn the illuminating LED on.
  • bool lightOff(); - Turn the illuminating LED off.
  • bool reticleOn(); - Turn the red "scanner" LED on.
  • bool reticleOff(); - Turn the red "scanner" LED off.
  • bool changeReadingArea(uint8_t percent); - Adjust the percentage of the frame area of the DE2120 to scan for barcodes. Valid options are 100%, 80%, 60%, 40% and 20%.
  • bool enableImageFlipping(); - Enable mirror image reading.
  • bool disableImageFlipping(); - Disable mirror image reading.
  • bool USBMode(char *mode); - Enable USB communication and set the mode. Note, the DE2120 no longer communicates via TTL when this is enabled.
  • bool enableContinuousRead(uint8_t repeatInterval = 2); - Enable continuous read mode and set the interval between scans. Default value is .
  • bool disableContinuousRead(); - Disable continuous read mode.
  • bool enableMotionSense(uint8_t sensitivity = 50); - Enable motion sensitive read mode and set the sensitivity level. Available sensitivity values are 15, 20, 30, 50 and 100.
  • bool disableMotionSense(); - Disable motion sensitive read mode.
  • bool enableAll1D(); - Enable decoding of all 1D symbologies.
  • bool disableAll1D(); - Disable decoding of all 1D symbologies.
  • bool enableAll2D(); - Enable decoding of all 2D symbologies.
  • bool disableAll2D(); - Disable decoding of all 2D symbologies.

Polling Scan Data

These two functions are pretty straightforward and control whether or not the DE2120 is scanning for barcodes in its view area.

  • bool startScan(); - Start scanning for barcodes.
  • bool stopScan(); - Stop scanning for barcodes.

Arduino Examples

The DE2120 Library includes three examples to demonstrate how to do simple scans, read the barcode data, configure the various settings available and sending specific commands. In this section we'll go over these examples in some detail and highlight important bits of code.

Important: Make sure to scan the barcode below to put the DE2120 into TTL mode or the barcode scanner will not communicate properly with the Arduino and the examples will freeze until the board is reset.

TTL Mode Barcode

The 2D Barcode Scanner saves all settings during power cycles so you can configure the DE2120 however you would like (e.g. scanning mode, image flipping, LED settings, etc.) prior to assembling your Arduino circuit and using the examples.

Example 1 - Serial Scan

This basic example demonstrates how to connect the scanner to an Arduino via Software Serial and output any barcodes it sees over serial. Open the example in Arduino by navigating to "File > Examples > SparkFun DE2120 Arduino Library > Example1-SerialScan". Select the correct Board and Port from the "Tools" menu and click upload. After the upload finishes, open the serial monitor with the baud set to 115200.

Since this example uses the Software Serial library, make sure to refer to this page for pin compatibility limitations for common Arduino boards. The example assumes an ATMel328-based Arduino like the SparkFun RedBoard is used so if you prefer a different board, adjust this line if necessary:

language:c
SoftwareSerial softSerial(2, 3);

After declaring the pins to use for RX/TX in Software Serial, the code creates the scanner object as well as the scanner buffer and buffer size:

language:c
DE2120 scanner;

#define BUFFER_LEN 40
char scanBuffer[BUFFER_LEN];

The setup attempts to initialize the barcode scanner and, if successful, the main loop will start polling the buffer for any data every 200ms. If there is data in the buffer, the code prints it. With a serial monitor open, try scanning barcodes with the breakout and watch the code data print out.

Example 2 - Serial Settings

The second example shows how to adjust a selection of seven scanner settings using a "menu" in the serial monitor. Select and upload the example and open a serial monitor with the baud set to 115200. After initializing the DE2120, the code prints out the selection options for the user.

Screenshot showing Arduino Serial Monitor of options menu
Click on the screenshot above for a larger view of the serial monitor

Select an option number by sending the corresponding number and hit ENTER. The code then prints out the available options for the selected setting. Enter the number corresponding to the preferred behavior and hit ENTER again to change the setting. After the setting is adjusted, the code prints if the adjustment was successful and returns to the "main menu".

Example 3 - Send Command

The third example demonstrates how to use the sendCommand(); function to send serial commands to the barcode scanner either through scanning barcodes or a serial monitor. As we mentioned in the previous section, sendCommand(); takes two strings, links them together, adds the command prefix ("^_^") and suffix (".") and sends the command to the DE2120.

Upload the example and open the serial monitor with the baud set to 115200. Once the terminal window is open, type in the command you want to use and press ENTER. Refer to the Scan Settings Manual for the Command Table (found starting on page 78). If the command is not recognized, the code prints out the code is invalid.

DE2120 Python Package

Note: This Python package and included examples assume you are using the latest version of Python 3. If this is your first time using Python or TTL UART hardware on a Raspberry Pi, these resources can help you get started:

The SparkFun DE2120 Python package helps streamline sending commands and receiving barcode data from the 2D Barcode Scanner Breakout. Install the sparkfun-de2120 Python package hosted by PyPi through a command interface or if you prefer to manually download and build the libraries from the GitHub Repository, click the button below to download the package:

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

Installation

Note: The Raspberry Pi OS should automatically install any necessary drivers for the 2D Barcode Scanner when it is connected and operating in USB-COM Mode. Find the USB-COM barcode on page 23 in the Scan Settings Manual (the DE2120 defaults to USB-Keyboard mode) or scan it below:
USB COM mode for the DE2120

PyPi Installation

The DE2120 Py repository is hosted on PyPi as the sparkfun-de2120 package. On systems that support PyPi, install the package via pip3 (use pip for Python 2) using the following commands:

For all users (The user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-de2120

For the current user:

language:bash
pip3 install sparkfun-de2120

Local Installation

Make sure to install the setuptools package on the system.

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

language:bash
python3 setup.py install

Use the following command to build a package for use with pip3:

language:bash
python3 steup.py sdist

A package file is built and placed in a subdirectory called dist. Install the package file using pip3.

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

DE2120 Python Package Operation

For a full overview of how to use this package along with all the functions included with the DE2120 Py package, take a look at the source code and package documentation hosted on ReadtheDocs.

Upgrading the Python Package

If needed, the DE2120 Python package can be upgraded using the following commands:

For all users:

language:bash
sudo pip3 install --upgrade sparkfun-de2120

For the current user:

language:bash
pip3 install --upgrade sparkfun-de2120

Python Examples

The DE2120 Python package includes three examples to demonstrate the basics of using the 2D Barcode Scanner Breakout with Python. In this section we'll cover the examples and highlight how they work.

To use the examples, open them from the DE2120 Py location or copy the code from the GitHub Repository into your preferred Python interpreter.

Reminder: The DE2120 Python Package communicates with the 2D Barcode Scanner Breakout over USB so make sure to set the DE2120 to USB-COM mode by scanning the barcode below or sending the appropriate serial command:

USB-COM mode barcode from the Scan Settings Manual

The 2D Barcode Scanner saves all settings during power cycles so you can configure the DE2120 however you would like (e.g. scanning mode, image flipping, LED settings, etc.) prior to using the examples.

Example 1 - Serial Scan

This basic example demonstrates how to initialize the barcode scanner and output any barcodes it reads. The example attempts to initialize the barcode scanner and, if successful, starts polling the buffer for any data every 200ms. If there is data in the buffer, the code prints it. With a terminal window open to the correct port, try scanning barcodes with the breakout and watch the decoded barcode data print out.

Example 2 - Serial Settings

This example shows how to configure various settings for the DE2120 using serial inputs sent over USB. The code creates an interactive menu for starting and stopping a scan along with the settings listed below:

  • Enable/Disable Flashlight
  • Enable/Disable Aiming Reticle
  • Enable/Disable Decode Beep
  • Enable/Disable Start Up Beep
  • Change Buzzer Frequency
  • Enablde/Disable Image Flipping
  • Set Reading Area
  • Set Reading Mode
  • Enable/Disable Symbologies

Run the example and open a terminal window to the Barcode Scanner's port. To adjust a setting, type in the corresponding number and hit ENTER. A second menu for will open with the available options for the setting. Type in the number matching the preferred option and hit ENTER again. The code prints out if the setting is adjusted successfully and then returns to the main menu.

Example 3 - Send Command

The third example demonstrates how to use the send_command function to send specific command strings to the DE2120. The send_command function takes two strings, links them together, adds the command prefix ("^_^") and suffix (".") and sends the command to the DE2120.

Run the example and open a terminal window to the Barcode Scanner's port. Once the terminal window is open, type in the command you want to use and press ENTER. Refer to the Scan Settings Manual for the Command Table (found starting on page 78). If the command is not recognized, the code prints out the code is invalid.

Troubleshooting

In this section we'll cover some troubleshooting tips and tricks to help with some common snags and questions for the 2D Barcode Scanner Breakout.

USB-COM Mode Functionality Test

To make sure the Barcode Scanner Breakout is working properly, try this quick test using USB-COM mode. First, plug the breakout into your computer with a USB-C cable. Next, scan this barcode from the Scan Settings Manual to enter into USB-COM mode:

USB-COM mode barcode from the Scan Settings Manual

After scanning the barcode, your operating system should automatically install any drivers needed for the board. Identify the port the barcode scanner enumerated on either using Device Manager (Windows) or through the System Information menu on OS X (Mac).

With the COM port identified, open a terminal program like CoolTerm or TeraTerm, select the appropriate port, set the baud rate to 115200 and connect to the port. Once the port is open, either scan a known barcode or head over to this site to generate a unique barcode from a variety of symbologies. Press the Trigger Button to initiate the scan (if the DE2120 is in Trigger Mode) and verify the printout in the terminal window matches the barcode. If the DE2120 is not scanning any code, see the next tip.

Scanner Orientation

The DE2120 has image flipping disabled by default so the scanner must be oriented properly (see image below) to scan codes. Enabling image flipping allows the DE2120 to scan codes from nearly any orientation. Turn image flipping on by scanning the corresponding barcode from the Scan Settings Manual.

Showing proper orientation of the barcode scanner with default settings

Codes Matching Settings Manual

In the rare case the barcode the DE2120 scans matches a code from the Scan Settings Manual, the scanner module will interpret that as a command from the user and execute whatever that command changes on the DE2120.

General Troubleshooting and Technical Support

Resources and Going Further

That's all for this guide. For more information on the 2D Barcode Scanner Breakout check out the following resources:


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

micro:bit Breakout Board Hookup Guide

$
0
0

micro:bit Breakout Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The micro:bit, by itself, offers a vast array of possibilities and potential projects, considering it includes an onboard temperature sensor, accelerometer, compass, LED array, Bluetooth radio, and more. However, when you're ready to branch out beyond those initial capabilities, like connecting to an SD card for logging, or taking advantage of one of our many Qwiic boards, you'll need to break out some of the pins on the micro:bit's card edge connector. For that, we've got you covered with the micro:bit Breakout Board.

SparkFun Qwiic micro:bit Breakout (with Headers)

SparkFun Qwiic micro:bit Breakout (with Headers)

BOB-16446
$5.95

There's also a version without headers, if you care to solder your own or use wires instead.

Required Materials

To follow along with this project tutorial, you will need the following materials:

Suggested Reading

If you have not yet used the micro:bit, check out this guide first.

Getting Started with the micro:bit

March 21, 2017

The BBC micro:bit is a compact, powerful programming tool that requires no software installation. Read on to learn how to use it YOUR way!

If you aren't familiar with the Qwiic system and plan to use the Qwiic connectors on this breakout board, we recommend reading here for an overview.

Qwiic Connect System
Qwiic Connect System

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

How to Solder: Through-Hole Soldering

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

How to Use a Breadboard

Welcome to the wonderful world of breadboards. Here we will learn what a breadboard is and how to use one to build your very first circuit.

Resistors

A tutorial on all things resistors. What is a resistor, how do they behave in parallel/series, decoding the resistor color codes, and resistor applications.

Light-Emitting Diodes (LEDs)

Learn the basics about LEDs as well as some more advanced topics to help you calculate requirements for projects containing many LEDs.

Hardware Overview

The micro:bit Breakout board allows you to utilize all of the pins on the micro:bit and opens up some previously inaccessible communication ports, like I2C and SPI.

Pins

Most of the micro:bit's pins can be configured for one or more functions.

Top-down diagram of the micro:bit breakout board
PinFunction 1Function 2Description
GNDGround
GNDGround
3V33.3V
0Analog InConnected to large pin 0
1Analog InConnected to large pin 1
2Analog InConnected to large pin 2
3Analog InLED Column 1Controls part of LED array
4Analog InLED Column 2Controls part of LED array
5Button AConnected to Button A on micro:bit
6LED Column 9Controls part of LED array
7LED Column 8Controls part of LED array
8Open GPIO pin
9LED Column 7Controls part of LED array
10Analog InLED Column 3Controls part of LED array
11Button BConnected to Button B on micro:bit
12Open GPIO pin
13SCKGPIO or SPI clock
14MISOGPIO or SPI MISO
15MOSIGPIO or SPI MOSI
16Open GPIO pin
19SCLGPIO or I2 clock
20SDAGPIO or I2 data

Power Pin

The pin listed as 3V3 can be used as an input (regulated 3.3V, do not exceed 3.6V!) or an output if you plug a battery pack or USB into the micro:bit.

LCn Pins

The pins labeled with LCn (e.g. LC1, LC8) refer to pins that are used to control the LED array on the front of the micro:bit. You can use them as GPIO, but you'll often get weird patterns to show up on the LEDs, or when you write to the LED array, you may see unexpected behavior. If you use them as GPIO, we recommend disabling the LED display.

Qwiic Connectors

We've added a couple of Qwiic connectors on either side of the breakout board to take advantage of the I2C bus. For more information on the qwiic system, head on over to the Qwiic Connect System Landing Page.

alt text

Board Outline

Outline of board 16446. Measurements in inches

Hardware Assembly

Attach Headers

If you have the version of the breakout board without headers, solder some breakaway headers to the board. You can also solder wire directly to the breakout.

Solder headers to the micro:bit Breakout board

Build Example Circuit

Note: The micro:bit must be facing up in order to make electrical connections to the pins.

To begin, let's light up an RGB LED. Attach the micro:bit to the breakout board, place the breakout board onto a breadboard, and connect an RGB LED through 330 Ω resistors. Use the image below to aid you in wire up the circuit.

Remember, LEDs are polarized parts and can only work properly in one orientation. The longest leg of the LED goes where the black GND wire is in the circuit.

micro:bit breakout board hookup Fritzing

Having a hard time seeing the circuit? Click on the wiring diagram for a closer look.

Example: Cycling Colors on an RGB LED

You can download the code from the emulator, or check out the project's page here:


Copy the .hex file to your micro:bit drive, and you should see a fancy array of colors appear on your LED!

micro:bit cycling colors

Resources and Going Further

With the micro:bit breakout board, you can start introducing more sensors, lights, and motors into your project! For more information, check out these resources:

Need some inspiration for your next project? Check out some of these related tutorials:

Using the SparkFun PicoBoard and Scratch

Here are a few tips in using the PicoBoard with Scratch v1.4. The PicoBoard allows us to write Scratch programs that interact with a variety of sensors on the PicoBoard. These sensors include: sound, light, a slider, a push button, and 4 external sensors (A, B, C, and D).

MAX31855K Thermocouple Breakout Hookup Guide

Learn how to take readings with a k-type thermocouple using the MAX31855K cold-junction-compensated k-type thermocouple-to-digital converter.

Qwiic Flex Glove Controller Hookup Guide

Is your finger bent? Is your finger straight? The Qwiic Flex Glove controller board will answer this age old question for you with the flex sensor!

Rotary Dial Kit Assembly Guide

Put together your Rotary Dial Kit and light it up with our Arduino example code!

Using SparkFun Edge Board with Ambiq Apollo3 SDK

We will demonstrate how to get started with your SparkFun Edge Board by setting up the toolchain on your computer, examining an example program, and using the serial uploader tool to flash the chip.

SparkFun Qwiic Digital Temperature Sensor - TMP102 Hookup Guide

Get started using your SparkFun Digital Temperature Sensor - TMP102 (Qwiic) with this Hookup Guide!

Qwiic SHIM for Raspberry Pi Hookup Guide

Ever wanted to prototype I2C components on a Pi? Now you can!

SparkFun QwiicBus Hookup Guide

Build a long-range, noise-isolated I2C bus with the SparkFun QwiicBus Kit featuring the QwiicBus EndPoint and MidPoint following this Hookup Guide.

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


SparkFun RTK Express Hookup Guide

$
0
0

SparkFun RTK Express Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The RTK Express 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 Express is a flexible and powerful tool.

SparkFun RTK Express

SparkFun RTK Express

SPX-18019
$499.95

With just a few minutes of setup, the RTK Express is one of the fastest ways to take centimeter grade measurements.

RTK Fix in SW Maps

An RTK Fix with 14mm accuracy in SW Maps

By connecting your phone to the RTK Express 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 Express 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 L1/L2 Surveying Antenna (TNC) - TOP106

GNSS Multi-Band L1/L2 Surveying Antenna (TNC) - TOP106

GPS-17751
$124.95
1
Interface Cable - SMA Male to TNC Male (300mm)

Interface Cable - SMA Male to TNC Male (300mm)

CAB-17833
$9.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 Express setup in base mode and a radio link connecting the Base to the Rover. Again, we'll go into details but we designed RTK Express 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 Express you will need a USB C cable and a power supply. SparkFun carries a few options:

Reversible USB A to C Cable - 0.8m

Reversible USB A to C Cable - 0.8m

CAB-15425
$4.95
1
USB 2.0 Type-C Cable - 1 Meter

USB 2.0 Type-C Cable - 1 Meter

CAB-16905
$4.50
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 Express). 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 u-blox.

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 Express is a fully enclosed, preprogrammed device. There are very few things to worry about or configure but we will cover the basics.

Buttons

RTK Express Buttons

The RTK Express uses two buttons, Power and Setup for in-field configuration.

Setup

This device can be used in four modes:

  • GNSS Positioning (~30cm accuracy) - also known as 'Rover'
  • GNSS Positioning with RTK (1.4cm accuracy) - also known as 'Rover with RTK Fix'
  • GNSS Base Station
  • GNSS Base Station NTRIP Server

At power on the device will enter Rover or Base mode; whichever state the device was in at the last power down. When the SETUP button is pressed the RTK Express will toggle between Rover and Base mode. The display will indicate the change with a small car or flag icon.

In Rover mode the RTK Express 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 Express will output industry standard NMEA sentences at 4Hz and broadcast them over any paired Bluetooth device. 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 device is in Rover mode 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 Express 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 Express setup as a base station.

In Base mode 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 Express will initiate a survey. After 60 to 120 seconds the survey will complete and the RTK Express will begin transmitting RTCM correction data out the radio port. A base is often used in conjunction with a second RTK Express (or RTK Surveyor) unit set to 'Rover' to obtain the 14mm accuracy. Said differently, the Base sits still and sends correction data to the Rover so that the Rover can output a really accurate position. You’ll create an RTK system without any other setup.

Power

RTK Express startup display with firmware version number

RTK Express showing the battery level

The Power button turns on and off the unit. Press and hold the power button until the display illuminates. Press and hold the power button at any time to turn the unit off. The RTK Express has a built-in 1300mAh lithium polymer battery that will enable over 5 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.

Charge LED

RTK Express Charge LED

The Charge LED is located above the Power button. It will illuminate any time there is an external power source and will turn off when the internal battery is charged. With the unit fully powered down, charging takes approximately 1.5 hours from a 1A wall supply or 3 hours from a standard USB port. The RTK Express can run while being charged but it increases the charge time. Using an external USB battery bank to run the device for extended periods or running the device on a permanent wall power source is supported.

Connectors

RTK Express Connectors and label

The SparkFun RTK Express has a variety of connectors

Antenna:

This SMA connector is used to connect an L1/L2 type GNSS antenna to the RTK Express. Please realize that a standard GPS antenna does not receive the L2 band signals and will greatly impede the performance of the RTK Express (RTK fixes are nearly impossible). Be sure to use a proper L1/L2 antenna.

RTK Express 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 Express u-blox connector

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 Express 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. The connector is a 4-pin locking 1.25mm JST SMD connector (part#: SM04B-GHS-TB, mating connector part#: GHR-04V-S). The RTK Express comes with a cable to interface to this connector but additional cables can be purchased. 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. 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 Express 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 Express Radio connector

Data:

This 4-pin JST connector is used to output and input a variety of data to the RTK Express. The connector is a 4-pin locking 1.25mm JST SMD connector (part#: SM04B-GHS-TB, mating connector part#: GHR-04V-S). The RTK Express comes with a cable to interface to this connector but additional cables can be purchased.

Internally the Data connector is connected to a digital mux allowing one of four software selectable setups:

  • NMEA - The TX pin outputs any enabled messages (NMEA, UBX, and RTCM) at a default of 460,800bps (configurable 9600 to 921600bps). The RX pin can receive RTCM for RTK and can also receive UBX configuration commands if desired.
  • PPS/Trigger - The TX pin outputs the pulse-per-second signal that is accurate to 30ns RMS. The RX pin is connected to the EXTINT pin on the ZED-F9P allowing for events to be measured with incredibly accurate nano-second resolution. Useful for things like audio triangulation. See the Timemark section of the ZED-F9P integration for more information.
  • I2C - The TX pin operates as SCL, RX pin as SDA on the I2C bus. This allows additional sensors to be connected to the I2C bus.
  • GPIO - The TX pin operates as a DAC capable GPIO on the ESP32. The RX pin operates as a ADC capable input on the ESP32. This is useful for custom applications.

Most applications do not need to utilize this port and will send the NMEA position data over Bluetooth. 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. 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 Express Data connector

microSD:

This slot accepts standard microSD cards up to 32GB formatted for FAT16 or FAT32. Logging any of 67 messages at up to 4Hz is supported for all constellations.

RTK Express microSD connector

The following 67 messages are supported for logging:

  • NMEA-DTM
  • NMEA-GBS
  • NMEA-GGA
  • NMEA-GLL
  • NMEA-GNS
  • NMEA-GRS
  • NMEA-GSA
  • NMEA-GST
  • NMEA-GSV
  • NMEA-RMC
  • NMEA-VLW
  • NMEA-VTG
  • NMEA-ZDA
  • NAV-CLOCK
  • NAV-DOP
  • NAV-EOE
  • NAV-GEOFENCE
  • NAV-HPPOSECEF
  • NAV-HPPOSLLH
  • NAV-ODO
  • NAV-ORB
  • NAV-POSECEF
  • NAV-POSLLH
  • NAV-PVT
  • NAV-RELPOSNED
  • NAV-SAT
  • NAV-SIG
  • NAV-STATUS
  • NAV-SVIN
  • NAV-TIMEBDS
  • NAV-TIMEGAL
  • NAV-TIMEGLO
  • NAV-TIMEGPS
  • NAV-TIMELS
  • NAV-TIMEUTC
  • NAV-VELECEF
  • NAV-VELNED
  • RXM-MEASX
  • RXM-RAWX
  • RXM-RLM
  • RXM-RTCM
  • RXM-SFRBX
  • MON-COMMS
  • MON-HW2
  • MON-HW3
  • MON-HW
  • MON-IO
  • MON-MSGPP
  • MON-RF
  • MON-RXBUF
  • MON-RXR
  • MON-TXBUF
  • TIM-TM2
  • TIM-TP
  • TIM-VRFY
  • RTCM3x-1005
  • RTCM3x-1074
  • RTCM3x-1077
  • RTCM3x-1084
  • RTCM3x-1087
  • RTCM3x-1094
  • RTCM3x-1097
  • RTCM3x-1124
  • RTCM3x-1127
  • RTCM3x-1230
  • RTCM3x-4072-0
  • RTCM3x-4072-1

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 Express but support may be added in the future.

RTK Surveyor Qwiic connector

Power

The RTK Express has a built in 1300mAh battery and consumes approximately 240mA worst case with Bluetooth connection active, GNSS fully tracking, and a 500mW radio broadcasting. This will allow for around 5.5 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 Express.

The RTK Express 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.

RTK Express Display showing two battery bars

To quickly view the state of charge, turn on the unit. The battery icon will indicate the following:

  • 3 bars: >75% capacity remain
  • 2 bars: >50% capacity remain
  • 1 bar: >25% capacity remain
  • 0 bars: <25% capacity remain

Hardware Overview - Advanced Features

The RTK Express is a hacker’s delight. Under the hood of the RTK Express 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 Express 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). In general, the ESP32 harvests the data from the ZED-F9Ps UART1 for Bluetooth transmission and logging to SD.

ZED-F9P GNSS Receiver

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 Express

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. These can then be closed with a 2-pin jumper.

Measurement Jumpers on SparkFun RTK Express

LiPo and Charging

The RTK Express houses a standard 1300mAh 3.7V LiPo. The charge circuit is set to 1A so with an appropriate power source, charging an empty battery should take a little over one hour. USB C on the RTK Express 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. This charge circuit also incorporates a 42C upper temperature cutoff to insure the LiPo cannot be charged in dangerous conditions.

LiPo and Charging on SparkFun RTK Express

Fuel Gauge and Accelerometer

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 reliably view the battery level when the unit is on.

The RTK Express also incorporates a the LIS2DH12 triple-axis accelerometer to aid in leveling in the field.

Fuel Gauge and Accelerometer on SparkFun RTK Express

Qwiic

Two Qwiic connectors are included in the unit. The internal Qwiic connector connects to the OLED display attached to the upper lid. The lower Qwiic connector is exposed on the end of the unit. These allow connection to the I2C bus on the ESP32. Currently the stock RTK Express does not support any additional Qwiic sensors or display but users may add support for their own application.

Dual Qwiic Connector on SparkFun RTK Express

microSD

A microSD socket is situated on the ESP32 SPI bus. Any microSD up to 32GB is supported. RTK Express supports RAWX and NMEA logging to the SD card. Max logging time can also be set (default is 10 hours) to avoid multi-gigabyte text files. For more information about RAWX and doing PPP please see this tutorial.

microSD socket on SparkFun RTK Express

Data Port and Digital Mux

The 74HC4052 analog mux controls which digital signals route to the external Data port. This allows a variety of custom end user applications. The most interesting of which is event logging. Because the ZED-F9P has microsecond accuracy of the incoming digital signal, custom firmware can be created to triangulate an event based on the receiver's position and the time delay between multiple captured events. Currently, TM2 event logging is supported.

Additionally, this mux can be configured to connect ESP pin 26 (DAC capable) and pin 39 (ADC capable) for end user custom applications.

SparkFun RTK Express Data port and mux

Hardware Assembly

The RTK Express 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 Express is mounted. The ¼” camera thread of the monopole is adapted to ⅝” 11-TPI and a L1/L2 antenna is attached. A Male TNC to Male SMA cable connects the antenna to the RTK Express. No radio is needed because RTCM correction data is provided by a phone over Bluetooth.

Basic RTK Express setup

Basic RTK Express Rover setup with RTCM over Bluetooth

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.

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

SparkFun RTK Express 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 Express.

RTK Express 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 Express 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 Express

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

Temporary RTK Express Base setup

Temporary RTK Express Base setup

Any tripod with a ¼” camera thread will work. The Amazon Basics tripod works well enough but is a bit light weight and rickety. A cell phone holder is clamped to the tripod and the RTK Express is held in the clamp. The ¼” camera thread is adapted to ⅝” 11-TPI and a L1/L2 antenna is attached. A Male TNC to Male SMA adapter connects the antenna to the RTK Express.

Once the base has been setup with a clear view of the sky, turn on the RTK Express. Once on, press the Setup button to put the device in Base mode. The display will show the Survey-In screen for 60-120 seconds. Once the survey is complete the display will show the 'Xmitting' display and begin producing RTCM correction data. 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 Express). The RTK Express 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.

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 +/-2mm of accuracy using PPP!

Bluetooth and NTRIP

The RTK Express 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 Express. 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 Express will broadcast itself as either 'Express Rover-5556' or 'Express Base-5556' depending on which state it is in. Discover and pair with this device from your phone or tablet. Once paired, open SW Maps.

alt text

MAC address 5522 is shown in the upper left corner

Pairing with the RTK Express over Bluetooth

Pairing with the 'Express Rover-5556' 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 'SparkFun RTK Surveyor' or '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 Express so that it can improve its fix accuracy. This is the amazing power of RTK Express 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 Express. Within a few seconds the RTK Express 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 Express. 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 Express.

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

Display

The RTK Express has a 0.96" high-contrast OLED display. While small, it packs various situational data that can be helpful in the field. We will walk you through each display.

Power On/Off

Startup and Shutdown Screens

RTK Express Startup and Shutdown Screens

Press and hold the power button until the display illuminates to turn on the device. Similarly, press and hold the power button to turn off the device.

Rover Fix

Rover with location fix

Rover with location fix

Upon power up the device will enter either Rover mode or Base mode. Above, the Rover mode is displayed.

  • MAC: The MAC address of the internal Bluetooth module. This is helpful knowledge when attempting to connect to the device from your phone. This will change to a Bluetooth symbol once connected.
  • HPA: Horizontal positional accuracy is an estimate of how accurate the current positional readings are. This number will decrease rapidly after first power up and settle around 0.3m depending on your antenna and view of the sky. When RTK fix is achieved this icon will change to a double circle and the HPA number will decrease even further to as low as 0.014m.
  • SIV: Satellites in view is the number of satellites used for the fix calculation. This symbol will blink before a location fix is generated and become solid when the device has a good location fix. SIV is a good indicator of how good of a view the antenna has. This number will vary but anything above 10 is adequate. We've seen as high as 31.
  • Log: This icon will remain animated while the log file is increasing. This is a good visual indication that you have an SD card inserted and RTK Express can successfully record to it.

Rover RTK Fix

Rover with RTK Fix and Bluetooth connected

Rover with RTK Fix and Bluetooth connected

Once NTRIP is enabled on your phone or RTCM data is being streamed into the Radio port the device will gain an RTK Fix. You should see the HPA drop to 14mm with a double circle bulls-eye as shown above.

Base Survey-In

RTK Express in Survey-In Mode

RTK Express in Survey-In Mode

Pressing the Setup button will change the device to Base mode. If the device is configured for Survey-In base mode, a flag icon will be shown and the survey will begin. The mean standard deviation will be shown as well as the time elapsed. For most Survey-In setups, the survey will complete when both 60 seconds have elapsed and a mean of 5m or less is obtained.

Base Transmitting

Once the survey in is complete the device enters RTCM Transmit mode. The number of RTCM transmissions is displayed. By default this is one per second.

RTK Express in Fixed Transmit Mode

RTK Express in Fixed Transmit Mode

The Fixed Base mode is similar but uses a structure icon to indicate a fixed base.

Base Transmitting NTRIP

RTK Express in Transmit Mode with NTRIP

RTK Express in Transmit Mode with NTRIP

If the NTRIP server is enabled the device will first attempt to connect over WiFi. The WiFi icon will blink until a WiFi connection is obtained. If the WiFi icon continually blinks be sure to check your SSID and PW for the local Wifi.

Once WiFi connects the device will attempt to connect to the NTRIP mount point. Once successful the display will show 'Casting' along with a solid WiFi icon. The number of successful RTCM transmissions will increase every second.

Note: During NTRIP transmission WiFi is turned on and Bluetooth is turned off. You should not need to know the location information of the base so Bluetooth should not be needed. If necessary, USB can be connected to the Config u-blox port to view detailed location and ZED-F9P configuration information.

Output to an Embedded System

Many applications using the RTK Express 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 Express)
  • Orange - RX (input to RTK Express)
  • 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 Express 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.

System Configuration

The RTK Express is an exceptional GNSS receiver out-of-box and can be used with little or no configuration. The following information is for advanced setups including advanced survey-in scenarios and post processing RAWX data.

All the following settings are stored both on internal memory and an SD card if one is detected. The RTK Express will load the latest settings at each power on. If there is a discrepancy between the internal settings and a settings file then the settings file will be used. This allows a group of RTK Expresses to be identically configured using one 'golden' settings file loaded onto an SD card.

Main Menu

To configure the RTK Express attach a USB C cable to the Config ESP32 connector. Open a terminal window at 115200bps; you should see various status messages every second. Press any key to open the configuration menu. Not sure how to use a terminal? Checkout our Serial Terminal Basics tutorial.

Terminal showing menu

Main Menu

Pressing any button will display the Main menu. The Main menu will display the current firmware version and the Bluetooth broadcast name. Note: When powered on, the RTK Express will broadcast itself as either Express Rover-XXXX or Express Base-XXXX depending on which state it is in.

The menus will timeout after 15 seconds of inactivity, so if you do not press a key the RTK Express will return to reporting status messages after 15 seconds.

Configure GNSS Receiver

Pressing 1 will bring up the GNSS Receiver configuration menu. The ZED-F9P is immensely configurable. The RTK Express will, by default, put the ZED-F9P into the most common configuration for rover/base RTK for use with SW Maps.

The GNSS Receiver menu allows a user to change the report rate, dynamic model, and SBAS.

GNSS menu showing measurement rates and dynamic model

GNSS menu showing measurement rates and dynamic model

Measurement Frequency can be set by either Hz or by seconds between measurements. Some users need many measurements per second; the RTK Express supports up to 20Hz with RTK enabled. Some users are doing very long static surveys that require many seconds between measurements; RTK Express supports up to 8255 seconds (137 minutes) between readings.

Note: When in base mode, measurement frequency is set to 1Hz. This is because RTK transmission does not benefit from faster updates, nor does logging of RAWX for PPP.

The Dynamic Model can be changed but it is recommended to leave as Portable. For more information, please refer to the ZED-F9P Integration Manual.

SBAS is a Satellite Based Augmentation Service that can, on some GNSS receivers, provide additional precision. As of v1.13 of the ZED-F9P firmware there is a bug that, when SBAS is enabled, causes the RTK status pin to fail to work. SBAS does not improve or detract from the RTK Express precision. We recommend leaving SBAS disabled.

Messages Menu

The Messages configuration menu

The messages configuration menu

From this menu a user can control the output of various NMEA, RTCM, RXM, and other messages. Any enabled message will be broadcast over Bluetooth and recorded to SD (if available).

Because of the large number of configurations possible, we provide a few common settings:

  • Reset to Surveying Defaults (NMEAx5)
  • Reset to PPP Logging Defaults (NMEAx5 + RXMx2)
  • Turn off all messages
  • Turn on all messages

Reset to Surveying Defaults (NMEAx5) will turn off all messages and enable the following messages:

  • NMEA-GGA, NMEA-SGA, NMEA-GST, NMEA-GSV, NMEA-RMC

These five NMEA sentences are commonly used with SW Maps for general surveying.

Reset to PPP Logging Defaults (NMEAx5 + RXMx2) will turn off all messages and enable the following messages:

  • NMEA-GGA, NMEA-SGA, NMEA-GST, NMEA-GSV, NMEA-RMC, RXM-RAWX, RXM-SFRBX

These seven sentences are commonly used when logging and doing Precise Point Positioning (PPP) or Post Processed Kinematics (PPK). You can read more about PPP here.

Turn off all messages will turn off all messages. This is handy for advanced users who need to start from a blank slate.

Turn on all messages will turn on all messages. This is a setting used for firmware testing and should not be needed in normal use.

Configuring the NMEA messages

Configuring the NMEA messages

As mentioned is the microSD section of the Hardware Overview there are a large number of messages supported. Each message sub menu will present the user with the ability to set the message report rate.

Note: The message report rate is the number of fixes between message reports. In the image above, with GSV set to 4, the NMEA GSV message will be produced once every 4 fixes. Because the device defaults to 4Hz fix rate, the GSV message will appear once per second.

Base

The RTK Express can also serve as a correction source, also called a Base. The Base doesn't move and 'knows' where it is so it can calculate the discrepancies between the signals it is receiving and what it should be receiving. These differences are the correction values passed to the Rover so that the Rover can have millimeter level accuracy.

There are two types of bases: Surveyed and Fixed. A surveyed base is often a temporary base setup in the field. Called a 'Survey-In', this is less accurate but requires only 60 seconds to complete. The 'Fixed' base is much more accurate but the precise location at which the antenna is located must be known. A fixed base is often a structure with an antenna bolted to the side. Raw satellite signals are gathered for a few hours then processed using Precision Point Position. We have a variety of tutorials that go into depth on these subjects but all you need to know is that the RTK Express supports both Survey-In and Fixed Base techniques.

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.

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!

The Base Menu allows the user to select between Survey-In or Fixed Base setups.

alt text

In Survey-In mode, the minimum observation time and Mean 3D Standard Deviation can be set. The defaults are 60s and 5m as directed by u-blox. Don't be fooled; setting the observation time to 4 hours is not going to significantly improve the accuracy of the survey - use PPP instead.

In Fixed mode, the coordinates of the antenna need to be sent. These can be entered in ECEF or Geographic coordinates. Whenever a user enters Base mode by pressing the SETUP button the GNSS receiver will immediately go into base mode with these coordinates and immediately begin outputting RTCM correction data.

NTRIP Server

NTRIP is where the real fun begins. The Base needs a method for getting the correction data to the Rover. This can be done using radios but that's limited to a few kilometers at best. If you've got WiFi reception, use the internet!

Enabling NTRIP will present a handful of new options seen below:

SparkFun RTK Express NTRIP Settings

Settings for the NTRIP Server

This is a new and powerful feature of the RTK Express. The RTK Express can be configured to transmit its RTCM directly over WiFi to the user's mountpoint. This eliminates the need for a radio link.

Once the NTRIP server is enabled you will need a handful of credentials:

  • Local WiFi SSID and password
  • A casting service such as RTK2Go or Emlid (the port is almost always 2101)
  • A mount point and password

NTRIP Server Connected

NTRIP Server Connected!

With these credentials set, RTK Express will attempt to connect to WiFi, your caster of choice, and begin transmitting the RTCM data over WiFi. We tried to make it as easy as possible.

Transmitting to mount point

Every second a few hundred bytes, up to ~2k, will be transmitted to your mount point.

Configure Ports Menu

Baud rate configuration of Radio and Data ports

Baud rate configuration of Radio and Data ports

By default the Radio port is set to 57600bps to match the Serial Telemetry Radios that are recommended to be used with the RTK Express (it is a plug and play solution). This can be set from 4800bps to 921600bps.

By default the Data port is set to 460800bps and can be configured from 4800bps to 921600bps. The 460800bps baud rate was chosen to support applications where a large number of messages are enabled and a large amount of data is being sent. If you need to decrease the baud rate to 115200bps or other, but be sure to monitor the MON-COMM message within u-center for buffer overruns. A baud rate of 115200bps and the NMEA+RXM default configuration at 4Hz will cause buffer overruns.

Monitoring the com ports on the ZED-F9P

Monitoring the com ports on the ZED-F9P

If you must run the data port at lower than 460800bps, and you need to enable a large number of messages and/or increase the fix frequency beyond 4Hz, be sure to verify that UART1 usage stays below 99%. The image above shows the UART1 becoming overwhelmed because the ZED cannot transmit at 115200bps fast enough.

The Data port on the RTK Express is very flexible. It can be configured in four different ways:

RTK Express Mux Menu

Internally the Data connector is connected to a digital mux allowing one of four software selectable setups. By default the Data port will be connected to the UART1 of the ZED-F9P and output any messages via serial.

  • NMEA - The TX pin outputs any enabled messages (NMEA, UBX, and RTCM) at a default of 460,800bps (configurable 9600 to 921600bps). The RX pin can receive RTCM for RTK and can also receive UBX configuration commands if desired.
  • PPS/Trigger - The TX pin outputs the pulse-per-second signal that is accurate to 30ns RMS. The RX pin is connected to the EXTINT pin on the ZED-F9P allowing for events to be measured with incredibly accurate nano-second resolution. Useful for things like audio triangulation. See the Timemark section of the ZED-F9P Integration Manual for more information.
  • I2C - The TX pin operates as SCL, RX pin as SDA on the I2C bus. This allows additional sensors to be connected to the I2C bus.
  • GPIO - The TX pin operates as a DAC capable GPIO on the ESP32. The RX pin operates as a ADC capable input on the ESP32. This is useful for custom applications.

Most applications do not need to plug anything into the Data port. Most users will get their NMEA position data over Bluetooth. However, 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. 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.

Configure Data Logging Menu

[[RTK Express Data Logging Configuration Menu](https://cdn.sparkfun.com/assets/learn_tutorials/1/8/5/7/SparkFun_RTK_Express_-_Logging_Menu.jpg)

RTK Express Data Logging Configuration Menu

Pressing 5 will enter the Logging Menu. This menu will report the status of the microSD card. While you can enable logging, you cannot begin logging until a microSD card is inserted. Any FAT16 or FAT32 formatted microSD card up to 32GB will work. We regularly use the SparkX brand 1GB cards but note that these log files can get very large (>500MB) so plan accordingly.

  • Option 1 will enable/disable logging. If logging is enabled, all messages from the ZED-F9P will be recorded to microSD. A log file is created at power on with the format SFE_Express_YYMMDD_HHMMSS.txt based on current GPS data/time.
  • Option 2 allows a user to set the max logging time. This is convenient to determine the location of a fixed antenna or a receiver on a repeatable landmark. Set the RTK Express to log RAWX data for 10 hours, convert to RINEX, run through an observation processing station and you’ll get the corrected position with <10mm accuracy. Please see the How to Build a DIY GNSS Reference Station tutorial for more information.

Note: If you are wanting to log RAWX sentences to create RINEX files useful for post processing the position of the receiver please see the GNSS Configuration Menu. For more information on how to use a RAWX GNSS log to get higher accuracy base location please see the How to Build a DIY GNSS Reference Station tutorial.

Configuring ZED-F9P with u-center

Note: Because the ESP32 does considerable configuration of the ZED-F9P at power on it is not recommended to modify the settings of the ZED-F9P. Nothing will break but your changes may be overwritten.

The ZED-F9P module can be configured independently using the u-center software from u-blox by connecting a USB cable to the *Config u-blox’ USB C connector. Settings can be saved to the module between power cycles. For more information please see SparkFun’s Getting Started with u-center by u-blox.

Direct Settings File Editing

SparkFun RTK Express Settings File

SparkFun RTK Express Settings File

Note: All system configuration can also be done by editing the SFE_Express_Settings.txt file (shown above) that is created when a microSD card is installed. The settings are clear text but it is safer and more straightforward to use the serial terminal interface.

Firmware Updates and Customization

The RTK Express is open source hardware meaning you have total access to the firmware and hardware. Be sure to checkout each repo for the latest firmware and hardware information. But for those who want to jump right in and tweak the firmware, we will discuss various methods.

Main Menu showing RTK Firmware v1.4-June 17 2021

Main Menu showing RTK Firmware v1.4-Jun 17 2021

You can check your firmware by opening the main menu by pressing a key at any time.

Updating Firmware From the SD Card

From time to time SparkFun will release new firmware for the RTK Express to add and improve functionality. For most users, firmware can be upgraded by loading the appropriate firmware file from the binaries repo folder onto the SD card and bringing up the firmware menu as shown below:

Firmware update menu

Firmware update taking place

The firmware upgrade menu will only display files that have the "RTK_Surveyor_Firmware*.bin" file name format so don't change the file names once loaded onto the SD card. Select the firmware you'd like to load and the system will proceed to load the new firmware, then reboot.

Note: The firmware is called RTK_Surveyor_Firmware_vXX.bin even though this product is called the RTK Express. We united the different platforms into one. The RTK Firmware runs on all our RTK products.

Updating Firmware From CLI

The command line interface is also available for more advanced users or users who want to avoid the hassle of swapping out SD cards. You’ll need to download esptool.exe and RTK_Surveyor_Firmware_vXXX_Combined.bin from the repo.

Connect a USB A to C cable from your computer to the ESP32 port on the RTK Express. Now identify the com port the RTK Enumerated at. The easiest way to do this is to open the device manager:

CH340 is on COM6 as shown in Device Manager

CH340 is on COM6 as shown in Device Manager

If the COM port is not showing be sure the unit is turned On. If an unknown device is appearing, you’ll need to install drivers for the CH340. Once you know the COM port, open a command prompt (Windows button + r then type ‘cmd’).

Navigate to the directory that contains the firmware file and esptool.exe. Run the following command:

language:c
esptool.exe --chip esp32 --port COM6 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0 RTK_Surveyor_Firmware_v13_combined.bin

Note: You will need to modify COM6 to match the serial port that RTK Express enumerates at.

Programming via the esptool CLI

Programming via the esptool CLI

Upon completion, your RTK Express will have the latest and greatest features!

Creating Custom Firmware

The RTK Express is an ESP32 and high-precision GNSS hackers’s delight. Writing custom firmware can be done using Arduino.

Selecting ESP32 Dev Module

Selecting ESP32 Dev Module

Please see the ESP32 Thing Plus Hookup Guide for information about getting Arduino setup. The only difference is that you will need to select ESP32 Dev Module as your board.

Arduino Library Links

Arduino Library Links

Pull the entire RTK Firmware repo and open /Firmware/RTK_Surveyor/RTK_Surveyor.ino and Arduino will open all the sub-files in new tabs. We’ve broken the functional pieces into smaller tabs to help users navigate it. There are a handful of libraries that will need to be installed. To make this easier, we’ve placed a link next to each library that will automatically open the Arduino Library Manager with that library ready for download.

After connecting a USB C cable to the ESP32 Config connector and selecting the correct COM port you should be able to upload new firmware through the Arduino IDE. Note: The RTK Express must be turned on for it to enumerate as a COM port.

Troubleshooting

Resources and Going Further

We hope you enjoy using the RTK Express as much as we have!

Here are the pertinent technical documents for the RTK Express:

Check out these additional tutorials for your perusal:

GPS Logger Shield Hookup Guide

How to assemble and hookup the SparkFun GPS Logger Shield. Never lose track of your Arduino again!

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!

nRF9160 Thing Plus Hookup Guide

Getting started with the nRF9160 from Circuit Dojo and SparkFun!

MicroMod Asset Tracker Carrier Board Hookup Guide

Get started with the SparkFun MicroMod Asset Tracker Carrier Board following this Hookup Guide. The Asset Tracker uses the u-blox SARA-R510M8S LTE-M / NB-IoT module to provide a host of data communication options.

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.

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!

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

Air Quality Sensor - SGP40 (Qwiic) Hookup Guide

$
0
0

Air Quality Sensor - SGP40 (Qwiic) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Air Quality Sensor - SGP40 (Qwiic) is a robust metal oxide (MOx) based indoor air-quality measurement tool using the SGP40 gas sensor from Sensirion. The SGP40 is based on Sensirion's CMOSens® technology that uses a MOx sensor with a temperature controlled micro hotplate and a humidity-compensated indoor air quality signal. The SGP40 is highly responsive and reports valid volatile organic compount (VOC) data within minutes of powering on the sensor.

SparkFun Air Quality Sensor - SGP40 (Qwiic)

SparkFun Air Quality Sensor - SGP40 (Qwiic)

SEN-18345
$16.95

The SGP40 outputs a digital value based on all VOC gases typically present in an indoor environment and this value can be combined with Sensirion's VOC Index Algorithm to provide responsive indoor air quality data. The SGP40 detects the relative intensity of VOC events in relation to the average readings in a 24hr period but does not return specific concentrations of VOC gases. Think of the SGP40 as a sensitive electronic nose for detecting VOCs in a room.

Users looking to measure specific gas concentrations may want to use the SparkFun Air Quality Sensor - SGP30 (Qwiic) instead.

This guide will cover the SGP40 sensor and other hardware present on this breakout, how to connect it to a microcontroller and use the Arduino and Python libraries so by the end you'll be able to easily monitor VOC events indoors.

Required Materials

To follow along with this guide you will need a microcontroller to communicate with the SGP40. 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
6
SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

SparkFun Qwiic Pro Micro - USB-C (ATmega32U4)

DEV-15795
$19.95
4
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$19.95
8
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
8

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

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
11
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Qwiic Shield for Arduino

SparkFun Qwiic Shield for Arduino

DEV-14352
$6.95
6
SparkFun Qwiic Shield for Arduino Nano

SparkFun Qwiic Shield for Arduino Nano

DEV-16789
$4.25

You will also need at least one Qwiic cable to connect your sensor to your microcontroller.

Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1

Suggested Reading

If you aren't familiar with the Qwiic system, take a look here for an overview.

Qwiic Connect System

We also recommend taking a look at the following tutorials if you aren't familiar with the concepts covered in them. If you are using one of the Qwiic Shields listed above, you may want to read through their respective Hookup Guides as well before you get started with the SparkFun Air Quality Sensor - SGP40 (Qwiic).

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.

Qwiic Shield for Arduino & Photon Hookup Guide

Get started with our Qwiic ecosystem with the Qwiic shield for Arduino or Photon.

SparkFun Qwiic Shield for Arduino Nano Hookup Guide

Hookup Guide for the SparkFun Qwiic Shield for Arduino Nano.

Hardware Overview

In this section we'll cover the features and specifications of the SGP40 Air Quality Sensor as well as highlight other hardware present on this Qwiic breakout.

SGP40 Gas Sensor

The SGP40 air quality gas sensor from Sensirion offers an easy-to-integrate indoor air quality monitoring system with Sensirion's VOC Index. The SGP40 is an I2C device that outputs either a raw digital signal of all typical VOC gases present in an indoor environment or a processed VOC index value.

Photo highlighting the SGP40 IC.

The SGP40's broad spectrum of sensing means it does not measure specific concentrations of individual VOC gases. Instead, the sensor outputs a digital signal sensitive to common indoor air pollutants/VOC gases[1]. Some common air pollutants the SGP40 detects are:

  • Acetone
  • Toluene
  • Ethanol
  • Hydrogen Sulfide & Volatile Sulfuric Compounds
  • Ammonia & Amines
  • Benzene & Nitrosamines

The raw signal can be read on its own but for best results, Sensirion's VOC Algorithm processes the signal to output VOC Index data. The processed VOC Index value ranges from 0 to 500 index points. The data is relative to the history of the monitored room where 100 is the average reading reported over the last 24 hours. Values above 100 signify a VOC event or worse-than-average air quality and values below indicate better-than-average air quality. The rate and intensity of change help identify the severity of the event to trigger actions such as turning on fans to ventilate the area until the signal stabilizes again.

The SGP40 accepts a supply voltage between 1.7V and 3.6V with this breakout intended to run at 3.3V to work with the Qwiic system. The SGP40 draws 34µA (typ.) while idling and 2.6mA@3.3V (typ.) during operation. Power is provied either over the Qwiic interface or through the pins labeled 3.3V and Ground on the 0.1"-spaced plated through hole (PTH) header.

I2C and Qwiic Interface

The SGP40 communicates via I2C so naturally we've routed that interface to a pair of Qwiic connectors for easy integration into SparkFun's Qwiic system. For users who prefer a more traditional interface, the SDA and SCL pins are routed to the same 0.1"-spaced PTH header as the 3.3V and GND pins.

Photo highlighting the Qwiic and I2C interfaces.

The SGP40's I2C address is 0x59 and the IC supports both "standard-mode" and "fast-mode" with max clock frequencies of 100 or 400kHz, respectively.

Solder Jumpers

If you have never worked with solder jumpers and PCB traces or would like a refresher, take a look at our How to Work with Jumper Pads and PCB Traces tutorial.

This breakout has two solder jumpers labeled PWR and I2C. The PWR jumper completes the power LED circuit and the I2C jumper pulls the SDA/SCL lines to 3.3V via a pair of 1k&ohm; resistors. Both jumpers' default state is CLOSED.

Photo highlighting the board's solder jumpers.

Disable the Power LED by severing the trace between the two pads. Opening this jumper helps reduce the total current draw of the breakout for low-power applications. Similarly, disable the pull-up resistors for the SDA/SCL lines by severing the trace between the three pads.

Note: Recommended practice suggests to only have a single pair of pull-up resistors on an I2C bus to avoid creating too strong of a parallel resistance on the bus. If these pull-ups are disabled, make sure the entire bus is operating at the appropriate logic level (in this case, 3.3V) or the lines are properly shifted to avoid damaging this or other devices on the bus.

Board Dimensions

The Air Quality Sensor - SGP40 (Qwiic) matches the 1.0" x 1.0" (25.4mm x 25.4mm) standard of Qwiic breakouts and has two mounting holes that fit a 4-40 screw.

Board Dimensions Image
1. Users looking to measure specific concentrations of VOC gases may want to consider using the SparkFun Air Quality Sensor - SGP30 (Qwiic) instead. The SGP30 reports concentrations of

Hardware Assembly

With the SparkFun Qwiic system, assembling the your sensor circuit is easy! All you need to do is connect your SparkFun Air Quality Sensor - SGP40 (Qwiic) 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 bottom of the board.

Air Quality Sensor connected to a RedBoard Qwiic

If you decide to use the PTH pins broken out on the Air Quality Sensor you need to solder to them or if you want a temporary connection for prototyping, these IC Hooks are a great option to make that 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.

With the SGP40 connected to your microcontroller it's time to get some code uploaded and start taking measurements!

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

We've written a simple Arduino library to quickly get started reading data from the SGP40. Install the library through the Arduino Library Manager tool by searching for "SparkFun SGP40". Users who prefer to manually install it can get the library from the GitHub Repository or download the ZIP by clicking the button below:

Library Functions

The list below outlines all of the functions of the library with some quick descriptions of what they do.

Class

Construct the SGP40 object in the global scope. mySensor is used as the SGP40 object in the example.

  • SGP40 mySensor;

Device Setup and Settings

  • bool SGP40::begin(TwoWire &wirePort); - Initialize I2C communication with the SGP40 on the defined port. If no port is specified, Wire is used. This function also initializes the VOC index parameters.
  • void enableDebugging(Stream &debugPort = Serial); - Turn debug printouts and select the Serial port used for prints. If no port is defined, Serial is used.
  • SGP40ERR measureTest(void); - Run a self test of the SGP40 chip. Returns SUCCESS (0) on pass or specific error code on fail when debugging prints are enabled. Primarily used during manufacturing but can be helpful for debugging.
  • SGP40ERR softReset(void); - Trigger a soft reset of the SGP40. Returns SUCCESS (0) if reset is successful with debugging enabled.
  • SGP40ERR heaterOff(void); - Turn the heater off. Returns SUCCESS (0) if heater is successfully disabled with debugging enabled.

SGP40 VOC Data

Both of these data outputs have default values set for relative humidity percentage and temperature (in °C) that can be adjusted to new static values or fed a live humidity and temperature data from an external sensor.

  • SGP40ERR measureRaw(uint16_t *SRAW_ticks, float RH = 50, float T = 25); - Returns the raw signal from the SGP40 in SRAW_ticks. If debugging statements are on, returns SUCCESS (0) on pass.
  • int32_t getVOCindex(float RH = 50, float T = 25); - Return the processed VOC index data from the SGP40. Returns -100 on error. Refer to the VOC Index app note document for more information on the Sensirion VOC Index.

Arduino Example

The SGP40 Arduino Library includes a single example demonstrating how to get the processed VOC Index data from the sensor. Let's take a closer look at this example.

Example 1 - Get VOC Index

Open this example by navigating to File > Examples > SparkFun SGP40 Arduino Library > Example1_GetVOCIndex. Next, open the Tools menu and select the Board (in our case, SparkFun RedBoard) and the Port the board enumerated on.

Upload the code and open the Arduino Serial Monitor with the baud set to 115200. The code starts both the Wire and Serial ports and initializes the SGP40 on the I2C bus. If the SGP40 is not detected at the default address, the code will print out SGP40 not detected. Check connections. Freezing... and will stop. If this error prints, double check the connections between the breakout and development board and reset it.

After initalizing, the code calls the getVOCIndex(); function and prints out the value every second. The SGP40 takes about 30 to 60 seconds to warm up and return valid VOC readings. The printed data starts at "0" and increases for about a minute as it acclimates to the room and stabilizes around 100 VOC index. Also, the SGP40 refers to VOC Index readings from the history of the room over the past 24 hours so the longer the sensor remains running in the room, the more accurate the data becomes.

Try creating VOC events by putting something like isopropyl alcohol or a permanent marker near the sensor and then pull it away after a few seconds. The VOC Index should rise significantly depending on the intensity of the event and after a couple of minutes the output should drop back towards 100 as the gases dissipate.

SGP40 Python Package

Note: This package and the included examples assume you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi, these tutorial can help you get started:

The SparkFun SGP40 Python package is a simple module to get you started getting VOC data from the sensor. The Sensirion VOC Index algorithm is written for C/C++ so the Qwiic SGP40 Python package uses a similar algorithm for Python from DFRobot.

The package is hosted on PyPi so it can be installed using the command interface with some simple commands. If you prefer to manually install the package you can find it on the Github repository or download the ZIP of it by clicking the button below:

(*Please be aware this package depends on the Qwiic I2C Driver. You can also check out the repository documentation page, hosted on Read the Docs.)

Qwiic SGP40 Py Installation

Now let's go over both ways of installing the Qwiic SGP40 Python package.

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

Since this repository is hosted on PyPi installation is simple on systems that support PyPi installation via pip3 (uses pip for Python 2). Open a command interface and install the package using the following commands:

For all users (The user must have sudo privileges):

language:bash
sudo pip3 install sparkfun-qwiic-sgp40

For the current user:

language:bash
pip3 install sparkfun-qwiic-sgp40

Local Installation

Follow these instructions for a local installation. Make sure to install the setuptools package prior to installing the Qwiic SGP40 package.

Use the following command for 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
python setup.py sdist

This builds and places a subdirector called "dist". Install the package using pip3 with this command making sure to fill in the correct version number:

langauge:bash
cd dist
pip3 install sparkfun_qwiic_sgp40-<version>.targ.gz

Qwiic SGP40 Python Package Operation

A complete overview of all the functions included in the Qwiic SGP40 Py is hosted on the ReadtheDocs. You can also take a look at the source code.

Upgrading the SGP40 Python Package

In case the package is updated in the future, you may need to upgrade it. Upgrade the package using the following commands:

For all users (The user must have sudo privileges):

language:bash
sudo pip3 install --upgrade sparkfun-qwiic-sgp40

For the current user:

language:bash
pip3 install --upgrade sparkfun-qwiic-sgp40

Python Example

The Qwiic SGP40 Python package includes one example to demonstrate how to get VOC Index data from the sensor. Open the example from the Qwiic SGP40 Py location or copy the code into your preferred Python interpreter.

Example 1 - VOC Index

This simple example initializes the SGP40 on the I2C bus and uses the get_VOC_index() function to, well, get the VOC index from the sensor. Take note, polling the VOC index should occur at 1Hz (once per second) for accurate results.

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

def run_example():

    print("\nSparkFun Qwiic Air Quality Sensor - SGP40, Example 1\n")
    my_sgp40 = qwiic_sgp40.QwiicSGP40()

    if my_sgp40.begin() != 0:
        print("\nThe Qwiic SGP40 isn't connected to the system. Please check your connection", \
            file=sys.stderr)
        return

    print("\nSGP40 ready!")

    while True:

        print("\nVOC Index is: " + str(my_sgp40.get_VOC_index()))

        time.sleep(1)

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

Run the example and let the sensor warm up for ~60 seconds and the readings should stabilize to around 100. Try creating VOC events by putting something like isopropyl alcohol or a permanent marker near the sensor and then pull it away. You should see the VOC index rise significantly and then return back to the "norm" of ~100 after a minute or so. For the best results, let the SGP40 run for 24hrs to generate a "history" of the average VOC gas concentration in the room.

Troubleshooting

VOC Index Data

The example in the Arduino library returns values processed through Sensirion's VOC Index which returns qualitative data based on the history of the room. While the sensor reports valid VOC readings within a minute of power up, leaving it running to gain a "history" of the room will provide more accurate data from the sensor when VOC events occur. In our testing we found the longer the SGP40 remains in the room it monitors, the more reliable the data becomes.

After acclimating to the room it is monitoring, the SGP40 should report "100" or close to it for the normal VOC Index for the room. Values below that indicate a lower concentration and values above indicate a higher concentration. Refer to Sensirion's VOC Index for Experts document as well as the SGP40 Datasheet for more information on how to interpret and use that data in your air quality measurement application.

Quick SGP40 Test

If you're looking for more accurate testing than using common household items like isopropyl alcohol or a permanent marker, Sensirion has a quick test document for testing the SGP40 is operating within specifications here: SGP40 Quick Testing Guide

General Troubleshooting and Technical Support

Resources and Going Further

That wraps up this Hookup Guide for the SparkFun Air Quality Sensor - SGP40 (Qwiic). For further information regarding this breakout, take a look at the links below:

Looking for some inspiration for an air quality sensing project or an air quality sensor that monitors specific gases and concentrations? Check out these tutorials:

SparkFun Air Quality Sensor - SGP30 (Qwiic) Hookup Guide

June 5, 2020

A hookup guide to get started with the SparkFun Air Quality Sensor - SGP30 (Qwiic).

Hazardous Gas Monitor

June 17, 2016

Build a portable gas monitor to check for dangerous levels of hazardous gases.

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

MicroMod Teensy Processor Hookup Guide

$
0
0

MicroMod Teensy Processor Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun MicroMod Teensy Processor leverages the awesome computing power of the NXP iMXRT1062 chip and pairs it with the M.2 MicroMod connector to allow you to plug it into your choice of compatible MicroMod Carrier Board.

SparkFun MicroMod Teensy Processor

SparkFun MicroMod Teensy Processor

DEV-16402
$19.95

On top of excellent processing power and speed, the Teensy Processor offers a plethora of interface options including multiple serial UARTs as well as two I2C and SPI buses. Along with these standard interfaces, the Teensy Processor Board also features USB Host capability, a CAN-Bus and a digital audio interface.

Required Materials

Along with your MicroMod Teensy Processor, you'll need a Carrier Board to plug your Processor into. SparkFun offers a variety of MicroMod Carrier Boards to fit your project's needs:

SparkFun MicroMod Input and Display Carrier Board

SparkFun MicroMod Input and Display Carrier Board

DEV-16985
$59.95
3
SparkFun MicroMod Weather Carrier Board

SparkFun MicroMod Weather Carrier Board

SEN-16794
$44.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. Below are some options for both of those cables:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
12
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 recommendations.

Suggested Reading

The SparkFun MicroMod ecosystem offers 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 (e.g. 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 ecosystem, 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.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

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.

Getting Started with the Teensy

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

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

We'll cover the hardware and components included on the MicroMod Teensy Processor Board in this section and highlight some of their unique features.

M.2 Connector

All of our MicroMod Processor come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor on your choice of Carrier Board.


M.2 Connector from the FrontM.2 Connector from the Back

The M.2 MicroMod connector is keyed (in tandem the set screw notch) to prevent the Processor from being inserted and secured improperly.

NXP iMXRT1062 Processor

The brain of the MicroMod Teensy Processor is the NXP iMXRT1062 from NXP Semiconductors. This Arm Cortex-M7 core processor is one of the most powerful microprocessors available today. The Teensy Processor takes advantage of the following properties:

  • ARM Cortex-M7 at 600MHz
  • Up to 600MHz clock frequency
  • 3 Serial Ports (1 dedicated USB, 2 Serial UART)
  • 2 SPI ports (One dedicated SPI available by default on most Carrier Boards[1]. Dedicated Hardware SDIO for SD.)
  • 2 I2C Ports (One I2C bus available by default on most Carrier Boards[1])
  • USB Host Capability
  • 1 CAN Bus Interface
  • 1 I2S Digital Audio
  • 12 Dedicated GPIO
  • 14 Analog pins (2 dedicated, 10 share signals.)
  • 3.3V-tolerant I/O pins
  • 8MB Flash Memory (64l reserved for recover & EEPROM emulation)
  • 1024K RAM Memory (512K is tightly coupled)

Photo of the Teensy Processor highlighting NXP iMXRT1062 IC.
Note: We recommend advanced users looking to take full advantage of all of the features of the Teensy Processor use it with the MicroMod ATP (All the Pins) Carrier Board or their own custom Carrier Board. Many of the pins with extra functionality may be tied to a specific use on other Carrier Boards and therefore essentially unavailable for things like extra UARTs, SPI/I2C or Analog In/PWM.

Flash IC

The MicroMod Teensy Processor uses the W25Q128JV-DTR serial flash memory IC from Windbond Electronics. The flash IC features 128mb of memory. For a detailed overview of the IC, refer to the datasheet.

Photo of the Teensy Processor highlighting the W25Q128JV-DTR Flash IC.

LEDs

There are two LEDs on the Teensy Processor. The PROG LED indicates when the HalfKay bootloader is enabled and the programming IC is powered. We'll cover how to enter the bootloader in the Software Setup and Arduino Example sections. The STAT LED is tied to SCK/13 and can be used as a status LED or as a built-in LED. Control it directly by writing to LED_BUILTIN.

Photo highlighting the LEDs

Measure Jumper

The Measure (MEAS) Jumper can be opened to measure how much current the Teensy Processor is pulling from V_USB. It's is CLOSED by default and ties the USB_VBUS pins to V_USB. Open it by severing the trace and then use a digital multimeter to measure the current draw.

Photo highlighting the MEAS Jumper

Teensy Processor Pin Functions

The Teensy Processor is similar to the Teensy 4.0 and 4.1 with a few notable differences. In order to maintain easy interoperability with MicroMod Carrier Boards, not all of the alternate pin functions are defined for the MicroMod Teensy board variant but we have done our best to make the Teensy Processor as versatile as possible with the right Carrier Board. The sections below outline the various signal protocols available on the MicroMod Teensy.

I2C

As you may have guessed from our extensive Qwiic System, we love communicating with devices using I2C! The Teensy Processor features two I2C buses. The main I2C bus has dedicated pins connected to MiroMod pads 12 (SDA) and 14 (SCL) (Teensy pins 18 and 19), along with a dedicated interrupt pin connected to MicroMod pad 16 (Teensy pin 29). The primary I2C Bus will almost always be connected to a Qwiic connector on your Carrier Board.

If you need a second I2C bus, the Teensy has SDA1 and SCL1 on MicroMod pads 51 and 51 (Teensy pins 25 and 24). To use this second bus, initialize it by calling Wire1.begin();.

UART

The Teensy Processor has three UARTs available. The primary UART is tied to USB_D&plusmin; (MicroMod pads 3 and 5) for serial communication over USB. This is used for your standard serial upload as well as serial prints in Arduino. The secondary UART is a hardware UART tied to MicroMod pads 19 (RX1) and 17 (TX1) (Teensy pins 0 and 1). The tertiary UART is another hardware UART tied to MicroMod pads 20 (RX2) and 22 (TX2) (Teensy pins 17 and 16). In Arduino, the three UARTs are called as listed below:

  • Serial - Communication over USB
  • Serial1 - Communication over RX1/TX1
  • Serial2 - Communication over RX2/TX2

SPI

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.

The Teensy Processor has two SPI buses. The primary SPI bus connects to the following pins:

  • SDI/CIPO - Serial data input (Controller In/Peripheral Out). MicroMod pad 61. Teensy pin 12.
  • SDO/COPI - Serial data output (Controller Out/Peripheral In). MicroMod pad 59. Teensy pin 11.
  • SCK - SPI Clock. MicroMod pad 57. Teensy pin 13.
  • CS - Chip select. MicroMod pad 55. Teensy pin 10.

Due to hardware limitations on most MicroMod Carrier Boards, SPI1 is only available for hardware SDIO communication with an SD card. Use the ATP Carrier to directly interact with SPI1.

CAN-Bus

One of the unique features of the Teensy is its ability to communicate with CAN devices. The Teensy MicroMod can receive CAN messages but in order to send them properly you will need a separate CAN transceiver. CAN-RX is tied to MicroMod pad 41 (Teensy pin 30) and CAN-TX is tied to MicroMod pad 43 (Teensy pin 31).

AUDIO

The Teensy 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"

GPIO/BUS

The MicroMod Teensy has all 12 general purpose IO pins available on top of 6 dedicated pins for digital, analog and PWM signals. 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. Take note that not all GPIO pins are broken out or in use on every carrier board. Refer to your Carrier Board's Hookup Guide for more information on pin use.

Dedicated Pins
  • A0 - Teensy pin 14, MicroMod pad 34
  • A1 - Teensy pin 15, MicroMod pad pad 38
  • D0 - Teensy pin 4, MicroMod pad pad 10
  • D1 - Teensy pin 5, MicroMod pad pad 18
  • PWM0 - Teensy pin 3, MicroMod pad pad 32
  • PWM1 - Teensy pin 2, MicroMod pad pad 47
General Purpose IO pins
  • G0 - GPIO pin 15, pad 40 on the MicroMod
  • G1 - GPIO pin 25, pad 42 on the MicroMod
  • G2 - GPIO pin 26, pad 44 on the MicroMod
  • G3 - GPIO pin 17, pad 46 on the MicroMod
  • G4 - GPIO pin 16, pad 48 on the MicroMod
  • G5 - GPIO pin 32, pad 73 on the MicroMod
  • G6 - GPIO pin 33, pad 71 on the MicroMod
Extra Teensy Functionality

As experienced users may know, the pins on Teensy development boards are very versatile and can be used for a multitude of purposes. As we noted above, in order to maintain compatibility with the rest of the MicroMod system, not all of these alternate functions are available on the MicroMod Teensy but some pins can be configured for things like Analog Inputs or Pulse Width Modulation. As mentioned before, the best way to interact with these pins is with the ATP Carrier Board.

The list below shows all 14 pins on the Teensy Processor available for use as Analog Inputs.

  • A0 - Teensy pin 14, dedicated on MM pad 34. PWM-Capable.
  • A1 - Teensy pin 15, dedicated on MM pad 38. PWM-Capable.
  • A2 - Teensy pin 16, shared with RX2 (MMpad 20). Input Only.
  • A3 - Teensy pin 17, shared with TX2 (MM pad 22). Input Only.
  • A4 - Teensy pin 18, shared with I2C_SDA (MM pad 12). PWM-Capable.
  • A5 - Teensy pin 19, shared with I2C_SCL (MM pad 14). PWM-Capable.
  • A6 - Teensy pin 20, shared with AUD_LRCLK (MM pad 52). Input Only.
  • A7 - Teensy pin 21, shared with AUD_BCLK (MM pad 50). Input Only.
  • A8 - Teensy pin 22, shared with BATT_VIN/3 (MM pad 49). Input Only.
  • A9 - Teensy pin 23, shared with AUD_MCLK (MM pad 58). PWM-Capable.
  • A10 - Teensy pin 24, shared with I2C_SCL1 (MM pad 53). PWM-Capable.
  • A11 - Teensy pin 25, shared with I2C_SDA1 (MM pad 51). PWM-Capable.
  • A12 - Teensy pin 26, shared with G8 (MM pad 67). Input Only.
  • A13 - Teensy pin 27, shared with G11 (MM pad 8). Input Only.

The default MicroMod Teensy Processor board definition is limited to these extra functionalities along with a few other pins that can technically be used for PWM signals when not in use for other signal protocols. Keep reading to the next section, MicroMod Pinout, for specific information on these pins.

MicroMod Pinout

Refer to the datasheet and user manual for a full overview of the iMXRT1062's capabilities. 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 Teensy pin associated with each MicroMod pin and this correlation can be used to identify alternate uses for pins on the Teensy Processor but not all of the alternate Teensy functionalities are available for use with the SparkFun Teensy MicroMod board definition. 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/BUSI2CSDIOSPIDedicated
Teensy PinAlternate FunctionPrimary FunctionBottom
Pin
   Top   
Pin
Primary FunctionAlternate FunctionTeensy Pin
(Not Connected)75GND
3.3V7473G545
RTC_3V_BATT7271G6PWM6
39SDIO_DATA37069G7PWM9
38SDIO_DATA26867G8A12 (Input only)26
34SDIO_DATA16665G932
35SDIO_DATA06463G10PWM33
37SDIO_CMD6261SPI_CIPOPWM12
36SDIO_SCK6059SPI_COPIPWM11
23A9 (PWM)AUD_MCLK5857SPI_SCKSTAT LED / PWM13
7PWMAUD_OUT5655SPI_CSPWM10
8PWMAUD_IN5453I2C_SCL1A10 (PWM)24
20A6 (Input Only)AUD_LRCLK5251I2C_SDA1A11 (PWM)25
21A7 (Input Only)>AUD_BCLK5049BATT_VIN / 3 (0 to 3.3V)A8 (Input Only)22
44G44847PWM12
43G34645GND
42G24443CAN_TX31
42G14241CAN_RX30
40G04039GND
15PWMA13837USBHOST_D+USB2_D+
GND3635USBHOST_D-USB2_D-
14PWMA03433GND
3PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423Not Connected
17A3 (Input Only)UART_TX22221Not Connected
17A3 (Input Only)UART_RX22019UART_RX10
5PWMD11817UART_TX1PWM1
29PWMI2C_INT1615Not Connected
19A5 (PWM)I2C_SCL1413Not Connected
18A4 (PWM)I2C_SDA1211BOOT (Open Drain)PROG
4PWMD0109USB_VINV_USB
27A13 (Input Only)G1187GND
ON/OFFRESET# (Open Drain)65USB_D+USB_D+
283.3V_EN43USB_D-USB_D-
3.3V21GND
FunctionBottom
Pin
   Top   
Pin
Function
(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 (I)
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
CAM_MCLKPCM_OUTI2S_OUTAUD_OUT5655SPI_CS#
CAM_PCLKPCM_INI2S_INAUD_IN5453I2C_SCL1 (I/O)
PDM_DATAPCM_SYNCI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PDM_CLKPCM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 to 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
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 request 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 Processors all measure in at 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 and Designing With MicroMod tutorials.

Teensy Processor Board Dimensions

Hardware Assembly

Now that we are familiar with the components on the Teensy Processor, it's time to assemble it with your chosen MicroMod Carrier Board and connect it to your computer.

Inserting the Processor Board

With the M.2 MicroMod connector, connecting your Processor is a breeze. Simply match up the key on your Processor's beveled edge connector to the key on the M.2 connector. At a 45° angle, insert the processor board to the M.2 connector. The Processor Board will stick up at an angle as shown here:

Teensy 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 down, grab the set screw and tighten it with a Phillip's head screwdriver:

Securing the Teensy Processor Board into place using the set screw.

Once the Processor is secure, your assembled MicroMod system should look similar to the image below.

MicroMod Teensy 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 when inserted incorrectly. 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.

Connecting Everything Up

Depending on which Carrier Board you are using with your Teensy Processor, plug in any other devices (Qwiic breakouts, UART devices, SD cards, I/O devices, etc.) prior to plugging in your Carrier Board to USB. Refer to your Carrier Board's Hookup Guide for specific instructions for Hardware Assembly.

With your Teensy Processor Board inserted and secured and your other devices connected properly it's time to connect your MicroMod Carrier Board to your computer using the USB-C connector. On first power-up, the STAT LED on your Teensy Processor should be blinking on and off every second.

Software Setup

To start working with the Teensy Processor (or any Teensy really), all you need to do is plug in your USB cable to your computer and your Carrier Board. There are two options for programming the Teensy boards - the Arduino IDE or your favorite C compiler. This tutorial will demonstrate how to use Arduino with the Teensy Processor so if you prefer to not use Arduino, download and install the Teensy Loader application.

Arduino IDE Installation

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. With Arduino installed, move on to installing the Teensyduino add-on.

Teensyduino Installation

With Arduino installed, download and install the Teensyduino add-on before uploading code to the Teensy Processor. You can find the Teensyduino download for Windows, Mac OS X and Linux from PJRC here.

Release Note: As of release (7/1/21) the Teensy MicroMod board definitions are only included in the Teensyduino Beta. Use the downloads from the above link for now. We'll remove this note once the Teensy MicroMod is included in the full Teensyduino release.

Teensyduino includes all Teensy board definitions as well as an optional installation of a selection of Arduino libraries to work with Teensy boards. Please follow their installation instructions for the most up-to-date version of the Teensyduino for your operating system. During installation, select which Teensy-compatible libraries you'd like to install. If you aren't sure which libraries you will want, you can skip this step and download and install them later from their curated list.

Programming the Teensy

Open up the Arduino IDE, select the Teensy MicroMod board from the Board menu and select the Port your Processor Board enumerated on. With everything selected properly, press the BOOT button on your Carrier Board to manually enter the bootloader. You should see this window:

Teensy Loader
Teensy Loader Window

Once the Teensy is in the bootloader, upload the code to your board as usual through Arduino. Press the BOOT button on the Carrier Board once Arduino has compiled the code to complete the upload if prompted. You should only need to do this the first time you upload code on every power cycle.

With the MicroMod Teensy Processor Board Definitions installed, let's do a quick code upload to make sure everything went correctly during the Arduino Software Setup.

Selecting and Loading Blink

We'll start off with a basic Blink example to turn the STAT LED on and off just to make sure everything is working properly and your Processor can accept code.

Open up the Arduino IDE and select the "Blink" example by navigating to "File > Examples > 01.Basics > Blink" or copy the code below into a blank sketch:

language:c
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function 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
}

With the example opened, select your Board (SparkFun MicroMod Teensy Processor Board) and Port using the Tools > Board and Tools > Port menus and click the "Upload" button. Barring any issues during compilation and upload, the STAT LED on your Teensy Processor should blink on and off every second.

Note, if this is the first time uploading click the Verify button, the Teensy Loader Program will open (if it is not already open) and prompt you to push the Pushbutton (the BOOT button on your Carrier Board). After that, you can upload to the Teensy Processor just like any other Arudino by clicking the Upload button.

Troubleshooting

Resources and Going Further

Now that you've gotten your MicroMod Teensy Processor up and running with your chosen Carrier Board, it's time to start your MicroMod project! Take a look at the following resources for more information about MicroMod and Teensy.

The links below offer more information about the Teensy Processor:

For more information on the MicroMod ecosystem, check out these resources:

For more information about Teensy, take a look at the following pages:


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

RedBoard Plus Hookup Guide

$
0
0

RedBoard Plus Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun RedBoard Plus is an Arduino-compatible development board that combines the design from the classicRedBoard and RedBoard Qwiic. The RedBoard Plus incorporates a few key improvements over its predecessors (see Hardware Overview). However, like the original RedBoard, it is designed to be an easy-to-use learning platform for coding, physical computing, and project prototyping. These skills are becoming increasingly significant in today's education and the technological community.

SparkFun RedBoard Plus

SparkFun RedBoard Plus

DEV-18158
$19.95

This tutorial aims to familiarize you with the new SparkFun RedBoard Plus and help you get started using it. To begin, we'll guide you through the installation of the Arduino IDE (Integrated Development Environment) software, the main user interface for programming the board. Next, we will go over the hardware and features of the board. Finally, we will walk you through a few examples using the Arduino IDE.

The RedBoard Plus can interact with real-world sensors, control motors, display information, and perform near-instantaneous calculations. It enables anyone to create unique, nifty projects from something as simple as displaying characters on an LCD display or detecting changes in light to vastly more complicated projects like an IoT cellular device (Not recommend for beginners... start with something simpler and work your way up.). If you're familiar with how the original RedBoard and RedBoard Qwiic worked, you may want to skim over parts of this tutorial.

Required Materials

To get started, all you need is a few things. 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.

  • RedBoard Plus - You'll definitely need this; otherwise, you might be on the wrong tutorial (wink-wink).
  • Reversible USB A to C Cable - 2m - The USB interface serves two purposes: it powers the board and allows you to upload programs to it.
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95
SparkFun RedBoard Plus

SparkFun RedBoard Plus

DEV-18158
$19.95

Required Software

You will also need a computer with the Arduino IDE installed on it - That is how we will program the board and interface with it.

    Troubleshooting Tip: If you are not a technical or computer savy individual and you have your choice of computers, a Windows 7 or 10 computer is highly recommended. You will usually run into the the least issues, if any, with these operating systems.

Suggested Tools and Peripherals

That is ALL... pretty simple right? Now you won't be able to do much since there are no additional sensors to interact with the physical world. However, you can at least blink an LED and do some math calculations.

Click the buttons above to toggle the additional materials based on the tasks you
wish to perform. Feel free to modify the items in your cart to fit your needs.

Jumper Modification

If you would like to modify the 3.3V/5V I/O jumper or A4/A5 Qwiic connector jumpers, you will need soldering equipment and/or a knife.

Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$8.95
7
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$7.95
3
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$44.95
2
Hobby Knife

Hobby Knife

TOL-09200
$2.95
2

Qwiic Example

If you would like to follow along with the examples below to interact with the physical world, you will also need the following items:

SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic)

SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic)

SEN-14722
$21.95
10
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50

Suggested Reading

The RedBoard Plus aims to be a beginner-friendly microcontroller platform. You can get started without an innate knowledge of Ohm's Law or How Electricity Works (but a little understanding wouldn't hurt!). The following are some subjects you should be familiar with; however, to use the more advanced features of the board, it is recommended that you read up on the Logic Levels and I2C tutorials.

What is a Circuit?

Every electrical project starts with a circuit. Don't know what a circuit is? We're here to help.

What is an Arduino?

What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.

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.

Qwiic Connect System

One of the new, advanced features of the board is that it takes advantage of the Qwiic connect system. We recommend familiarizing yourself with the Logic Levels and I2C tutorials (above) before using it, as all Qwiic sensors utilize an I2C communication protocol. Click on the banner above to learn more about Qwiic products.

Fun Fact: Qwiic is a play on words between "quick" and I2C or "iic".

Hardware Overview

New Features

Building off the RedBoard Qwiic, the RedBoard Plus includes:

  • USB Type C Connector - The RedBoard has seen many types of USB connectors. The RedBoard Plus takes advantange of the USB C connector.
  • I/O Logic Switch - Instead of cutting a jumper pad and adding solder to the board, you can now flip the switch to adjust the logic level for the system voltage.
  • Two More Analog Pins - Two additional analog pins are included for A6 and A7. Previous designs of the Uno R3 footprint on the RedBoard did not include the pins. These analog pins are included by the power pins as PTH pads.
  • PTH Pads - All of the edge pins on the RedBoard Plus now include an additional PTH pad by each female header. This makes the board slightly wider but you have the advantage of soldering wires or additional header pins to the board.
  • Bypass Jumper - The board includes a jumper to bypass the resettable fuse.



RedBoard QwiicRedBoard Plus
RedBoard QwiicRedBoard Plus

Power

The RedBoard Plus can be powered via the USB and/or barrel jack connectors. If you choose to power it via USB, the other end of the USB cable can be connected to either a computer or a 5V (regulated)USB wall charger. Otherwise, should you choose to use the barrel jack, any wall adapter connected to this jack should supply a DC voltage between 7 and 15V. You could also power the board via the header pins.

alt text

Barrel Jack

The barrel jack accepts a male, center-positive connector with a 5.5mm outer diameter and 2.1mm inner diameter. Check out this tutorial for more information on power connectors.

alt text

Our 9V and 12V power adapters are good choices if you're looking to power the board through the barrel jack. Any wall adapter connected to this jack should supply a DC voltage between 7 and 15V as specified by the electrical characteristics of the LM1117 voltage regulator used on the board. The input voltage pin VIN on the power headers is directly connected to the input voltage of the barrel jack. Depending on your project, you can also wire your own power supply with the DC barrel jack adapter or add a switch between your power supply and RedBoard Plus.

Wall Adapter Power Supply - 12VDC, 600mA (Barrel Jack)

Wall Adapter Power Supply - 12VDC, 600mA (Barrel Jack)

TOL-15313
$5.95
Wall Adapter Power Supply - 9VDC, 650mA (Barrel Jack)

Wall Adapter Power Supply - 9VDC, 650mA (Barrel Jack)

TOL-15314
$5.95
1
DC Barrel Jack Adapter - Male

DC Barrel Jack Adapter - Male

PRT-10287
$2.95
Barrel Jack Power Switch - M-F (3")

Barrel Jack Power Switch - M-F (3")

COM-11705
$2.50
Troubleshooting Tips: The board could operate on an external supply of 6 to 20 volts, but the recommended range is 7 to 12 volts. (*If supplied with less than 7V, the 5V pin may supply less than five volts and the board may be unstable. Using more than 12V, the voltage regulator may overheat and damage itself and/or the board.)

For more technical details about voltage regulators and thermal dissipation, I suggest taking a look at these blog posts and tutorial:

USB

A USB C cable is usually the easiest way to power the board, especially when you're programming it because the USB interface is required for uploading code too.

alt text

A traditional USB port supplies a regulated 5V, but is limited to about 500mA (USB 2.0). Additionally, there is a resettable fuse that protects your computer from shorts and overcurrent. If more than ~750mA is drawn through the USB port, it automatically throttles the current draw or disconnects power until the short/overload is removed. If you need more than that a barrel jack wall adapter is the best choice.

alt text

An example of how to pull USB cable straight out.
Troubleshooting Tip: Users should take care NOT to pry or leverage on the connector when inserting/removing the USB cable. Doing so, WILL damage the board and cause the pads and/or traces to tear off as well. The cable should be removed by pulling straight outwards from the board. The fuse can also be tripped with a high current draw and high ambient temperatures.

Dual Power

It is fine to connect both a barrel jack and a USB connector at the same time. The SparkFun RedBoard Plus has power-control circuitry to automatically select the best power source.

USB and barrel jack wires connected

USB and barrel jack wires connected.

AP2112 Voltage Regulator

The AP2112 uses a robust 3.3V regulator to provide more power to daisy chain multiple Qwiic (I2C) devices. Unlike the MIC5205 on the original RedBoard, which could only source about 150mA of current; the AP2112 can source up to 600mA of current and should be able to handle the needs of your Qwiic devices.

Troubleshooting Tip: If you need more power for your Qwiic devices, you can attach a separate power supply. However, it is recommended that you cut the 3.3V line of the Qwiic cable to the SparkFun RedBoard Plus. Leave the GND line alone, as that ground loops your system, providing a consistent reference voltage for your I2C signals. By cutting the 3.3V line, this allows you to power all your devices without straining the 3.3V regulator. For more details on voltage regulators, check out this According to Pete blog post.

The Power Header

The power headers provides all your reference, input, and output voltages.

  • IOREF - This pin is connected to the I/O logic level switch. The voltage will either be 3.3V or 5V depending on what voltage is selected. This pin provides the voltage reference for the microcontroller's I/O pins. A properly configured shield can read the IOREF pin voltage and select the appropriate power source, or enable voltage translators on the outputs to work with 5V or 3.3V. We recommend selecting 5V as most Arduino Uno boards and shields expect 5V. However, depending on your needs, you can select 3.3V.
  • RESET - This pin is tied to the Reset pin of the microcontroller and reset Button. If this pin is toggled low or shorted to the GND pin, it will trigger a reset of the microcontroller.
  • 3.3V - A 3.3V supply generated by the on-board regulator. Maximum current draw is 600 mA.
  • 5V - This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.
  • GND - Ground pins.
  • VIN - The input voltage to the Arduino board when it's using an external power source. You can provide an external supply voltage through this pin or access the external supply voltage from the power jack through this pin. If only powered through a USB connection, voltage will be around 5V.

alt text

RedBoard Plus Power Header

Reset

Pushing the reset button will temporarily connect the reset pin to ground and restart any code that is loaded on the Arduino. This can be very useful if your code doesn’t repeat, but you want to test it multiple times. You can also use a jumper wire to connect the RESET pin to ground as another option. Certain shields may utilize this pin and reroute it to the top of the shield as well.

alt text

Status LEDs

There are 4 status LEDs on the RedBoard Plus.

  • ON - The first LED is the power LED. This LED indicates that there is a potential between the VCC and GND pins. A good secondary test for this status indicator is to use a multimeter to test the VIN, 5V, and 3.3V pins against the GND pin.
  • RX/TX - The next two status LEDs are the serial communication LEDs. These LEDs indicate that there is data moving between the serial UART RX/TX pins and the USB-to-Serial Converter. A good secondary test for this status indicator is to make sure that these LEDs are flashing during upload or any other serial communication.
  • 13 - The last indicator is the pin 13** LED. This is typically only used as a test LED to make sure that a board is working or for basic debugging. However, for the SparkFun RedBoard Plus, this LED can also indicate if there is presence of the bootloader. Usually the board is flashed with the bootloader . If the board was properly flashed, the LED should blink when powered up.
Troubleshooting Tips:
  • New boards will come programmed with a test sketch that cycles between the RX and TX LEDs.
  • Pin 13 is difficult to use as a digital input because of the voltage drop from status LED and resistor soldered in series to it. If the pin is enabled as an input with the internal 20k pullup resistor, it will always read a LOW state; an expected 5V (HIGH) signal will instead read around 1.7V (LOW).

    If you must use pin 13 as a digital input, it is recommended that you set the pinMode() as an INPUT and use an external pulldown resistor.

    pinMode(13, INPUT);

alt text

Status LEDs on the RedBoard Plus.
Note: There is a small change to the color of ther status LEDs from the originalRedBoard. The power LED is green, the LED for Pin 13 is blue, the RX LED is yellow, and the TX LED is green. However, the color of the LED's don't really matter, the indication is based on whether the LED is on/off. The color differences only help to indicate which LED is on when the LED is blinks quickly or from a quick glance.

Microcontroller

The microcontroller (ATmega328P IC) is the work horse of the RedBoard Plus. The ATmega328 is an 8-bit AVR microcontroller manufactured by Atmel, now Microchip. Once an Arduino sketch is uploaded to the board, the program is stored in the memory of the ATmega328. The microcontroller will then run/execute the program while the RedBoard Plus is powered.

alt text

Image of the ATmega328 IC.

Clock

An external 16MHz crystal is used as the clock for the ATmega328P. When setting the system voltage to 3.3V using the I/O logic level switch, technically you will be overclocking the ATmega328P. We've done this on other designs and have not seen any issues so your mileage may vary. If this is a concern, we recommend setting the system voltage to 5V.

Memory

The ATmega328 has Flash, SRAM (Static Random Access Memory), and EEPROM (Electrically Erasable Programmable Read-Only Memory) memory.

  • 32KB Flash Memory - where the Arduino sketch/program is stored (including the 512 byte Optiboot bootloader).
  • 2KB SRAM - where the sketch/program creates and manipulates variables when it runs.
  • 1KB EEPROM - is available for stable long-term storage (read/written with the EEPROM library).

The Flash and EEPROM memory are non-volatile; the data is still stored even when the board is no longer powered. The SRAM, on the other hand, is volatile and the data is only available while the board is powered.

Troubleshooting Tips
  • The EEPROM can be corrupted with low power/brown out issues.
  • When you run out of SRAM, the sketch may fail or act strangely after it is uploaded. If you suspect this is the issue, try to comment out any long strings or large data structures. If the sketch starts to run normally, then you may need to modify your data requirements.

Bootloader

The Optiboot bootloader is a unique piece of firmware (512 bytes) at the end of the address space of the flash memory. The Optiboot bootloader is specifically configured for the ATmega328P to interface with the Arduino IDE, through a serial interface, to upload code. Without a bootloader, you would need an external programmer and program the microcontroller through the SPI interface (specifically, the ISP/ICSP headers).

For more details on the ATmega328, memory, and the bootloader check out these tutorials:

You can also find the datasheet for the ATmega328 from the Microchip product page.

Board Dimensions

The board dimension is approximately 2.7" x 2.3". The board includes four mounting holes and female headers laid out in a standard Arduino Uno R3 footprint for Arduino shields. For the more details on the board sizing and component placement please refer to the Eagle files provided.

Board Dimensions

Hardware Assembly

To power and program the board, all you need is a USB C cable. Hold down on the connector with your index finger and thumb on one hand. Using your other hand's index finger and thumb, insert the USB cable into the connector.

alt text

At a minimum, your board should look like the image below.

alt text

I/O Logic Level Voltage

We recommend having the board set to 5V for the system voltage. Once set, we recommend adding a piece of tape to hold the switch down to avoid accidentally damaging any 3.3V sensitive devices connected to the board or any peripherals expecting 5V logic when prototyping.

alt text

Qwiic Device

If you decide to connect a Qwiic-enabled device to the board, simply plug in a Qwiic cable between the RedBoard Plus and your chosen Qwiic device. The Qwiic connect system makes it easy to add additional functionality to the board. If you're going to be soldering to the through hole pins for I2C functionality, then just attach lines to power, ground, and the I2C data lines on the header pins or PTH pads.

alt text

3.3V Power Injection

The 3.3V voltage regulator should provide sufficient power to your Qwiic enabled devices. In special cases, you may need to disconnect the 3.3V line and inject a separate 3.3V regulated voltage down the line if you have several daisy chained Qwiic devices. For more information, check out the How to Power a Project: Voltage/Current Considerations for some ideas.

alt text

Jumper Wire

All of the pins are broken out to 0.1"-spaced female headers (i.e. connectors) on the outer edges of the board. Additionally, there are PTH pads adjacent to each pin. There are a variety of wires, connectors, and other items that can be inserted into these headers to interface with the Arduino. Jumper wires are a good option if you want to connect the RedBoard Plus up to other pieces of circuitry that may live on a breadboard. Below is an example circuit taken from the SparkFun Inventor's Kit V4.1.

alt text

A tangled assortment of jumper wires run between the RedBoard headers and components on a breadboard. An Arduino baseplate holds them all in one place.

When connecting to the headers, be sure you are aware of the functionality of the pins you are using.

Troubleshooting tip: If you don't have jumper wires, you can strip and cut some solid core wire (20-24 AWG wire works best).

Arduino Shields

Shields are another popular way to interface with the headers. These Arduino-shaped boards are stackable and connect to all four headers of the RedBoard Plus at once. Shields exist in hundreds of forms, they can add GPS, WiFi, MP3 decoding, and all sorts of other functionality to your Arduino. For more details on Arduino shields and shield assembly, please refer to this Arduino Shields tutorial.

alt text

An XBee Shield with an XBee Series 3 module stacks onto a RedBoard Plus to wirelessly transmit characters to another remote XBee.
Troubleshooting tip: Most shields are expecting a 5V board. Double check the documentation or datasheet for the shield you are using to verify what voltage it is expecting. You will need to adjust the I/O jumper accordingly.

Installing Drivers

Note: The USB-to-Serial adapter IC, used on the RedBoard Plus, is different from what was used on the original RedBoard. The new CH340G chip will require a different driver than the FTDI chip used on the original RedBoard because they are different chips made by separate manufacturers. Please make sure to follow the driver installation guide before plugging this new board into your computer.

The SparkFun RedBoard Plus uses a CH340G USB-to-Serial adapter made by WCH. The driver for the CH340G chip will need to be installed on your computer. We have tested and confirmed that the driver works on Windows 7, Windows 10, Mac OSX High Sierra, and Raspbian Stretch (11-13-2018 release) for the Raspberry Pi. On all operating systems, if you have previously installed the CH340G drivers, you will need to uninstall those drivers first before updating to the new CH340G driver. For more information, check out our How to Install CH340 Drivers Tutorial.

How to Install CH340 Drivers

August 6, 2019

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

Installing the CH340G driver allows your computer to recognize the SparkFun RedBoard Plus as a device and lets it communicate with the board over the USB connection. You can also find the latest version of the CH340 drivers from WCH here. (Most of their pages are in Mandarin, but if you use a Chrome web browser, you should have the option to have the web page translated.)

Installing the Arduino IDE

Download/Install Arduino

You can download the Arduino IDE from their website. They have installation instructions, but we will also go over the installation process as well. Make sure you download the version that matches your operating system.

Click for Arduino IDE Download Page

The installation procedure is fairly straightforward, but it does vary by OS. Here are some tips to help you along. We've also written a separate Installing Arduino tutorial in case you get stuck.

Troubleshooting Tips:
  • We recommend using a computer with a full desktop operating system like Windows 7/10 (avoid Windows 8 if you can), Mac OSX, and certain flavors Linux (check the Arduino FAQ page for compatibility).

    • If you are not a technical or computer savy individual and you have your choice of computers, I highly recommend using a Windows 7 or 10 computer. You will usually run into the the least issues, if any, with these operating systems.

  • We do NOT recommend using a Chromebook, Netbook, tablet, phone, or the Arduino Web IDE in general. You will be responsible for troubleshooting any driver or Arduino Web IDE issues.

  • As of writing this tutorial (12-14-2018), the most recent and stable release of the Arduino IDE is version 1.8.5. We recommend using that version of the Arduino IDE; you can download the previous releases here.

  • On Windows 10, we do NOT recommend installing the Arduino IDE from the app store. You may run into issues because the OS will automatically update to the most recent release of the Arduino IDE, which may have unknown bugs (like the compiler errors in versions 1.8.6 and 1.8.7).

  • Raspberry Pi users with Raspbian installed should use the Linux ARM download. We do not recommend using the command line installation. It will install the oldest release of Arduino, which is useless when it comes to installing new boards definitions or libraries.

  • For additional troubleshooting tips, here is a troubleshooting guide from Arduino.

Click the buttons above for OS specific instructions.

Windows Install Tips

The Windows version of Arduino is offered in two options: an installer or a zip file. The installer is the easier of the two options, just download that, and run the executable file to begin the installation.

Windows 10- Arduino Installation Diagram
Windows install steps. Click the image to get a bigger view.

When you're prompted to install a driver during installation, select "Install". This will install drivers for Arduino specific boards (like the Uno, Nano, etc.) that you may use in the future.

  • If you choose to download the zip file version of Arduino, you'll need to extract the files yourself. Don't forget which folder you extract the files into! You will need to run the executable Arduino file in the folder to start the Arduino IDE.

  • On Windows 10, there is an option to install Arduino through their app store. we do not recommend installing the Arduino IDE from the app store. You may run into issues because the OS will automatically update to the most recent release of the Arduino IDE, which may have unknown bugs.

Mac Install Tips

The Mac download of Arduino is only offered in a zip file version. After the download is finished, simply double-click the .zip file to unzip it.

Mac Install Screenshot
Mac OSX Arduino.app

Following that, you'll need to copy the Arduino application into your applications folder to complete the installation.

Linux Install Tips

As Linux users are no doubt aware, there are many flavors of Linux out there, each with unique installation routines. Check out the FAQ section of the Arduino webpage for more details. Otherwise, you can also use the Linux section of our Installing Arduino tutorial for some helpful links for an assortment of Linux distributions.
Raspbian Stretch
Raspberry Pi users with Raspbian installed should use the Linux ARM download. Do not use the command line installation process. For more information, please refer to this blog post from Arduino.
Ubuntu and Debian
For Ubuntu and Debian users, installing Arduino should only need a simple "apt-get" command like:

sudo apt-get update && sudo apt-get install arduino arduino-core
Other Distributions
Other Linux distros aren't too dissimilar from the Ubuntu and Debian instructions.


With Arduino downloaded and installed, the next step is to plug the board in and test it out! Pretty soon you'll be blinking LEDs, reading buttons, and doing some physical computing!


Arduino Examples

Example 1: Uploading Blink

In this example we will go over the basics of the Arduino IDE and upload a sample code. This is a great way to test the basic functionality of any board to make sure it is working.

The Arduino IDE

Now it's finally time to open up the Arduino software. You'll be presented with a window that looks a little something like this:

Arduino IDE annotated
Layout of the Arduino IDE.

Before we can send the code over to the RedBoard, there are a couple of adjustments we need to make.

Select a Board

This step is required to tell the Arduino IDE which of the available Arduino boards, we are using. Go up to the Tools menu. Then hover over Board and make sure Arduino/Genuino Uno is selected.
Board Selection
Screen shot of Board selection.

Select a Serial Port

Next up we need to tell the Arduino IDE which of our computer's serial ports the RedBoard is connected to. For this, again go up to Tools, then hover over Serial Port and select your RedBoard's COM port.
Port Selection
Screen shot of COM Port selection.

If you've got more than one port, and you're not sure which of the serial ports is your RedBoard, unplug it for a moment and check the menu to see which one disappears.

Blink Sketch

Code written for the Arduino IDE are referred to as sketches. All code in Arduino is C based. Let us upload a Blink sketch to make sure our new RedBoard setup is totally functional. Go up to the File menu in Arduino, then go to Examples > 01.Basics > Blink to open it up.
Board Selection
Screen shot of Blink sketch selection.

Upload!

With all of those settings adjusted, you're finally ready to upload some code! Click the Upload button (the right-pointing arrow) and allow the IDE some time to compile and upload your code. It should take around 10-20 seconds for the process to complete. When the code has uploaded, you should see something like this in your console window:
Done uploading
Screen shot of upload complete.

And if you look over to the RedBoard, you should see the blue LED turn on for a second, off for a second, on for a second, off for a second...ad infinitum (at least until it loses power).

alt text

Expected response from board.

If you want to adjust the blink speed, try messing with the "1000" value in the delay(1000); lines. You're well on your way to becoming an Arduino programmer!

Something Wrong?

Uh oh! If you didn't get a "Done Uploading" message, and instead got an error, there are a few things we can double-check.

If you got an avrdude: stk500_getsync(): not in sync: resp=0x00 error in your console window.

Upload error
Screen shot of Error Message in the Console.

Either your serial port or board may be incorrectly set. Again, make sure Arduino/Genuino Uno is the board selection (under the "Tools>Board" menu). The serial port is usually the more common culprit here. Is the Serial Port correctly set (under the "Tools>Serial Port" menu)? Did the drivers successfully install? To double check your RedBoard's serial port, look at the menu when the board is plugged in, then unplug it and look for the missing port. If none of the ports are missing, you may need to go back to driver installation.

Example 2: Qwiic Connector

One of the great features of the RedBoard (Qwiic) is its ability to interface with I2C devices using our Qwiic system. The Qwiic system is a solderless connection system that allows users to seamlessly daisy chain multiple I2C devices with ease.

The Qwiic Distance Sensor

For this example, we will be running a basic sketch using the SparkFun 4m Distance Sensor (VL53L1X). For more examples with this sensor, please refer to the complete hookup guide.

Hardware Assembly

The wiring for this is simple. Use the Qwiic cable and connect the distance sensor to the board. That is it! The connections are polarized, so you don't have to worry about which side or connector you are using.

Hardware assembly for VL53L1X example

Hardware assembly for VL53L1X distance sensor example.

Let's run an example for our distance sensor to see how it behaves.

Install the Arduino Library

Note: If you have not previously installed an Arduino library, please check out our Arduino library installation guide.

First, you'll need the Sparkfun VL53L1X Arduino library. You can obtain these libraries through the Arduino Library Manager. Search for Sparkfun VL53L1X Arduino Library to install the latest version. If you prefer downloading the libraries from the GitHub repository and manually installing it, you can grab them here:

DOWNLOAD THE SPARKFUN VL53L1X ARDUINO LIBRARY (ZIP)

Example 1 - Read Distance

To get started with this example, open up File>Examples>SparkFun VL53L1x 4M Laser Distance Sensor>Example1_ReadDistance. In this example, we begin by creating a SFEVL53L1X object called distanceSensor with our wire port, Wire, and then our shutdown and interrupt pins. Then we initialize our sensor object in the setup() loop. The code to do this is shown below.
language:c
#include <Wire.h>
#include "SparkFun_VL53L1X.h"

//Optional interrupt and shutdown pins.
#define SHUTDOWN_PIN 2
#define INTERRUPT_PIN 3

SFEVL53L1X distanceSensor(Wire, SHUTDOWN_PIN, INTERRUPT_PIN);

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

  Serial.begin(9600);
  Serial.println("VL53L1X Qwiic Test");

  if (distanceSensor.init() == false)
    Serial.println("Sensor online!");

}

Once we've initialized our sensor, we can start grabbing measurements from it. To do this, we send some configuration bytes to our sensor using distanceSensor.startRanging() to initiate the measurement. We then wait for data to become available and when it does, we read it in, convert it from millimeters to feet, and print it out over serial. The void loop() function that does this is shown below.

language:c
void loop(void)
{
  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.stopRanging();

  Serial.print("Distance(mm): ");
  Serial.print(distance);

  float distanceInches = distance * 0.0393701;
  float distanceFeet = distanceInches / 12.0;

  Serial.print("\tDistance(ft): ");
  Serial.print(distanceFeet, 2);

  Serial.println();
}

Opening your serial monitor to a baud rate of 9600 should show the distance between the sensor and the object it's pointed at in both millimeters and feet. The output should look something like the below image.

Read Distance
Distance readings in mm and ft

Troubleshooting

Below, we have also included some additional troubleshooting tips for issues that you may come across with the new RedBoard Plus.

  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, I recommend starting with their troubleshooting guide.

If neither of the troubleshooting guides above were able to help, here are some tips you might have missed. (Most of this material is summarized from the tutorial.):

Are You Using a Recommended Computer OS?

This board is not tested using the Arduino Web IDE. We do NOT recommend using a Chromebook, Netbook, tablet, phone, or the Arduino Web IDE in general. If you are here, try a RECOMMENDED operating system (see Installing the Arduino IDE).

My Board Isn't Working:

Every board that we manufacture gets tested. If you didn't buy the board from us or one of our authorized distributors, it could be a knock-off. That being said, let's try a basic test to see if just the board is working. Disconnect everything that you have attached to the board; we just want to test the board.
  1. Inspect the board:
    Check the board to make sure everything looks about right. Use the pictures on the product page to verify component placement or alignment, and bad solder joints, or damage.
  2. Power and check the status LEDs:
    Using a known good USB C cable, plug your board in to the computer. Do any of the status LEDs turn on (see Hardware Overview)?
    • New boards will come programmed with a test sketch that cycles between the RX and TX LEDs.
  3. Upload the Blink sketch:
    Try to upload a blink sketch. Why blink? It is simple, known to work (from the example files), and you have an indicator LED.
    • Double check that you have the proper Board and Serial Port selected.
    • For boards that are already running the blink example, I recommend changing the timing parameters to check for a change in the board's response.
    Verify that you see the status LED blinking properly and that the Arduino IDE shows a status of "Done uploading."

I Don't See My Board on a Serial/COM Port:

If you don't see your board as an available COM port on the Arduino IDE:
  • Try to re-open the Arduino IDE.
  • Check the Device Manager to verify that your computer recognizes the board. Click the Driver Verification button in the Installing Drivers section of the tutorial.
  • If you have previously installed the older CH340G drivers, you may need to update your drivers. Particularly on Macs, you will need to delete the previous drivers and install the updated drivers.
  • If that is not the case, you issue might be related to your USB cable. Check that you are using a USB cable capable of data transfers. Some cables only have the power pins connected for charging. A good way to test this is to plug in a device to your USB cable (like a phone). If it doesn't show up as a device or drive, then try a new USB micro-B cable.
  • This rarely happens, but it is easy to check. If you are using a USB 3.0 port (you will see a blue "tongue" in the USB jack or bad USB port, try a different USB port. You can also try to test the board on a different computer to double check for a hardware incompatibility (usually with expansion boards).

Errors Uploading to the Board:

There are two types of issues that you will usually see in the console of the Arduino IDE, compile errors or upload errors. The easiest way to see where to start is by clicking the Verify button (check mark); the Arduino IDE will try to compile your code. A failure here is a compile error.

It takes a some experience, but if you enable the verbose output from the Arduino IDE preferences, it may give you more clues to where the issue is.

Screen shots of enabling verbose output

Screen shots of how to enable verbose output. Click to enlarge.
  • Compile Errors:
    With compile errors, there are several things that could be causing issues. However, 99% of the time, it is user error. Usually something wrong with your code or the library you are using. Once in a while you will have a file structure issue if you manually added a file/folder in any of the Arduino folders (still user error).
  • Upload Errors:
    Upload errors get a little more tricky. You will usually just see the Arduino IDE trying to upload to the board multiple times. There are usually several different causes for this, often without specific errors in the console. Here are a few common examples:
    • Wrong Board Selection:
      Double check you board selection options. If you uploaded with the wrong board selection, there is a small chance that you may have overwritten the bootloader on the board or damaged the microcontroller.
    • Missing Bootloader:
      If your board has the bootloader flashed, pin 13 will flash several times on power up.
    • Serial Port Interference:
      If a device is communicating to the microcontroller over digital pins 0 and 1, while you are trying to upload code.
    • Bad USB cable or port (see Serial Port section above).

Additional Tips:

  • If an input pin is read and that is floating (with nothing connected to it), you will see random data/states. In practice, it may be useful to tie an input pin to a known state with a pullup resistor (to VCC), or a pulldown resistor (to GND).

  • Pin 13 is difficult to use as a digital input because of the voltage drop from status LED and resistor soldered in series to it. If you must use pin 13 as a digital input, it is recommended that you set the pinMode() as an INPUT and use an external pulldown resistor.

  • The maximum current an I/O pin can source (provide positive current) or sink (provide negative current) is 40 mA (milliamps). You can power small sections of LED strips or small motors, but will run into issue with high power devices.

  • Be sure to double check that you are not trying to use an I2C device while you are trying use analog pins A4 or A5 to read analog data. You will run into issues where the analog read will appear to be at a constant value. As a result, the analog readings will not reflect the changes seen from the sensor output. You can only do one or the other.

  • Using the Serial Peripheral Interface, configures the SCK and MOSI pins to be directly managed by the SPI hardware. Therefore, while in use, pins 11 and 13 can't be used (i.e. the LED on pin 13 can no longer be used as a debug/status indicator.) Executing "SPI.end();" allows those pins 11 and 13 to be used as general I/O again.

  • This issue doesn't happen too often, but it can be arbitrarily, common: If your mouse pointer begins to move erratically, your mouse becomes unresponsive to your inputs, and your board is sending a lot of serial data, there is a chance that your computer thinks your board as a serial mouse. The fix is to unplug your board and the plug it back in while holding the reset button down, giving your computer a chance enumerate the COM port.

Resources and Going Further

Now that you've successfully got started with your SparkFun RedBoard Plus, 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:

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

What is an Arduino?

What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Arduino Tutorials

Arduino Board Comparison Guides

Choosing an Arduino for Your Project

Examining the diverse world of Arduino boards and understanding the differences between them before choosing one for a project.

Standard Arduino Comparison Guide

Arduino Comparison Guide Uno or Pro Mini? Bluetooth or wireless? When it comes to Arduinos, there are a lot of choices. We've compiled every Arduino development…

RedBoard vs. Uno

In this tutorial we discuss the differences and similarities between the RedBoard and the Arduino Uno (SMD and PTH). The development platforms

Arduino Shields

Arduino Shields v2

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

Click the buttons above for tutorials relating to the board functionality based on topic difficulty.

Beginner

Serial Communication

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

Analog to Digital Conversion

The world is analog. Use analog to digital conversion to help digital devices interpret the world.

Logic Levels

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

Analog vs. Digital

This tutorial covers the concept of analog and digital signals, as they relate to electronics.

Data Types in Arduino

Learn about the common data types and what they signify in the Arduino programming environment.

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.

Intermediate

Serial Peripheral Interface (SPI)

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

I2C

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

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.

Advanced

Installing an Arduino Bootloader

This tutorial will teach you what a bootloader is and why you would need to install or reinstall it. We will also go over the process of burning a bootloader by flashing a hex file to an Arduino microcontroller.

Integrated Circuits

An introduction to integrated circuits (ICs). Electronics' ubiquitous black chips. Includes a focus on the variety of IC packages.

Reading and Writing Serial EEPROMs

EEPROM is a great way to add extra memory to your microcontroller project. Wait 'til you see how easy it is to use!

Example Projects

Assembly Guide for RedBot with Shadow Chassis

Assembly Guide for the RedBot Kit. This tutorial includes extra parts to follow to go along with the RedBot Inventor's Kit tutorial.

RedBoard Edge Hookup Guide

The RedBoard Edge is a RedBoard that's been rebuilt around the idea that projects are eventually put into an enclosure to help clean up their look.

SparkFun Inventor's Kit Experiment Guide - v4.1

The SparkFun Inventor's Kit (SIK) Experiment Guide contains all of the information needed to build all five projects, encompassing 16 circuits, in the latest version of the kit, v4.1.

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

LTE GNSS Breakout - SARA-R5 Hookup Guide

$
0
0

LTE GNSS Breakout - SARA-R5 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun LTE GNSS Breakout - SARA-R5 provides a robust development tool for the SARA-R510M8S LTE-M / NB-IoT module from u-blox.

SparkFun LTE GNSS Breakout - SARA-R5

SparkFun LTE GNSS Breakout - SARA-R5

GPS-18031
$124.95

The u-blox SARA-R510M8S module is a secure cloud LTE Cat M1, LTE Cat NB2 solution based on u-blox's UBX-R5 cellular chipset with an integrated u-blox M8 GNSS receiver chip and separate GNSS antenna interface. This breakout routes all of the functional pins on the R510M8S module to user interfaces (USB or plated-through hole) so you can take full advantage of all of the features available on this impressive LTE/GNSS module.

The SARA-R5's UART interface can be configured into one of five variants, providing connectivity over one or two UARTs. A separate USB port provides access to the SARA's trace log for diagnostic purposes. This breakout provides access to all three serial interfaces (UART1, UART2 and SARA Diag) via separate USB-C connections. All eight 3.3V serial signals are available on a 0.1"-pitch breakout header.

The breakout ships with a Hologram SIM card. If you prefer to use your own SIM card, please check that your chosen service provider offers LTE-M / NB-IoT coverage for your area before purchasing.

Required Materials

In order to follow along with this tutorial you'll need the following items to use with the LTE GNSS Breakout - SARA-R5.

The primary interface for this breakout is over USB-C so you'll need at least one USB-C cable:

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 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

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

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

For those who prefer to use the LTE GNSS Breakout with our u-blox SARA-R5 Arduino Library, you'll need an Arduino development board:

SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
7
SparkFun RedBoard Turbo - SAMD21 Development Board

SparkFun RedBoard Turbo - SAMD21 Development Board

DEV-14812
$24.95
6
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$19.95
8
SparkFun Thing Plus - SAMD51

SparkFun Thing Plus - SAMD51

DEV-14713
$19.95
1
Note: The LTE GNSS Breakout runs at 3.3V logic and requires some hardware modifications to work with an Arduino and the u-blox SARA-R5 Library. Read on to the Hardware Assembly section for detailed instructions.

The breakout requires a pair of antennas, one for the LTE module and another for the GNSS receiver. The options below work with the LTE GNSS Breakout:

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GPS-15192
$67.95
1
GPS/GNSS Magnetic Mount Antenna - 3m (SMA)

GPS/GNSS Magnetic Mount Antenna - 3m (SMA)

GPS-14986
$12.95
2
LTE Hinged External Antenna - 698MHz-2.7GHz, SMA Male

LTE Hinged External Antenna - 698MHz-2.7GHz, SMA Male

CEL-16432
$6.95
Note: The SMA connections are standard polarity: the connector on the LTE GNSS Breakout is female, the antenna connection needs to be standard male. Antennas with reverse-polarity connectors are not suitable for the LTE GNSS Breakout.

Suggested Reading

If you aren't familiar with the following concepts you may want to check out these tutorials before continuing.

How to Solder: Through-Hole Soldering

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

Serial Communication

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

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.

Hardware Overview

Let's take a closer look at the SARA-R510M8S LTE-M / NB-IoT module and other features of the SparkFun LTE GNSS Breakout - SARA-R5.

u-blox SARA-R510M8S

The SARA-R510M8S LTE-M / NB-IoT module from u-blox combines u-blox's UBX-R5 cellular chipset with their M8 GNSS receiver chipset to provide a 5G-Ready wireless IoT device complete with positioning data all on a single chip. For a thorough overview of the SARA-R5 modules, please review the SARA-R5 datasheet.

Photo highlighting the SARA-R5 module, LTE and GNSS antennas and Nano SIM slot.

The u-blox UBX-R5 chipset boasts some impressive features including:

  • Multi-region LTE M1 and NB2 Half-Duplex.
  • Built-in end-to-end security with hardware-based root of trust inside a discrete secure element.
  • A full security suite with foundation, design, end-to-end security as well as access control.
  • Over-the-air cirital firmware updates and services enabled via the uFOTA client/server solution.
  • Optimized for ultra-low power consumption.

The built-in u‑blox M8 GNSS receiver provides accurate and reliable positioning with a separate GNSS antenna interface for an external antenna. The GNSS position data is enhanced with u-blox's CellLocate® data. The receiver outputs data in NMEA format which can be parsed through our u-blox SARA-R5 Arduino Library.

The SARA-R5 supports many different forms of data communication from full TCP/IP sockets and packet switched data, through HTTP Get/Put/Post, FTP (the SARA has a built-in file system), Ping, to good old SMS text messaging!

The board also includes the necessary SMA connectors for external GNSS and LTE antennas as well as a nano SIM card slot.

SARA-R5 UARTs and USB-C Connectors

The LTE GNSS Breakout has three USB-C connectors on board to provide power or interact with the module's two hardware UARTs as well as the SARA Diagnostic port to access the SARA's trace log1. The UART data for both the UART1 and UART2 USB-C connectors is translated to USB data through a CH340C USB-to-Serial adapter IC.

Photo highlighting the three USB-C connectors and CH340 IC.

The breakout comes pre-configured to support a single UART interface (either Variant 0 or Variant 1). Enable any of the dual UART interfaces (Variants 2-4) by adjusting several jumpers on the board (refer to section 2.5.1 of the SARA-R5 datasheet and section 1.9.1. of the SARA-R5 System Integration Manual for more information on the UART variants). Read on to the Hardware Assembly section for detailed instructions on how to configure the breakout to use the dual UART variants.

1. Please consult the SARA R5 Integration Manual for more details on using the diagnostic interface. You cannot (currently) upgrade the SARA via the diagnostic interface. Using the diagnostic interface is beyond the scope of this tutorial.

Power Supply

The LTE GNSS Breakout is designed to accept power either over USB-C or the dedicated power pin, V EXT. The V EXT pin feeds into the 3.3V regulator which accepts a supply voltage between 3.7V to 6.0V. u-blox designed the SARA-R510M8S to be power-efficient with a variety of low-power and sleep modes and pulls a max of 395mA during transmission (Tx).

Photo highlighting USB-C connectors and power PTH connections.

Plated Through Hole (PTH) Interfaces

As expected with a breakout, we've routed nearly all functional pins from the SARA-R510M8S to plated through-hole (PTH) headers for users to directly interact with them. We've already covered the power PTHs so let's take a look at the other pins on the LTE GNSS Breakout.

Trouble seeing the detail? View high-resolution versions of these images here: Top View& Bottom View

UART PTHs

In the center of the board you'll find the Serial UART PTH header. This header is normally netted to the UART1 USB-C connector through a CH340 serial converter IC for single-UART operation. You can isolate any of the pins to directly interact with them by opening the jumpers on the bottom of the board (more on that in the following "Solder Jumpers" section).

The behavior of some of the pins on this header change depending on whether the SARA-R5 is in single or dual-UART mode. The table below outlines their functionality when in either UART mode. Read on to the Hardware Assembly section for instructions on how to enable the UART2 USB-C connection.

UART Header Pin LabelSingle UART BehaviorDual UART Behavior
3V33.3V Out
TXD IUART1 Serial Data Input
RXD OUART1 Serial Data Output
RTS IUART1 Request to Send Input
DTR / TXD2 IData Terminal ReadyUART2 Serial data input
DCD / RXD2 OData Carrier DetectUART2 Serial data
RI / CTS2 ORing IndicatorUART2 Clear to Send Output
DSR O / RTS2 IData Set Ready OutputUART2 Request to Send Input
CTS OUART1 Clear to Send Output
GNDGround

Take note these pins are level shifted from the SARA-R5's 1.8V logic to 3.3V logic for the PTHs and 5V logic for USB. Modify the board to isoloate these signals and connect them to an Arduino development board to use this breakout with the SparkFun u-blox SARA-R5 Arduino Library. Read on to the Hardware Assembly and Arduino Library/Example sections for more information on using the board with the u-blox SARA-R5 Arduino library.

Additional GPIO PTHs

The board routes the pins for the SARA-R5 I2C bus to a labeled PTH header on one side of the board. On the other side, the SARA On, SARA External Interrupt, Reset and 3V3 Enable pins are broken out along with indicator outputs for Time Pulse Output (labeled TP) and Network Status Indication (labeled NI).

Control power to the SARA-R5 with the SARA On pin. Pull it low for 5 seconds and release to turn the module off. When powered down, pull the pin low briefly to turn it on.

The TP and NI pins are tied to GPIO1 and GPIO6, respectively as well as indicator LEDs with the same labels. The NI pin state alternates between full LOW (no service/not registered), full HIGH (data transmission) and various pulse lengths to indicate other network statuses when configured using the +CREG AT command. The TP pin behaves as a GNSS / LTE Timing Pulse (PPS) and toggles LOW/HIGH when configured by the +UTIME-1,1 AT command. Refer to section 17 of the AT Command Manual for more information about using GPIO pins for these behaviors.

Indicator LEDs

The breakout includes seven LEDs to indicate the status of the SARA-R5 labeled: On, NI, TP, 3V3, VIN, RX and TX.

Photo highlighting LTE GNSS Breakout indicator LEDs

The voltage and power indicator LEDs are fairly self-explanatory. When power is applied to VIN or 3.3V, those respective indicator LEDs turn on (unless the solder jumpers tied to their respective circuits have been opened). The On LED indicates whether or not the SARA-R5 module is powered on. The RX and TX LEDs are tied to the RX/TX lines on UART1 to show when those are transmitting data.

The NI LED shows the cellular network status when GPIO1 is configured to act as a network status indicator output. The NI LED alternates from full Off (No service), full On (Data Transmission) as well as various pulse lengths to show different network statuses. Refer to section 17.1.3 of the AT Command Manual for the AT commands and description of this LED and the GPIO1/NI pin's behavior for different network states.

The TP LED can be configured as a visual indicator of the time pulse output signal to provide time information for the LTE system. When enabled, the LED will pulse once per second. Refer to section 17 of the AT Command Manual for the command set to configure this LED and TP/GPIO6 pin.

Solder Jumpers

Never worked with solder jumpers and PCB traces before or need a quick refresher? Check out our How to Work with Solder Jumpers and PCB Traces tutorial for detailed instructions and tips.

The LTE/GNSS Breakout has a host of solder jumpers to adjust the behavior of the board and components on it. The tables below outline what each jumper does, their default states and some notes about their behavior.

Photo highlighting all solder jumpers on the LTE GNSS Breakout.
Jumper LabelDescriptionDefault StateNotes
SARA I2CPulls SARA-R5 I2C lines to 3.3V via a pair of 2.2k&ohm; resistors.CLOSED
ANT GNSS PWRA dual jumper to select power control for the GNSS antenna.SEE NOTEBy default, GNSS antenna is tied to VCCIO to continuously power it. Switch the jumper from VCCIO to SARA GPIO2 to use that pin to control GNSS antenna power.
EXT INT / GPIO 3A dual jumper to select which SARA pin is tied to the SARA_INT PTH pin.SEE NOTEBy default, this jumper routes the external interrupt pin to the PTH header. Adjust it to the pad labeled GPIO3 to tie this general purpose I/O pin to the PTH header instead.
IN/OUTA dual jumper to select the direction of DSR (Data Set Ready) for dual UART communication.SEE NOTEBy default, this jumper sets DSR as an output. Adjust the jumper to the "IN" side to set DSR as a flow control input.
MEASCurrent measuring jumperCLOSEDOpen this jumper to measure the current draw of the board with a multimeter.
V EXT DiodeV EXT diode bypassOPENClose this jumper to bypass the external voltage input diode.
3V3 LEDLED power control.CLOSEDOpen to disable the labeled LED. Disabling the LEDs helps reduce total current draw of the breakout.
VIN LEDCLOSED
RX LEDCLOSED
TX LEDCLOSED
Jumper LabelDescriptionDefault StateNotes
TXD ITies UART1 TX line to the UART1 USB-C connector through the CH340C.CLOSEDOpen this jumper to isolate the TX pin from the USB-C connector for use with an Arduino or other device.
RXD OTies UART1 RX lne to the UART1 USB-C connector through the CH340C.CLOSEDOpen this jumper to isolate the RX pin from the USB-C connector for use with an Arduino or other device.
RTS ITies UART1 Request to Send to the UART1 USB-C connector through the CH340C.CLOSEDOpen this jumper to isolate the RTS pin from the CH340C and pull it LOW/0V via a 100k&ohm; resistor. The RTS pin must be pulled LOW/0V when using RX/TX only for serial communication as used in the Arduino library.
DTR TXD2CLOSEDOpen this jumper to use DTR pin as UART2 data in (TX) for dual UART modes (when the TXD2_I jumper is CLOSED). If the TXD2_I jumper is OPEN, opening this jumper pulls the DTR pin LOW/0V to enable RX/TX only serial communication used in the Arduino library.
DCDCLOSEDOpen the DCD jumper to use the DCD pin as UART2 data out (RX) for dual UART modes.
RI CTS2 OCLOSEDOpen the RI CTS2 O jumper to use the RI pin as UART2 clear to send (CTS) for dual UART modes.
DSR O RTS2 ICLOSEDOpen the DSR O RTS2 I jumper to use the DSR pin as UART2 request to send (RTS) for dual UART modes.
CTS OTies UART1 Clear to Send to the UART1 USB-C connector through the CH340C.CLOSEDOpen this jumper to isolate the CTS pin from the USB-C connector for use with an Arduino or other device.
TXD2 ITies the labeled UART2 pin to the UART2 USB-C connector.OPENClose these jumpers to connect the labeled UART2 pin to the UART2 USB-C connector. Using Dual UART modes requires other jumper manipulation. Read on to the Hardware Assembly section for more detailed instructions.
RXD2 OOPEN
RTS2 IOPEN
CTS2 OOPEN

Board Dimensions

The SparkFun LTE GNSS Breakout - SARA-R5 measures 3.0in x 2.0in (76.2mm x 50.7mm) with four mounting holes that fit a 4-40 screw.

LTE GNSS Breakout Board Dimensions

Hardware Assembly

In this section we'll go over the basics of connecting the LTE GNSS Breakout to your computer along with some tips on how to use it in some alternate configurations.

Basic Assembly

For quick basic assembly, connect the LTE and GNSS antennas to their respective SMA connectors and then plug in the board to your computer with a USB-C cable connected to the UART1 USB-C connector.

Assembled LTE GNSS Breakout with LTE and GNSS antennas.
Not pictured: SIM Card inserted.

Your computer should automatically install any necessary USB drivers for the breakout when it is plugged in for the first time. In case your computer does not automatically install the USB drivers for the CH340 serial converter IC, read through our How to Install CH340 Drivers tutorial:

Dual UART Configuration

As covered in the Hardware Overview section, the LTE GNSS Breakout comes pre-configured for single UART behavior. In order to use one of the dual UART variants, make the following modifications to the board:

  • Open the DTR, DCD, RI and DSR jumpers.
  • Close the UART2 jumpers labeled TXD2, RXD2, RTS2 and CTS2
  • Adjust the IN/OUT jumper from the "OUT" (default) position to the "IN" position.

Annotated Image describing which jumpers to adjust for Dual UART modes.

Use the +USIO AT Command to select which variant you prefer. Refer to section 15.8 of the AT Command Set Manual for more information on the configuration selection command and section 1.9.1 of the System Integration Manual for detailed descriptions of the UART interface variants.

Arduino Assembly

Users who wish to use the LTE GNSS Breakout with an Arduino microcontroller need to solder to the board. If you are not familiar with through-hole soldering or want a refresher, 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.

Before soldering to the breakout, make the following adjustments to use the board with the u-blox SARA-R5 Arduino Library:

  • Open the TXD_I, RXD_O, RTS_I and DTR/TXD2_I Solder Jumpers.
  • Solder either headers or wire to the TXD I and RXD O PTH pins.
  • Power the circuit using one of the following options:
    • If powering the LTE GNSS Breakout from the Arduino, solder headers or wire to V_EXT PTH pin and one of the Ground PTHs.
    • If powering the LTE GNSS Breakout and Arduino via the same power source (e.g. USB on the same computer), no power connections are necessary.
    • If separate power supplies are used for both boards, make sure to create a common ground between the two circuits.
Reminder: All of the PTH signals, TXD and RXD included, run at 3.3V. Do not connect them directly to a 5V Arduino board.

With the board modified, make the appropriate connections between the LTE GNSS Breakout and Arduino. The connections listed below assume the RedBoard/Arduino provides power to the LTE GNSS Breakout at 5V via USB:

  • LTE GNSS TXD I → RedBoard TX1 (if using Serial1) or D9 (if using SoftwareSerial)
  • LTE GNSS RXD O → RedBoard RX1 (if using Serial1) or D8 (if using SoftwareSerial)
  • LTE GNSS V_EXT → RedBoard VIN
  • LTE GNSS GND → RedBoard GND

This tutorial uses a SparkFun RedBoard Artemis for the Arduino examples so the completed circuit looks like the photo below:

Completed LTE GNSS and RedBoard Artemis circuit.
Having trouble viewing the detail in the image? Click on it for a larger view.

Software Setup

u-blox m-center

Interacting with the SARA-R5 over USB is a great way to get started with this breakout. For detailed instructions on installing and using the u-blox m-center software with your LTE GNSS Breakout - SARA-R5, head on over to the MicroMod Asset Tracker Update Tool Hookup Guide:

AT Command Set

For users who want to go right into directly manipulating the SARA-R5 using the AT Command Set, review the AT Command Manual from u-blox:

Read on to the next sections if you prefer to use the LTE GNSS Breakout - SARA-R5 with the SparkFun u-blox SARA-R5 Arduino Library.

SARA-R5 Arduino Library

Note: The software examples assume you are using the latest version of the Arduino IDE on your computer. 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 read through our Arduino Library Installation Guide

The SparkFun u-blox SARA-R5 Arduino Library provides a quick way to interact with the interfaces on the LTE GNSS Breakout. Install the library through the Arduino Library Manager tool by searching for "SparkFun u-blox SARA-R5". Users who prefer to manually install the library can get it from the GitHub Repository or download the .ZIP by clicking the button below:

The library primarily works by associating a selection of AT Commands from the Command Set Manual with standard Arduino functions to run automatically in a sketch.

View the full list of AT Commands included in this library (along with all other available functions) in the header file. The list of included AT Commands starts on line 67.

Arduino Examples

The SparkFun u-blox SARA-R5 Arduino Library includes nine examples to cover how to configure and use different features of the SARA-R5 module. These examples are mostly intended to build on the previous one so we recommend going through them in sequential order in order to properly set up and use your LTE GNSS Breakout with an inserted SIM card.

If you have not used m-center or AT commands to configure the network information for operator selection and packet switched data (PSD) profiles prior to using this library, make sure to go through Example 3 - Network Info, Example 4 - Register Operator and Example 7 - Configure Packet Switched Data to get the SARA-R5 registered and configured properly on your mobile network.

Code Adjustments

We initially wrote this library for the MicroMod Asset Tracker Carrier Board so there are some unnecessary lines of code and minor adjustments needed to get everything running smoothly depending on your circuit and preferences. The information below outlines the common adjustments and we'll detail any adjustments for each example if needed.

LTE GNSS Breakout Adjustments

When using the LTE GNSS Breakout, feel free to comment out this line:

language:c
mySARA.invertPowerPin(true);

SoftwareSerial Adjustments

The SARA-R5 library automatically includes the SoftwareSerial.h file when a board that works with SoftwareSerial is selected. When using Software Serial in any of the examples, comment out this line:

language:c
#define saraSerial Serial1

and uncomment this line:

language:c
SoftwareSerial saraSerial(8, 9);

Adjust the pins for RX (8) and TX (9) depending on your selected board's limitations with the SoftwareSerial library.

Example 1 - GNSS GPRMC

The first example enables the GNSS receiver and reads the GPRMC message for position, speed and time data. Open the example by navigating to File>Examples>SparkFun u-blox SARA-R5 Arduino Library>SARA-R5_Example1_GNSS_GPRMC.

The breakout continuously powers the GNSS antenna by default so this line is unnecessary and can be commented out/deleted but if you have adjusted the ANT GNSS PWR jumper to use GPIO2 as a control pin, leave it as is.

language:c
mySARA.setGpioMode(mySARA.GPIO2, mySARA.GPIO_OUTPUT, 1);

Select your board in the Tools menu (in our case SparkFun RedBoard Artemis) and the correct Port it enumerated on and click "Upload". After uploading the code, open the Serial Monitor or terminal emulator of your choice with the baud rate set to 115200. The code waits for a keyboard input from the user before progresssing and running the setup and loop. After user input, the code prints out GPS data every second when there is a GPS lock.

Heads up! Make sure your GNSS antenna has a clear view of the open sky. Placing the antenna outdoors away from large objects (buildings, large trees, etc.) is best but if necessary you can usually place the antenna in a window that has a view of the sky to get a lock.

Code to note. This function organizes the GPS data to print out neatly whenever the data returns as valid:

language:c
void printGPS(void)
{
  Serial.println();
  Serial.println("UTC: " + String(gps.utc));
  Serial.print("Time: ");
  if (clk.time.hour < 10) Serial.print('0'); // Print leading 0
  Serial.print(String(clk.time.hour) + ":");
  if (clk.time.minute < 10) Serial.print('0'); // Print leading 0
  Serial.print(String(clk.time.minute) + ":");
  if (clk.time.second < 10) Serial.print('0'); // Print leading 0
  Serial.print(String(clk.time.second) + ".");
  if (clk.time.ms < 10) Serial.print('0'); // Print leading 0
  Serial.println(String(clk.time.ms));
  Serial.println("Latitude: " + String(gps.lat, 7));
  Serial.println("Longitude: " + String(gps.lon, 7));
  Serial.println("Speed: " + String(spd.speed, 4) + " @ " + String(spd.cog, 4));
  Serial.println("Date (MM/DD/YY): " + String(clk.date.month) + "/" + 
    String(clk.date.day) + "/" + String(clk.date.year));
  Serial.println("Magnetic variation: " + String(spd.magVar));
  Serial.println("Status: " + String(gps.status));
  Serial.println("Mode: " + String(gps.mode));
  Serial.println();
}

Example 2 - Identification

The second example prompts the LTE module to read the SARA-R5's identification information:

  • Manufacturer ID
  • Model
  • Firmware Version
  • Serial Number
  • IMEI ID
  • IMSI ID
  • SIM CCID
  • Subscriber Number (from the SIM)
  • Capabilities
  • SIM state

This example primarily functions as a check to make sure the SARA-R5 is working properly and the SIM card is detected then polls the SIM status in the main loop. Upload the code and open a terminal window with the baud set to 115200. The code initializes the SARA-R5 and after a user input, initializes the SARA-R5 and prints out the ID information and SIM state.

Example 3 - Network Info

This example verifies the SARA-R5 is receiving an LTE signal on a selected network and prints out the network information and IDs. The code creates the SARA-R5 object and assigns a network operator value. Depending on the network for your SIM card uses, adjust this line:

language:c
const mobile_network_operator_t MOBILE_NETWORK_OPERATOR = MNO_GLOBAL;

After uploading the code, open a terminal window with the baud set to 115200 and enter any key to start the example. After initializing everything needed, the code attempts to set the Network Profile to the Mobile Network Operator entered. If successful, the code prints out the RSSI (Received Signal Strength), Network Registration Status and Context IDs, Access Point Names and IP Addresses.

Example 4 - Register Operator

Example 4 checks to see if the SARA-R5 is connected to a network and lets you register on a different network if available and if the SIM supports this. This example can also be used to list all the LTE operators the SARA-R5 can detect. Note, you can only connect to networks supported by your SIM card. Refer to your SIM card manufacturer's documentation for supported networks.

Example 5 - Receive SMS

The fifth example demonstrates how to read and print any SMS text messages the SARA-R5 receives. The code checks whether the module is connected to an operator and will freeze if unsuccessful. If the code freezes here, wait and retry as it may be a connection issue with your network. Otherwise, return to Examples 3 and 4 to set set up the Network Operator.

The main loop accesses the message storage memory used for reading and deleting messages for data and prints the used and total number of memory locations in the message storage.

The code waits for any new messages to arrive and prints the Message Index (location), Status, Originator, Date and Time and then the message contents.

New messages are automatically marked as read once the code prints them. To force the code to print all the messages stored in the message memory, comment out this line:

language:c
if (unread == "REC UNREAD")

Example 6 - Send SMS

The sixth example sends SMS messages to another phone or LTE module from the LTE GNSS Breakout - SARA-R5. The code prompts the user for the destination number and message contents. In the Arduino Serial Monitor, just type both of these into the text box at the top and click Send or press ENTER.

Example 7 - Configure Packed Switched Data

Example 7 configures the "Context Identifier" for the mobile data connection. Make sure to go through this example to properly set up your SARA-R5 Context ID. Open a serial monitor with the baud set to 115200 and after the SARA initializes, press a key and then follow the prompts to select the appropriate Context ID. You may see a few Context IDs so make sure to select one that looks correct (i.e. not a blank IP):

Screenshot showing Context ID Selection

The code provides a warning that “deactivate profile failed”. We see this because the SARA needs to disconnect from a profile before it can connect to a new one, and in this case this failed because there was no profile active. Don't worry about this warning, it is just there for information. The example shows that our connection was successful by displaying the Internet Protocol (IP) address the SARA has been allocated by the service operator.

Example 8 - Ping

The eighth example tests the SARA's data connection by a standard server ping. Open a terminal window and follow the prompts then enter a server to ping. Any valid web address like www.google.com or www.sparkfun.com works. If the ping succeeds the code prints out the time to send and receive the ping in milliseconds.

alt text
Having trouble seeing the detail in this image? Click on it for a larger view.

If the ping fails, try uncommenting this line that enables debugging over serial:

language:c
assetTracker.enableDebugging(SERIAL_PORT);

Upload the code again, retry the ping and look for any messages that include +UUPINGER:. Refer to the list of Ping error codes in Appendix A. 10 of the AT Command Reference to decipher the error code.

For example, error 8 means the SARA "Cannot resolve host" which usually means a Domain Name Server (DNS) is not available. Error 17 indicates "Packet Switched Data connection not established". If you see this or similar errors, make sure you ran examples 3, 4 and 7 correctly and in the proper order as each builds on the previous example.

Example 9 - ThingSpeak

Heads Up! Unless using the Asset Tracker Carrier Board, the temperature data in the default code does not work as the LTE GNSS Breakout does not include the ICM-20948 9-DoF IMU found on the Asset Tracker.


We're including this example for completeness' sake but users will need to attach the 9DoF IMU Breakout to their microcontroller or modify the code to use other data for it to work properly.

The final example shows how to send data to ThingSpeak using HTTP POST or GET.

Make sure to complete these setup actions before using this example:

  • Create a ThingSpeak User Account
  • Create a new Channel by navigating to Channels → My channels → New Channel
  • Check the Write API Key value and Copy/Paste it into myWriteAPIKey in the example.

The main loop reads the temperature from the ICM-20948 and POSTs it to ThingSpeak. The data posts to your ThingSpeak channel as "Field 1".

Note: The temperature data from the ICM-20948 will always be a few degrees warmer than ambient temperature since the sensor measures the temperature inside the IMU IC.

Open a serial monitor with the baud set to 115200 to see the data sent to ThingSpeak printed out:

Screenshot showing serial monitor printout while temperature data is posted to ThingSpeak.

Check your ThingSpeak channel and you should see data posted to it similar to the screenshot below:

Screenshot of ThingSpeak application showing temperature data posts.

Troubleshooting

This section outlines a few troubleshooting tips and common snags when using the LTE GNSS Breakout - SARA-R5.

LTE Network Availability

The SARA-R5 supports LTE-M and NB-IoT data communication for multi-regional use. Please check the LTE signal availability for your area before purchasing a SARA-R5 product and selecting an LTE service provider / operator.

Data Connectivity

When working through the data connectivity examples, it is important that you run examples 13, 14 and 17 in order, before moving on to example 18 or 19. Each example builds on the last and together they configure the SARA’s data connection correctly.

TP (1PPS) Pin and LED

At the time of writing, we are shipping the SARA-R5 on the Asset Tracker with firmware version 02.06 on it. 02.06 contains a feature (which is just a polite name for a bug!) which means the 1 Pulse-Per-Second from the GNSS does work, but the pulse is only ~3 microseconds wide and cannot be adjusted. Handy huh? u-blox are aware of this - in fact we told them about it - and a fix is coming but they haven’t added it yet. We will keep an eye out for it and update this section once the fix is released.

Just to complicate matters, 3 microseconds is too short for the buffer FET and LED connected to the timing pulse to respond. So, we regret that you cannot currently use the TP PTH. We will share the fix with you as soon as we have it.

Arduino Debug Messages

If you run into any trouble using one of the Arduino examples, uncomment this line:

language:c
assetTracker.enableDebugging(SERIAL_PORT);

This enables serial debugging to print out the full debug report from AT commands sent via functions in the library. Read through the data and search for matching error codes in Appendix A of the AT Command Reference manual to decipher the code.

General Troubleshooting Help

Resources and Going Further

That wraps up this Hookup Guide. For more information about the SparkFun LTE GNSS Breakout - SARA-R5 take a look at the resources below:

LTE GNSS Breakout - SARA-R5 Documentation:

u-blox SARA-R5 LTE-M / NB-IoT module Documentation:

For more information on using the SARA-R5 with u-blox m-center, check out the MicroMod Update Tool Hookup Guide (specifically the Software Setup section):

MicroMod Update Tool Hookup Guide

February 25, 2021

Follow this guide to learn how to use the MicroMod Update Tool to interact directly with the UART on the MicroMod Asset Tracker's SARA-R5. Using this board you can talk directly to the module using u-blox's m-center software as well as update the firmware using EasyFlash.

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>