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

MicroMod Environmental Function Board Hookup Guide

$
0
0

MicroMod Environmental Function Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun MicroMod Environmental Function Board adds additional sensing options to the MicroMod Processor Boards. This function board includes three sensors to monitor air quality (SGP40), humidity & temperature (SHTC3), and CO2 concentrations (STC31) in your indoor environment. To make it even easier to use, all communication is over the MicroMod's I2C bus! In this tutorial, we will go over how to connect the board and read the sensors.

SparkFun MicroMod Environmental Function Board

SparkFun MicroMod Environmental Function Board

SEN-18632
$149.95

Required Materials

To follow along with this tutorial, you will need the following materials at a minimum. 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 MicroMod Environmental Function Board

SparkFun MicroMod Environmental Function Board

SEN-18632
$149.95
SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95
Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$3.95
5
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
microSD Card - 1GB (Class 4)

microSD Card - 1GB (Class 4)

COM-15107
$4.95

MicroMod Main Board

To hold the processor and function boards, you will need one Main board. Depending on your application, you may choose to have either one or two function boards.

SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
SparkFun MicroMod Main Board - Double

SparkFun MicroMod Main Board - Double

DEV-18576
$17.95

MicroMod Function Board

To add additional functionality to your Processor Board, you'll want to include one or two function boards when connecting them to the Main Board. Besides the MicroMod Environmental Function Board which this tutorial is focused on, you may descide to add the WiFi Function Board to the mix. Make sure to adjust the cart and include the MicroMod Main Board - Double as opposed to the Single when using two Function Boards. Check out the SparkFun catalog for other function boards.

SparkFun MicroMod Environmental Function Board

SparkFun MicroMod Environmental Function Board

SEN-18632
$149.95
SparkFun MicroMod WiFi Function Board - ESP32

SparkFun MicroMod WiFi Function Board - ESP32

WRL-18430
$14.95

Tools

You will need a screw driver to secure the Processor and Function boards.

SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3

Suggested Reading

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

MicroMod Logo
MicroMod Ecosystem

If you aren’t familiar with the following concepts, we also recommend checking out a few of these tutorials before continuing. Make sure to check the respective hookup guides for your processor board and function board to ensure that you are installing the correct USB-to-serial converter. You may also need to follow additional instructions that are not outlined in this tutorial to install the appropriate software.

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.

How to Install CH340 Drivers

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic) Hookup Guide

A Hookup Guide to get started using the SHTC3 breakout.

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!

Air Quality Sensor - SGP40 (Qwiic) Hookup Guide

Get started measuring indoor air quality with the SparkFun Air Quality Sensor - SGP40 (Qwiic) Hookup Guide.

Hardware Overview

This section goes over the important features on the MicroMod Environmental Function Board. Of course, we recommend checking out the Resources and Going Further for more information on each sensor.

Power

To power the board, you will need to apply power to a SparkFun Main Board. Power applied will connect to the Function Board's VIN pin, which will be regulated down for the rest of the board with the AP2112 3.3V/600mA voltage regulator.

Voltage Regulator

SGP40

The board includes the Sensirion SGP40 sensor IC which measures air quality. The reserved I2C address for the SGP40 is 0x59. For easy reference, the default address for the SGP40 is labeled on the board.

SGP40

SHTC3

The board includes the Sensirion SHTC3 sensor IC which measures humidity and temperature. The reserved I2C address for the SHTC3 is 0x70. For easy reference, the default address for the SHTC3 is labeled on the board.

SHTC3

STC31

The board includes the Sensirion STC31 sensor IC which measures CO2 concentrations in N2 and CO2 in air. The reserved I2C address for the STC31 is 0x29. For easy reference, the default address for the STC31 is labeled on the board.

STC31

EEPROM

The board includes an I2C EEPROM. Unfortunately, this is not available for the user and was meant to hold board specific information.

EEPROM

LED

There is one LED to indicate when there is power available. You can disable the LED with the PWR jumper

LED

Jumpers

The following jumpers are included to configure the board.

  • PWR - By default, the jumper with the label PWR is closed. This jumper connects the 3.3V line and LED. Cutting this jumper will disable the LED.
  • I2C Pull-up Resistors - By default, this three way jumper labeled I2C is closed and connects two pull-up resistors to the I2C data lines. If you have many devices on your I2C data lines, then you may consider cutting these two jumpers.
  • STC31 Address Selection - There are three jumpers available on the board to adjust the STC31's address. By default, the jumpers are open. The alternative addresses for the sensor are 0x2A, 0x2B, and 0x2C. To select the address, you will need to close the jumper by adding a solder blob to one of the solder jumpers.


alt text

MicroMod Function Board Pinout

Depending on your window size, you may need to use the horizontal scroll bar at the bottom of the table to view the additional pin functions. Note that the M.2 connector pins on opposing sides are offset from each other as indicated by the bottom pins where it says (Not Connected)*. There is no connection to pins that have a "-" under the primary function.

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
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
Alternative FunctionPrimary FunctionBottom
Pin
   Top   
Pin
Primary FunctionAlternative Function
(Not Connected)75GND
VIN74733.3V
VIN7271Power EN
-7069-
-6665-
-6463-
-6261-
-6059-
-5857-
-5655-
-5453-
-5251-
-5049-
-4847-
-4645GND
-4443-
-4241-
-4039GND
-3837-
EEPROM_A03635-
EEPROM_A13433GND
EEPROM_A23231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423-
-2221I2C_SCL
-2019I2C_SDA
-1817-
-1615-
-1413-
-1211-
-109-
-87-
-65-
-43-
-21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board uses the standard MicroMod Function Board size which measures about 1.50"x2.56".

Board Dimensions

Hardware Hookup

If you have not already, make sure to check out the Getting Started with MicroMod: Hardware Hookup for information on inserting your Processor and Function Boards to the Main 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 securing the Processor and Function Board to the Main Board, your setup should look like the image below. Connect a USB Type C Cable to begin programming your Processor Board. In this case, we used the MicroMod Main Board - Single, MicroMod Artemis Processor, and MicroMod Environmental Function Board.

Main Board, Processor, and Function Boards

Software Installation

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 the following tutorials.

Arduino Board Definitions and Driver

We'll assume that you installed the necessary board files and drivers for your Processor Board. In this case, we used the MicroMod Artemis Processor Board which uses the CH340 USB-to-serial converter. If you are using a Processor Board, make sure to check out its hookup guide for your Processor Board.

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.

MicroMod Artemis Processor Board Hookup Guide

October 21, 2020

Get started with the Artemis MicroMod Processor Board in this 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.

Arduino Library

The SparkFun SGP40, SHTC3, and STC3X Arduino libraries can be downloaded with the Arduino library manager by searching 'SparkFun SGP40,' 'SHTC3,' and 'STC3X'. Or you can grab the zip here from each respective GitHub repository (SGP40, SHTC3, STC3X) to manually install:

Arduino Examples

Example 1: Reading SHTC3, STC31, and SGP40

Below is the combined example to read SHTC3, STC31, and SGP40. If you have not already, select your Board (in this case the MicroMod Artemis), and associated COM port. Copy and paste the code below in your Arduino IDE. Hit the upload button and set the serial monitor to 115200 baud.

language:c
/******************************************************************************

  WRITTEN BY: Ho Yun "Bobby" Chan
  @ SparkFun Electronics
  DATE: 10/19/2021
  GITHUB REPO: https://github.com/sparkfun/MicroMod_Environmental_Sensor_Function_Board
  DEVELOPMENT ENVIRONMENT SPECIFICS:
    Firmware developed using Arduino IDE v1.8.12

  ========== DESCRIPTION==========
  This example code combines example codes from the SHTC3, STC31, and SGP40 libraries.
  Most of the steps to obtain the measurements are the same as the example code.
  Generic object names were renamed (e.g. mySensor => mySGP40 and mySTC3x).

     Example 1: Basic Relative Humidity and Temperature Readings  w/ SHTC3; Written by Owen Lyke
     Example 2: PHT (SHTC3) Compensated CO2 Readings w/ STC31; Written by Paul Clark and based on earlier code by Nathan Seidle
     Example 1: Basic VOC Index w/ SGP40; Written by Paul Clark

  Open a Serial Monitor at 115200 baud to view the readings!

  Note: You may need to wait about ~5 minutes after starting up the code before VOC index
  has any values.

  ========== HARDWARE CONNECTIONS ==========
  MicroMod Artemis Processor Board => MicroMod Main Board => MicroMod Environmental Function Board (with SHTC3, STC31, and SGP40)

  Feel like supporting open source hardware?
  Buy a board from SparkFun!
       MicroMod MicroMod Artemis Processor   | https://www.sparkfun.com/products/16401
       MicroMod Main Board - Single          | https://www.sparkfun.com/products/18575
       MicroMod Environmental Function Board | https://www.sparkfun.com/products/18632

  You can also get the sensors individually.

       Qwiic SHTC3 | https://www.sparkfun.com/products/16467
       Qwiic STC31 | https://www.sparkfun.com/products/18385
       Qwiic SGP40 | https://www.sparkfun.com/products/17729

  LICENSE: This code is released under the MIT License (http://opensource.org/licenses/MIT)

******************************************************************************/



#include <Wire.h>

#include "SparkFun_SHTC3.h" //Click here to get the library: http://librarymanager/All#SparkFun_SHTC3
SHTC3 mySHTC3; // Create an object of the SHTC3 class

#include "SparkFun_STC3x_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_STC3x
STC3x mySTC3x; // Create an object of the mySTC3x class

#include "SparkFun_SGP40_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SGP40
SGP40 mySGP40; //Create an object of the SGP40 class

float RH = 0.00; // Variable to keep track of SHTC3 temperature compensation for the STC31
float temperature = 0.00; // Variable to keep track of SHTC3 relative humidity compensation for the STC31






void setup() {

  Serial.begin(115200);
  //while (!Serial) ; // Wait for Serial Monitor/Plotter to open for Processors with Native USB (i.e. SAMD51)
  Serial.println(F("Initializing Combined Example w/ SGP40, SHTC3, and STC31."));
  Wire.begin();

  //mySTC3x.enableDebugging(); // Uncomment this line to get helpful debug messages on Serial
  //mySGP40.enableDebugging(); // Uncomment this line to print useful debug messages to Serial



  if (mySHTC3.begin() != SHTC3_Status_Nominal)
  {
    Serial.println(F("SHTC3 not detected. Please check wiring. Freezing..."));
    while (1)
      ; // Do nothing more
  }

  if (mySTC3x.begin() == false)
  {
    Serial.println(F("STC3x not detected. Please check wiring. Freezing..."));
    while (1)
      ; // Do nothing more
  }

  if (mySGP40.begin() == false)
  {
    Serial.println(F("SGP40 not detected. Check connections. Freezing..."));
    while (1)
      ; // Do nothing more
  }



  //We need to tell the STC3x what binary gas and full range we are using
  //Possible values are:
  //  STC3X_BINARY_GAS_CO2_N2_100   : Set binary gas to CO2 in N2.  Range: 0 to 100 vol%
  //  STC3X_BINARY_GAS_CO2_AIR_100  : Set binary gas to CO2 in Air. Range: 0 to 100 vol%
  //  STC3X_BINARY_GAS_CO2_N2_25    : Set binary gas to CO2 in N2.  Range: 0 to 25 vol%
  //  STC3X_BINARY_GAS_CO2_AIR_25   : Set binary gas to CO2 in Air. Range: 0 to 25 vol%
  if (mySTC3x.setBinaryGas(STC3X_BINARY_GAS_CO2_AIR_25) == false)
  {
    Serial.println(F("Could not set the binary gas! Freezing..."));
    while (1)
      ; // Do nothing more
  }



  //We can compensate for temperature and relative humidity using the readings from the SHTC3

  if (mySHTC3.update() != SHTC3_Status_Nominal) // Request a measurement
  {
    Serial.println(F("Could not read the RH and T from the SHTC3! Freezing..."));
    while (1)
      ; // Do nothing more
  }

  //In case the ‘Set temperature command’ has been used prior to the measurement command,
  //the temperature value given out by the STC31 will be that one of the ‘Set temperature command’.
  //When the ‘Set temperature command’ has not been used, the internal temperature value can be read out.
  temperature = mySHTC3.toDegC(); // "toDegC" returns the temperature as a floating point number in deg C
  Serial.print(F("Setting STC3x temperature to "));
  Serial.print(temperature, 2);
  Serial.print(F("C was "));
  if (mySTC3x.setTemperature(temperature) == false)
    Serial.print(F("not "));
  Serial.println(F("successful"));

  RH = mySHTC3.toPercent(); // "toPercent" returns the percent humidity as a floating point number
  Serial.print(F("Setting STC3x RH to "));
  Serial.print(RH, 2);
  Serial.print(F("% was "));
  if (mySTC3x.setRelativeHumidity(RH) == false)
    Serial.print(F("not "));
  Serial.println(F("successful"));

  //If we have a pressure sensor available, we can compensate for ambient pressure too.
  //As an example, let's set the pressure to 840 mbar (== SF Headquarters)
  uint16_t pressure = 840;
  Serial.print(F("Setting STC3x pressure to "));
  Serial.print(pressure);
  Serial.print(F("mbar was "));
  if (mySTC3x.setPressure(pressure) == false)
    Serial.print(F("not "));
  Serial.println(F("successful"));

  Serial.println(F("Note: Relative humidity and temperature compensation for the STC31 will be updated frequently in the main loop() function."));

} //end setup()






void loop() {

  //==============================
  //==========READ SHTC3==========
  //==============================
  //minimum update rate = ~100Hz

  SHTC3_Status_TypeDef result = mySHTC3.update();           // Call "update()" to command a measurement, wait for measurement to complete, and update the RH and T members of the object

  RH = mySHTC3.toPercent();                                 // "toPercent" returns the percent humidity as a floating point number
  Serial.print(F("RH = "));
  Serial.print(RH);

  Serial.print(F("%, T = "));
  Serial.print(mySHTC3.toDegF());                           // "toDegF" return the temperature as a flaoting point number in deg F
  Serial.print(F(" deg F, "));

  temperature = mySHTC3.toDegC();                           // "toDegC" returns the temperature as a floating point number in deg C
  Serial.print(temperature);
  Serial.print(F(" deg C"));

  if (mySHTC3.lastStatus == SHTC3_Status_Nominal)           // You can also assess the status of the last command by checking the ".lastStatus" member of the object
  {
    Serial.println("");                                         //Sample data good, no need to output a message
  }
  else {
    Serial.print(F(",     Update failed, error: "));        //notify user if there is an error
    errorDecoder(mySHTC3.lastStatus);
    Serial.println("");
  }



  //==============================
  //==========READ STC31==========
  //==============================
  //minimum update rate = 1Hz


  if (mySTC3x.setRelativeHumidity(RH) == false)
    Serial.print(F("Unable to set STC31 Relative Humidity with SHTC3."));

  if (mySTC3x.setTemperature(temperature) == false)
    Serial.println(F("Unable to set STC31 Temperature with SHTC3."));


  Serial.print(F("CO2(%): "));

  if (mySTC3x.measureGasConcentration())                   // measureGasConcentration will return true when fresh data is available
  {
    Serial.println(mySTC3x.getCO2(), 2);
  }
  else
  {
    Serial.print(mySTC3x.getCO2(), 2);
    Serial.println(F(",     (old STC3 sample reading, STC31 was not able to get fresh data yet)"));  //output this note to indicate  when we are not able to obtain a new measurement
  }



  //==============================
  //==========READ SGP40==========
  //==============================
  //minimum update rate = 1Hz

  Serial.print(F("VOC Index is: "));
  Serial.println(mySGP40.getVOCindex()); //Get the VOC Index using the default RH (50%) and T (25C)



  //================================
  //=========SPACE & DELAY==========
  //================================
  //Serial.println("");// Uncomment this line to add some space between readings for the Serial Monitor
  delay(1000); //Wait 1 second - the Sensirion VOC and CO2 algorithms expects a sample rate of 1Hz

}//end loop()





void errorDecoder(SHTC3_Status_TypeDef message)                             // The errorDecoder function prints "SHTC3_Status_TypeDef" results in a human-friendly way
{
  switch (message)
  {
    case SHTC3_Status_Nominal : Serial.print("Nominal"); break;
    case SHTC3_Status_Error : Serial.print("Error"); break;
    case SHTC3_Status_CRC_Fail : Serial.print("CRC Fail"); break;
    default : Serial.print("Unknown return code"); break;
  }
}

Example 2: Reading SHTC3, STC31, and SGP40 in CSV

Below is the same combined code but formatted for CSV. If you have not already, select your Board (in this case the MicroMod Artemis), and associated COM port. Copy and paste the code below in your Arduino IDE. Hit the upload button and set the serial monitor to 115200 baud.

language:c
/******************************************************************************

  WRITTEN BY: Ho Yun "Bobby" Chan
  @ SparkFun Electronics
  DATE: 10/19/2021
  GITHUB REPO: https://github.com/sparkfun/MicroMod_Environmental_Sensor_Function_Board
  DEVELOPMENT ENVIRONMENT SPECIFICS:
    Firmware developed using Arduino IDE v1.8.12

  ========== DESCRIPTION==========
  This example code combines example codes from the SHTC3, STC31, and SGP40 libraries.
  Most of the steps to obtain the measurements are the same as the example code.
  Generic object names were renamed (e.g. mySensor => mySGP40 and mySTC3x).

     Example 1: Basic Relative Humidity and Temperature Readings  w/ SHTC3; Written by Owen Lyke
     Example 2: PHT (SHTC3) Compensated CO2 Readings w/ STC31; Written by Paul Clark and based on earlier code by Nathan Seidle
     Example 1: Basic VOC Index w/ SGP40; Written by Paul Clark

  Open a Serial Monitor/Plotter at 115200 baud to view the readings!

  Note: You may need to wait about ~5 minutes after starting up the code before VOC index
  has any values.

  ========== HARDWARE CONNECTIONS ==========
  MicroMod Artemis Processor Board => MicroMod Main Board => MicroMod Environmental Function Board (with SHTC3, STC31, and SGP40)

  Feel like supporting open source hardware?
  Buy a board from SparkFun!
       MicroMod MicroMod Artemis Processor   | https://www.sparkfun.com/products/16401
       MicroMod Main Board - Single          | https://www.sparkfun.com/products/18575
       MicroMod Environmental Function Board | https://www.sparkfun.com/products/18632

  You can also get the sensors individually.
       SHTC3 | https://www.sparkfun.com/products/16467
       STC31 | https://www.sparkfun.com/products/18385
       SGP40 | https://www.sparkfun.com/products/17729

  LICENSE: This code is released under the MIT License (http://opensource.org/licenses/MIT)

******************************************************************************/



#include <Wire.h>

#include "SparkFun_SHTC3.h" //Click here to get the library: http://librarymanager/All#SparkFun_SHTC3
SHTC3 mySHTC3; // Create an object of the SHTC3 class

#include "SparkFun_STC3x_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_STC3x
STC3x mySTC3x; // Create an object of the STC3x class

#include "SparkFun_SGP40_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SGP40
SGP40 mySGP40; //Create an object of the SGP40 class

float RH = 0.00; // Variable to keep track of SHTC3 temperature compensation for the STC31
float temperature = 0.00; // Variable to keep track of SHTC3 relative humidity compensation for the STC31

//Debug mode, comment one of these lines out using a syntax
//for a single line comment ("//"):
#define DEBUG 0     //0 = Output for Serial Plotter, CSV
//#define DEBUG 1     //1 = Output for Serial Monitor





void setup() {

  Serial.begin(115200);
  //while (!Serial) ; // Wait for Serial Monitor/Plotter to open for Processors with Native USB (i.e. SAMD51)


#if DEBUG
  Serial.println(F("Initializing Combined Example w/ SGP40, SHTC3, and STC31."));
#else
  Serial.println(F("RH,degF,degC,SHTC3_Valid,RH_Compensate_Valid,degC_Compensate_Valid,CO2%,STC31_Valid,VOC_Index"));
#endif

  Wire.begin();

  //mySTC3x.enableDebugging(); // Uncomment this line to get helpful debug messages on Serial
  //mySGP40.enableDebugging(); // Uncomment this line to print useful debug messages to Serial



  if (mySHTC3.begin() != SHTC3_Status_Nominal)
  {
#if DEBUG
    Serial.println(F("SHTC3 not detected. Please check wiring. Freezing..."));
#endif
    while (1)
      ; // Do nothing more
  }

  if (mySTC3x.begin() == false)
  {
#if DEBUG
    Serial.println(F("STC3x not detected. Please check wiring. Freezing..."));
#endif
    while (1)
      ; // Do nothing more
  }

  if (mySGP40.begin() == false)
  {
#if DEBUG
    Serial.println(F("SGP40 not detected. Check connections. Freezing..."));
#endif
    while (1)
      ; // Do nothing more
  }



  //We need to tell the STC3x what binary gas and full range we are using
  //Possible values are:
  //  STC3X_BINARY_GAS_CO2_N2_100   : Set binary gas to CO2 in N2.  Range: 0 to 100 vol%
  //  STC3X_BINARY_GAS_CO2_AIR_100  : Set binary gas to CO2 in Air. Range: 0 to 100 vol%
  //  STC3X_BINARY_GAS_CO2_N2_25    : Set binary gas to CO2 in N2.  Range: 0 to 25 vol%
  //  STC3X_BINARY_GAS_CO2_AIR_25   : Set binary gas to CO2 in Air. Range: 0 to 25 vol%
  if (mySTC3x.setBinaryGas(STC3X_BINARY_GAS_CO2_AIR_25) == false)
  {
#if DEBUG
    Serial.println(F("Could not set the binary gas! Freezing..."));
#endif
    while (1)
      ; // Do nothing more
  }



  //We can compensate for temperature and relative humidity using the readings from the SHTC3

  if (mySHTC3.update() != SHTC3_Status_Nominal) // Request a measurement
  {
#if DEBUG
    Serial.println(F("Could not read the RH and T from the SHTC3! Freezing..."));
#endif
    while (1)
      ; // Do nothing more
  }

  //In case the ‘Set temperature command’ has been used prior to the measurement command,
  //the temperature value given out by the STC31 will be that one of the ‘Set temperature command’.
  //When the ‘Set temperature command’ has not been used, the internal temperature value can be read out.
  temperature = mySHTC3.toDegC(); // "toDegC" returns the temperature as a floating point number in deg C
#if DEBUG
  Serial.print(F("Setting STC3x temperature to "));
  Serial.print(temperature, 2);
  Serial.print(",");
  Serial.print(F("C was "));
#endif

  if (mySTC3x.setTemperature(temperature) == false) {
#if DEBUG
    Serial.print(F("not "));
#endif
  }
#if DEBUG
  Serial.println(F("successful"));
#endif

  RH = mySHTC3.toPercent(); // "toPercent" returns the percent humidity as a floating point number

#if DEBUG
  Serial.print(F("Setting STC3x RH to "));
  Serial.print(RH, 2);
  Serial.print(",");
  Serial.print(F("% was "));
#endif

  if (mySTC3x.setRelativeHumidity(RH) == false) {
#if DEBUG
    Serial.print(F("not "));
#endif
  }
#if DEBUG
  Serial.println(F("successful"));
#endif



  //If we have a pressure sensor available, we can compensate for ambient pressure too.
  //As an example, let's set the pressure to 840 mbar (== SF Headquarters)
  uint16_t pressure = 840;

#if DEBUG
  Serial.print(F("Setting STC3x pressure to "));
  Serial.print(pressure);
  Serial.print(F("mbar was "));
#endif

  if (mySTC3x.setPressure(pressure) == false) {
#if DEBUG
    Serial.print(F("not "));
#endif
  }
#if DEBUG
  Serial.println(F("successful"));

  Serial.println(F("Note: Relative humidity and temperature compensation for the STC31 will be updated frequently in the main loop() function."));
#endif

} //end setup()





void loop() {


  //==============================
  //======DEBUG TURNED ON=========
  //==============================
#if DEBUG
  //==============================
  //==========READ SHTC3==========
  //==============================
  //minimum update rate = ~100Hz

  SHTC3_Status_TypeDef result = mySHTC3.update();           // Call "update()" to command a measurement, wait for measurement to complete, and update the RH and T members of the object

  RH = mySHTC3.toPercent();                                 // "toPercent" returns the percent humidity as a floating point number
  Serial.print(F("RH = "));
  Serial.print(RH);

  Serial.print(F("%, T = "));
  Serial.print(mySHTC3.toDegF());                           // "toDegF" return the temperature as a flaoting point number in deg F
  Serial.print(F(" deg F, "));

  temperature = mySHTC3.toDegC();                           // "toDegC" returns the temperature as a floating point number in deg C
  Serial.print(temperature);
  Serial.print(F(" deg C"));

  if (mySHTC3.lastStatus == SHTC3_Status_Nominal)           // You can also assess the status of the last command by checking the ".lastStatus" member of the object
  {
    Serial.println("");                                         //Sample data good, no need to output a message
  }
  else {
    Serial.print(F(",     Update failed, error: "));        //notify user if there is an error
    errorDecoder(mySHTC3.lastStatus);
    Serial.println("");
  }



  //==============================
  //==========READ STC31==========
  //==============================
  //minimum update rate = 1Hz


  if (mySTC3x.setRelativeHumidity(RH) == false)
    Serial.print(F("Unable to set STC31 Relative Humidity with SHTC3."));

  if (mySTC3x.setTemperature(temperature) == false)
    Serial.println(F("Unable to set STC31 Temperature with SHTC3."));


  Serial.print(F("CO2(%): "));

  if (mySTC3x.measureGasConcentration())                   // measureGasConcentration will return true when fresh data is available
  {
    Serial.println(mySTC3x.getCO2(), 2);
  }
  else
  {
    Serial.print(mySTC3x.getCO2(), 2);
    Serial.println(F(",     (old STC3 sample reading, STC31 was not able to get fresh data yet)"));  //output this note to indicate  when we are not able to obtain a new measurement
  }



  //==============================
  //==========READ SGP40==========
  //==============================
  //minimum update rate = 1Hz

  Serial.print(F("VOC Index is: "));
  Serial.println(mySGP40.getVOCindex()); //Get the VOC Index using the default RH (50%) and T (25C)





  //==============================
  //=====DEBUG TURNED OFF=========
  //==============================
#else
  //==============================
  //==========READ SHTC3==========
  //==============================
  //minimum update rate = ~100Hz

  SHTC3_Status_TypeDef result = mySHTC3.update();           // Call "update()" to command a measurement, wait for measurement to complete, and update the RH and T members of the object

  RH = mySHTC3.toPercent();
  Serial.print(RH);
  Serial.print(",");
  Serial.print(mySHTC3.toDegF());
  Serial.print(",");
  temperature = mySHTC3.toDegC();                           // "toDegC" returns the temperature as a floating point number in deg C
  Serial.print(temperature);
  Serial.print(",");

  if (mySHTC3.lastStatus == SHTC3_Status_Nominal)           // You can also assess the status of the last command by checking the ".lastStatus" member of the object
  {
    Serial.print("1");                                         //Sample data good, no need to output a message
    Serial.print(",");
  }
  else
  {
    Serial.print("0");                                         //Sample data bad, no need to output a message
    Serial.print(",");
  }



  //==============================
  //==========READ STC31==========
  //==============================
  //minimum update rate = 1Hz


  if (mySTC3x.setRelativeHumidity(RH) == false)
  {
    //Serial.print(F("Unable to set STC31 Relative Humidity with SHTC3."));
    Serial.print("0");
    Serial.print(",");
  }
  else
  {
    Serial.print("1");
    Serial.print(",");
  }

  if (mySTC3x.setTemperature(temperature) == false)
  {
    //Serial.println(F("Unable to set STC31 Temperature with SHTC3."));
    Serial.print("0");
    Serial.print(",");
  }
  else
  {
    Serial.print("1");
    Serial.print(",");
  }

  if (mySTC3x.measureGasConcentration())                   // measureGasConcentration will return true when fresh data is available
  {
    Serial.print(mySTC3x.getCO2(), 2);
    Serial.print(",");
    Serial.print("1");                                     //Fresh Data
    Serial.print(",");
  }
  else
  {
    Serial.print(mySTC3x.getCO2(), 2);
    Serial.print(",");
    Serial.print("0");                                     //Data not fresh
    Serial.print(",");
  }



  //==============================
  //==========READ SGP40==========
  //==============================
  //minimum update rate = 1Hz

  Serial.println(mySGP40.getVOCindex()); //Get the VOC Index using the default RH (50%) and T (25C)

#endif



  //================================
  //=========SPACE & DELAY==========
  //================================
  //Serial.println("");// Uncomment this line to add some space between readings for the Serial Monitor
  delay(1000); //Wait 1 second - the Sensirion VOC algorithm expects a sample rate of 1Hz

}//end loop()





void errorDecoder(SHTC3_Status_TypeDef message)                             // The errorDecoder function prints "SHTC3_Status_TypeDef" resultsin a human-friendly way
{
  switch (message)
  {
    case SHTC3_Status_Nominal : Serial.print("Nominal"); break;
    case SHTC3_Status_Error : Serial.print("Error"); break;
    case SHTC3_Status_CRC_Fail : Serial.print("CRC Fail"); break;
    default : Serial.print("Unknown return code"); break;
  }
}

Troubleshooting

Resources and Going Further

Now that you've successfully got your MicroMod Environmental Function Board up and running, it's time to incorporate it into your own project! For more information, check out the resources below:

Need some inspiration for your next project? Check out some of these related tutorials 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 SAMD51 Processor Board Hookup Guide

This tutorial covers the basic functionality of the MicroMod SAMD51 and highlights the features of the ARM Cortex-M4F development board.

MicroMod ESP32 Processor Board Hookup Guide

A short hookup guide to get started with the SparkFun MicroMod ESP32 Processor Board.

MicroMod Teensy Processor Hookup Guide

Add the processing power and versatility of the Teensy to your MicroMod project following this guide for the SparkFun MicroMod Teensy Processor.

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


SparkFun RTK Facet Hookup Guide

$
0
0

SparkFun RTK Facet Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The RTK Facet from SparkFun is our most advanced GNSS receiver to date. It's 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 Facet is a flexible and powerful tool.

SparkFun RTK Facet

SparkFun RTK Facet

GPS-19029
$699.95

With just a few minutes of setup, the RTK Facet is one of the fastest ways to take centimeter grade measurements.

Image of Nate getting measurements

Surveying with a monopod and SW Maps

RTK Fix in SW Maps

An RTK Fix with 14mm accuracy in SW Maps

By connecting your phone to the RTK Facet 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

The RTK Facet has all you need built into one small unit. In addition, the RTK Facet Kit includes everything you might need as well. The only thing you need to add is your own tablet or cell phone (Android and IOS supported).

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 Facet setup in base mode and a radio link connecting the Base to the Rover. We'll go into details but we designed RTK Facet to work with these 100mW 915MHz telemetry radios out of the box.

Serial Telemetry Radio Kit - 915MHz, 100mW

Serial Telemetry Radio Kit - 915MHz, 100mW

WRL-15007

To charge the RTK Facet you will need a USB C cable and a power supply. These are included with the kit but any USB C port should charge the Facet at a maximum rate of 1A per hour.

USB 2.0 Type-C Cable - 1 Meter

USB 2.0 Type-C Cable - 1 Meter

CAB-16905
$4.50
Reversible USB A to C Cable - 0.8m

Reversible USB A to C Cable - 0.8m

CAB-15425
$4.95
1
USB Wall Charger - 5V, 2A

USB Wall Charger - 5V, 2A

TOL-16893
$5.95
USB-C Wall Adapter - 5.1V, 3A (Black)

USB-C Wall Adapter - 5.1V, 3A (Black)

TOL-16272
$4.95

Suggested Reading

GNSS RTK is an incredible feat of engineering that has been made easy to use by powerful GNSS receivers such as the ZED-F9P by u-blox (the receiver inside RTK Facet). 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 Facet is a fully enclosed, preprogrammed device. There are very few things to worry about or configure but we will cover the basics.

Power/Setup Button

RTK Facet Front Face

The RTK Facet has one button used for both Power and Setup for in-field configuration changes. Pressing and holding the Power button will cause it to power on or off. Short pressing the button will cause the RTK Facet to change modes.

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 POWER/SETUP button is pressed momentarily, a menu is presented to change the RTK Facet to Rover or Base mode. The display will indicate the change with a small car or flag icon.

In Rover mode the RTK Facet 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 Facet 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 over Bluetooth or into the radio port, the device will automatically enter Positioning with RTK mode. In this mode RTK Facet will receive L1/L2 signals from the antenna and correction data from a base station. The receiver will quickly (within a second) obtain RTK float, then fix. The NMEA sentences will have increased accuracy of 14mm horizontal and 10mm vertical accuracy. The RTCM correction data is most easily obtained over the internet using a free app on your phone (see SW Maps or Lefebure NTRIP) and sent over Bluetooth to the RTK Facet but RTCM can also be delivered over an external cellular or radio link to a 2nd RTK Facet 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 Facet will initiate a survey. After 60 to 120 seconds the survey will complete and the RTK Facet will begin transmitting RTCM correction data out the radio port. A base is often used in conjunction with a second RTK Facet (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 Facet startup display with firmware version number

RTK Facet startup display with firmware version number

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.

RTK Facet showing the battery level

RTK Facet showing the battery level

The RTK Facet has a large, built-in 6000mAh lithium polymer battery that will enable over 25 hours of field use between charging. If more time is needed a common USB power bank can be attached boosting the field time to any amount needed.

Charge LED

RTK Facet Charge LED

The Charge LED is located on the front face. 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 6 hours from a 1A wall supply or 12 hours from a standard USB port. The RTK Facet 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 Facet Connectors

The SparkFun RTK Facet connectors shown with the dust cover removed

There are a variety of connectors protected by a dust flap.

USB:

RTK Facet USB C Connector

This USB C connector is used for three purposes:

  • Charging the device
  • Configuring the RTK Facet, and reprogramming the ESP32
  • Directly configuring and inspecting the ZED-F9P GNSS receiver

There is a USB hub built into the RTK Facet. When you attach the device to your computer it will enumerate as two COM ports.

Two COM ports from one USB device

In the image above, the USB Serial Device is the ZED-F9P and the USB-SERIAL CH340 is the ESP32.

Configuring the RTK Facet can be done over the USB-Serial CH340 COM port via serial text menu. Various debug messages are printed to this port at 115200bps and a serial menu can be opened to configure advanced settings.

Configuring the ZED-F9P can be configured over the USB Serial Device port 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.

Radio:

RTK Facet Radio Connector

This port is used when an external cellular or radio link is needed. This port is not used if you transfer RTCM from your phone to the RTK Facet over Bluetooth.

This 4-pin JST connector can be 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 Facet 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 from left to right as pictured. 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 Facet 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). This port is capable of sourcing up to 600mA and is protected by a PTC (resettable fuse). This port should not be connected to a power source.

Data:

RTK Facet Data Port

This port is used when an external system is connected such as a rover, car, timing equipment, camera triggers, etc. This port is not used if you transfer NMEA positional data to your phone from the RTK Facet over Bluetooth.

This 4-pin JST connector is used to output and input a variety of data to the RTK Facet. The connector is a 4-pin locking 1.25mm JST SMD connector (part#: SM04B-GHS-TB, mating connector part#: GHR-04V-S). The RTK Facet 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 from left to right as pictured, which 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.

microSD:

RTK Facet microSD connector

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.

The following 67 messages are supported for logging:

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

RTK Facet Qwiic connector

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 Facet but support may be added in the future.

Antenna:

Internal RTK Facet Antenna

It's built in! Housed under the dome of the RTK Facet is a surveyor grade L1/L2 antenna. It is the same element found within our GNSS Multi-Band L1/L2 Surveying Antenna. Its datasheet is available here.

SparkFun RTK Facet Antenna Reference Point

SparkFun RTK Facet Antenna Reference Points

The built in antenna has an ARP of 61.4mm from the base to the measuring point of the L1 antenna and an ARP of 57.4mm to the measuring point of the L2 antenna.

Power

RTK Facet Display showing three battery bars

RTK Facet Display showing three battery bars

The RTK Facet has a built in 6000mAh battery and consumes approximately 240mA worst case with Bluetooth connection active and GNSS fully tracking. This will allow for around 25 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 56 hours of run time assuming 25% is lost to efficiencies of the power bank and charge circuit within RTK Facet.

The RTK Facet can be charged from any USB port or adapter. The charge circuit is rated for 1000mA so USB 2.0 ports will charge at 500mA and USB 3.0+ ports will charge at 1A.

To quickly view the state of charge, turn on the unit. 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

RTK Facet Circuit Boards

The boards that make up the RTK Facet

The RTK Facet is a hacker’s delight. Under the hood of the RTK Facet 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 Facet Schematic

Click on the image to get a closer look at the Schematic!

Internal RTK Facet Antenna

The Facet with three sub boards, the battery, and antenna

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.

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.

LiPo and Charging

The RTK Facet houses a standard 6000mAh 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 six hours. USB C on the RTK Facet 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.

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 Facet also incorporates a the LIS2DH12 triple-axis accelerometer to aid in leveling in the field.

Qwiic

An internal Qwiic connector is included in the unit for future expansion. Currently the stock RTK Facet does not support any additional Qwiic sensors or display but users may add support for their own application.

microSD

A microSD socket is situated on the ESP32 SPI bus. Any microSD up to 32GB is supported. RTK Facet supports RAWX and NMEA logging to the SD card. Max logging time can also be set (default is 24 hours) to avoid multi-gigabyte text files. For more information about RAWX and doing PPP please see this tutorial.

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.

Hardware Assembly

The RTK Facet was designed to work with low-cost, off the shelf equipment. Here we’ll describe how to assemble a Rover and Base.

Surveying (Rover Mode)

Basic RTK Facet setup

Basic RTK Facet Rover setup with RTCM over Bluetooth

Shown above is the most common RTK Rover setup. A monopole designed for cameras is used. The ¼” camera thread of the monopole is adapted to ⅝” 11-TPI and the RTK Facet is mounted on top. No radio is needed because RTCM correction data is provided by a phone 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.

If you prefer to mount your tablet or cell phone to the monopole be sure to get a clamp that is compatible with the diameter of your monopole and has a knob to increase clamp pressure. Our monopole is 27mm in diameter so a device clamp would need to be able to handle that diameter.

RTK Facet setup with radio

2nd most common setup with a 915MHz Radio providing RTCM

If you are receiving RTCM correction data over a radio link it’s recommended that you attach a radio to the bottom of the RTK Facet.

New Radio Version Coming Soon: We are currently waiting for the new version of the 100mW and 500mW serial radios to be released by Holybro. In the mean time, any serial radio should work with the RTK Facet/Express/Surveyor product line. The Radio Port is 57600bps by default so adjust the baud as needed to match the baud of the serial radio you choose.

Serial Telemetry Radio mounted to the back of RTK Facet

Picture hanging strips from 3M make a nice semi-permanent mount. Plug the 4-pin to 6-pin JST cable included with the RTK Facet 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 100mW radios and a big 915MHz antenna on the base (see this tutorial for more info).

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 Facet 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 100mW telemetry radios are used because they provide what is basically a serial cable between our base and rover.

Temporary RTK Facet Base setup

Temporary RTK Facet 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. The ¼” camera thread is adapted to ⅝” 11-TPI and the RTK Facet is attached on top.

Once the base has been setup with a clear view of the sky, turn on the RTK Facet. 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 Facet). The RTK Facet 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.

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 calculated 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 Facet 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 Facet. 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.

SW Maps with RTK Fix

SW Maps with RTK Fix

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 the later section.

Display has MAC address 5522 in the upper left corner

MAC address 5522 is shown in the upper left corner

Pairing with the RTK Facet over Bluetooth

Pairing with the 'Facet Rover-37E2' over Bluetooth

When powered on, the RTK Facet will broadcast itself as either 'Facet Rover-37E2' or 'Facet Base-37E2' depending on which state it is in. Discover and pair with this device from your phone or tablet. Once paired, open SW Maps.

List of BT Devices in SW Maps

List of available Bluetooth devices

With SW Maps open, click on the blue button in the upper left corner to open the main menu. Select Bluetooth GNSS. This will display a list of available Bluetooth devices. Select the Rover or Base you just paired with. For the Instrument Model drop down select 'SparkFun RTK Surveyor' or 'u-blox RTK' (rather than just 'u-blox'). This is important and will enable the use of NTRIP.

If you are taking height measurements (altitude) in addition to position (lat/long) be sure to enter the height of your antenna off the ground including the ARP offset of the RTK Facet.

SparkFun RTK Facet Antenna Reference Point

SparkFun RTK Facet Antenna Reference Point

The built in antenna has an ARP of 61.4mm from the base to the measuring point of the L1 antenna and an ARP of 57.4mm to the measuring point of the L2 antenna. So if your monopod is 67 inches long fully extended, the antenna offset is 1701.8mm + 61.4mm = 1763mm. You would want to enter 1.763m into SW Maps to get accurate altitude of the point being measured on the ground.

Click on 'CONNECT' to open a Bluetooth connection. Assuming this process takes a few seconds, you should immediately have a location fix.

Next we need to send RTCM correction data back to the RTK Facet so that it can improve its fix accuracy. You can either provide this from the phone or you can use your own radio backhaul (via 915MHz serial radios, cellular, LoRa, etc). We will describe in detail the use of NTRIP and your cellular phone because we find it's the easiest and fastest to get setup.

SW Maps NTRIP Connection menu

NTRIP Connection - Not there? Be sure to select 'SparkFun RTK Surveyor' or 'u-blox RTK' instrument

This is the amazing power of RTK Facet 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 'SparkFun RTK Surveyor' or 'u-blox RTK' instrument when connecting. Disconnect and change the instrument choice to enable the NTRIP Connection option.

SW Maps NTRIP client

Connecting to an NTRIP caster

Enter your NTRIP caster credentials and click connect. You will see bytes begin to transfer from your phone to the RTK Facet. Within a few seconds the RTK Facet will go from ~300mm accuracy to 14mm. Pretty nifty, no?

What's an NTRIP caster? In a nutshell, 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 Facet. 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 Facet.

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 Facet 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 Facet 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 Facet 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.
  • Model: This icon will change depending on the selected dynamic model: Portable (default) Pedestrian, Sea, Bike, Stationary, etc.
  • 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 Facet 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 Facet in Survey-In Mode

RTK Facet 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

RTK Facet in Fixed Transmit Mode

RTK Facet in Fixed Transmit Mode

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.

The Fixed Base mode is similar but uses a structure icon (shown above) to indicate a fixed base.

Base Transmitting 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.

RTK Facet in Transmit Mode with NTRIP

RTK Facet in Transmit Mode with NTRIP

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 USB port to view detailed location and ZED-F9P configuration information.

Output to an Embedded System

Many applications using the RTK Facet 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.

Wires connected to a SparkFun USB C to Serial adapter

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 Facet)
  • Orange - RX (input to RTK Facet)
  • Black - GND

Open a terminal at 115200bps and you should see NMEA sentences:

NMEA output from the RTK Surveyor

The Data connector on the RTK Facet 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 Facet 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 Facet 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 Facets to be identically configured using one 'golden' settings file loaded onto an SD card.

There are three ways to configure the RTK Facet.

System Configuration - WiFi

Starting with firmware v1.7, WiFi based configuration is supported and recommended. For more information about updating the firmware on your device, please see Firmware Updates and Customization.

Discovered WiFi networks

The WiFi network RTK Config as seen from a cellphone

Display showing IP address

Device ready for cellphone configuration

To get into WiFi configuration follow these steps:

  1. Power on the RTK Facet.
  2. Once the device has started press the Setup button repeatedly until the Config menu is highlighted.
  3. The RTK Facet will blink a WiFi icon indicating it is waiting for incoming connections.
  4. Connect to WiFi network named ‘RTK Config’.
  5. Open a browser (Chrome is preferred) and type 192.168.4.1 into the address bar.

Note: Upon connecting, your phone may warn you that this WiFi network has no internet. That's ok. Stay connected to the network and open a browser.

Webpage showing the RTK Configuration options

Connected to the RTK WiFi Setup Page

Clicking on a category 'carrot' will open or close that section. Clicking on an ‘i’ will give you a brief description of the options within that section.

Firmware highlighted

This unit has firmware version 1.8 and a ZED-F9P receiver

Please note that the firmware for the RTK device and the firmware for the ZED receiver are shown at the top of the page. This can be helpful when troubleshooting or requesting new features.

GNSS Configuration

The ZED-F9P module used in the Facet is immensely configurable. The RTK Facet 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 enable/disable various sentences and options for the ZED-F9P:

  • Measurement Frequency
  • Dynamic Model
  • Constellation Support
  • Messages (NMEA Sentences)

GNSS Configuration menus

The most common settings on the RTK Facet

Measurement Frequency

By default, the RTK Facet outputs a solution or location 'fix' 4 times a second. This can be increased but anything above 4Hz is not guaranteed to be stable. The Bluetooth buffer can quickly become overwhelmed and/or if datalogging is enabled the system can become bogged down with SD write delays. Decreasing to 1Hz is completely acceptable and will reduce the log sizes significantly.

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.

Dynamic Model

The ZED-F9P uses various models to augment the location fix. Select the model appropriate for your particular application for best performance. The default is Portable.

Constellation Support

The ZED-F9P is capable of tracking 184 channels across four constellations and two bands (L1/L2) including GPS (USA), Galileo (EU), BeiDou (China), and GLONASS (Russia). SBAS (satellite-based augmentation system) is also supported. By fault, all constellations are used. Some users may want to study, log, or monitor a subset. Disabling a constellation will cause the ZED to ignore those signals when calculating a location fix.

Messages

The ZED-F9P supports more than 70 different messages. Some messages, like NMEA, output location information. Other messages report the internal status of the ZED-F9P. Please see the ZED-F9P Integration Manual for more information about specific message types.

Each message rate input controls which messages are disabled (0) and how often the message is reported (1 = one message reported per 1 fix, 5 = one report every 5 fixes). The message rate range is 0 to 20.

Message rate configuration boxes

Message rate configuration

The two large buttons at the top allow you to quickly enable the defaults or logging defaults.

NMEA Defaults: By default, the RTK Facet outputs 5 NMEA sentences allowing for connectivity to most GIS applications. These include GxGGA, GxGSA, GxGST, GxGSV, and GxRMC.

Logging Defaults: If you are doing post processing (PPP) for base station creation or study, it is handy to record RAWX and SFRBX messages in addition to the 5 NMEA message. Pressing this button will set the messages accordingly.

Note: All enabled messages are broadcast over Bluetooth and logged (if a microSD card is present and enabled).

Base Configuration

Base type and location configuration

Controlling the type of Base

Survey-In

By default, the RTK Facet will enter 'Survey-In' mode when a user presses the POWER/SETUP button and selects 'Base'. The unit will monitor all constellations until both the observation time and required mean 3D standard deviation is met. u-blox recommends 60s and 5m but these are configurable. Please know that setting very long observation times (people have tried 24 hours) and very small means (1m or less) really doesn't get you much. Survey-in is limited in its precision. It's quick (1 minute!) but it's much less precise than a PPP setup.

Fixed Base

A fixed base is where the precise location of a device is known. This is either obtained via PPP or by locating a device on a survey marker. Once ‘Fixed’ is selected a user is able to enter the known position of the antenna in either ECEF or Geographic coordinates. Whenever a user selects 'Base' the GNSS receiver will immediately go into base mode with these coordinates and nearly immediately begin outputting RTCM correction data.

NTRIP Server

NTRIP Server Settings

The RTK Facet can be configured to transmit its RTCM directly over WiFi to the user's mountpoint. This eliminates the need for a radio link or a cell phone link.

Once the NTRIP server is enabled you will need a handful of credentials:

  • Local WiFi SSID and password
  • A casting service and port such as RTK2Go or Emlid (the port is almost always 2101)
  • A mount point and password

With these credentials set, RTK Facet will attempt to connect to WiFi, then connect to your caster of choice, and then begin transmitting the RTCM data over WiFi. We tried to make it as easy as possible. Every second a few hundred bytes, up to ~2k, will be transmitted to your mount point. Any rover can then connect to this mount point and gain its RTCM correction data over a cellular or internet connection.

Ports Configuration

Setting the baud rate of the ports

Setting the baud rates of the two available external 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 Facet (it is a plug and play solution). This can be set from 4800bps to 921600bps.

The Data port on the RTK Facet is very flexible. 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.

By default the Data port is set to NMEA and 460800bps. It is configurable 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.

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.

System Configuration

Advanced system settings

Advanced system settings

Log to SD

If a microSD card is detected, all messages will be logged. Once the max log time is achieved, logging will cease. This is useful for limiting long term, overnight, static surveys to a certain length of time. Default: 1440 minutes (24 hours). Limit: 1 to 2880 minutes.

Enable Factory Defaults

Factory Defaults will erase any user settings and reset the internal receiver to stock settings. Any logs on SD are maintained. To prevent accidental reset the checkbox must first be checked before the button is pressed.

SD Card

Various stats for the SD card are shown. If valid firmware is detected, available firmware files will be shown. The user must select the firmware they would like to update to. To prevent accidental updates the checkbox must first be checked before the button is pressed.

Add Firmware

New firmware may be uploaded via WiFi to the SD card. Firmware is only loaded to the SD card and must then be loaded to the unit.

Reset Counter

A counter is displayed indicating the number of non-power-on-resets since the last power on.

Saving and Exit

Save and Exit buttons

Once settings are input, please press ‘Save Configuration’. This will validate any settings, show any errors that need adjustment, and send the settings to the unit. The page will remain active until the user presses ‘Exit to Rover Mode’ at which point the unit will exit WiFi configuration and return to standard Rover mode.

System Configuration - Serial Terminal

Main Menu

To configure the RTK Facet attach a USB C cable to the USB 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 Facet will broadcast itself as either Facet Rover-XXXX or Facet 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 Facet 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 Facet 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 select which constellations should be used for fix calculations.

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 Facet supports up to 20Hz with RTK enabled. Some users are doing very long static surveys that require many seconds between measurements; RTK Facet 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.

Enable or disable the constellations used for fixes

Enable or disable the constellations used for fixes

Constellations Menu: The ZED-F9P is capable of tracking 184 channels across four constellations and two bands (L1/L2) including GPS (USA), Galileo (EU), BeiDou (China), and GLONASS (Russia). SBAS (satellite-based augmentation system) is also supported. By fault, all constellations are used. Some users may want to study, log, or monitor a subset. Disabling a constellation will cause the ZED to ignore those signals when calculating a location fix.

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

Dos CMD window showing Base menu optionns

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 Facet NTRIP Settings

Settings for the NTRIP Server

This is a new and powerful feature of the RTK Facet. The RTK Facet 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 Facet 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 Facet (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 Facet is very flexible. It can be configured in four different ways:

RTK Facet 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 Facet Data Logging Configuration Menu](https://cdn.sparkfun.com/assets/learn_tutorials/1/8/5/7/SparkFun_RTK_Express_-_Logging_Menu.jpg)

RTK Facet 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_Facet_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 Facet 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.

System Configuration - Settings File

SparkFun RTK Facet Settings File

SparkFun RTK Facet Settings File

Note: All system configuration can also be done by editing the SFE_Facet_Settings.txt file (shown above) that is created when a microSD card is installed. The settings are clear text but there are no safety guards against setting illegal states. It is not recommended to use this method unless You Know What You're Doing®.

Firmware Updates and Customization

The RTK Facet 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.8-Oct 7 2021](https://cdn.sparkfun.com/assets/learn_tutorials/2/1/8/8/SparkFun_RTK_Facet_-_Serial_Config_-_Main.jpg)

Main Menu showing RTK Firmware v1.8-Oct 7 2021

You can check your firmware by opening the main menu by pressing a key at any time.

Updating Firmware From the SD Card

Firmware update menu

Firmware update taking place

From time to time SparkFun will release new firmware for the RTK Facet 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 above.

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 Facet. We united the different platforms into one. The RTK Firmware runs on all our RTK products.

Updating Firmware From WiFi

Advanced system settings

Advanced system settings

Alternatively, firmware may be uploaded via the WiFi AP interface. Currently, the upload process is limited in speed resulting in upload times of nearly 2 minutes. Once the firmware has been uploaded it will be viewable on the firmware list on the page. To prevent accidental loading the Enable Firmware Update checkbox must first be checked before the button is enabled.

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 Facet. 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_v19_combined.bin

Note: You will need to modify COM6 to match the serial port that RTK Facet enumerates at.

Programming via the esptool CLI

Programming via the esptool CLI

Upon completion, your RTK Facet will have the latest and greatest features!

Creating Custom Firmware

The RTK Facet 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 Facet must be turned on for it to enumerate as a COM port.

Troubleshooting

Resources and Going Further

We hope you enjoy using the RTK Facet as much as we have!

Here are the pertinent technical documents for the RTK Facet:

Check out these additional tutorials for your perusal:

Getting Started with the GeoFence

How to get started using the GeoFence GPS Boundary Widget and GeoFence Software.

HX1 APRS Transmitter Hookup Guide

The HX1 is a low-power amateur radio transmitter that can be used to send data to the Automatic Packet Reporting System (APRS) network.

LTE Cat M1/NB-IoT Shield Hookup Guide

The SparkFun LTE CAT M1/NB-IoT Shield equips your Arduino or Arduino-compatible microcontroller with access to data networks across the globe. This shield adds wireless, high-bandwidth cellular functionality to your IoT project!
New!

Artemis Global Tracker Hookup Guide

The SparkFun Artemis Global Tracker combines the Artemis processor with an Iridium 9603N satellite transceiver, ZOE-M8Q GNSS transceiver, and MS8607 PHT sensor. With a clear view of the sky, this board allows you to send and receive short data messages from anywhere in the world including remote locations far beyond the reach of WiFi and GSM networks. Follow this guide to get started with the Artemis Global Tracker.

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

MicroMod Main Board Hookup Guide

$
0
0

MicroMod Main Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The MicroMod Main Board - Single and Double are specialized carrier boards that allow you to interface a Processor Board with a Function Board(s). The modular system allows you to add an additional feature(s) to a Processor Board with the help of a Function Board(s).

SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
SparkFun MicroMod Main Board - Double

SparkFun MicroMod Main Board - Double

DEV-18576
$17.95

Required Materials

To follow along with this tutorial, you will need the following materials at a minimum. 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 MicroMod Environmental Function Board

SparkFun MicroMod Environmental Function Board

SEN-18632
$149.95
SparkFun MicroMod WiFi Function Board - ESP32

SparkFun MicroMod WiFi Function Board - ESP32

WRL-18430
$14.95
SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$3.95
5
microSD Card - 1GB (Class 4)

microSD Card - 1GB (Class 4)

COM-15107
$4.95

MicroMod Main Board

To hold the processor and function boards, you will need one Main board. Depending on your application, you may choose to have either one or two function boards.

SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
SparkFun MicroMod Main Board - Double

SparkFun MicroMod Main Board - Double

DEV-18576
$17.95

MicroMod Processor Board

There are a variety of MicroMod Processor Boards available to choose from. You will probably want to avoid having the same Processor and Function Board since there is an ESP32 on both types of boards.

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$16.95
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$18.95
SparkFun MicroMod RP2040 Processor

SparkFun MicroMod RP2040 Processor

DEV-17720
$11.95

MicroMod Function Board

To add additional functionality to your Processor Board, you'll want to include one or two function boards when connecting them to the Main Board. Make sure to check out the catalog for other function boards.

SparkFun MicroMod Environmental Function Board

SparkFun MicroMod Environmental Function Board

SEN-18632
$149.95
SparkFun MicroMod WiFi Function Board - ESP32

SparkFun MicroMod WiFi Function Board - ESP32

WRL-18430
$14.95

Tools

You will need a screw driver to secure the Processor and Function boards. To set the charge rate, you will need a precision screw driver (or a tiny, rounded object). The pocket screwdriver set is an excellent option. For users using a microSD card and want to easily read the contents of the memory card, you will need a microSD card adapter or USB reader.

microSD USB Reader

microSD USB Reader

COM-13004
$4.95
10
Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$3.95
5
SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3

Suggested Reading

If you aren't familiar with the MicroMod ecosystem, we recommend reading here for an overview. We recommend reading here for an overview if you decide to take advantage of the Qwiic connector.

MicroMod LogoQwiic Connect System
MicroMod EcosystemQwiic Connect System

If you aren’t familiar with the following concepts, we also recommend checking out a few of these tutorials before continuing. Make sure to check the respective hookup guides for your processor board and function board to ensure that you are installing the correct USB-to-serial converter. You may also need to follow additional instructions that are not outlined in this tutorial to install the appropriate software.

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.

How to Install CH340 Drivers

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

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 overall functionality of the Single and Double Main Boards are the same. We'll use the Single Main Board more in this section to highlight the features since this is also included in the Double Main Board. We'll switch to the Double Main Board when necessary to highlight the features that are only included in the Double Main Board.

The only differences are that the Double Main Board includes:

  • two jumper shunts
  • ability to add a second MicroMod Function Board to the mix
  • board's width
Main Board - Single MeasurementsMain Board - Double Measurements
(Zoomed Out)

Power

There are two ways to power the Main Boards, Processor Board, and Function Board(s).

  • USB
  • Single Cell LiPo Battery

It is fine to connect a power source to the USB connector and LiPo battery's JST connector at the same time. The MicroMod Main Board has power-control circuitry to automatically select the best power source.

Power USB

One option of powering the board is through the USB Type C connector. You will need a USB Type C cable to power the board with 5V. Power connected to the board's USB C connector will go through a resettable PTC fuse (rated at 2A max) and then the AP7361C 3.3V voltage regulator (rated at 1A max). The little green component close to the USB connector is the resettable PTC fuse while the square IC is the voltage regulator. The voltage regulator accepts voltages between ~3.3V to 6.0V.

USB Connector, PTC Fuse, and AP7361C Voltage Regulator

The USB Type C connector is also used to upload code to your Processor Board, send serial data to a terminal window, or charge the LiPo battery. Of course for portable power, you could connect a USB battery as an alternative to using a LiPo battery.

Power applied to the connector will light up the VIN and 3V3 LED. If you decide to bypass the PTC fuse, simply add a solder blob to the jumper labeled as PTC. There is also a jumper labeled as MEAS to measure the current consumption at the output of the 3.3V voltage regulator for your project.

Power LiPo

The other option is to connect a single cell LiPo battery (i.e. nominal 3.7V, 4.2V fully charged) to the 2-pin JST connector as shown below. A MCP73831 charge IC is included on the boards to safely charge the LiPo batteries via USB Type C connector. A switch is included to set the charge rate. The charge rate is probably set to ~166mA with both switches flipped to the ON position. This may vary depending on the position of the switch when it was pulled from the reel. Flip the switch to adjust the charge rate to either 100mA or 500mA using a precision flat head screw driver or tweezers.

LiPo Charge IC, Charge Rate Switch, and 2-Pin JST Connector

The voltage from the LiPo battery is regulated down to 3.3V as it goes through the AP7361C 3.3V voltage regulator (rated at 1A max).

MicroMod Processor Board

The MicroMod ecosystem allows you to easily swap out processors depending on your application. The location of the M.2 connector labeled as Processor is where you would connect and secure a MicroMod Processor Board.

Processor Board Socket

MicroMod Function Board

Beside the MicroMod Processor's socket is another M.2 connector for MicroMod Function Boards, which allow you to add additional functionality to your Processor Board. The Single Main Board includes one socket for a single Function Board while the Double Main Board includes two sockets for up two Function Boards.

Main Board - Single Function Board SocketsMain Board - Double Function Board Sockets
Main Board - Single Function Board SocketMain Board - Double Function Board Sockets

Reset and Boot Buttons

Each board includes a reset and boot button. There is an additional reset button PTH next to the reset button. Hitting the reset button to restart your Processor Board. Hitting the boot button will put the Processor Board into a special boot mode. Depending on the processor board, this boot pin may not be connected.

Reset and Boot Buttons

SWD Pins

For advanced users, we proke out the 2x5 SWD programming pins. Note that this is not populated so you will need a compatible header and compatible JTAG programmer to connect.

SWD Pins

MicroSD Socket

The board includes a microSD socket if your application requires you to log and save data to a memory card. The primary SPI pins (SDO, SDI, SCK, CS0) from your Processor and Function Board are connected to the microSD Socket.

MicroSD Card Socket

LEDs

There are three LEDs on the board:

  • VIN - The VIN LED lights up to indicate when power available from the USB connector.
  • 3V3 - The 3V3 LED lights up to indicate when there is a 3.3V available after power is regulated down from the USB connector or LiPo battery.
  • CHG - The on-board yellow CHG LED can be used to get an indication of the charge status of your battery. Below is a table of other status indicators depending on the state of the charge IC.

Charge StateLED status
No BatteryFloating (should be OFF, but may flicker)
ShutdownFloating (should be OFF, but may flicker)
ChargingON
Charge CompleteOFF

LEDs

Jumpers

The following five jumpers are included on both the Single and Double Main Boards.

  • MEAS - By default, the jumper is closed and located on the top side of the board. This jumper is used to measure your system's current consumption. You can cut this jumper's trace and connect the PTHs to a ammeter/multimeter to probe the output from the 3.3V voltage regulator. Check out our How to Use a Multimeter tutorial for more information on measuring current.
  • PTC - By default, the jumper is open and located on the bottom of the board. For advanced users that know what you are doing, add a solder blob to the jumper to bypass the resettable PTC fuse to pull more than 2A from the USB source.
  • 3.3V EN - By default, this jumper is open and located on the bottom of the board. Closing this jumper enables processor control of the 3.3V bus.
  • VIN LED - By default, this jumper is closed and located on the bottom of the board. Cut this trace to disable the LED that is connected to the input of the USB
  • 3.3V LED - By default, this jumper is closed and located on the bottom of the board. Cut this trace to disable the LED that is connected to the output of the 3.3V voltage regulator.
Top View Jumpers
Main Board - Single
Top View Jumpers
Main Board - Single
Bottom View Jumpers

Included only on the Double Main Board are two 1x3 male headers with 2-pin jumper shunts to enable the 3.3V voltage regulator for any Function Board connected to Function Zero and Function One using alternative Processor GPIO pins. Since certain processors have limited GPIO and may not be broken out on certain locations, alternative pins have been provided on the board. The ALT PWR EN0 jumper allows users to control the 3.3V voltage regulator on any Function Board that is connected to Function Zero. When the jumper shunt is on the left side toward the 2-pin JST connector, the jumper shunt connects the PWR EN0 to the Processor Board's GPIO G5 pin. Moving the jumper shunt to the other side connects the Processor Board's GPIO G5 pin to Function Board One's GPIO G3 pin.

Main Board - Double Jumpers

The ALT PWR EN1 jumper allows users control power from the 3.3V voltage regulator for any Function Board that is connected to Function One when the jumper shunt is connecting PWR EN1 and Processor Board's GPIO G6 pin. Moving the jumper shunt to the other side connects the Processor Board's GPIO G6 pin to Function Board One's GPIO G4 pin.

Qwiic and I2C

The board includes a vertical and horizontal Qwiic connector. These are connected to the primary I2C bus and 3.3V power on both the Processor and Function Board connectors allowing you to easily add a Qwiic-enabled device to your application.

Qwiic Connectors

Note that there are two mounting holes for Qwiic-enabled boards that have a standard 1.0"x1.0" size board. The image below highlighted with a black square is where you would place the board.

Qwiic Mounting Holes

MicroMod Pinout

Depending on your window size, you may need to use the horizontal scroll bar at the bottom of the table to view the additional pin functions. Note that the M.2 connector pins on opposing sides are offset from each other as indicated by the bottom pins where it says (Not Connected)*. There is no connection to pins that have a "-" under the primary function.

AUDIOUARTGPIO/BUSI2CSDIOSPIDedicated
Processor PinsFunction Zero PinsMain Board - Single Miscellaneous Pins
GNDGNDGND
3.3V-3.3V
USB_D+_Processor-USB_D+
3.3V_EN-3.3V_EN
USB_D-_Processor-USB_D-
RESET# (I - Open Drain)-RESET# (I - Open Drain)
GNDGNDGND
USB_VIN-USB_VIN
D0_ProcessorF0-
BOOT (I - Open Drain)-BOOT (I - Open Drain)
I2C_SDA_ProcessorI2C_SDAI2C_SDA (Qwiic)
UART_RTS_ProcessorUART_RTS-
I2C_SCL_ProcessorI2C_SCLI2C_SCL (Qwiic)
UART_CTS_ProcessorUART_CTS-
I2C_INT_ProcessorI2C_INT-
UART_TX_ProcessorUART_RX-
D1_Processor-SD Card CS
(microSD Card)
UART_RX_ProcessorUART_TX-
SWDCK_Processor-SWDCK (2x5 Header)
SWDIO_Processor-SWDCK (2x5 Header)
PWM0_ProcessorPWM0-
GNDGNDGND
A0_ProcessorA0-
USBHOST_D+_ProcessorUSBHOST_D+-
GNDGNDGND
USBHOST_D-_ProcessorUSBHOST_D--
A1_ProcessorPWR_EN0-
GNDGNDGND
G0_ProcessorF3-
CAN_RX_ProcessorCAN_TX-
G1_ProcessorF4-
CAN_TX_ProcessorCAN_RX-
G2_ProcessorF5-
GNDGNDGND
G3_ProcessorF6-
G4_ProcessorF7-
BATT_VIN / 3 (I - ADC) (0 to 3.3V)-BATT_VIN / 3 (I - ADC) (0 to 3.3V)
SPI_CS0_ProcessorF1-
SPI_SCK_ProcessorSPI_SCKSPI_SCK
(microSD Card)
SPI_DI_ProcessorSPI_DOSPI_DO
(microSD Card)
SPI_DO_ProcessorSPI_DISPI_DI
(microSD Card)
SDIO_DATA2_ProcessorPWR_EN0-
Processor PinsFunction Zero PinsFunction One PinsMain Board - Double Miscellaneous Pins
GNDGNDGNDGND
3.3V--3.3V
USB_D+_Processor--USB_D+
3.3V_EN--3.3V_EN
USB_D-_Processor--USB_D-
RESET# (I - Open Drain)--RESET# (I - Open Drain)
GNDGNDGNDGND
----
USB_VIN--USB_VIN
D0_ProcessorF0--
BOOT (I - Open Drain)--BOOT (I - Open Drain)
I2C_SDA_ProcessorI2C_SDAI2C_SDAI2C_SDA (Qwiic)
UART1_RTS_ProcessorUART_RTS(No Flow Control)-
I2C_SCL_ProcessorI2C_SCLI2C_SCLI2C_SCL (Qwiic)
UART_CTS_ProcessorUART_CTS(No Flow Control)-
I2C_INT_ProcessorI2C_INTI2C_INT-
UART1_TX_ProcessorUART_RX--
D1_Processor-F0-
UART1_RX_ProcessorUART_TX--
UART2_RX_Processor-UART_TX-
SWDCK_Processor--SWDCK (2x5 Header)
UART2_TX_Processor-UART_RX-
SWDIO_Processor--SWDCK (2x5 Header)
PWM0_ProcessorPWM--
GNDGNDGNDGND
A0_ProcessorA0--
USBHOST_D+_ProcessorUSBHOST_D+(No USB Host)-
GNDGNDGNDGND
USBHOST_D-_ProcessorUSBHOST_D-(No USB Host)-
A1_Processor-A0-
GNDGNDGNDGND
G0_ProcessorF3--
CAN_RX_ProcessorCAN_TX(No CAN BUS)-
G1_ProcessorF4--
CAN_TX_ProcessorCAN_RX(No CAN BUS)-
G2_ProcessorF5--
GNDGNDGNDGND
G3_ProcessorF6--
PWM1_Processor-PWM-
G4_ProcessorF7-SD Card CS
(microSD Card)
BATT_VIN / 3 (I - ADC) (0 to 3.3V)--BATT_VIN / 3 (I - ADC) (0 to 3.3V)
----
----
----
----
----
SPI_CS0_ProcessorF1--
----
SPI_SCK_ProcessorSPI_SCKSPI_SCKSPI_SCK
(microSD Card)
----
SPI_DI_ProcessorSPI_DOSPI_DOSPI_DO
(microSD Card)
SDIO_CLK_Processor-F7-
SPI_DO_ProcessorSPI_DISPI_DISPI_DI
(microSD Card)
SDIO_CMD_Processor-F6-
----
----
----
SDIO_DATA1_Processor-PWR_EN1-
----
SDIO_DATA2_ProcessorPWR_EN0--
G7_Processor-F5-
SPI_CS1_Processor-SPI_CS1-
G6_Processor-F4-
----
Alternative
Function
Primary
Function
Bottom
Pin
   Top   
Pin
Primary
Function
Alternative
Function
(Not Connected)75GND
VIN74733.3V
VIN7271Power EN
-7069-
-6665-
-6463-
-6261F7
-6059F6
-5857F5
-5655F4
-5453F3
-5251F2PWM
-5049F1SPI_CS0
-4847F0INT
-4645GND
-4443CAN_TX
-4241CAN_RX
-4039GND
A03837USBHOST_D-
EEPROM_A03635USBHOST_D+
EEPROM_A13433GND
EEPROM_A23231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423I2C_INT
-2221I2C_SCL
-2019I2C_SDA
UART_CTS1817-
UART_RTS1615UART_RX
-1413UART_TX
-1211-
-109-
-87SPI_SDO
-65SPI_SDI
-43SPI_SCK
-21GND
Alternative FunctionAlternative FunctionAlternative FunctionPrimary FunctionBottom
Pin
   Top   
Pin
Primary FunctionAlternative FunctionAlternative FunctionAlternative 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 Dimensions

The board dimension of the MicroMod Main Board - Single is 2.90" x 3.40" while the MicroMod Main Board - Double is 2.90" x 4.90". Both boards include 5x mounting holes. Four are located on the edge of each board. The fifth mounting hole is located 0.80" away from another mounting hole to mount Qwiic-enabled boards that have the standard 1.0"x1.0" size board.

MicroMod Main Board - SingleMicroMod Main Board - Double

Hardware Hookup

If you have not already, make sure to check out the Getting Started with MicroMod: Hardware Hookup for information on inserting your Processor and Function Boards to the Main 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!

USB

To program and power the Main Board, you will need to insert the USB-C cable into the USB connector. We will leave the other end disconnected when connecting a Processor or Function board to the Main Board.

When the boards are secure, insert the other end to a computer. When you are finished programming the processor, you can use a USB battery via the USB connector or LiPo battery via the JST connector to power the board.

Processor Board

Align the Processor Board's key into its M.2 connector's socket. Insert the board at an angle (~25°), push down, and tighten the screw. In this case, we had the MicroMod Artemis Processor Board secured in the M.2 connector socket. Depending on your application, you may have a different Processor Board.

Function Boards

Align the Function Board's key into its M.2 connector's socket. Insert the board at an angle (~25°), push down, and tighten one of the screw to hold the board down. Attach the second screw on the other side of the board. Once the board is aligned, tighten both screws fully to secure the board. In this case, we had the Environmental Function Board secured in the M.2 connector socket. Depending on your application, you may have a different Function Board.

Main - Single, Processor, and Function Board

If you decide to have two function boards attached to the Main Board - Double, we recommend tightening the screw between the two Function Boards first to hold them down before attaching the remaining screws on either side of the Function Boards. In this case, we had the WiFi Function Board and the Environmental Function Board secured in the M.2 connector socket. Depending on your application, you may have different function boards.

Main - Double, Processor, and Function Boards

Single Cell LiPo Battery

A precision flat head (or a tiny, rounded object) is needed to set the charge rate for your single cell LiPo battery. When the switch is flipped to the ON position on the 500mA side, the charge rate will be 500mA. When the switch is flipped to the ON position on the 100mA side, the charge rate will be 100mA. When the switch is flipped to the ON position on both the 100mA and 500mA sides, the charge rate will be 166mA.

Setting the LiPo Charge Rate on the DIP Switch

For mobile applications, attach a single cell LiPo battery to the 2-pin JST connector. Attach a USB cable to a USB port or charger when the battery is low to begin charging.

LiPo Battery Connected

To remove the LiPo battery, you can pull the white JST connector away from the socket while also wiggling the connector side to side using your thumb and index finger.

Qwiic-Enabled Devices

To Qwiic-ly connect I2C devices, simply insert a Qwiic cable between one of the MicroMod Main Board's Qwiic ports and your Qwiic device.

Qwiic-Enabled Board Connected

If you need to mount a Qwiic-enabled board to the MicroMod Main Board, you can grab some standoffs and mount a standard Qwiic 1.0"x1.0" sized board using the two mounting holes near the USB Type C connector. Place the standoff between the boards and tighten the screws to mount. The image below used standoffs with built-in threads.

Qwiic-Enabled Board Mounted

MicroSD Card

With power removed from the board, insert a microSD card (with the pins facing toward the board) into the socket. You'll hear a nice click indicating that the microSD card is locked in place.

MicroSD Card Inserting into the MicroSD Card Socket

To remove, make sure power is off and press the microSD card into the socket to eject. You'll hear a nice click indicating that the card is ready to be removed from the socket.

Software Installation

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 the following tutorials.

Arduino Board Definitions and Driver

We'll assume that you installed the necessary board files and drivers for your Processor Board. In this case, we used the MicroMod Artemis Processor Board which uses the CH340 USB-to-serial converter. If you are using a Processor Board, make sure to check out its hookup guide for your Processor Board.

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.

MicroMod Artemis Processor Board Hookup Guide

October 21, 2020

Get started with the Artemis MicroMod Processor Board in this 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.

Arduino Examples

Let's go over a few basic examples to get started with the MicroMod Main Board Single and Double. We'll toggle the 3.3V voltage regulator and log data to a microSD card on both boards.

Example 1: MicroMod Main Board - Single Enable Function Board

If you have not already, select your Board (in this case the MicroMod Artemis), and associated COM port. Copy and paste the code below in your Arduino IDE. Hit the upload button and set the serial monitor to 115200 baud.

language:c
/******************************************************************************

  WRITTEN BY: Ho Yun "Bobby" Chan
  @ SparkFun Electronics
  DATE: 10/19/2021
  GITHUB REPO: https://github.com/sparkfun/SparkFun_MicroMod_Main_Board_Single
  DEVELOPMENT ENVIRONMENT SPECIFICS:
    Firmware developed using Arduino IDE v1.8.12

  ========== DESCRIPTION==========
  This example code toggles the Function Board's AP2112 3.3V voltage 
  regulator's enable pin. The Function Boards built-in power LED should blink.
  This example is based on Arduino's built-in Blink Example:

      https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink

  Note that this example code uses the MicroMod Main Board - Single. The MicroMod
  Main Board - Double routes the PWR_EN# pins slightly different for the
  two function boards. 

  ========== HARDWARE CONNECTIONS ==========
  MicroMod Artemis Processor Board => MicroMod Main Board - Single => Function Board

  Feel like supporting open source hardware?
  Buy a board from SparkFun!
       MicroMod Artemis Processor Board - https://www.sparkfun.com/products/16401
       MicroMod Main Board - Single - https://www.sparkfun.com/products/18575
       MicroMod Environmental Function Board - https://www.sparkfun.com/products/18632

  LICENSE: This code is released under the MIT License (http://opensource.org/licenses/MIT)

******************************************************************************/

/*Define the power enable pins for the processor board with either SDIO_DATA2 or A1.
  Depending on the processor board, the Arduino pin may be different. 

  Note: Certain Processor Boards like the Artemis have SDIO_Data2 and A1 available
        to control the Function Board's voltage regulator. SAMD51, ESP32, and STM32
        Processor Board pins do not have SDIO Data 2, so users will need to reference
        the Processor Pin A1. Below are a few examples. */


//ARTEMIS
#define PWR_EN0 4   //Function Board 0's "PWR_EN0" pin <= MicroMod SDIO_DATA2 => Artemis Processor Board (D4)
//Alternative option that does the same thing. Make sure to just choose one for PWR_EN0
//#define PWR_EN0 35   //Function Board 0's "PWR_EN0" pin <= MicroMod A1 => Artemis Processor Board (A35)

//TEENSY
//#define PWR_EN0 15   //Function Board 0's "PWR_EN0" pin <= MicroMod A1 => Teensy Processor Board (A1)

//SAMD51
//#define PWR_EN0 18   //Function Board 0's "PWR_EN0" pin <= MicroMod A1 => SAMD51 Processor Board (18)



void setup() {
  // initialize the digital pin as an output.
    pinMode(PWR_EN0, OUTPUT);
}



void loop() {
  digitalWrite(PWR_EN0, HIGH); // turn the 3.3V regulator on (HIGH is the voltage level)
  delay(5000);                 // wait for a few seconds to do something with the function boards

  digitalWrite(PWR_EN0, LOW);  // turn the 3.3V regulator off by making the voltage LOW
  delay(5000);                 // wait for a few seconds before turning function boards back on

}

After uploading, take a look at your Function Board's PWR LED. The LED will be on for about 5 seconds and then turn off for another 5 seconds. It will continue to repeat until power is removed from the MicroMod Main Board - Single.

Example 2: MicroMod Main Board - Double Enable Function Boards

If you have not already, select your Board (in this case the MicroMod Artemis), and associated COM port. Copy and paste the code below in your Arduino IDE. Hit the upload button and set the serial monitor to 115200 baud.

language:c
/******************************************************************************

  WRITTEN BY: Ho Yun "Bobby" Chan
  @ SparkFun Electronics
  DATE: 10/19/2021
  GITHUB REPO: https://github.com/sparkfun/SparkFun_MicroMod_Main_Board_Double
  DEVELOPMENT ENVIRONMENT SPECIFICS:
    Firmware developed using Arduino IDE v1.8.12

  ========== DESCRIPTION==========
  This example code toggles the Function Board's AP2112 3.3V voltage
  regulator's enable pin. The Function Boards built-in power LED should blink.
   This example is based on Arduino's built-in Blink Example:

      https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink

  Note that this example code uses the MicroMod Main Board - Double. The MicroMod
  Main Board - Single routes the PWR_EN0 pin slightly different for the
  function board. 

  ========== HARDWARE CONNECTIONS ==========
  MicroMod Artemis Processor Board => MicroMod Main Board - Double => Function Boards

  Feel like supporting open source hardware?
  Buy a board from SparkFun!
       MicroMod Artemis Processor Board - https://www.sparkfun.com/products/16401
       MicroMod Main Board - Double - https://www.sparkfun.com/products/18576
       MicroMod Environmental Function Board - https://www.sparkfun.com/products/18632

  LICENSE: This code is released under the MIT License (http://opensource.org/licenses/MIT)

******************************************************************************/

/*Define the power enable pins for the processor board with SDIO_DATA2.
  Depending on the processor board, the Arduino pin may be different. 

  Note: Certain Processor Boards like the Artemis have more than one pin available 
        to control the Function Board's voltage regulator (e.g. SDIO_DATA2 and G5).
        SAMD51, ESP32, and STM32 Processor Board pins do not have SDIO Data 2, so
        users will need to reference the Processor Pin G5. Below are a few examples. */

//ARTEMIS
#define PWR_EN0 4    //Function Board 0's "PWR_EN0" pin <= MicroMod SDIO_DATA2 => Artemis Processor Board (D4)  
#define PWR_EN1 26   //Function Board 1's "PWR_EN1" pin <= MicroMod SDIO_DATA1 => Artemis Processor Board (D26)

//Alternative option that does the same thing. Make sure to just choose one for PWR_EN0 and PWR_EN1
//#define PWR_EN0 29   //Function Board 0's "PWR_EN0" pin <= MicroMod G5 => Artemis Processor Board (A29)
//#define PWR_EN1 14   //Function Board 1's "PWR_EN0" pin <= MicroMod G6 => Artemis Processor Board (D14)


//TEENSY
//#define PWR_EN0 39   //Function Board 0's "PWR_EN0" pin <= MicroMod SDIO_DATA2 => Teensy Processor Board (D39)
//#define PWR_EN1 34   //Function Board 1's "PWR_EN1" pin <= MicroMod SDIO_DATA1 => Teensy Processor Board (D34)

//Alternative option that does the same thing. Make sure to just choose one for PWR_EN0 and PWR_EN1
//#define PWR_EN0 45   //Function Board 0's "PWR_EN0" pin <= MicroMod G5 => Teensy Processor Board (45)
//#define PWR_EN1 6   //Function Board 1's "PWR_EN1" pin <= MicroMod G6 => Teensy Processor Board (6)

//Note: The SAMD51, ESP32, and STM32 Processor Board Pins do not have SDIO Data 2 and SDIO Data 1.

//SAMD51
//#define PWR_EN0 7   //Function Board 0's "PWR_EN0" pin <= MicroMod G5 => SAMD51 Processor Board (D7)
//#define PWR_EN1 8   //Function Board 1's"PWR_EN1" pin <= MicroMod G6 => SAMD51 Processor Board (D8)

//ESP32
//#define PWR_EN0  32   //Function Board 0's "PWR_EN0" pin <= MicroMod G5 => ESP32 Processor Board (32)
//#define PWR_EN1  33   //Function Board 1's"PWR_EN1" pin <= MicroMod G6 => ESP32 Processor Board (33)



void setup() {
  // initialize the digital pins as an output.
  pinMode(PWR_EN0, OUTPUT); 
  pinMode(PWR_EN1, OUTPUT);

}



void loop() {

  digitalWrite(PWR_EN0, HIGH); // turn the 3.3V regulator on (HIGH is the voltage level)
  digitalWrite(PWR_EN1, HIGH); // turn the 3.3V regulator on (HIGH is the voltage level)
  delay(5000);                 // wait for a few seconds to do something with the function boards 

  digitalWrite(PWR_EN0, LOW);  // turn the 3.3V regulator off by making the voltage LOW
  digitalWrite(PWR_EN1, LOW);  // turn the 3.3V regulator off by making the voltage LOW
  delay(5000);                 // wait for a few seconds before turning function boards back on

}

After uploading, take a look at the PWR LEDs on the Function Boards. The LEDs will be on for about 5 seconds and then turn off for another 5 seconds. It will continue to repeat until power is removed from the MicroMod Main Board - Double.

Example 3: Reading and Writing to a MicroSD Card

The example below uses the built-in SD Arduino library. The only difference in the code is the CS pin for the microSD card, which you will need to adjust for your processor board (in this case we use the Artemis Processor Board). Make sure to reference your Processor Board's CS pin for either the Main Board - Single (D1) or Main Board - Double (G4).

If you have not already, select your Board (in this case the MicroMod Artemis), and associated COM port. Copy and paste the code below in your Arduino IDE. Hit the upload button and set the serial monitor to 9600 baud.

language:c
/*
  SD Card Read/Write

  This example shows how to read and write data to and from an SD card file
  The circuit:

  SD card attached to SPI bus as follows:

   SD Card  - MicroMod Artemis Processor Board
   -----------------------------------
   COPI/SDO - pin 38
   CIPO/SDI - pin 43
   CLK      - pin 42
   CS       - pin 1 (Main Board - Single) or 28 (Main Board - Double)

  created   Nov 2010
  by David A. Mellis
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

*/

#include <SPI.h>
#include <SD.h>

//ARTEMIS
//const int SD_CS_PIN = 1; // The microSD Card CS pin is D1 for the MicroMod Main Board - Single and Artemis Processor (D1). Adjust for your processor if necessary.
const int SD_CS_PIN = 28; // The microSD Card's CS pin is G4 for the MicroMod Main Board - Double and Artemis Processor (D28). Adjust for your processor if necessary.

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(SD_CS_PIN)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}

If all goes well, you should see the following output if this is the first time writing to the card!

language:bash
Initializing SD card...initialization done.
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.

If you are looking to go the extra mile to see if data was saved, close the Serial Monitor and remove power from the MicroMod Main Board. Eject your microSD card from the socket and insert into a microSD card adapter. Then insert the microSD card into your computer's card reader or USB port. Open the test.txt file in a text editor. You should see an output similar to what you saw in the Serial Monitor after the file was opened as shown below.

language:bash
testing 1, 2, 3.

Besides verifying the data in the file, this step is also useful if you adjust the code to continuously log data in a CSV format. After logging data, you could the open text document in a spreadsheet and graph the values!

More Examples!

Sweet! Now that we know that we can read and write to the microSD card, try exploring the other examples in either the SD or SdFat Arduino libraries. Or check out the following MicroMod tutorials that have a built-in microSD card socket for ideas on data logging. Better yet, try adding a sensor and write some code to log some data!

MicroMod Weather Carrier Board Hookup Guide

A quick guide to help to create your own MicroMod weather station using the MicroMod Weather Carrier Board and Processor of your choice.

MicroMod Data Logging Carrier Board Hookup Guide

Get started with some customizable MicroMod data logging with the Data Logging Carrier Board.

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.

Looking for more examples with a Function Board? Below are a few Function Board examples from our tutorials that are tagged with MicroMod.

1W LoRa MicroMod Function Board Hookup Guide

Everything you need to get started with the 1W LoRa MicroMod function board; a MicroMod function board that provides LoRa capabilities for your MicroMod project. Must be used in conjunction with a MicroMod main board and processor.

MicroMod WiFi Function Board - ESP32 Hookup Guide

The MicroMod ESP32 Function Board adds additional wireless options to MicroMod Processor Boards that do not have that capability. This special function board acts as a coprocessor that takes advantage of Espressif's ESP32 WROOM to add WiFi and Bluetooth® to your applications.

MicroMod Environmental Function Board Hookup Guide

The SparkFun MicroMod Environmental Function Board adds additional sensing options to the MicroMod Processor Boards. This function board includes three sensors to monitor air quality (SGP40), humidity & temperature (SHTC3), and CO2 concentrations (STC31) in your indoor environment. To make it even easier to use, all communication is over the MicroMod's I2C bus! In this tutorial, we will go over how to connect the board and read the sensors.

MicroMod WiFi Function Board - DA16200 Hookup Guide

Add IoT functionality to any MicroMod project with the MicroMod WiFi function Board - DA16200!

Better yet, try connecting a Qwiic-enabled device to the Main Board's Qwiic connector. Below are a few examples from our tutorials that are tagged with Qwiic.

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.

SparkFun Qwiic Digital Temperature Sensor - TMP102 Hookup Guide

Get started using your SparkFun Digital Temperature Sensor - TMP102 (Qwiic) with this Hookup Guide!

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.

SparkFun Qwiic Alphanumeric Display Hookup Guide

A Hookup Guide to get you started with the Qwiic Alphanumeric Display.

Troubleshooting

Resources and Going Further

Now that you've successfully got your MicroMod Main Board with a Processor Board, it's time to incorporate it into your own project! For more information, check out the resources below:

Looking for more inspiration? Check out these other tutorials related to MicroMod.

MicroMod Weather Carrier Board Hookup Guide

A quick guide to help to create your own MicroMod weather station using the MicroMod Weather Carrier Board and Processor of your choice.

MicroMod ESP32 Processor Board Hookup Guide

A short hookup guide to get started with the SparkFun MicroMod ESP32 Processor Board.

MicroMod Data Logging Carrier Board Hookup Guide

Get started with some customizable MicroMod data logging with the Data Logging Carrier Board.
New!

MicroMod GNSS Carrier Board (ZED-F9P) Hookup Guide

Easily switch between Processor Boards using the MicroMod ecosystem and get precision down to the diameter of a dime with the ZED-F9P from u-blox using the MicroMod GNSS Carrier Board!

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

Getting Started with the Raspberry Pi Zero 2 W

$
0
0

Getting Started with the Raspberry Pi Zero 2 W a learn.sparkfun.com tutorial

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

Introduction

The latest entry into the immensely popular Raspberry Pi Single Board Computer (SBC) catalog, the Raspberry Pi Zero 2 W, provides an upgraded drop-in replacement to the Pi Zero W powered by a quad-core 64-bit Arm Cortex-A53 CPU. This guide highlights the improvements in hardware on the Pi Zero 2 W, how to set it up in a desktop configuration as well as installing and the basics of using the Raspberry Pi OS.

Raspberry Pi Zero 2 W

Raspberry Pi Zero 2 W

DEV-18713
4

The Raspberry Pi Zero 2 W Basic Kit provides the bare bones of a Pi Zero 2 W setup. The kit includes a Pi Zero 2 W, Raspberry Pi 12.5W Micro-USB Power Adapter, mini HDMI cable, USB OTG cable and a 64GB MicroSD Card with adapter.

SparkFun Raspberry Pi Zero 2 W Basic Kit

SparkFun Raspberry Pi Zero 2 W Basic Kit

KIT-18735
$49.95

Required Materials

This guide assumes users have the Pi Zero 2 W Basic Kit so if you do not have the kit, make sure you have the necessary accessories (power adapter, mini HDMI cable, USB OTG cable or USB hub & a microSD card). Along with the Basic Kit, you will need a monitor (or TV), keyboard, mouse and USB hub (for more than one USB device) to follow this tutorial. Users in need of a keyboard/mouse combo may want to consider the Logitech K400 Plus Wireless Touch Keyboard.

Suggested Reading

Users unfamiliar with the concepts covered in the tutorials below may want to read through them before continuing with this guide:

Single Board Computer Benchmarks

How to set up different benchmarking programs on single board computers or computing modules and run them. The results for various generations are shown on the subsequent pages.

SD Cards and Writing Images

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

Raspberry gPIo

How to use either Python or C++ to drive the I/O lines on a Raspberry Pi.

Raspberry Pi SPI and I2C Tutorial

Learn how to use serial I2C and SPI buses on your Raspberry Pi using the wiringPi I/O library for C/C++ and spidev/smbus for Python.

Hardware Overview

In this section we'll explore the hardware present on the Pi Zero 2 W and, where relevant, compare it to the previous version and other Rapsberry Pi SBCs.

Raspberry Pi RP3A0 SiP

Photo highlighting RP3A0 SiP

The Pi Zero 2 W features an upgraded RP3A0 system-in-package (SiP) incorporates a quad-core 64-bit Arm Cortex-A53 CPU, clocked at 1GHz The SiP integrates a Broadcom BCM2710A1 die with 512MB of LPDDR2 SDRAM. The processor provides the Raspberry Pi Zero 2 W with 40% more single-threaded performance, and five times more multi-threaded performance, than the original single-core Raspberry Pi Zero.

Mini HDMI

Photo highlighting Mini HDMI connector

Unlike the previous models of the Raspberry Pi which use a standard HDMI connector, the Zero uses a mini HDMI connector to save space. To connect the Zero to a monitor or television, you will need a mini HDMI to HDMI adapter or cable.

USB On-the-Go

Photo highlighting the Pi Zero USB OTG

The Raspberry Pi 3 and other models have traditionally had 2-4 standard size female USB connectors, which allowed for all variety of devices to connect including mice, keyboards, and WiFi dongles. Again to save space, the Zero has opted for a USB On-the-Go (OTG) connection. The Pi Zero uses the same Broadcom IC that powered the original Raspberry Pi A and A+ models. This IC connects directly to the USB port allowing for OTG functionality, unlike the Pi B, B+, 2 and 3 models, which use an onboard USB hub to allow for multiple USB connections.

To connect a device with a standard male USB connection, the Basic Kit includes a USB OTG cable. Plug the microUSB end into the Pi Zero, and plug your USB device into the standard female USB input.

For use with other standard USB devices, we recommended that you use a powered USB hub. Wireless keyboard and mouse combos work best as they have one USB dongle for both devices.

Power

Photo highlighting Pi Zero power In USB connector.

Like other Pis, power is provided through a microUSB connector. Voltage supplied to the power USB should be in the range of 5-5.25V.

microSD Card Slot

Photo highlighting the microSD card slot

Another familiar interface is the microSD card slot. Insert your microSD cards that contains your Raspberry Pi image file here.

WiFi and Bluetooth

The Raspberry Pi Zero 2 W offers 2.4GHz 802.11 b/g/n wireless LAN and Bluetooth 4.2, along with support for Bluetooth Low Energy (BLE), and modular compliance certification. This frees up many of the connections that would have been made over USB, such as a WiFi dongle and a USB keyboard and mouse if substituting a Bluetooth keyboard/mouse.

Camera Connector

Photo highlighting the camera connector

The Raspberry Pi Zero V1.3+ and all Zero Ws have an onboard camera connector. This can be used to attach the Raspberry Pi Camera module. However, the connector is a 22pin 0.5mm and different than the standard Pi. You will need a different cable to connect the camera to the Pi Zero W.

GPIO

Photo highlighting Pi Zero GPIO

As with all other models of the Raspberry Pi, the Pi Zero 2 W includes a 2x20 set of GPIO pins broken out offering functionality such as SPI, I2C, digital I/O, PWM, etc. If you are using the GPIO header, you may want to consider soldering headers to it.

Choosing and installing an OS

Before powering on your Pi Zero 2 W you'll need to flash an image of the Raspberry Pi OS (or if you prefer, a third party operating system that work with Raspberry Pi) to the microSD card included with the Basic Kit. The Raspberry Pi Foundation created a great tool called the Raspberry Pi Imager that makes downloading and flashing an OS image a microSD card simple. This section briefly goes over how use that tool to upload an image of the Raspberry Pi OS on your microSD card.

Raspberry Pi Imager

The Raspberry Pi Imager tool makes selecting and writing an image of a Raspberry Pi-compatible operating system to a microSD card way easier than it was in the past. All you need to do is select the OS and storage device and the tool takes care of the rest. Download the tool from Raspberry Pi's software page here:

Once the tool is downloaded and installed on your computer, follow the steps below to complete the image installation:

  • Insert the microSD card and SD adapter into the appropriate port on your computer.
  • Open the Raspberry Pi Imager.
  • Click the Choose OS button to select your preferred Operating System (this tutorial will use the default Raspberry Pi OS).
  • Click the Choose Storage button and select your microSD's drive location.
  • Click Write.

Writing the OS to the microSD card can take a few minutes depending on which version was selected and the speed of the port/microSD card. Once the write is finished, the tool should automatically perform the software ejection for the microSD card so you can remove it once the process completes.

Note: The software page also includes a link to a range of alternate operating systems for users who prefer to download and install them manually. For help manually writing and installing images, check out [this tutorial](https://learn.sparkfun.com/tutorials/sd-cards-and-writing-images).

Hardware Assembly

With an OS written to the microSD card, we can start connecting everything up. We used the Logitech K400 Plus Wireless Touch Keyboard to keep all the input devices tied to a single USB connection. Note, this keyboard is not included with the SparkFun Raspberry Pi Zero 2 W Basic Kit.

Insert the microSD card

Plug the microSD card into the microSD socket on the Pi Zero 2 W.

microSD inserted into slot

Connecting Peripheral Devices

Next up, connect any peripheral equipment to the Pi. Most users will need at least a monitor and keyboard/mouse to get started with the Pi.

USB OTG Cable

Plug the USB OTG cable into the microUSB connector labeled USB on the Pi. This provides a standard USB connection for devices like a keyboard or mouse. A USB hub or extender is required if you need to connect multiple USB devices to your Pi Zero 2 W.

USB OTG Cable connected

Keyboard and Mouse

You can use the USB OTG cable to plug in a Keyboard/Mouse. For this tutorial we used the Logitech K400 Plus Wireless Touch Keyboard as it has one USB dongle for both devices. For use with other standard USB devices, it is recommended that you use a powered USB hub.

Keyboard/Touch Pad connected
Note: The Logitech K400 Plus Wireless Touch Keyboard pictured here is not included in the Basic Kit

Monitor

Plug in the miniHDMI cable included with the Basic Kit to the miniHDMI connector on the Pi Zero 2 W. Connect the other end of the cable to the HDMI port on your monitor or TV.

miniHDMI connected

Power Supply

With everything connected and the microSD card inserted, connect the power supply to the microUSB connector labeled PWR IN and the Pi should start booting up.

Power supply plugged in

Completed Setup

With everything connected, your setup should look similar to the photo below:

Full Assembly

Connecting Hardware

The steps above provide the basics to get the Pi Zero 2 W up and running but we've barely scratched the surface of the potential of this little computer. The 2x20 GPIO header on the Pi provides access to a host of additional functionality so users who wish to take advantage of that will want to solder a set of headers like these to it.

Users looking to do some breadboard prototyping with the Pi Zero 2 W may want to use the Pi Wedge and these tutorials to use the GPIO pins:

Preassembled 40-pin Pi Wedge Hookup Guide

October 29, 2015

Using the Preassembled Pi Wedge to prototype with the Raspberry Pi B+.

Raspberry gPIo

October 29, 2015

How to use either Python or C++ to drive the I/O lines on a Raspberry Pi.

Headless Raspberry Pi Setup

April 23, 2018

Configure a Raspberry Pi without a keyboard, mouse, or monitor.

If you want to use any SparkFun Qwiic devices with your Pi Zero 2 W, take a look at the SparkFun Qwiic SHIM or Qwiic SHIM Kit or Qwiic Starter Kit for Raspberry Pi:

Qwiic SHIM for Raspberry Pi Hookup Guide

December 5, 2019

Ever wanted to prototype I2C components on a Pi? Now you can!

Qwiic SHIM Kit for Raspberry Pi Hookup Guide

February 16, 2021

Get started with the Serial LCD with RGB backlight and 9DoF IMU (ICM-20948) via I2C using the Qwiic system and Python on a Raspberry Pi! Take sensor readings and display them in the serial terminal or SerLCD.

Qwiic Kit for Raspberry Pi Hookup Guide

July 4, 2019

Get started with the CCS811, BME280, VCNL4040, and microOLED via I2C using the Qwiic system and Python on a Raspberry Pi! Take sensor readings from the environment and display them on the microOLED, serial terminal, or the cloud with Cayenne!

Finally, the camera connector allows you to connect a Raspberry Pi camera. Be aware, the connector is a 22pin 0.5mm and different than the standard Pi and needs a different cable to connect the camera to the Pi Zero 2 W.

Headless

If you prefer a "headless" setup with no monitor, keyboard or mouse; the tutorials below can help (note, headless setups are much more advanced than a standard setup):

Headless Raspberry Pi Setup

April 23, 2018

Configure a Raspberry Pi without a keyboard, mouse, or monitor.

How to Use Remote Desktop on the Raspberry Pi with VNC

July 9, 2018

Use RealVNC to connect to your Raspberry Pi to control the graphical desktop remotely across the network.

Using the Raspberry Pi OS

Now that you've gotten your board up and running let's go over some basics of the Raspberry Pi OS. This section covers how to use the Pi via HDMI out to a monitor.

Raspberry Pi OS

The Raspberry Pi OS is Linux based (to be specific it is a port of Debian Bullseye with the Raspberry Pi Desktop). Don't let that scare you too much. Gone are the days of having to remember lots of commands or that you need to type :wq to save and exit your text editor. The OS runs a desktop Graphical User Interface (GUI) similar to Windows or MacOS, and, while you will probably want to learn a few basic commands and shorcuts, you can usually get away with not using them.

Initial Boot

The first boot of the Pi with a fresh install of the OS takes a few minutes and the Pi will most likely restart at least once. Once the OS finishes initial setup, you should be greeted by a desktop setup similar to the image below:

Set Up Wizard

Follow the set up wizard to configure the location settings, set a new password, connect to WiFi, update the system and packages and more settings on the Pi. You can skip some of these steps but we strongly recommend at least setting the location and setting a new password. If you ever need to go back and update the settings, open them by going to the Raspberry Pi Start Menu>Preferences>Raspberry Pi Configuration.

Raspberry Pi Configuration from Start Menu

This opens a pop up allowing you to update the region, monitor, keyboard, password, as well as turn on any peripheral interfaces like SPI and I2C.

Raspberry Pi Configuration

Update Software

In case you skipped the step in the set up wizard or need to update software packages in the future, we can update the software package on the Pi through the Command Line Interface (CLI). Access it by opening the terminal and type the following and hit Enter:

language:bash
sudo apt-get update

This command tells the Pi to retrieve the latest package information and tells the package manager what needs updating.

  • sudo (also known as super user) is a command that you will see a lot, specifically with high security commands. It temporarily allows the user (if you’re not already logged in as root) the ability to run these commands if your user name is in a list of users ('sudoers').

  • apt-get is the package manager and update is the command we are giving it.

This downloads and upgrades all packages on the system and may take a while.

Shutdown/Reboot

The desktop includes a standard shutdown button in the desktop main menu but you can also tell the Pi to shutdown through the CLI using this command:

language:bash
sudo shutdown -h now
  • shutdown as you may guess, shuts down the machine. now tells it do perform the action immediately (15 would tell the machine to shutdown in 15 minutes).

To reboot the Pi through the CLI send this command:

language:bash
sudo shutdown -r now

Other Useful Linux Commands

A few other useful commands for use in the terminal command line:

  • pwd - Print Working Directory, if you not sure what folder you are in this will tell you where you are in the filesystem.

  • ls - List, this will show you the contents of the folder. To show all files, including hidden ones, type ls -a to show all files/folders. Alternatively, typing ls -al will show you all files/folders as well as their permission settings.

  • cd - this is how you change directories. cd foldername will move you to that folder. cd .. will back you up one level. cd ~ will take you back to your home directory.

  • passwd - this will allow you to change your password

  • man - this stands for manual. Type man before a command to get a summary of how to use it.

  • nano - this will open a basic text editor that is fairly easy to use.

Troubleshooting

Having issues getting the Raspberry Pi to work? Check out this sticky note from the Raspberry Pi Foundation's forum for basic troubleshooting.

Having problems with a piece of SparkFun hardware designed for the Raspberry Pi and interfacing it? Try checking out the SparkFun forums to see if we can assist.

Resources and Going Further

At this point your Pi Zero 2 W should be acting similar to any other computer. From here, you can teach yourself the finer points of Linux, learn Python, program the GPIO pins, setup a Minecraft server, build a network storage system, game console, or media center, or just surf the web.

For more information about the Pi Zero 2 W or Raspberry Pi in general, check out these resources:

Looking to make the Raspberry Pi Zero W a dongle? Check out the Pi Zero USB Stem:

Need some inspiration? Check out these tutorials and projects.

Raspberry Pi Twitter Monitor

How to use a Raspberry Pi to monitor Twitter for hashtags and blink an LED.

Python Programming Tutorial: Getting Started with the Raspberry Pi

This guide will show you how to write programs on your Raspberry Pi using Python to control hardware.

How to Use Remote Desktop on the Raspberry Pi with VNC

Use RealVNC to connect to your Raspberry Pi to control the graphical desktop remotely across the network.

SparkFun Photodetector (MAX30101) Hookup Guide

The SparkFun Photodetector - MAX30101 (Qwiic) is the successor to the MAX30105 particle sensor, a highly sensitive optical sensor. This tutorial will get you started on retrieving the raw data from the MAX30101 sensor.

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

MicroMod WiFi Function Board - DA16200 Hookup Guide

$
0
0

MicroMod WiFi Function Board - DA16200 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Want to add all the IoT functionality of the DA16200 to the adaptability of the MicroMod system? Then you're in luck! The SparkFun MicroMod DA16200 Function Board adds a fully integrated WiFi module with a 40MHz crystal oscillator, 32.768KHz RTC clock, RF Lumped RF filter, 4MB flash memory, and an on-board chip antenna to any MicroMod project. With the addition of JTAG connectors for deep dive programming, you've got everything you need to get your MicroMod setup ready for your next IoT project.

SparkFun MicroMod WiFi Function Board - DA16200

SparkFun MicroMod WiFi Function Board - DA16200

WRL-18594
$29.95
1

Required Materials

To follow along with this tutorial, you will need the following materials at a minimum. 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 MicroMod WiFi Function Board - DA16200

SparkFun MicroMod WiFi Function Board - DA16200

WRL-18594
$29.95
1
SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$7.95
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95

MicroMod Main Board

To hold the processor board and function board, you will need one Main board. Depending on your application, you may choose to have one or two additional function boards.

SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95
SparkFun MicroMod Main Board - Double

SparkFun MicroMod Main Board - Double

DEV-18576
$17.95

MicroMod Processor Board

There are a variety of MicroMod Processor Boards available to choose from.

SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$16.95
SparkFun MicroMod nRF52840 Processor

SparkFun MicroMod nRF52840 Processor

WRL-16984
$19.95
SparkFun MicroMod STM32 Processor

SparkFun MicroMod STM32 Processor

DEV-17713
$14.95
SparkFun MicroMod RP2040 Processor

SparkFun MicroMod RP2040 Processor

DEV-17720
$11.95

Tools

You will need a screw driver to secure the Processor and Function boards.

SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3

Suggested Reading

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

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!

Designing with MicroMod

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

Hardware Overview

DA16200

The MicroMod WiFi Function Board includes the DA16200 module from Dialog with AT command firmware. This chip is a fully integrated Wi-Fi® module with ultra-low power consumption, 40 MHz crystal oscillator, 32.768 KHz RTC clock, RF Lumped RF filter, 4 M-byte flash memory, and an onboard chip antenna. For more information, refer to the datasheet.

Wifi module is highlighted

Power

To power the board, you will need to apply power to a SparkFun Main Board; either a Single or a Double. Power applied will connect to the Function Board's VIN pin, which will be regulated down for the rest of the board with the AP2112 3.3V/600mA voltage regulator.

USB C of the Main board with USBC cable plugged in is highlighted

AP2112

Operating voltage for the DA16200 is 3.3 V. The AP2112 can handle a voltage range of 2.5-6V with a 600mA output and ensures appropriate voltage to the WiFi unit.

Voltage regulator is highlighted

CH340

The board is populated with the CH340E USB-to-Serial converter to update firmware on the DA16200 through its USB Type C connector. You will need a Main Board (for power) and a second USB cable to update the firmware.

CH340 and USB C are highlighted on the function board

Reset Button

The reset button allows users to reset the program running on the Artemis module without unplugging the board.

Factory Reset Button is highlighted

WPS Button

The Wi-Fi Protected Setup Button allows you to easily and quickly connect to a WiFi network.

WPS Button is highlighted

EEPROM

The board includes an I2C EEPROM. To enable writing to the EEPROM, pull WP low, either through the EEPROM_WP pin or by closing JP3.

EEProm is highlighted

JTAG

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

JTAG pins are highlighted

LED

There is only one LED available which is the Power LED. The LED lights up to indicate availability for the DA16200 from the 3.3V voltage regulator. You can disable it by cutting the jumper on the back of the board (see Jumpers below).

Power LED is just below the WiFi module on the right side of the board

Jumpers

The following jumpers are included to configure the board.

  • PWR - By default, the jumper with the label PWR is closed. This jumper connects the 3.3V line and LED. Cutting this jumper will disable the LED.

Power LED Jumper is on the back of the board on the opposite side from the M2 connector
  • I2C Pull-up Resistors - By default, this three way jumper labeled I2C is closed and connects two pull-up resistors to the I2C data lines. If you have many devices on your I2C data lines, then you may consider cutting these two jumpers.

I2C jumper is on the front of the board to the left of the WPS button
  • WP - By default, write protect for the EEPROM is on. To disable write protection, close this jumper.

Write protect jumper is on the back of the board just next to the M2 Connector

Hardware Pinout

The M.2 connector on the MicroMod WiFi Function Board - DA16200 is routed according to the pinout chart below:

Highlighted function board M.2 connector

Depending on your window size, you may need to use the horizontal scroll bar at the bottom of the table to view the additional pin functions. Note that the M.2 connector pins on opposing sides are offset from each other as indicated by the bottom pins where it says (Not Connected)*. There is no connection to pins that have a "-" under the primary function.

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
DescriptionFunctionBottom
Pin
   Top   
Pin
FunctionDescription
(Not Connected)75GND
-74733.3VPower Supply: 3.3-6V
-7271Power ENPower Supply: 3.3-6V
-7069-
-6665-
-6463-
-6261-
-6059-
-5857RTC_WAKE1This pin is an input pin for receiving an external event signal from an external device like a sensor. The RTC block detects an external event signal via this pin and wakes up DA16200 from Sleep mode 2 or Sleep mode 3.
-5655RTC_WAKE2This pin is an input pin for receiving an external event signal from an external device like a sensor. The RTC block detects an external event signal via this pin and wakes up DA16200 from Sleep mode 2 or Sleep mode 3.
-5453RTC_PWR_KEYEnable to kick off a predefined power-up sequence and eventually all the necessary power is supplied to all the sub-blocks including the main digital block in DA16200. When disabled, all blocks are powered off and this mode is defined as Sleep mode 1.
-5251GPIOA11
-5049CS
-4847GPIOA10
-4645GND
-4443-
-4241-
Controls the write protection pin for the EEPROM. Pull low to enable.EEPROM_WP4039GND
-3837-
Controls EEPROM's I2C address configuration.EEPROM_A03635-
Controls EEPROM's I2C address configuration.EEPROM_A13433GND
Controls EEPROM's I2C address configuration.EEPROM_A23231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423-
-2221I2C_SCLI2C - Clock signal for EEPROM
-2019I2C_SDAI2C - Data signal for EEPROM
-1817-
-1615U1_RXI
-1413U1_TXO
-1211-
-109-
-87CIPO
-65COPI
-43SCK
-21GND

Board Dimensions

The board uses the standard MicroMod Function Board size which measures about 1.50"x2.56".

Board Dimensions

Hardware Hookup

Adding a Processor Board to the Main Board

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

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

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

Main board with Processor Board sticking up at an angle

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

Main board with Processor Board screwed in

Adding a Function Board to the Main Board

As with the Processor Board, align the top key of the MicroMod WiFi Function Board to the screw terminal of your Main Board on the Function Board side and angle the board into the socket. Insert the board at an angle into the M.2 connector.

Main board with Function Board sticking up at an angle

Once the board is in the socket, gently push the MicroMod Function Board down and tighten the screws with a Phillip's head.

Main board with Function Board screwed in

Once both boards are secure, your assembled MicroMod system should look similar to the image below!

Assembled main board with both processor and function boards securely fastened

DA16200 Firmware Update

To update the firmware you will need to connect the USB C cable to the MicroMod WiFi Function Board (DA16200) to a computer's COM port. An additional Main Board with a second USB C cable is also needed to power the Main Board and MicroMod WiFi Function Board.

USBC outlet on function board

Software Installation

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 Definitions

We'll assume that you installed the necessary board files for your Processor Board. In this case, we used the MicroMod Artemis Processor Board.

MicroMod Artemis Processor Board Hookup Guide

October 21, 2020

Get started with the Artemis MicroMod Processor Board in this tutorial!

CH340 Driver

You may need to install CH340 driver for the USB-to-serial converter. Check out our section on "How to Install CH340 Drivers" for help with the installation.

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.

Main Board Example - Pin Connection Table

For the following examples, we are using the Artemis Processor Board. For DA16200 specific pins, here is the mapping to use in Arduino sketches:

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
Function Board
Pin Name
I/O
Direction
Main Board's
Processor Pin
Slot 0Slot 1
VCCInput-
3.3VInput-
GND--
RTC_WAKE1InputG2G7
RTC_WAKE2OutputG1G6
RTC_PWR_KEYInputG0G5
GPIOA11PWM0PWM1
CSCS0CS1
GPIOA10D0D1

Example 1: Basic Connection

Copy and paste the code below into a fresh Arduino sketch.

language:c
/******************************************************************************
  Example_01 Basic Connection

  Connect to the DA16200 Module
  Print help commands

  Development environment specifics:
  IDE: Arduino 1.8.13
  Hardware Platform: MicroMod Artemis Processor, Single MicroMod Main Board

  Hardware Connections:
  Connect the MicroMod Processor Board to the Processor M2 Connector of the Main Board
  Connect the MicroMod DA16200 Function Board to the Function M2 Connector of the Main Board

  G0      --> RTC_PWR_KEY
  4       --> PWR_EN
  3.3V    --> 3.3V
  GND     --> GND

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/    
#define PWR_EN 4
#define RTC_PWR_KEY G0

void setup() {
  pinMode(PWR_EN,OUTPUT);
  digitalWrite(PWR_EN,LOW);

  pinMode(RTC_PWR_KEY,OUTPUT);
  digitalWrite(RTC_PWR_KEY,LOW);

  Serial.begin(115200);
  Serial1.begin(115200); 

  while(!Serial){

  }
  delay(1000);



  //Enable DA16200 Module RTC power block
  pinMode(PWR_EN,OUTPUT);
  digitalWrite(PWR_EN,LOW);

  pinMode(RTC_PWR_KEY,OUTPUT);
  digitalWrite(RTC_PWR_KEY,LOW);

  Serial.println("DA16200 AT Command example sending/receiving commands\n");
  while(!Serial){

  }

  pinMode(PWR_EN,INPUT);

  pinMode(RTC_PWR_KEY,OUTPUT);
  digitalWrite(RTC_PWR_KEY,HIGH);

  delay(2000);


  //Listen for ready message ("+INIT:DONE")
  byte count = 0;
  String msg = "";

  while(count<20)
  {
    delay(100);
    while(Serial1.available())
    {
      msg += char(Serial1.read());
    }
    if(msg.length() > 5) break;
    count++;
    delay(100);
  }
  msg = msg.substring(3,msg.length());

  if(msg.length()>5)
  {
    Serial.println("Expecting: \"INIT:DONE,(0 or 1)");
    Serial.println("Received: " + msg);
  }
  else
  {
    Serial.println("Failed to receive initialization message\n");

    Serial.println("Make sure the baud rate for Serial1 matches the baud rate\n" \
                   "saved to the DA16200. You can also perform a factory reset by\n" \
                   "pressing and holding the GPIOA7 button for ~5s, which will\n" \
                   "reset the baud rate back to 115200");
  }
    Serial.println("\nTry entering \"?\" or \"help\" to print out the list of AT commands\n" \
                 "\nIf the received text is unreadable, try changing the baud rate to\n" \
                 "9600 with the command \"ATB=9600\" in the terminal. Next, update the\n" \
                 "example code by setting Serial1 to 9600 baud and trying again.\n");
}

void loop() {
    while(Serial.available())
    {
      Serial1.print(char(Serial.read()));
    }

    while(Serial1.available())
    {
      Serial.print(char(Serial1.read()));
    }
}

Set your Board and Serial Port, and then upload the sketch to your Arduino. Then open the serial monitor. Make sure your baud rate is set to 9600. You'll begin to see output.

Basic connection just makes sure you get a response from the DA16200 module

Example 2: Connecting to WiFi

Let's check out the WiFi with a simple example to grab the time.

Copy and paste the code below into a fresh Arduino sketch.

language:c
/******************************************************************************
  Example_02 WiFi Communcation

  Connect WiFi using the provided network credentials
  Talk to NTP server to set the current date/time
  Update the time to the correct time zone
  Print the current time approx. once every second

  Development environment specifics:
  IDE: Arduino 1.8.13
  Hardware Platform: MicroMod Artemis Processor, Single MicroMod Main Board

  Hardware Connections:
  Connect the MicroMod Processor Board to the Processor M2 Connector of the Main Board
  Connect the MicroMod DA16200 Function Board to the Function M2 Connector of the Main Board

  G0      --> RTC_PWR_KEY
  4       --> PWR_EN
  3.3V    --> 3.3V
  GND     --> GND

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#define PWR_EN 4
#define RTC_PWR_KEY G0

String wifiSSID = "SSID";
String wifiPass = "PASSWORD";

int timezoneOffset = 0; //The hours offset from UTC (Mountain time is -6 for daylight savings, and -7 for standard)

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

  //Enable DA16200 Module RTC power block
  pinMode(RTC_PWR_KEY,OUTPUT);
  digitalWrite(RTC_PWR_KEY,HIGH);

  Serial.println("DA16200 AT Command Example: Connecting to WiFi\n");

  //Listen for ready message ("+INIT:DONE")
  byte count = 0;
  String msg = "";
  while(count<20)
  {
    while(Serial1.available())
    {
      msg += char(Serial1.read());
    }
    if(msg.length() > 5) break;
    count++;
    delay(100);
  }
  msg = msg.substring(3,msg.length()); //Remove NULL,CR,LF characters from response

  if(msg.length()>5)
  {
    Serial.println("Expecting: \"INIT:DONE,(0 or 1)");
    Serial.println("Received: " + msg);
  }
  else
  {
    Serial.println("Failed to receive initialization message.\n" \
                   "Make sure you're using the correct baud rate.\n");
    while(1);
  }

  //Configure module for STA mode
  Serial.println("Sending:AT+WFMODE=0");
  Serial1.println("AT+WFMODE=0");

  //Wait for "OK" response
  while(1)
  {
    msg = "";
    while(Serial1.available())
    {
      msg += char(Serial1.read());
      delay(1);
    }
    Serial.print(msg);
    if(msg.length() > 1) break;
  }

  //Apply a software reset to finish changing the mode
  Serial.println("Sending:AT+RESTART");
  Serial1.println("AT+RESTART");

  //Wait for "OK" response
  while(1)
  {
    msg = "";
    while(Serial1.available())
    {
      msg += char(Serial1.read());
      delay(1);
    }
    Serial.print(msg);
    if(msg.length() > 1) break;
  }

  //Listen for ready message ("+INIT:DONE") after the reset is finished
  count = 0;
  msg = "";
  while(count<20)
  {
    while(Serial1.available())
    {
      msg += char(Serial1.read());
    }
    if(msg.length() > 5) break;
    count++;
    delay(100);
  }

  Serial.println(count);
  Serial.println(msg);
  msg = msg.substring(3,msg.length()); //Remove NULL,CR,LF characters from response

  if(msg.length()>5)
  {
    Serial.println("Expecting: \"INIT:DONE,(0 or 1)");
    Serial.println("Received: " + msg);
  }
  else
  {
    Serial.println("Failed to receive initialization message.\n" \
                   "Continuing anyway...\n");
  }

  //Connect to WiFi using the provided credentials
  Serial.println("Sending:AT+WFJAPA=" + wifiSSID + "," + wifiPass);
  Serial1.println("AT+WFJAPA=" + wifiSSID + "," + wifiPass);

  Serial.println("Waiting for connection response...");
  while(1)
  {
    msg = "";
    while(Serial1.available())
    {
      msg += char(Serial1.read());
      delay(1);
    }

    if(msg.length() > 10) 
    {
      Serial.print("Response:");
      Serial.println(msg);
      break;
    }
  }

  msg = msg.substring(3,msg.length()); //Remove NULL,CR,LF characters from response

  //If connection to AP is successful, response will be WFJAP:1,SSID,IP_ADDRESS, or WJAP:0 if failed
  if(msg.startsWith("WFJAP:1"))
  {
      //Talk to NTP server to get the current time, along with how often to get time sync
      Serial.println("Sending:AT+NWSNTP=1,pool.ntp.org,86400");
      Serial1.println("AT+NWSNTP=1,pool.ntp.org,86400");

      //Wait for "OK" response
      while(1)
      {
        String msg = "";
        while(Serial1.available())
        {
          msg += char(Serial1.read());
          delay(1);
        }
        Serial.print(msg);
        if(msg.length() > 1) break;
      }

      //Provides the correct UTC offset for the current time
      Serial.println("Sending:AT+TZONE="+String(timezoneOffset*3600));
      Serial1.println("AT+TZONE="+String(timezoneOffset*3600));

      //Wait for "OK" response
      while(1)
      {
        String msg = "";
        while(Serial1.available())
        {
          msg += char(Serial1.read());
          delay(1);
        }
        Serial.print(msg);
        if(msg.length() > 1) break;
      }  
  }
  else
  {
    Serial.println("Connection unsucessful :(\n\n" \
                   "Make sure the WiFi credentials are correct, and the module is in the station mode");
    while(1);
  }
}

void loop() {
  //Get the current time
  Serial.println("Sending:AT+TIME");
  Serial1.println("AT+TIME");

  while(Serial1.available())
  {
    Serial.print(char(Serial1.read()));
    delay(1);
  }

  delay(1000);
}

Set your Board and Serial Port, and then upload the sketch to your Arduino. Then open the serial monitor. Make sure your baud rate is set to 9600. You'll begin to see output.

Getting time output on serial monitor

Firmware Update

If for any reason you want to re-flash the AT Firmware from Dialog Semiconductor, you can download it below:

Troubleshooting

Resources and Going Further

Now that you've successfully got your MicroMod ESP Function Board up and running, it's time to incorporate it into your own project! For more information, check out the resources below:

Looking for more inspiration? Check out these other tutorials related to MicroMod.

MicroMod RP2040 Processor Board Hookup Guide

This tutorial covers the basic functionality of the MicroMod RP2040 Processor Board and highlights the features of the dual-core ARM Cortex-M0+ processors development board. Get started with the first microcontroller from the Raspberry Pi Foundation!

MicroMod STM32 Processor Hookup Guide

Get started with the MicroMod Ecosystem and the STM32 Processor Board!

MicroMod WiFi Function Board - ESP32 Hookup Guide

The MicroMod ESP32 Function Board adds additional wireless options to MicroMod Processor Boards that do not have that capability. This special function board acts as a coprocessor that takes advantage of Espressif's ESP32 WROOM to add WiFi and Bluetooth® to your applications.
New!

MicroMod GNSS Carrier Board (ZED-F9P) Hookup Guide

Easily switch between Processor Boards using the MicroMod ecosystem and get precision down to the diameter of a dime with the ZED-F9P from u-blox using the MicroMod GNSS Carrier Board!

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

SparkFun GPS-RTK Dead Reckoning ZED-F9K Hookup Guide

$
0
0

SparkFun GPS-RTK Dead Reckoning ZED-F9K Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun GPS ZED-F9K takes advantage of dead reckoning for navigation. The u-blox ZED-F9K is a powerful GPS-RTK unit that uses a fusion of IMU, wheel ticks, a vehicle dynamics model, correction data, and GNSS measurements to provide highly accurate and continuous position for navigation in the difficult conditions. We will quickly get you set up using the Qwiic ecosystem through Arduino. so that you can start reading the output!

SparkFun GNSS-RTK Dead Reckoning Breakout - ZED-F9K (Qwiic)

SparkFun GNSS-RTK Dead Reckoning Breakout - ZED-F9K (Qwiic)

GPS-18719
$299.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. Depending on your application, you may need additional parts for a correction source or connecting to you a vehicle to obtain heel tick/direction information. Add it to your cart, read through the guide, and adjust the cart as necessary.

Microcontroller

If you are using the breakout board and programming in Arduino, we recommend the SparkFUn Thing Plus - ESP32 WROOM with the associated USB cable to start.

SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
7
Qwiic Cable - 100mm

Qwiic Cable - 100mm

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

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

CAB-15427
$5.95
2

Antenna

We recommend using the magnetic mount antenna for the full RF reception and mounting it on top of a vehicle. The antenna uses an SMA connector so you can direclty connect it to the breakout board. Link for that is below in the antenna accessories. The length of the antenna cable was also useful in mounting it.

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GPS-15192
$67.95
1
GNSS Multi-Band L1/L2 Surveying Antenna (TNC) - TOP106

GNSS Multi-Band L1/L2 Surveying Antenna (TNC) - TOP106

GPS-17751
$124.95
7
GNSS  Multi-Band L1/L2 Helical Antenna (SMA) BT-560

GNSS Multi-Band L1/L2 Helical Antenna (SMA) BT-560

GPS-17383
$84.95
1
MagmaX2 Active Multiband GNSS Magnetic Mount Antenna - AA.200

MagmaX2 Active Multiband GNSS Magnetic Mount Antenna - AA.200

GPS-17108
$77.95

GPS Antenna Accessories

Depending on your antenna, you will need an adapter to connect to the GPS-RTK's u.FL connector. If you need more than the metal from the top of a vehicle or are mounting it on a robot that does not have the necessary ground plane, you can use the GPS antenna ground plate to improve your GPS antenna's performance. If you are using the GNSS Multi-Band L1/L2 Surveying Antenna (TNC) - TOP106, you'll need to grab the interface cable.

Interface Cable - SMA Male to TNC Male (300mm)

Interface Cable - SMA Male to TNC Male (300mm)

CAB-17833
$9.95
GPS Antenna Ground Plate

GPS Antenna Ground Plate

GPS-17519
$6.50

Other Qwiic Cable Accessories

There are different Qwiic cable lengths available. Depending on your application, you can adjust it to your project's specifications.

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
13
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

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.

GPS Basics

The Global Positioning System (GPS) is an engineering marvel that we all have access to for a relatively low cost and no subscription fee. With the correct hardware and minimal effort, you can determine your position and time almost anywhere on the globe.

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.

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.

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.

ESP32 Thing Plus Hookup Guide

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

What is Dead Reckoning?

Dead Reckoning is the process of determining current position by combining previously determined positional data with speed and heading. This process can also be applied to determine future positions as well! The ZED-F9K uses Dead Reckoning which calculates speed and heading (amongst many other points of data) through the use of an internal inertial measurement unit (IMU). The addition of an wheel ticks, RTCM-formatted corrections, and IMU allows the ZED-F9K to produce high precision and more accurate readings in between GNSS data refreshes!

In addition, the module can also give accurate and useful GNSS data in areas where satellite connections are difficult to maintain: areas like the dense urban environments of major cities, long tunnels, parking garages, any large UFO's that may descend from the sky, etc.

Dead Reckoning Overview

As mentioned in the "What is Dead Reckoning?" section, the u-blox F9K module has an internal inertial measurement unit or IMU for short. The IMU calculates position based on the last GNSS refresh and its own movement data points. To use the SparkFun GPS-RTK Dead Reckoning Board, there are a few guidelines to orienting and mounting the module to a vehicle that are outlined from u-blox. For more detailed information, check out the integration manual for mounting.

Orientation for the SparkFun Dead Reckoning

The SparkFun Dead Reckoning adheres to two particular frames of reference: one frame of reference for the car and the second a geodetic frame of reference anchoring it to the globe. The latter, known as the local level frame uses the following as its' axes:

  • X-axis points to the North
  • Y-axis points to the East
  • Z-axis uses the right hand system by pointing down.

This frame will be referred to by its acronym NED (North-East-Down) in the image below.

The second frame of references is the Body-Frame reference and uses the following as its' axes.

  • X-axis points to the front of the vehicle
  • Y-axis points to the right of the vehicle
  • Z-axis uses the right hand system by pointing down.

You can reference the Body-Frame axes directly on the SparkFun Dead Reckoning ZED-F9K breakout board by looking for the silkscreen with the xyz axis.

Top View with the the Axis for ReferenceBottom View with the the Axis for Reference
Top View with the the Axis for ReferenceBottom View with the the Axis for Reference

Vehicle Attitude

The transformation of the vehicle within these two frames are given as heading, pitch, and roll. In the datasheet these three angles are called the vehicle's attitude. Below is an image that illustrates how all of these elements fit together.

Diagram Vehicle Attitude Output with respect to Vehicle Frame or Vehicle Reference Point (VRP)

Vehicle attitude output as shown on page 30 of the Integration Manual (UBX-20046189-R02)

Mounting the SparkFun Dead Reckoning ZED-F9K

The only guideline here is that the SparkFun Dead Reckoning is stable within 5 degrees, and of course that the X-axis points towards the front of the car as mentioned above. Below is an image that illustrates the ZED-F9K with the installation frame as opposed to the vehicle frame.

Diagram Vehicle Attitude with Position of Dead Reckoning IMU

Installation frame as shown on page 19 of the Integration Manual (UBX-20046189-R02)

With the physical board mounted, it will look similar to the following image.

alt text

In the images above, the SparkFun Dead reckoning is seen in the front, driver's side of the car and it may be tempting to think that this is also a necessary requirement. However, it can be mounted anywhere within the vehicle (or RC-car, or boat). Keep in mind that the pitch and roll is relative to the SparkFun Dead Reckoning's position.

Calibration

After you've mounted the SparkFun Dead Reckoning ZED-F9K, there is still a calibration phase to complete that must satisfy the following movements:

  • First, the car needs to be stopped with the engine turned on.
  • Secondly, the car must do left and right hand turns.
  • Lastly, the car must reach a speed over 30 km/h.

In SparkFun's u-blox Arduino library, SparkFun has included the calibration example, that prints out the module's calibration status.

Hardware Overview

Power

Power for this board is 3.3V and we have provided multiple power options. This first and most obvious is the USB-C connector. Secondly, are the Qwiic Connectors on the left and right of the board. Thirdly, there is a 5V pin on the PTH header along the side of the board that is regulated down to 3.3V. Make sure that power you provide to this pin does not exceed 6 volts. Finally, just below the 5V pin is a 3.3V pin that should only be provided a clean 3.3V power signal.

alt text

Battery

The small metal disk in the upper right corner next to the Qwiic connector is a small lithium battery. This battery does not provide power to the IC like the 3.3V system does, but to relevant systems inside the IC that allow for a quick reconnection to satellites. The time to first fix will about ~26 seconds, but after it has a lock, that battery will allow for a two second time to first fix. This is known as a hot start and lasts for four hours after the board is powered down. The battery provides over a years worth of power to the backup system and charges slowly when the board is powered. To charge it to full, leave your module plugged in for 48 hours.

alt text

LEDs

There are four LEDs on the bottom left of the board. Starting from the left:

  • PWR: The power LED labeled as PWR will illuminate when 3.3V is activated.
  • PPS: The pulse per second LED labelled as PPS will illuminate each second once a position lock has been achieved. This generates a pulse that is synchronized with a GPS or UTC time grid. By default, you'll see one pulse a second.
  • RTK: The RTK LED will be illuminated constantly upon power up. Once RTCM data has been successfully received it will begin to blink. This is a good way to see if the ZED-F9K is getting RTCM from various sources. Once an RTK fix is obtained, the LED will turn off.
  • GEO: The GEO LED can be configured to turn on/off for geofencing applications.

alt text

Jumpers

If you flip the board over, you will notice a few jumper pads. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

  • I2C: This three way jumper labeled I2C connects two pull-up resistors to the I2C data lines. If you have many devices on your I2C data lines, then you may consider cutting these.
  • SPI: The jumper labeled SPI which enables the SPI data bus thus disabling the UART functions on those lines. This also disables I2C interface.
  • PWR: Starting from the right side is a jumper labeled PWR. If you cut this trace, it will disconnect the Power LED.
  • PPS: On the left of the jumper is the PPS jumper that when cut disconnects the PPS LED.
  • GEO: Cutting the GEO jumper disconnect the LED used to indicate when we reach a certain condition for geofencing applications.
  • RTK: The RTK jumper disconnects the LED used for RTK applications.

alt text

SMA Connector

The ZED-F9K requires a good quality GPS or GNSS (preferred) antenna. A SMA connector is provided for a secure connection. To get the best out of your ZED-F9K, make sure to get a GNSS multi-band antenna.

alt text

Qwiic and I2C

There are two pins labeled SDA and SCL which indicates the I2C data lines. Similarly, you can use either of the Qwiic connectors to provide power and utilize I2C. The Qwiic ecosystem is made for fast prototyping by removing the need for soldering. All you need to do is plug a Qwiic cable into the Qwiic connector and voila!

alt text

SPI

There are four pins on the right most header that are labeled with their corresponding SPI functionality. As mentioned in the jumpers section, you'll need to close the SPI jumper on the underside to enable SPI.

alt text

UART

There are two pins on the right most header currently labeled as MISO and MOSI. These are shared with the UART pins. By default, the UART interface is enabled. Be sure that the DSEL jumper on the back of the board is open.

  • TX/MISO = TX out from ZED-F9K
  • RX/MOSI = RX into ZED-F9K
Top ViewBottom View
Top ViewBottom View

There is a second serial port available on the ZED-F9K. This is primarily used for RTCM3 correction data. By default, this port will automatically receive and parse incoming RTCM3 strings enabling RTK mode on the board like the other RTK breakout boards for the NEO-M8P-2 and ZED-F9P. The RTCM Correction port pins are arranged to match the industry standard serial connection (aka the 'FTDI' pinout). This pinout is compatible with our Serial Basic so you can send RTCM correction data from a computer. Note that RTCM3 data can also be sent over I2C, UART1, SPI, or USB if desired.

alt text

Wheel Tick and Direction Pins

For advanced users that are interested in taking advantage of your vehicle's sensor readings, you can connect the following pins. Caution is advised however as this requires you to open up up the hood of your car and hack into the its system.

  • D-: The reference GND pin (D-) when connecting the direction pin.
  • D+: The direction pin is labeled as (D+) tells the ZED-F9K what direction the vehicle is moving (forward/reverse).
  • W-: The reference GND pin (W-) when connecting the wheel tick pin.
  • W+: The wheel tick pin (W+) tells the ZED-F9K the distance a vehicle's wheel has traveled. Depending on the odometer type that you connect to, the ZED-F9K can also receive speed data from the vehicle.

alt text

Broken Out Pins

There are four other pins broken out:

  • TXR: The transmit ready pin (TXR) enables a port to notify a device when bytes are ready to be transmitted.
  • RESET: The reset pin (RESET) resets the chip.
  • SFBT: The safeboot pin (SFBT) is used to start up the IC in safe boot mode, this could be useful if you somehow manage to corrupt the module's Flash memory.
  • INT: The interrupt pin (INT) can be used to wake the chip from power save mode.
  • PPS: The pulse per second pin (PPS) outputs pulse trains synchronized with the GPS or UTC time grid. The signal defaults to once per second but is configurable over a wide range. Read the u-blox Receiver Protocol Specification in the Resources and Going Further tab for more information.

alt text

3D IMU Orientation and Reference

For easy reference, we've documented the IMU'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 so that the ZED-F9K can accurately calculate navigation information. Remember, it's all relative.

9DoF Reference (Top View)9DoF Reference (Bottom View)
9DoF Reference (Top View)9DoF Reference (Bottom View)

GPS Capabilities

The ZED-F9K is able to connect to up to four different GNSS constellations simultaneously with the 3D gyro and 3D accelerometer making it very accurate for its size. Below are the listed capabilities of the GPS unit.

ParameterSpecification
Max navigation update rate (RTK)Priority navigation mode30 Hz
Non-Priority navigation mode2 Hz
Velocity Accuracy0.05m/s
Dynamic Attitude AccuracyHeading0.2 degrees
Pitch0.3 degrees
Roll0.5 degrees
Navigation LatencyPriority Navigation Mode0.5 degrees
Max Sensor Output Rate100Hz
GNSSGPS+GLO+GAL +BDSGPS+GLO+GALGPS+GALGPS+GLOBDS+GLO
Time-To-First-FixCold Start26s25s30s25s28s
Hot Start2s2s2s2s2s
Aided Start3s3s3s3s3s
Re-convergence timeRTK&leq; 10s&leq; 10s&leq; 10s&leq; 10s&leq; 30s
SensitivityTracking and Navigation-160dBm-160dBm-160dBm-160dBm-160dBm
Reacquisition-157dBm-157dBm-157dBm-157dBm-157dBm
Cold Start-147dBm-147dBm-147dBm-147dBm-145dBm
Hot Start-158dBm-158dBm-158dBm-158dBm-158dBm
Position Accuracy RTKAlong Track0.20m0.20m0.25m0.25m0.60m
Cross Track0.20m0.20m0.25m0.25m0.60m
2D CEP0.30m0.30m0.40m0.40m0.85m
Vertical0.30m0.30m0.40m0.40m1.00m

Performance in Different GNSS Modes from the ZED-F9K Datasheet
GNSSGPSGLONASSBeiDouGalileo
Time-To-First-FixCold Start30s28s40s-
Hot Start2s2s2s-
Aided Start3s3s3s-
SensitivityTracking and Navigation-158dBm-158dBm-158dBm-156dBm
Reacquisition-157dBm-155dBm-157dBm-153dBm
Cold Start-147dBm-147dBm-141dBm-137dBm
Hot Start-158dBm-157dBm-158dBm-155dBm
Position Accuracy RTK2D CEP0.80m1.00m-1.50m
Vertical1.00m1.50m-2.00m

Performance in Single-GNSS Modes from the ZED-F9K Datasheet

Board Dimensions

Overall, the board is about 2.00" x 1.70" (50.8mm x 43.2mm). With the USB and SMA connector, it's about 2.40" 1.70" (61.0mm x 43.2mm). There are 4x mounting holes by each corner of the board.

alt text

Hardware Assembly

For this example, I used a SparkFun Thing Plus - ESP32 WROOM and associated USB cable. Connecting the boards with Qwiic cable, the assembly is very simple. Plug a Qwiic cable between the Thing Plus - ESP32 WROOM and SparkFun GPS RTK Dead Reckoning ZED-F9K. Then plug in one of our patch antennas to the SMA connector 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 to a microcontroller of your choice.

When using the ZED-F9K, you will want to orient the board according to the guidelines explained earlier. Below is a top-down view with the board pointing up. Your setup should look similar to the image below.

alt text

Make sure to secure the board above a vehicle's dashboard using some tape or sticky tack when prototyping and testing. For best signal reception, it is suggested to guide the antenna from the inside of the car and through a window before attaching the GPS on top of a car. We recommend the magnetic mount GPS/GNSS antenna to easily mount.

alt text

Adding a RTCM Correction Source

To get the most out of the ZED-F9K you will need an RTCM correction source. There are a few methods of adding a RTCM correction source. If you have been following along with our GPS-RTK and GPS-RTK2, you can pipe correction data from a wireless network, LoRa, or cellular network. Depending on your setup, you will probably need a ZED-F9P for a correction source. For more information, check out these tutorials.

What is GPS RTK?

September 14, 2018

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

How to Build a DIY GNSS Reference Station

October 15, 2020

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!

Setting up a Rover Base RTK System

October 14, 2020

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.

Software Installation

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.

All of our u-blox based GPS boards share the same library: the breakout board, their predeccesors and the higher precisionu-blox cousins. The SparkFun u-blox Arduino library can be downloaded with the Arduino library manager by searching 'SparkFun u-blox GNSS' or you can grab the zip here from the GitHub repository to manually install. Once calibrated, you can take advantage of the examples for the ZED-F9K.

There are 13 example sketches provided to get you up and receiving messages from space. The examples listed below highlight the additional capabilities of the SparkFun Dead Reckoning ZED-F9K. For the scope of this tutorial, we will not focus on the basic GPS polling sketches as shown in the other u-blox hookup guides.

Arduino Examples

Example 1 - Calibrate Sensor

Now that the GPS-RTK SparkFun Dead Reckoning is mounted and oriented correctly with regards to the vehicle, it's time to calibrate the sensor. To do this, a few movements with the vehicle must be done all while maintaining good GNSS reception.

  • First, the car needs to be stopped with the engine turned on.
  • Secondly, the car must do left and right hand turns.
  • Lastly, the car must reach a speed over 30 km/h.

For the first example (located in File Examples > SparkFun u-blox GNSS Arduino Library>Dead Reckoning>Example1_calibrateSensor), the calibration status will be printed to the Arduino's serial monitor to indicate when calibration is ongoing and when it has completed.

If you have not already, select your Board (in this case the SparkFun ESP32 Thing Plus), and associated COM port. Upload the code to the board and and set the serial monitor to 115200 baud. Perform those fancy maneuvers (while obeying the traffic laws) before parking your car in a safe location. Then turn your engine off before checking the status! You should see a message indicating that the ZED-F9P is calibrated. If you do not, try driving around with the board once again!

Example 2 - IMU Data

After you have your sensor calibrated (see example1), you can now poll the internal IMU to see what data is being fed to the GNSS calculations. Open the second example (located in File Examples > SparkFun u-blox GNSS Arduino Library>Dead Reckoning>Example2_getIMUData) to follow along! First, the sketch checks to see that the board is calibrated before it attempts to read IMU data.

If you have not already, select your Board (in this case the SparkFun ESP32 Thing Plus), and associated COM port. Upload the code to the board and set the serial monitor to 115200 baud. This may be a good time to bring a friend along to drive if you decide to actively monitor the output. Otherwise, check out the data after taking the board for a stroll. Try driving around as the board senses the car's movement. Then park in a safe location with the engine turned off before inspecting the data.

Example 4 - Vehicle Dynamics

What happened to Example 3? It's been skipped over because its used primarily as a diagnostic sketch. What sensors are currently being used, are they functioning correctly, are the measurements being listed as bad or non-existent? Example 3 helps diagnose these various issues. Lets move ahead to the fourth example in the library (located in File Examples > SparkFun u-blox GNSS Arduino Library>Dead Reckoning>Example4_vehicleDynamics)

The vehicle attitude is a termed coined by u-blox that encompasses three measurements: vehicle pitch, vehicle roll, and vehicle heading. Much like the other example sketches, this one checks to make sure that the SparkFun Dead Reckoning ZED-F9K has been calibrated before pulling data. If the SparkFun Dead Reckoning ZED-F9K has indeed been calibrated, then it gets the relevant information by calling myGNSS.getVehAtt(). As in Example 2, the data is stored within a struct called vehAtt.

If you have not already, select your Board (in this case the SparkFun ESP32 Thing Plus), and associated COM port. Upload the code to the board and set the serial monitor to 115200 baud. This may be a good time to bring a friend along to drive if you decide to actively monitor the output. Otherwise, check out the data after taking the board for a stroll. Try driving around as the board senses the car's movement. Then park in a safe location with the engine turned off before inspecting the data.

Connecting the GPS-RTK to a Correction Source

To get the most out of the ZED-F9K you will need an RTCM correction source. There are a few methods of adding a RTCM correction source. If you have been following along with our GPS-RTK and GPS-RTK2, you can pipe correction data from a wireless network, LoRa, or cellular network. Depending on your setup, you will probably need a ZED-F9P for a correction source. For more information, check out these tutorials.

What is GPS RTK?

September 14, 2018

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

How to Build a DIY GNSS Reference Station

October 15, 2020

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!

Setting up a Rover Base RTK System

October 14, 2020

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.

Resources and Going Further

Now that you've successfully got your GPS receiver up and running, it's time to incorporate it into your own project! For more information, check out the resources below:

Need some inspiration for your next project? Check out some of these related tutorials:

GPS Shield Hookup Guide

This tutorial shows how to get started with the SparkFun GPS Shield and read and parse NMEA data with a common GPS receiver.

GPS Mouse - GP-808G Hookup Guide

Get started with the GP-808G GPS Mouse. This GPS module is great for advanced projects such as autonomous vehicles.

GPS Geo-Mapping at the Push of a Button

Let's ramp up our GPS tracking skills with KML files and Google Earth. We'll make a tracker that logs location and allows us to visualize our steps with Google Earth.

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!

Or check out this blog post for ideas.


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

Sending Sensor Data Over WiFi

$
0
0

Sending Sensor Data Over WiFi a learn.sparkfun.com tutorial

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

Introduction

We’re all familiar with WiFi. It runs our home, let’s us stream our favorite movies, and keeps us from having to talk with other people when we’re at a coffee shop. But there's more ways to use WiFi than simply accessing the internet through different applications. In this tutorial, we'll show you how to set up your own peer-to-peer network to sense data from one area and send that data to an LCD screen somewhere else without needing any internet connection or routers. This a great first step in being able to remove the wires from any embedded physical computing application.

The project: Wirelessly Monitor Temperature, Humidity, and Barometric Pressure

For this build, we're going to create a simple point-to-point closed WiFi system that reads the data from an environmental sensor and sends it to a display somewhere else. We'll keep this example as simple as possible by using our hardware, utilizing the Qwiic Connect System to connect our hardware without the need for soldering. The hardware includes a pair of ESP32 Thing Plus Wroom modules, a Qwiic Environmental Combo Breakout, a Qwiic 20x4 SerLCD RGB Backlight Display, and a couple of Qwiic Cables. (And of course, a power supply - either battery or wall charger - for each.) You can add all the items of this tutorial to your cart using the wishlist below.

 


Step 1: Obtaining MAC Addresses

In order to communicate with any device over WiFi, we need to know its Media Access Control Address, or MAC address. There’s a short and simple Arduino sketch that will find the MAC address of each device, and this one should go in your drawer of super-useful Arduino utility sketches right next to your I2C sniffer.

/*
 * MAC Address Finder
 * Run this on each of your WiFi-enabled
 * boards to get their MAC addresses, so
 * you can plug them into your code,
 * allowing your components to connect
 * on power-up or after power-cycling
 * without the need for any intervention!
 * 
 * Once you've uploaded the code, open
 * the Serial Monitor, hit the reset
 * button on your board, and write down
 * the MAC address.
 * (I use a label maker to put the MAC
 * address on the back of each board.)
 */

#include "WiFi.h"

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

}

void loop(){
  WiFi.mode(WIFI_STA);
  Serial.print("The MAC address for this board is: ");
  Serial.println(WiFi.macAddress());
  while(1){     // This holds the loop, so it doesn't 
    }           // print the info a million times.
}

MAC Address Finder
Once the code is uploaded, open a Serial Monitor, reset the board, and write down the MAC address.
Tip from the author:
When I first starting to work with WiFi boards, I would find the MAC address, write it on a sticky note, then put that on each board. Of course I would then throw them all in my bag, go from my home workspace into SparkFun HQ and pull all the boards out, only to find that the sticky notes were all stuck to each other in the bottom of my bag. Useless! Since then I’ve been using a label maker to tag the back of each board. I would recommend against using a permanent marker on your boards for this since the MAC addresses can be changed.
MAC Addresses on boardsA label maker is a non-permanent solution to putting the MAC address on each board.

Step 2: Connecting the Hardware

As stated before, working with SparkFun's Qwiic Connect System is very simple and this project will only require you to make 6 total connections. To one of the ESP32 Thing Plus boards (the transmitter or server board), we’ve connected the SparkFun Qwiic Environmental Breakout, and to the other ESP32 Thing Plus board (the receiver or client board), the Qwiic 20x4 SerLCD RGB Backlight Display. Note that since we’re only using the BME280 sensor from the environmental combo board, you could also use our Atmospheric Sensor Breakout - BME280 without any change to the code, if you would like to use that sensor board instead.

alt text
Our Qwiic components make projects like this incredibly fast and easy to set up.

Step 3: Uploading the Code

For this example we have two Arduino sketches - one for the data transmitter, and one for the data receiver.

Copy this sketch and upload it to your transmitting board, the one with the Qwiic Environmental Combo connected to it. Make sure that before you upload it, you insert the MAC address of your receiving board on line 34 of the sketch, so that, in our case,

uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

would become

uint8_t broadcastAddress[] = {0x94, 0x3C, 0xC6, 0x96, 0x38, 0xB4};

Full Transmitter Code

The proper board (SparkFun ESP32 Thing Plus) should still be selected, just make sure you've connected to the proper COM port, and upload the following sketch.

/* WiFi Peer-to-Peer example, Transmitter Sketch
 * Rob Reynolds, SparkFun Electronics, November 2021
 * This example uses a pair of SparkFun ESP32 Thing Plus Wroom modules
 * (https://www.sparkfun.com/products/15663, a SparkFun Qwiic Environmental
 * Combo Breakout (https://www.sparkfun.com/products/14348), and a SparkFun
 * Qwiic 20x4 SerLCD - RGB Backlight (https://www.sparkfun.com/products/16398).
 * 
 * Feel like supporting our work? Buy a board from SparkFun!
 * https://www.sparkfun.com/
 * 
 * License: MIT. See license file for more information but you can
 * basically do whatever you want with this code.
 * 
 * Based on original code by 
 * Rui Santos
 * Complete project details at https://RandomNerdTutorials.com/esp-now-esp32-arduino-ide/
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files.
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
*/

#include <esp_now.h>
#include <WiFi.h>

#include <Wire.h>            // Used to establish serial communication on the I2C bus
#include "SparkFunBME280.h"  // Install library for the BME280
BME280 mySensor;             // Define sensor


// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
  float a;
  float b;
  float c;
} struct_message;

// Create a struct_message called myData
struct_message myData;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}

void setup() {
  Serial.begin(115200);
  Serial.println("Reading basic values from BME280");

  Wire.begin();

  //**********Setup for BME280 module**********//
  if (mySensor.beginI2C() == false) //Begin communication over I2C
  {
    Serial.println("The sensor did not respond. Please check wiring.");
    while(1); //Freeze
  }  

  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);

  // Register peer
  esp_now_peer_info_t peerInfo;
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;

  // Add peer        
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
}

void loop() {
  // Set values to send
  //strcpy(myData.a, "THIS IS A CHAR");
  myData.a = (mySensor.readTempF());
  myData.b = (mySensor.readFloatHumidity());
  myData.c = (mySensor.readFloatPressure());

  // Send message via ESP-NOW
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));

  // The following is only used for testing, to check data in Serial Monitor
  Serial.print("Temperature in Fahrenheit: ");
  Serial.println(myData.a);
  Serial.print("Humidity: ");
  Serial.println(myData.b);
  Serial.print("Pressure: ");
  Serial.println(myData.c);

  if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
  }
  delay(2000); // Send data every two seconds
}

The crux of this sketch happens in this line (line 103):

esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));

Since we've already established the receiving board's MAC address in the variable broadcastAddress[] and established each of the three myData variables esp_now_send() sends to the receiving board all of our myData variables. (Note that we could certainly send more than the three we are using, but for the sake of simplicity and display size, I've kept the number low.)

In the original code by Rui Santos on which these sketches are based, the receiver will ping back to let the transmitter know that data was received. I’ve left this in the sketches, as it’s great during the testing phase. Once this sketch is uploaded, open the Serial Monitor. You should see the data as it’s being recorded, plus the message “Sent with success”. Following that, however, you’ll see the ominous message “Last Packet Send Status: Delivery Fail”. That’s okay, because we have nothing receiving the data. Let’s take care of that. Grab the other ESP32 Thing Plus, connect the SerLCD using the Qwiic connector, and upload the following sketch. (Make sure you change the COM port to that of this new board.)

Full Receiver Code

/* WiFi Peer-to-Peer example, Receiver Sketch
 * Rob Reynolds, SparkFun Electronics, November 2021
 * This example uses a pair of SparkFun ESP32 Thing Plus Wroom modules
 * (https://www.sparkfun.com/products/15663, a SparkFun Qwiic Environmental
 * Combo Breakout (https://www.sparkfun.com/products/14348), and a SparkFun
 * Qwiic 20x4 SerLCD - RGB Backlight (https://www.sparkfun.com/products/16398).
 * 
 * Feel like supporting our work? Buy a board from SparkFun!
 * https://www.sparkfun.com/
 * 
 * License: MIT. See license file for more information but you can
 * basically do whatever you want with this code.
 * 
 * Based on original code by 
 * Rui Santos
 * Complete project details at https://RandomNerdTutorials.com/esp-now-esp32-arduino-ide/
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files.
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
*/

#include <esp_now.h>
#include <WiFi.h>

#include <SerLCD.h> //Click here to get the library: http://librarymanager/All#SparkFun_SerLCD
SerLCD lcd; // Initialize the library with default I2C address 0x72


// Structure example to receive data
// Must match the sender structure
typedef struct struct_message {
    float a;
    float b;
    float c;
    float d;
} struct_message;

// Create a struct_message called myData
struct_message myData;



void setup() {
  // Initialize Serial Monitor
  Serial.begin(115200);

  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  Wire.begin();
  //********** Setup for LCD display**********//
  lcd.begin(Wire); //Set up the LCD for I2C communication

  lcd.setBacklight(50, 55, 255); //Set backlight to bright white
  lcd.setContrast(5); //Set contrast. Lower to 0 for higher contrast.

  lcd.clear(); //Clear the display - this moves the cursor to home position as well
  lcd.print(" Current Conditions");
  lcd.setCursor(0, 1);
  lcd.print("Temperature: ");
  lcd.setCursor(0,2);
  lcd.print("Humidity: ");
  lcd.setCursor(0,3);
  lcd.print("Pressure: ");

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for recv CB to
  // get recv packer info
  esp_now_register_recv_cb(OnDataRecv);
}

void loop() {

}



// callback function that will be executed when data is received
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
  memcpy(&myData, incomingData, sizeof(myData));

  // Use this for testing in Serial Monitor if you're not seeing anything on the LCD display 
  Serial.print("Temperature F: ");
  Serial.println(myData.a);
  Serial.print("Humidity: ");
  Serial.println(myData.b);
  Serial.print("Pressure: ");
  Serial.println(myData.c);
  Serial.println();
  lcd.setCursor(13, 1);
  lcd.print(String(myData.a) + (char)223 + " F");
  lcd.setCursor(13, 2);
  lcd.print(String(myData.b) + (char)37);
  lcd.setCursor(13, 3);
  lcd.print(String(myData.c, 1)); // The comma followed bt 1 limits output to 1 decimal place

}

In the receiving script, the line we want to focus on is here inside the onDataRecv() function (line 86):

memcpy(&myData, incomingData, sizeof(myData));

This takes the the incoming data and moves it to myData so it can be displayed. Just make sure that the the data structure in the receiving sketch matches the data structure in the transmitting sketch. (That is, the data type for each of your variable to be sent matches the data types that the receving sketch expects.)

Once you've got the code loaded to both boards, powering them up will connect them, and you should see incoming data after only a few seconds.

Project parts

WiFi communication over WiFi without the need for a router is fast and easy!

Troubleshooting

If you aren't getting anything on the LCD display, or some other issue seems to have shown up, there are a few things you can check. Let's start by connecting the transmitting board (with the Environmental Sensor) to your computer with a USB cable, then opening up the Serial Monitor window. If the sensor is working properly and the WiFi module is sending the package, you should see something like this in the Serial Monitor:

Temperature in Fahrenheit: 74.46
Humidity: 22.21
Pressure: 84992.97
Sent with success

If the receiver isn't powered up, you'll also see:

Last Packet Send Status: Delivery Fail

If all is as it should be here, you can connect connect the receiving ESP32 to your computer, power up the transmitter with a battery or power supply, and check the results there. The Serial Monitor should be displaying the temperature, humidity, and pressure readings. If you're still having issues, reach out to our support team.


Resources and Going Further

The focus of this project was simply to show you how to send data wirelessly. The great thing about the simplicity of this tutorial is that you could change out the sensor board we used for any one of many sensors with relative ease. You could also add another Qwiic sensor to this setup such as the SparkFun Ambient Light Sensor to add another data point which expands the dataset showing on your LCD. Looking through the hookup guides for the sensor you would like to use is a great place to start.

If you want to learn more about the SparkFun components used in this project, you can find that information in the hookup guides below.

CCS811/BME280 (Qwiic) Environmental Combo Breakout Hookup Guide

Sense various environmental conditions such as temperature, humidity, barometric pressure, eCO2 and tVOCs with the CCS811 and BME280 combo breakout board.

AVR-Based Serial Enabled LCDs Hookup Guide

The AVR-based Qwiic Serial Enabled LCDs are a simple and cost effective solution to include in your project. These screens are based on the HD44780 controller, and include ATmega328P with an Arduino compatible bootloader. They accept control commands via Serial, SPI and I2C (via PTH headers or Qwiic connector). In this tutorial, we will show examples of a simple setup and go through each communication option.

ESP32 Thing Plus Hookup Guide

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

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

GNSS Timing Breakout - ZED-F9T (Qwiic) Hookup Guide

$
0
0

GNSS Timing Breakout - ZED-F9T (Qwiic) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Introducing the SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic), a unique entry into SparkFun's GNSS catalog featuring the ZED-F9T GNSS receiver from u-blox. The ZED-F9T provides up to 5 nanosecond timing accuracy under clear skies with no external GNSS correction making it perfect for applications where timing accuracy is imperative. Need an extremely accurate time reference to maximize the efficiency of your IoT network of 5G devices? The GNSS Timing Breakout - ZED-F9T could be the perfect solution.

SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic)

SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic)

GPS-18774
$299.95

This breakout shares a similar design as the SparkFun GPS-RTK-SMA Breakout to create a small but comprehensive development tool for ZED-F9T. The design includes a USB-C connector for primary power and communication, two Qwiic connectors for communicating over I2C using the SparkFun Qwiic system, three SMA connectors for the antenna and timing pulse signals as well as a host of PTH pins allowing direct interaction with most of the ZED-F9T's pinout.

Required Materials

You will need the following materials along with the SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic) to follow along with this tutorial.

GNSS Antenna

The ZED-F9T is a dual receiving GNSS receiver which means it can receive both L1 and L2 GNSS frequencies. To enable this, you will need an appropriate antenna such as those listed below:

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GNSS Multi-Band Magnetic Mount Antenna - 5m (SMA)

GPS-15192
$67.95
1
GNSS Multi-Band L1/L2 Surveying Antenna (TNC) - TOP106

GNSS Multi-Band L1/L2 Surveying Antenna (TNC) - TOP106

GPS-17751
$124.95
7
GNSS  Multi-Band L1/L2 Helical Antenna (SMA) BT-560

GNSS Multi-Band L1/L2 Helical Antenna (SMA) BT-560

GPS-17383
$84.95
1
MagmaX2 Active Multiband GNSS Magnetic Mount Antenna - AA.200

MagmaX2 Active Multiband GNSS Magnetic Mount Antenna - AA.200

GPS-17108
$77.95

A low cost GNSS antennawill work and provide a basic fix but the advanced timing and positional accuracy features of the ZED-F9T will not be available without L2 support.

USB Cable

Basic use of the ZED-F9T either through a serial terminal or u-blox's u-center application needs a USB-C cable to connect the board to your computer:

Reversible USB A to C Cable - 0.3m

Reversible USB A to C Cable - 0.3m

CAB-15426
$3.95
1
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

Arduino Examples Materials

For those who want to use the breakout board with the SparkFun u-blox GNSS Arduino Library, you'll need an Arduino microcontroller, Qwiic cable and USB-C cable to get started. We found the ESP32 works as a great transmitting option when creating a network of GNSS devices receiving time correction data from a ZED-F9T configured to act as a base station:

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
13
SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
7
SparkFun Thing Plus - ESP32-S2 WROOM

SparkFun Thing Plus - ESP32-S2 WROOM

WRL-17743
$19.95
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50

SparkFun u-blox library examples

The SparkFun u-blox GNSS Arduino Library has a tremendous number of examples and features to demonstrate the power of our GNSS receivers. For the ZED-F9T specifically, be sure to view the Time Pulse examples. These will show you how to configure the time pulse settings for the two time pulse outputs.

While configuring the ZED-F9T over Qwiic from a microcontroller is pretty easy, many applications for timing require a set it and forget it mentality. Consider using u-center from u-blox to configure your ZED-F9T over USB and then saving the configuration to BBR (battery backed RAM) so that the module comes on with the same settings at the next power on.

Recommended Reading

Before getting started with the GNSS Timing Breakout you may want to read through these tutorials if you are not familiar with the concepts covered in them:

GPS Basics

The Global Positioning System (GPS) is an engineering marvel that we all have access to for a relatively low cost and no subscription fee. With the correct hardware and minimal effort, you can determine your position and time almost anywhere on the globe.

I2C

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

Serial Basic Hookup Guide

Get connected quickly with this Serial to USB adapter.

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.

Hardware Overview

Let's take a closer look at the ZED-F9T and other hardware present on the SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic).

ZED-F9T GNSS Timing Module

The ZED-F9T is a multi-band GNSS receiver that excels at timing accuracy with the capability to achieve 5 nanosecond (ns) timing accuracy with a standard position lock.

Photo highlighting ZED-F9T module.

The ZED-F9T needs a clear view of the open sky to reduce the timing error to 5ns but requires no external correction. The module also features a Differential Timing Mode where correction data is shared between neighboring ZED-F9T receivers configured in a communication network. When configured properly in a communication network, the module can reduce timing errors to 2.5ns.

The GNSS Timing Breakout specifically uses a ZED-F9T-00B version of the module supporting L1/L2/E5b bands. The ZED-F9T operates on all major constellations (GPS, GLONASS, Galileo and BeiDou) concurrently making it extremely versatile and able to retain its timing precision even the module loses lock with one or more of the visible constellations.

The ZED-F9T also supports the creation of up to four geofence areas, security monitoring and detection systems that, when paired with an IoT controller, can send this data to the user. On top of all that, the ZED-F9T also has an integrated logging system users can configure to store position fixes and arbitrary byte strings in the receiver's Flash memory.

For a detailed overview of the module, these integrated systems and how to use them, refer to the datasheet and integration manual.

Communication Interfaces

The ZED-F9T features standard communication interfaces including USB, two UARTs, SPI and I2C. USB and UART2 have dedicated pins. UART1, SPI and I2C share pins and are selected by the state of the Interface Select pin (labeled D_SEL). The D_SEL pin is left open/"high" by default to enable UART1 and I2C and disable SPI. The shared pins are outlined below:

Photo highlighting communication interfaces.

Default (D_SEL = 1/HIGH)

  • TX
  • RX
  • SDA
  • SCL

Alternate (D_SEL = 0/LOW)

  • SPI CIPO
  • SPI COPI
  • SPI CS
  • SPI CLK
Note: The GNSS Timing Breakout routes the SDA/CS and SCL/SPI CLK lines to separate PTH headers labeled for one of the two operation modes (i.e. The pin labeled CS also connects to the pin labeled SDA as well as the SDA line on the Qwiic connector).

USB

The ZED-F9T USB interface is routed to a USB-C connector. The USB acts as both a power input as well as a serial interface to quickly connect the module to u-blox's u-center software to configure the module and view NMEA sentences. See Getting Started with U-Center for more information about using the GNSS Timing Breakout with u-center over USB.

UART/Serial

The breakout routes the ZED-F9T's two UARTs (UART1 and UART2) to PTH headers. UART1 acts as a typical serial interface for NMEA sentences or other data. UART2 is a dedicated interface for sending or receiving RTCM correction data. The default settings for both UARTs are 38400 baud, 8-bits, no parity bit, 1 stop bit.

I2C/Qwiic

The board connects the ZED-F9T's I2C interface to PTH headers as well as a pair of Qwiic connectors to make it easy to add the GNSS Timing Breakout into a chain of I2C devices using the Qwiic ecosystem. Note, the pull-up resistors for the Qwiic connectors are disabled by default. Close the I2C jumper on the back of the breakout to enable those pull-up resistors.

The default 7-bit unshifted address for the ZED-F9T is 0x42 but is fully adjustable using the appropriate commands. Refer to the Integration Manual for more information.

Note: The pullup resistors on the SDA/SCL lines on the GNSS Timing Breakout are disabled by default. You may need to close th I2C jumper in certain configurations when communicating over I2C.

SPI

The ZED-F9T's SPI interface is also broken out but is disabled by default. Enable SPI communication for the ZED-F9T by tying the D_SEL pin to GND/0V. Reminder, enabling the SPI interface disables UART1 and I2C.

Power

Power for the GNSS Timing Breakout can be provided either via a USB-C connection or Qwiic connectors. The breakout also includes outputs for both 5V and 3.3V as well as a backup battery and charging circuit.

Photo highlighting power inputs/outputs
Note: The 5V output PTH only is active when the breakout is powered via USB.

RTC Backup Battery Circuit

The board includes an RTC backup battery circuit to preserve settings and help with quick restarts and warm lock starts. The 1mAh battery can run the backup battery circuit on the ZED-F9T with no external power for roughly one day (24hrs) to preserve stored settings and let the module perform a hot start on restart.

SMA Connectors

The GNSS Timing Breakout has three SMA connectors. One for a GNSS antenna and two for the time pulse signals.

Photo highlighting SMA connectors.

The time pulse signals can be connected to external devices to synchronize their action.

Note: A low cost GNSS antenna will work to get a basic position lock but in order to use the advanced timing and positional accuracy features of the ZED-F9T an antenna with L2 support is required.

Control PTHs

The breakout also routes several control pins to PTHs from the ZED-F9T highlighted below:

Photo highlighting Control PTH connections.
  • RST: ZED-F9T reset pin. Pull the line LOW to reset the module.
  • SAFE: Safeboot pin. Safeboot mode is required for firmware updates and generally should not be used or connected for normal operation.
  • INT: Interrupt I/O pin. Use u-center to configure the pin to bring the module out of deep sleep or use it as an output interrupt for various operations.
  • TP1: Timepulse 1 output signal.
  • TP2: Timepulse 2 output signal.
  • FENCE Geofence output pin. Configure with u-center to go either HIGH or LOW depending on settings when creating a geofence area. Use this to trigger alarms or actions when the module exits the defined geofence area.
  • D_SEL: Interface selection pin. Default is Open/HIGH and selects UART1 and I2C interfaces. Connect to 0V/LOW to select SPI interface.
  • TX_RDY: UART1 Ready to send pin.

LEDs

The breakout includes four status LEDs highlighted in the image below:

Photo highlighting status LEDs.
  • PWR: Power LED. Illuminates whenever 3.3V is present from either USB or the Qwiic bus.
  • TP1: Timepulse 1 status LED. Pulses on/off in sync with the signal from timepulse 1.
  • TP2: Timepulse 2 status LED. Pulses on/off in sync with the signal from timepulse 2.
  • FEN: Geofence status LED. Will turn on or off when the module exits the geofence area depending on settings.

Solder Jumpers

Never worked with solder jumpers or PCB traces before or would like a refresher? Take a look at our How to Work with Jumper Pads and PCB Traces tutorial.

The GNSS Timing Breakout has eight jumpers on board labeled I2C, MEAS, PWR, TP1, TP2, TP1_LED, TP2_LED, and FENCE. The table below outlines the functionality of each jumper and their default state.

Photo highlighting solder jumpers.
Not pictured: I2C solder jumper on front of the board.
Jumper LabelDefault StateJumper Function
I2COPENClose to enable I2C pullups on bus.
MEASCLOSEDOpen to measure current draw by the breakout from VBUS. Note, opening this jumper disables 5V input from USB
PWRCLOSEDCompletes Power LED circuit. Open to disable Power LED.
TP1CLOSEDOpen to isolate the TP1 SMA connector from the TP1 PTH. Helps limit the stray time delay introduced by extra copper or externally soldered devices.
TP2CLOSEDOpen to isolate the TP2 SMA connector from the TP2 PTH. Helps limit the stray time delay introduced by extra copper or externally soldered devices.
TP1_LEDCLOSEDCompletes TP1 STAT LED circuit. Open to disable TP1 STAT LED.
TP2_LEDCLOSEDCompletes TP2 STAT LED circuit. Open to disable TP2 STAT LED
FENCECLOSEDCompletes the FENCE STAT LED circuit. Open to disable FENCE STAT LED.

Board Dimensions

The GNSS Timing Breakout - ZED-F9T (Qwiic) measures 1.70" x 1.70" (43.18mm x 43.18mm) and includes four mounting holes that fit a 4-40 screw.

Board dimensions

Hardware Assembly

The GNSS Timing Breakout requires very little assembly to initialize the device, get a lock and start receiving data. Setting up a device network to take advantage of the differential timing mode or using the GNSS Timing Breakout with the SparkFun u-blox Arduino library requires a bit more assembly and configuration.

Basic Assembly (Single GNSS Timing Breakout)

GNSS Timing Breakout connected to antenna and USB-C

Initial setup and use of the GNSS Timing Breakout only requires a USB-C cable and GNNS antenna connected to the board. On first connection, drivers should automatically install. In case drivers do not install, head over to this section of our Getting Started with u-center for u-blox tutorial. Verify the port the device enumerated on and either open u-center (Windows only) to interact with and configure the device. Users who prefer to can use a serial terminal program and the Interface Description document.

With a clear view of the sky, the ZED-F9T should achieve a lock within 26s from a Cold Start (2 seconds from a Hot Start).

Arduino Assembly via Qwiic

Assembling the GNSS Timing Breakout into an Arduino circuit is easy thanks to the Qwiic system. Simply connect a GNSS antenna to the SMA connector and then connect the breakout to a Qwiic-enabled microcontroller like the SparkFun Thing Plus - ESP32 WROOM using a Qwiic cable.

GNSS Timing Breakout connected via Qwiic to Arduino microcontroller
Reminder: The pullup resistors on the SDA/SCL lines on the GNSS Timing Breakout are disabled by default. You may need to close th I2C jumper in certain configurations when communicating over I2C.

Differential Timing Network

The GNSS Timing Breakout can be configured to act as a controller operating in reference station mode to provide timing correction data to a network of ZED devices. All that is needed here is 2 or more ZED devices with one acting as the reference station and a way to transmit the correction data (hard-wired, radio or WiFi.

For more information on setting up a Differential Timing Network using multiple devices, read on to the Using the ZED-F9T in Differential Timing Mode section of this guide as well as the Differential Timing Setup appnote from u-blox.

Arduino Examples

Note: These examples assume the latest version of the Arduino IDE is used. If this is your first time using Arduino, please review our tutorials on Installing the Arduino IDE and Installing an Arduino Library.

The SparkFun u-blox GNSS Arduino Library includes a host of examples to get users started with everything from a simple position lock to configuring and taking advantage of most features of all u-blox boards SparkFun carries. In this section we'll take a closer look at the examples demonstrating how to set up and use both time pulse signals on the ZED-F9T.

Install the u-blox GNSS Arduino Library through the Arduino Library Manager tool by searching for "SparkFun u-blox GNSS". Users who prefer to manually install the library can download a ZIP of the repository by clicking the button below:

Time Pulse Parameters Example

The u-blox GNSS Arduino Library includes a set of three examples, "Example 23 - Time Pulse Parameters" for configuring and using the time pulse pins on the ZED-F9T and other u-blox modules capable of outputting time pulse signals. Open the examples by navigating to **File > Examples > SparkFun u-blox GNSS Arduino Library > Example23_TimePulseParameters and select one of the three "sub" examples:

  • Example23_TimePulse_Period - Demonstrates how to change the time pulse parameters and configure the time pulse pin(s) to produce a 1 second pulse every 30 seconds.
  • Example23_TimePulse_Frequency - Shows how to adjust the time pulse parameters and configure the Time Pulse pin(s) to produce a 1kHz square wave.
  • Example23_TimePulse_BulletTime - Demonstrates how to configure the Time Pulse pin(s) to produce a pulse once per second with an adjustable delay. You could use this to trigger multiple cameras and replicate the "bullet time" effect.

Open one of the examples, select your Board and Port and upload the code. Open the serial monitor with the baud set to 115200 to view the print out and confirm the time pulse pin(s) was configured and settings saved properly.

Using the ZED-F9T in Differential Timing Mode

The receiver has two time pulse signals, each with an accuracy of 5ns. These signals can be configured to have a frequency 0.25Hz to 25MHz with configurable pulse width and polarity. These tightly coupled signals make the ZED-F9T an excellent source as a time base.

Additionally, multiple ZED units can be synchronized by transmitting correction data from a control unit to multiple peripheral units. This allows multiple units, up to 20km (12 miles) apart to have synchronized time pulses with 2.5ns relative accuracy. In other words, differential timing mode will improve the phase alignment of the time pulse between units (and you can have 2 or 20, doesn't matter).

Setup Considerations

If you're familiar with GNSS RTK and base/rover setups the ZED-F9T is very similar. We will be scratching the surface so if you need additional information be sure to check out What is RTCM? and How to Setup a Temporary Base.

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

For specifics of configuring the ZED-F9T for reference station mode, please see the ZED-F9T Differential Timing Setup app note from u-blox. This will walk you through how to put a ZED-F9T into stationary mode. Once complete this unit will begin producing RTCM packets once per second.

Once packets are being produced, determine how the ~550 bytes per second will be delivered to the peripheral units to be synchronized. Typically, these packets are pushed to a NTRIP caster over an internet connection (you can read here about Setting up an NTRIP Caster). Alternatively these packets can be broadcast over serial modem radios, buried cable, or any other back haul option capable of supporting ~1kB/s. We've found that using an ESP32 along with a Qwiic connection and WiFi makes setting up an NTRIP connection enticingly easy.

Once a reference station has been setup, the peripheral ZED-F9Ts simply need to access these RTCM packets and have them fed into the module. Generally, this is done over UART2 but can be done over USB, I2C, UART1 or SPI. Don't worry, we've got Arduino examples demonstrating both NTRIP Client and Server that can be leveraged for the ZED-F9T. And if Arduino and RTK2Go are not your cup of tea, u-center has a built in Caster and Client that will make the connection between multiple units over USB using their Windows application.

Resources and Going Further

That's a wrap for this tutorial. For more information about the SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic), check out the following resources:

For more information on setting up a GNSS Timing Breakout - ZED-F9T as a time base station and broadcasting RTCM data, head over to these tutorials:

Looking for inspiration for your next GNSS project? The tutorials below may help:

GPS Mouse - GP-808G Hookup Guide

Get started with the GP-808G GPS Mouse. This GPS module is great for advanced projects such as autonomous vehicles.

Three Quick Tips About Using U.FL

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

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.

smôl ZOE-M8Q Hookup Guide

Small in size, small on current draw. It's a smôl world! This guide will get you up and running with the smôl ZOE-M8Q GNSS Peripheral Board.

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


Qwiic ToF Imager - VL53L5CX Hookup Guide

$
0
0

Qwiic ToF Imager - VL53L5CX Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The Qwiic ToF Imager - VL53L5CX and the Qwiic Mini ToF Imager - VL53L5CX are here! These little breakout boards are built around ST Electronics' VL53L5CX; a state of the art, Time-of-Flight (ToF), multizone ranging sensor enhancing the ST FlightSense product family. This chip integrates a SPAD array, physical infrared filters, and diffractive optical elements (DOE) to achieve the best ranging performance in various ambient lighting conditions with a range of cover glass materials.

Multizone distance measurements are possible up to 8x8 zones with a wide 63° diagonal FoV which can be reduced by software. Thanks to ST Histogram patented algorithms, the VL53L5CX is able to detect different objects within the FoV. The Histogram also provides immunity to cover glass crosstalk beyond 60 cm.

Ideal for 3D room mapping, obstacle detection for robotics, gesture recognition, IoT, laser-assisted autofocus, and AR/VR enhancement, the Qwiic connector on this sensor makes integration easy.

SparkFun Qwiic ToF Imager - VL53L5CX

SparkFun Qwiic ToF Imager - VL53L5CX

SEN-18642
$24.95
1
SparkFun Qwiic Mini ToF Imager - VL53L5CX

SparkFun Qwiic Mini ToF Imager - VL53L5CX

SEN-19013
$24.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.

Logic Levels

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

I2C

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

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

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.

Hardware Overview

VL53L5CX

The SparkFun Qwiic ToF Imager and Qwiic ToF Mini are state of the art, 64 pixel Time-of-Flight (ToF) 4 meter ranging sensors built around the VL53L5CX from ST. To see more details, refer to the datasheet.

Note: Both of these boards ship with vacuum tape over the sensor. Please be sure to remove this tape before first use!
The sensor is smack in the middle of the front side of the board.The sensor is a little bit higher than the middle of the front side of the board.
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

Qwiic Connectors

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

The 7-bit unshifted I2C address (most commonly used with Arduino) is 0x29. The 8-bit I2C address of the board is 0x52 for writing and 0x53 for reading.

Qwiic connectors live on either side of the front side of the board (left and right).Qwiic connectors live on either side of the back side of the board (left and right).
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

Power

Ideally power will be supplied by the Qwiic connector, but if you wish to supply your own power, pins have been broken out along the bottom side of the board labeled 3V3 and GND. The input voltage range should be between 2.7-3.3V.

First two pins from the left on the bottom of the front side of the board are Ground and 3V3First two pins from the right on the bottom of the front side of the board are Ground and 3V3.
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

I2C

The I2C pins break out the functionality of the Qwiic connectors. Depending on your application, you can connect to these pins via the plated through holes for SDA and SCL.

The two middle pins on the bottom edge of the front side of the board are SDA and SCL (in that order from left)The two middle pins on the bottom edge of the front side of the board are SDA and SCL (in that order from left)
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

INT and RST

The interrupt pin is the interrupt output and defaults to an open-drain output. A 47 kΩ pull-up resistor to IOVDD is included.

The reset pin is the I2C interface reset pin and is active high. It is pulled to ground with a 47 kΩ resistor.

Interrupt and Reset are the two pins on the far right on the bottom side of the front of the boardInterrupt and Reset are the two pins on the far left on the bottom side of the front of the board
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

LP, VDDIO, & VDDA

The pins in this section are specific to the 1"x1" board. LP is a low power enable pin. Drive this pin to logic 0 to disable the I2C comms to reduce power consumption. Drive this pin to logic 1 to enable I2C comms. This pin is typically only needed when you need to change the I2C address in multidevice systems. A 47 kΩ pull-up resistor to IOVDD is included so it can be left unconnected.

VDDIO/VDDA: These pins are used as an alternate power supply. By default, VDDIO and VDDA are tied together but by opening the PSU jumper they can be isolated. A user must then provide separate VDDIO and VDDA supplies. This is most applicable for users who want to use IO voltages (1.8, 2.8, or 3.3V) separate from AVDD voltages (2.8 or 3.3V) for maximum power reduction.

LP, VDDIO, and VDDA all live on the top side of the back of the board (in that order from left)

Jumpers

INT

Cut the INT jumper to remove the 47 kΩ pull-up resistor from the INT pin.

INT is the top right jumper on the back of the boardThe INT jumper is just to the right of middle on the back of the board
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

I2C

The SparkFun Qwiic ToF Imager Sensor has two 2.2 kΩ pull-up resistors attached to the I2C bus by default. If multiple sensors are connected to the bus with the pull-up resistors enabled the parallel equivalent resistance may create too strong of a pull-up for the bus to operate correctly. As a general rule of thumb, disable all but one pair of pull-up resistors if multiple devices are connected to the bus. If you need to disconnect the pull-up resistors they can be removed by cutting the traces on the corresponding jumper highlighted below.

The I2C Jumper is at the top left of the back of the boardThe I2C jumper is on the right side of the back of the board near the qwiic connector
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

PSU

This jumper is related to the pins specific to the 1" x 1" ToF board. By default, VDDIO and VDDA are tied together. Cutting the PSU jumper will isolate the power rails. A user must then provide separate VDDIO and VDDA supplies. This is most applicable for users who want to use IO voltages (1.8, 2.8, or 3.3V) separate from AVDD voltages (2.8 or 3.3V) for maximum power reduction.

The PSU is the left, bottom jumper

LED

If minimal power consumption is a concern, or you just don't want that Power LED on the front of the board to light up, go ahead and cut this jumper.

LED is the bottom right jumperThe LED jumper is on the back of the board to the left of the middle
Qwiic ToF Imager - VL53L5CXQwiic Mini ToF Imager - VL53L5CX

Board Outline

Qwiic ToF Imager - VL53L5CX

This sensor measures 1" x 1".

Board measures 1" x 1"

Click the image for a closer view

Qwiic Mini ToF Imager - VL53L5CX

This sensor measures 0.5" x 1".

Board measures 0.5" x 1"

Click the image for a closer view

Hardware Hookup

A note on choosing a board: The VL53L5CX is unique in that it requires its firmware to be loaded at power-on over the I2C bus. Because this firmware is ~90k bytes, we recommend a microcontroller with enough flash to store VL53L5CX's firmware as well as your program code. Sorry, Uno's are out. But didn't you want an excuse to try out something new? We recommend choosing either an Artemis Thing Plus or an ESP32 Thing Plus board as your development board.

Using the Qwiic system, assembling the hardware is simple. All you need to do is connect your VL53L5CX Imager Breakout to your chosen development board with a Qwiic cable or adapter cable. If Qwiic is not your thing, or if your dev board doesn't have one built in you can always solder directly to the I2C pins. If you are not using a Qwiic-enabled board, make sure your input voltage and logic are either running at 3.3V or you are shifting the logic level from whatever logic your controller runs at to 3.3V.


Qwiic ToF Imager - VL53L5CX

Artemis thing plus is connected to the ToF with a qwiic cable

Click the image for a closer view


Qwiic Mini ToF Imager - VL53L5CX

Artemis thing plus is connected to the ToF Mini with a qwiic cable

Click the image for a closer view
Before Use: Make sure to remove the vacuum tape from the VL53L5CX sensor before first use!

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.

We've written a simple Arduino library to quickly get started reading data from the Qwiic ToF Imager. Install the library through the Arduino Library Manager tool by searching for "SparkFun VL53L5CX". Users who prefer to manually install it can get the library from the GitHub Repository or download the ZIP by clicking the button below:


Example1_DistanceArray

Hook up your ToF imager to your Artemis Thing Plus via the Qwiic cables, and click "File>Examples>SparkFun VL53L5CX Arduino Library>Example1_DistanceArray".

Where to find the Examples in the arduino menu

We'll assume that you have selected the board (in this case the SparkFun Artemis Thing Plus) and the correct COM port at this point. If you have the code open, hit the upload button. Otherwise, copy and paste the following into the Arduino IDE, make sure to select the correct board and COM port, and then upload:

language:c
/*
  Read an 8x8 array of distances from the VL53L5CX
  By: Nathan Seidle
  SparkFun Electronics
  Date: October 26, 2021
  License: MIT. See license file for more information but you can
  basically do whatever you want with this code.

  This example shows how to read all 64 distance readings at once.

  Feel like supporting our work? Buy a board from SparkFun!
  https://www.sparkfun.com/products/18642

*/

#include <Wire.h>

#include <SparkFun_VL53L5CX_Library.h> //http://librarymanager/All#SparkFun_VL53L5CX

SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM

int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output

void setup()
{
  Serial.begin(115200);
  delay(1000);
  Serial.println("SparkFun VL53L5CX Imager Example");

  Wire.begin(); //This resets to 100kHz I2C

  Serial.println("Initializing sensor board. This can take up to 10s. Please wait.");
  if (myImager.begin() == false)
  {
    Serial.println(F("Sensor not found - check your wiring. Freezing"));
    while (1) ;
  }

  myImager.setResolution(8*8); //Enable all 64 pads

  imageResolution = myImager.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
  imageWidth = sqrt(imageResolution); //Calculate printing width

  myImager.startRanging();
}

void loop()
{
  //Poll sensor for new data
  if (myImager.isDataReady() == true)
  {
    if (myImager.getRangingData(&measurementData)) //Read distance data into array
    {
      //The ST library returns the data transposed from zone mapping shown in datasheet
      //Pretty-print data with increasing y, decreasing x to reflect reality
      for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
      {
        for (int x = imageWidth - 1 ; x >= 0 ; x--)
        {
          Serial.print("\t");
          Serial.print(measurementData.distance_mm[x + y]);
        }
        Serial.println();
      }
      Serial.println();
    }
  }

  delay(5); //Small delay between polling
}


Open up your Serial Monitor, make sure the baud rate is set appropriately, and you should see something like the following:

Serial Monitor output

Click the image for a closer view

Example2_FastStartup

Hook up your ToF imager to your Artemis Thing Plus via the Qwiic cables, and click "File>Examples>SparkFun VL53L5CX Arduino Library>Example2_FastStartup".

Where to find the Examples in the arduino menu

We'll assume that you have selected the board (in this case the SparkFun Artemis Thing Plus) and the correct COM port at this point. If you have the code open, hit the upload button. Otherwise, copy and paste the following into the Arduino IDE, make sure to select the correct board and COM port, and then upload:

language:c
/*
  Read an 8x8 array of distances from the VL53L5CX
  By: Nathan Seidle
  SparkFun Electronics
  Date: October 26, 2021
  License: MIT. See license file for more information but you can
  basically do whatever you want with this code.

  This example shows how to setup the I2C bus to minimize the amount
  of time taken to init the sensor.

  At each power on reset, a staggering 86,000 bytes of firmware have to be sent to the sensor.
  At 100kHz, this can take ~9.4s. By increasing the clock speed, we can cut this time down to ~1.4s.

  Two parameters can be tweaked: 

    Clock speed: The VL53L5CX has a max bus speed of 400kHz but we have had success up to 1MHz.

    Max transfer size: The majority of Arduino platforms default to 32 bytes. If you are using one 
    with a larger buffer (ESP32 is 128 bytes for example), this can help decrease transfer times a bit.

  Measurements:
    Default 100kHz clock and 32 byte transfer: 9.4s
    400kHz, 32 byte transfer: 2.8s
    400kHz, 128 byte transfer: 2.5s
    1MHz, 32 byte transfer: 1.65s
    1MHz, 128 byte transfer: 1.4s

  Feel like supporting our work? Buy a board from SparkFun!
  https://www.sparkfun.com/products/18642

*/

#include <Wire.h>

#include <SparkFun_VL53L5CX_Library.h> //http://librarymanager/All#SparkFun_VL53L5CX

SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM

int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output

void setup()
{
  Serial.begin(115200);
  delay(1000);
  Serial.println("SparkFun VL53L5CX Imager Example");

  Wire.begin(); //This resets I2C bus to 100kHz
  Wire.setClock(400000); //Sensor has max I2C freq of 400kHz 
  //Wire.setClock(1000000); //Run sensor out of spec

  //myImager.setWireMaxPacketSize(128); //Increase default from 32 bytes to 128 - not supported on all platforms

  Serial.println("Initializing sensor board. This can take up to 10s. Please wait.");

  //Time how long it takes to transfer firmware to sensor
  long startTime = millis();
  bool startup = myImager.begin();
  long stopTime = millis();

  if (startup == false)
  {
    Serial.println(F("Sensor not found - check your wiring. Freezing"));
    while (1) ;
  }

  Serial.print("Firmware transfer time: ");
  float timeTaken = (stopTime - startTime) / 1000.0;
  Serial.print(timeTaken, 3);
  Serial.println("s");

  myImager.setResolution(8*8); //Enable all 64 pads

  imageResolution = myImager.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
  imageWidth = sqrt(imageResolution); //Calculate printing width

  myImager.startRanging();
}

void loop()
{
  //Poll sensor for new data
  if (myImager.isDataReady() == true)
  {
    if (myImager.getRangingData(&measurementData)) //Read distance data into array
    {
      //The ST library returns the data transposed from zone mapping shown in datasheet
      //Pretty-print data with increasing y, decreasing x to reflect reality
      for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
      {
        for (int x = imageWidth - 1 ; x >= 0 ; x--)
        {
          Serial.print("\t");
          Serial.print(measurementData.distance_mm[x + y]);
        }
        Serial.println();
      }
      Serial.println();
    }
  }

  delay(5); //Small delay between polling
}


Open up your Serial Monitor, make sure the baud rate is set appropriately, and you should see something like the following:

Serial Monitor output

Click the image for a closer view

Example3_SetFrequency

Hook up your ToF imager to your Artemis Thing Plus via the Qwiic cables, and click "File>Examples>SparkFun VL53L5CX Arduino Library>Example3_SetFrequency".

Where to find the Examples in the arduino menu

We'll assume that you have selected the board (in this case the SparkFun Artemis Thing Plus) and the correct COM port at this point. If you have the code open, hit the upload button. Otherwise, copy and paste the following into the Arduino IDE, make sure to select the correct board and COM port, and then upload:

language:c
/*
  Read an 8x8 array of distances from the VL53L5CX
  By: Nathan Seidle
  SparkFun Electronics
  Date: October 26, 2021
  License: MIT. See license file for more information but you can
  basically do whatever you want with this code.

  This example shows how to increase output frequency.

  Default is 1Hz.
  Using 4x4, min frequency is 1Hz and max is 60Hz
  Using 8x8, min frequency is 1Hz and max is 15Hz

  Feel like supporting our work? Buy a board from SparkFun!
  https://www.sparkfun.com/products/18642

*/

#include <Wire.h>

#include <SparkFun_VL53L5CX_Library.h> //http://librarymanager/All#SparkFun_VL53L5CX

SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM

int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output

void setup()
{
  Serial.begin(115200);
  delay(1000);
  Serial.println("SparkFun VL53L5CX Imager Example");

  Wire.begin(); //This resets I2C bus to 100kHz
  Wire.setClock(400000); //Sensor has max I2C freq of 400kHz

  Serial.println("Initializing sensor board. This can take up to 10s. Please wait.");
  if (myImager.begin() == false)
  {
    Serial.println(F("Sensor not found - check your wiring. Freezing"));
    while (1) ;
  }

  myImager.setResolution(8 * 8); //Enable all 64 pads

  imageResolution = myImager.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
  imageWidth = sqrt(imageResolution); //Calculate printing width

  //Using 4x4, min frequency is 1Hz and max is 60Hz
  //Using 8x8, min frequency is 1Hz and max is 15Hz
  bool response = myImager.setRangingFrequency(15);
  if (response == true)
  {
    int frequency = myImager.getRangingFrequency();
    if (frequency > 0)
    {
      Serial.print("Ranging frequency set to ");
      Serial.print(frequency);
      Serial.println(" Hz.");
    }
    else
      Serial.println(F("Error recovering ranging frequency."));
  }
  else
  {
    Serial.println(F("Cannot set ranging frequency requested. Freezing..."));
    while (1) ;
  }

  myImager.startRanging();
}

void loop()
{
  //Poll sensor for new data
  if (myImager.isDataReady() == true)
  {
    if (myImager.getRangingData(&measurementData)) //Read distance data into array
    {
      //The ST library returns the data transposed from zone mapping shown in datasheet
      //Pretty-print data with increasing y, decreasing x to reflect reality
      for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
      {
        for (int x = imageWidth - 1 ; x >= 0 ; x--)
        {
          Serial.print("\t");
          Serial.print(measurementData.distance_mm[x + y]);
        }
        Serial.println();
      }
      Serial.println();
    }
  }

  delay(5); //Small delay between polling
}


Open up your Serial Monitor, make sure the baud rate is set appropriately, and you should see something like the following:

Serial Monitor output

Click the image for a closer view

Visualizing the Output

To ‘see’ the output, Example4_MaxOutput can be used with the SparkFun Processing visualization app.

Hook up your ToF imager to your Artemis Thing Plus via the Qwiic cables, and click "File>Examples>SparkFun VL53L5CX Arduino Library>Example4_MaxOutput".

Where to find the Examples in the arduino menu

Load this sketch onto your platform and open the serial monitor. You should see the distance array output in CSV format.

Next, download the Processing sketch here and unzip it into a directory you can locate. If you don’t have it installed, download and unzip Processing into a directory of your choice. Open the SparkFun VL53L5CX 3D Depth Map sketch and modify the following line to match your COM port:

Modify this line to connect Processing to the sensor

Modify this line to connect Processing to the sensor

Once connected you should see output like this:

Visualizing the distances

Visualizing the distances

Our apologies if you suddenly realize an hour has gone by and you’ve done nothing but wave your hand in front of the sensor and looked at things like coffee cups from a meter away. It’s really a lot of fun. Enjoy!

Troubleshooting

Resources and Going Further

Now that you've successfully got your Qwiic ToF sensor up and running, it's time to incorporate it into your own project!

For more information, check out the resources below:

Qwiic ToF Imager - VL53L5CX:

Qwiic Mini ToF Imager - VL53L5CX:

VL53L5CX Module:

Need some inspiration for your next project? Check out some of these related tutorials:

AVR-Based Serial Enabled LCDs Hookup Guide

The AVR-based Qwiic Serial Enabled LCDs are a simple and cost effective solution to include in your project. These screens are based on the HD44780 controller, and include ATmega328P with an Arduino compatible bootloader. They accept control commands via Serial, SPI and I2C (via PTH headers or Qwiic connector). In this tutorial, we will show examples of a simple setup and go through each communication option.

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.

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.

SparkFun GPS Dead Reckoning NEO-M8U Hookup Guide

The u-blox NEO-M8U is a powerful GPS units that takes advantage of untethered dead reckoning (UDR) technology for navigation. The module provides continuous positioning for vehicles in urban environments and during complete signal loss (e.g. short tunnels and parking garages). We will quickly get you set up using the Qwiic ecosystem and Arduino so that you can start reading the output!

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

Qwiic Distance Sensor (VL53L1X, VL53L4CD) Hookup Guide

$
0
0

Qwiic Distance Sensor (VL53L1X, VL53L4CD) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction


The VL53L1X and VL53L4CD are Time Of Flight (ToF) sensors. Both uses a VCSEL (vertical cavity surface emitting laser) to emit a class 1 IR laser (940 nm) and time the reflection to the target. (You can’t see the laser but cell phones can) What does all this mean? You can measure the distance to an object up to 4 meters away with millimeter resolution using the VL53L1X and up to 1.3 meters away with 1 millimeter resolution using the VL53L4CD! That’s pretty incredible.

SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic)

SparkFun Distance Sensor Breakout - 4 Meter, VL53L1X (Qwiic)

SEN-14722
$14.95
10
SparkFun Distance Sensor - 1.3 Meter, VL53L4CD (Qwiic)

SparkFun Distance Sensor - 1.3 Meter, VL53L4CD (Qwiic)

SEN-18993
$19.95

We’ve found the precision of the VL53L1X sensor to be 1mm but the accuracy is around ±5mm. The minimum read distance of this sensor is 4cm (or 40mm). For the VL53L4CD sensor, we've to also found the precision to be 1mm but the accuracy is around ±7mm. The minimum read distance of this sensor is 1cm (or 10mm). In this hookup guide, we'll go over how to read distance, change ranging modes, and check the status of our range measurement along with the sample rate. We'll also check out how to display distance and speed over an LCD display.

Required Materials

The Qwiic Distance Sensor does need a few additional items for you to get started. The RedBoard Plus is for the Arduino examples and the Qwiic SHIM is for the Raspberry Pi example (see note below). You may already have a few of these items, 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
13
SparkFun RedBoard Plus

SparkFun RedBoard Plus

DEV-18158
$19.95
1
SparkFun Qwiic SHIM for Raspberry Pi

SparkFun Qwiic SHIM for Raspberry Pi

DEV-15794
$0.95
10
Qwiic compatible microcontrollers:
SparkFun Thing Plus - ESP32 WROOM

SparkFun Thing Plus - ESP32 WROOM

WRL-15663
$20.95
8
SparkFun RedBoard Plus

SparkFun RedBoard Plus

DEV-18158
$19.95
1
SparkFun RedBoard Turbo - SAMD21 Development Board

SparkFun RedBoard Turbo - SAMD21 Development Board

DEV-14812
$24.95
6
SparkFun Thing Plus - SAMD51

SparkFun Thing Plus - SAMD51

DEV-14713
$19.95
2
In addition we also offer, Qwiic compatible stackable shields for microcontrollers and pHATs for single board computers (like the Raspberry Pi boards) that don't include a Qwiic connector.
SparkFun Qwiic 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 Photon

SparkFun Qwiic Shield for Photon

DEV-14477
$6.50
SparkFun Qwiic HAT for Raspberry Pi

SparkFun Qwiic HAT for Raspberry Pi

DEV-14459
$6.50
4
SparkFun Qwiic pHAT v2.0 for Raspberry Pi

SparkFun Qwiic pHAT v2.0 for Raspberry Pi

DEV-15945
$6.95
2
SparkFun Qwiic SHIM for Raspberry Pi

SparkFun Qwiic SHIM for Raspberry Pi

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

SparkFun Servo pHAT for Raspberry Pi

DEV-15316
$11.95
4
You will also need a Qwiic cable to connect to your Qwiic Distance Sensor, choose a length that suits your needs.
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

Raspberry Pi Example: If you don't already have them, you will need a Raspberry Pi and standard peripherals. An example setup is listed below. (The Qwiic Distance Sensor and Python library have not been tested on the newly released Raspberry Pi 4 because we don't carry it in out catalog yet.)

Suggested Reading

If you're unfamiliar with jumper pads, I2C, Qwiic, or Python be sure to checkout some of these foundational tutorials.

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.

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.

Raspberry Pi SPI and I2C Tutorial

Learn how to use serial I2C and SPI buses on your Raspberry Pi using the wiringPi I/O library for C/C++ and spidev/smbus for Python.

Raspberry Pi 3 Starter Kit Hookup Guide

Guide for getting going with the Raspberry Pi 3 Model B and Raspberry Pi 3 Model B+ starter kit.

Python Programming Tutorial: Getting Started with the Raspberry Pi

This guide will show you how to write programs on your Raspberry Pi using Python to control hardware.

Qwiic pHAT for Raspberry Pi Hookup Guide

Get started interfacing your Qwiic enabled boards with your Raspberry Pi. The Qwiic pHAT connects the I2C bus (GND, 3.3V, SDA, and SCL) on your Raspberry Pi to an array of Qwiic connectors.

Qwiic Shield for Arduino & Photon Hookup Guide

Get started with our Qwiic ecosystem with the Qwiic shield for Arduino or Photon.

RedBoard Plus Hookup Guide

This tutorial covers the basic functionality of the RedBoard Plus. This tutorial also covers how to get started blinking an LED and using the Qwiic system.

Qwiic Connect System

The Qwiic Distance Sensor is intended for the Qwiic connect system. We recommend familiarizing yourself with the Logic Levels and I2C tutorials before using it. Click on the banner above to learn more about our Qwiic products.

Hardware Overview

First, let's check out some of the characteristics of the VL53L1X and VL53L4CD we're dealing with, so we know what to expect out of the board. Below is a comparison table for both sensors taken from the datasheet.

CharacteristicVL53L1XVL53L4CD
Operating Voltage2.6V to 3.5V
Power Consumption20 mW @10Hz-
Current Consumption18mA24mA
Measurement Range~40mm to 4,000mm1mm to 1300mm
Resolution±1mm
Light SourceClass 1 940nm VCSEL
I2C Address0x29
Field of View15&deg to 27&deg18&deg
Max Read Rate50Hz100Hz

Pins

The following table lists all of the VL53L1X and VL53L4CD's pins and their functionality.

VL53L1XVL53L4CD
  VL53L1X VL53L4CD
PinDescriptionDirection
GNDGroundIn
3.3VPowerIn
SDADataIn
SCLClockIn
INTInterrupt, goes low when data is ready.Out
SHUTShutdown, can be pulled low to put the IC in shutdown mode.In

Qwiic and I2C

Both breakout boards include 2x Qwiic connectors to easily access the I2C data lines and power. The Qwiic ecosystem is made for fast prototyping by removing the need for soldering. All you need to do is plug a Qwiic cable into the Qwiic connector and voila! Of course, you can still solder header pins or wires to the PTHs. The I2C address for each sensor is 0x29 (7-bit unshifted) as stated earlier. You may notice that the datasheet and library use 0x52, which is the address shifted.

VL53L1X Qwiic Connector and I2C PinsVL53L4CD  Qwiic Connector and I2C Pins
  VL53L1X VL53L4CD

LED

The onboard power LED (PWR) will light up when the board is powered. Exclusively for the VL53L4CD, this can be disabled by cutting the jumper labeled as LED on the back of the board.

VL53L1X JumpersVL53L4CD Power LED
  VL53L1X VL53L4CD

Jumpers

The VL53L1X and VL53L4CD breakout boards include jumpers on the back of the board. If you need to disconnect any of the jumpers, they can be removed by cutting the traces on the corresponding jumpers highlighted below.

  • I2C - By default, this 3-way jumper is closed by default. The pull-up resistors attached to the I2C bus; if multiple sensors are connected to the bus with the pull-up resistors enabled, the parallel equivalent resistance will create too strong of a pull-up for the bus to operate correctly. As a general rule of thumb, disable all but one pair of pull-up resistors if multiple devices are connected to the bus.
  • INT - By default, this jumper is closed by default. As stated earlier, this connects to the PTH and goes low when data is ready.
  • LED - Exclusive to the VL53L4CD, this jumper is closed by default. Cutting this jumper will disable the PWR LED.
VL53L1X JumpersVL53L4CD Jumpers
  VL53L1X VL53L4CD

Hardware Assembly

Arduino Examples

If you haven't yet assembled your Qwiic Shield, now would be the time to head on over to that tutorial. Depending on the microcontroller and shield you've chosen, your assembly may be different, but here's a handy link to the Qwiic Shield for Arduino and Photon Hookup Guide to get you started!

With the shield assembled, SparkFun's new Qwiic environment means that connecting the sensor could not be easier. Just plug one end of the Qwiic cable into the VL53L1X breakout, the other into the Qwiic Shield and you'll be ready to upload a sketch and figure out how far away you are from that thing over there. It seems like it's too easy too use, but that's why we made it that way!

Connected to Qwiic Shield

SparkFun RedBoard and Qwiic Shield with the Qwiic Distance Sensor Attached

Raspberry Pi Examples

Note: Update in progress for Python Examples...

Arduino Library Overview

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.

First, you'll need the SparkFun VL53L1X Arduino library, which is an easy to use wrapper of ST's driver. 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:

Before we get started developing a sketch, let's look at the available functions of the library.

  • boolean init(); --- Initialize the sensor
  • void startRanging(); --- Starts taking measurements.
  • void stopRanging(); --- Stops taking measurements.
  • bool checkForDataReady(); --- Checks if a measurement is ready.
  • void setTimingBudgetInMs(uint16_t timingBudget) --- Set the timing budget for a measurement in ms. The timing budget is the amount of time over which a measurement is taken. This can be set to any of the following.
    • 15
    • 20
    • 33
    • 50
    • 100 (default)
    • 200
    • 500
  • uint16_t getTimingBudgetInMs(); --- Get's the current timing budget in ms.
  • void setDistanceModeLong(); --- Sets to 4M range.
  • void setDistanceModeShort(); --- Sets to 1.3M range
  • uint8_t getDistanceMode(); --- Returns 1 for short range, 2 for long range.
  • void setIntermeasurementPeriod(uint16_t intermeasurement); --- Set's the period in between measurements. Must be greater than or equal to the timing budget. Default is 100 ms.
  • uint16_t getIntermeasurementPeriod(); --- Returns the intermeasurement period in ms.
  • bool checkBootState(); --- Checks whether the device has been booted. Returns true if the device has been booted.
  • uint16_t getSensorID(); --- Get the sensor ID, should be 0xEEAC.
  • uint16_t getDistance(); --- Returns the results from the last measurement, distance in mm
  • uint16_t getSignalPerSpad(); --- Returns the average signal rate per SPAD (The sensitive pads that detect light, the VL53L1X has a 16x16 array of these) in kcps/SPAD, or kilo counts per second per SPAD.
  • uint16_t getAmbientPerSpad(); --- Returns the ambient noise when not measuring a signal in kcps/SPAD.
  • uint16_t getSignalRate(); --- Returns the signal rate in kcps. All SPADs combined.
  • uint16_t getSpadNb(); --- Returns the current number of enabled SPADs
  • uint16_t getAmbientRate(); --- Returns the total ambinet rate in kcps. All SPADs combined.
  • uint8_t getRangeStatus(); --- Returns the range status, which can be any of the following.
    • 0: No error
    • 1: Signal fail
    • 2: Sigma fail
    • 7: Wrapped target fail
  • void setOffset(int16_t offset); --- Manually set an offset for a measurement in mm.
  • int16_t getOffset(); --- Get the current offset in mm.
  • void setXTalk(uint16_t xTalk); --- Manually set the value of crosstalk in counts per second (cps), which is interference from any sort of window in front of your sensor.
  • uint16_t getXTalk(); --- Returns the current crosstalk value in cps.
  • void setDistanceThreshold(uint16_t lowThresh, uint16_t hiThresh, uint8_t window); --- Set bounds for the interrupt. lowThresh and hiThresh are the bounds of your interrupt while window decides when the interrupt should fire. The options for window are shown below.
    • 0: Interrupt triggered on measured distance below lowThresh.
    • 1: Interrupt triggered on measured distance above hiThresh.
    • 2: Interrupt triggered on measured distance outside of bounds.
    • 3: Interrupt triggered on measured distance inside of bounds.
  • uint16_t getDistanceThresholdWindow(); --- Returns distance threshold window option.
  • uint16_t getDistanceThresholdLow(); --- Returns lower bound in mm.
  • uint16_t getDistanceThresholdHigh(); --- Returns upper bound in mm
  • void setROI(uint16_t x, uint16_t y, uint8_t opticalCenter); --- Set the height and width of the ROI in SPADs, lowest possible option is 4. The center of the ROI you set is based on the table below. Set the opticalCenter as the pad above and to the right of your exact center.
128136144152160168176184192200208216224232240248
129137145153161169177185193201209217225233241249
130138146154162170178186194202210218226234242250
131139147155163171179187195203211219227235243251
132140148156164172180188196204212220228236244252
133141149157165173181189197205213221229237245253
134142150158166174182190198206214222230238246254
135143151159167175183191199207215223231239247255
12711911110395877971635547393123157
12611811010294867870625446383022146
12511710910193857769615345372921135
12411610810092847668605244362820124
1231151079991837567595143352719113
1221141069890827466585042342618102
121113105978981736557494133251791
120112104968880726456484032241680
  • uint16_t getROIX(); --- Returns the width of the ROI in SPADs
  • uint16_t getROIY(); --- Returns the height of the ROI in SPADs
  • void setSignalThreshold(uint16_t signalThreshold); --- Programs the necessary threshold to trigger a measurement. Default is 1024 kcps.
  • uint16_t getSignalThreshold(); --- Returns the signal threshold in kcps
  • void setSigmaThreshold(uint16_t sigmaThreshold); --- Programs a new sigma threshold in mm. (default=15 mm)
  • uint16_t getSigmaThreshold(); --- Returns the current sigma threshold.
  • void startTemperatureUpdate(); --- Recalibrates the sensor for temperature changes. Run this any time the temperature has changed by more than 8°C
  • void calibrateOffset(uint16_t targetDistanceInMm); --- Autocalibrate the offset by placing a target a known distance away from the sensor and passing this known distance into the function.
  • void calibrateXTalk(uint16_t targetDistanceInMm); --- Autocalibrate the crosstalk by placing a target a known distance away from the sensor and passing this known distance into the function.

Arduino Example Code

Now that we have our library installed and we understand the basic functions, let's run some examples for our distance sensor to see how it behaves.

Example 1 - Read Distance

To get started with the first 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 and is repeated in some form in all of the examples.

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

Example 2 - Set Distance Mode

In this example, we'll change the distance mode of the VL53L1X. The default long range mode is the most robust as far as sample rate and range are concerned, but for a slightly higher sample rate, you can bring the range down to short (~1.3M). To get started with the second example, open up File>Examples>SparkFun VL53L1x 4M Laser Distance Sensor>Example2_SetDistanceMode. The main difference between this example and the previous example is that we call distanceSensor.setDistanceModeShort to change the range of our sensor to short range. Although this feature is available, we'd recommend sticking with long range as it is the most robust.

Example 3 - Status and Rate

In the third example, we'll read and average our distance as well as read the sample rate and status of each measurement. To get started with the third example, open up File>Examples>SparkFun VL53L1x 4M Laser Distance Sensor>ExampleStatusandRate. The status of a measurement can be any of 8 values. Our void loop() interprets the value returned by distanceSensor.getRangeStatus() and prints that value over serial. The below table shows the possible values of rangeStatus and their corresponding errors.

Range StatusError
0Valid measurement
1Raised if sigma estimator (uncertainty in measurement) check is above the internal defined threshold
2 Raised if signal value is below the internal defined threshold
4Raised when phase is out of bounds
5Raised in case of HW or VCSEL failure
7Wrapped target, not matching phases
8Internal algorithm underflow or overflow
14The reported range is invalid

In the example code, notice how the sketch stores our previous values in the array history so that the average distance can also be calculated. Uploading this sketch to your microcontroller and opening the serial monitor to a baud rate of 9600 should give you an output similar to the image shown below.

Status and Rate

Click the image for a closer look.

Example 4 - Set Intermeasurement Period

The fourth example allows you to change the time alotted for a measurement. The VL53L1X will send out a laser pulse and then listen for the alotted time. We'd recommend 20, 33, and 100 ms for short, medium and long distance modes respectively. To open up the example, head to File >Examples>SparkFun VL53L1x 4M Laser Distance Sensor>Example4_SetIntermeasurementPeriod. There's not much that needs to be done to change the intermeasurement period other than a call to distanceSensor.setIntermeasurementPeriod(33) to change the time alotted time for a measurement to 33 ms. This will give us a data rate of roughly 30 Hz, lengthening the intermeasurement period will give us a lower sample rate, but will yield higher accuracy at longer ranges. Opening the serial monitor should yield an output similar to example 1.

Example 5 - LCD Demo

The fifth example requires a serial enabled LCD screen for us to write our distance values to. If you haven't played around with a Serial enabled LCD before, checkout our hookup guide on the matter. To get started with the fourth example, open up File >Examples>SparkFun VL53L1x 4M Laser Distance Sensor>Example5_LCDDemo. We'll first need to connect the RX pin of our Serial LCD to pin A3 on our Arduino. Connect 5V and ground on the LCD and the backlight should light up. Notice how we also include the SoftwareSerial library. Uploading the sketch to our Arduino then takes in our sample rate and distances. By using these values, it calculates a velocity. Like the sketch before, distances are stored in an array. The sketch uses these values in the array to calculate velocity and the velocity is then displayed along with the current distance on the LCD. The output on the LCD should look something like the below GIF.

LCD Distance Display

Python Package Overview

Note: This sensor and the Python package have not been tested on the newly released Raspberry Pi 4.

Update: This package has been updated to version 1.0.1 (released 1-20-2020), which is not backwards compatible with the previous packages. The package still retains the same functionality as version 0.9.4; however, most of the methods have been renamed to conform to the more "Pythonic" naming conventions (i.e. not camel case). For more details, check out the commit history in the GitHub repository.

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

We've written a Python package to easily get setup and take readings from the Qwiic Distance Sensor. However, before we jump into getting data from the sensor, let's take a closer look at the available functions in the Python package. You can install the sparkfun-qwiic-vl53l1x Python package hosted by PyPi. However, if you prefer to manually download and build the libraries from the GitHub repository, you can grab them here (*Please be aware of any package dependencies. You can also check out the repository documentation page, hosted on Read the Docs.):

Installation

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

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-vl53l1x 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-vl53l1x

For the current user:

language:bash
pip3 install sparkfun-qwiic-vl53l1x

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

Python Package Operation

Below is a description of the basic functionality of the Python package. This includes the package organization, built-in methods, and their inputs and/or outputs. For more details on how the Python package works, check out the source code, sensor datasheet, and API user manual.

Dependencies

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

language:python
import time                         # Time access and conversion package
import math                         # Basic math package
import qwiic_i2c                    # I2C bus driver package

Default Variables

The default variables, in the code, for this Python package are listed below:

language:python
# From vL53l1x_class.h Header File
###############################################################################
###############################################################################
SOFT_RESET =                                                            0x0000
VL53L1_I2C_SLAVE__DEVICE_ADDRESS =                                      0x0001
VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND =                          0x0008
ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS =                        0x0016
ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS =                    0x0018
ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS =                    0x001A
ALGO__PART_TO_PART_RANGE_OFFSET_MM =                                    0x001E
MM_CONFIG__INNER_OFFSET_MM =                                            0x0020
MM_CONFIG__OUTER_OFFSET_MM =                                            0x0022
GPIO_HV_MUX__CTRL =                                                     0x0030
GPIO__TIO_HV_STATUS =                                                   0x0031
SYSTEM__INTERRUPT_CONFIG_GPIO =                                         0x0046
PHASECAL_CONFIG__TIMEOUT_MACROP =                                       0x004B
RANGE_CONFIG__TIMEOUT_MACROP_A_HI =                                     0x005E
RANGE_CONFIG__VCSEL_PERIOD_A =                                          0x0060
RANGE_CONFIG__VCSEL_PERIOD_B =                                          0x0063
RANGE_CONFIG__TIMEOUT_MACROP_B_HI =                                     0x0061
RANGE_CONFIG__TIMEOUT_MACROP_B_LO =                                     0x0062
RANGE_CONFIG__SIGMA_THRESH =                                            0x0064
RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS =                           0x0066
RANGE_CONFIG__VALID_PHASE_HIGH =                                        0x0069
VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD =                                0x006C
SYSTEM__THRESH_HIGH =                                                   0x0072
SYSTEM__THRESH_LOW =                                                    0x0074
SD_CONFIG__WOI_SD0 =                                                    0x0078
SD_CONFIG__INITIAL_PHASE_SD0 =                                          0x007A
ROI_CONFIG__USER_ROI_CENTRE_SPAD =                                      0x007F
ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE =                         0x0080
SYSTEM__SEQUENCE_CONFIG =                                               0x0081
VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD =                                 0x0082
SYSTEM__INTERRUPT_CLEAR =                                               0x0086
SYSTEM__MODE_START =                                                    0x0087
VL53L1_RESULT__RANGE_STATUS =                                           0x0089
VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 =                         0x008C
RESULT__AMBIENT_COUNT_RATE_MCPS_SD =                                    0x0090
VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 =                 0x0096
VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 =    0x0098
VL53L1_RESULT__OSC_CALIBRATE_VAL =                                      0x00DE
VL53L1_FIRMWARE__SYSTEM_STATUS =                                        0x00E5
VL53L1_IDENTIFICATION__MODEL_ID =                                       0x010F
VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD =                               0x013E

_VL53L1X_DEFAULT_DEVICE_ADDRESS =                                       0x52
###############################################################################
###############################################################################

_DEFAULT_NAME = "Qwiic 4m Distance Sensor (ToF)"

###############################################################################
###############################################################################
_FULL_ADDRESS_LIST = list(range(0x08,0x77+1))                   # Full I2C Address List (excluding resrved addresses)
_FULL_ADDRESS_LIST.remove(_VL53L1X_DEFAULT_DEVICE_ADDRESS >> 1) # Remove Default Address of VL53L1X from list
_AVAILABLE_I2C_ADDRESS = [_VL53L1X_DEFAULT_DEVICE_ADDRESS >> 1] # Initialize with Default Address of VL53L1X
_AVAILABLE_I2C_ADDRESS.extend(_FULL_ADDRESS_LIST)               # Add Full Range of I2C Addresses


# From vL53l1x_class.cpp C++ File
###############################################################################
###############################################################################
ALGO__PART_TO_PART_RANGE_OFFSET_MM =                                    0x001E
MM_CONFIG__INNER_OFFSET_MM =                                            0x0020
MM_CONFIG__OUTER_OFFSET_MM =                                            0x0022

# DEBUG_MODE

VL51L1X_DEFAULT_CONFIGURATION = [
0x00,   # 0x2d : set bit 2 and 5 to 1 for fast plus mode (1MHz I2C), else don't touch
0x01,   # 0x2e : bit 0 if I2C pulled up at 1.8V, else set bit 0 to 1 (pull up at AVDD)
0x01,   # 0x2f : bit 0 if GPIO pulled up at 1.8V, else set bit 0 to 1 (pull up at AVDD)
0x01,   # 0x30 : set bit 4 to 0 for active high interrupt and 1 for active low (bits 3:0 must be 0x1), use SetInterruptPolarity()
0x02,   # 0x31 : bit 1 = interrupt depending on the polarity, use CheckForDataReady()
0x00,   # 0x32 : not user-modifiable
0x02,   # 0x33 : not user-modifiable
0x08,   # 0x34 : not user-modifiable
0x00,   # 0x35 : not user-modifiable
0x08,   # 0x36 : not user-modifiable
0x10,   # 0x37 : not user-modifiable
0x01,   # 0x38 : not user-modifiable
0x01,   # 0x39 : not user-modifiable
0x00,   # 0x3a : not user-modifiable
0x00,   # 0x3b : not user-modifiable
0x00,   # 0x3c : not user-modifiable
0x00,   # 0x3d : not user-modifiable
0xff,   # 0x3e : not user-modifiable
0x00,   # 0x3f : not user-modifiable
0x0F,   # 0x40 : not user-modifiable
0x00,   # 0x41 : not user-modifiable
0x00,   # 0x42 : not user-modifiable
0x00,   # 0x43 : not user-modifiable
0x00,   # 0x44 : not user-modifiable
0x00,   # 0x45 : not user-modifiable
0x20,   # 0x46 : interrupt configuration 0->level low detection, 1-> level high, 2-> Out of window, 3->In window, 0x20-> New sample ready , TBC
0x0b,   # 0x47 : not user-modifiable
0x00,   # 0x48 : not user-modifiable
0x00,   # 0x49 : not user-modifiable
0x02,   # 0x4a : not user-modifiable
0x0a,   # 0x4b : not user-modifiable
0x21,   # 0x4c : not user-modifiable
0x00,   # 0x4d : not user-modifiable
0x00,   # 0x4e : not user-modifiable
0x05,   # 0x4f : not user-modifiable
0x00,   # 0x50 : not user-modifiable
0x00,   # 0x51 : not user-modifiable
0x00,   # 0x52 : not user-modifiable
0x00,   # 0x53 : not user-modifiable
0xc8,   # 0x54 : not user-modifiable
0x00,   # 0x55 : not user-modifiable
0x00,   # 0x56 : not user-modifiable
0x38,   # 0x57 : not user-modifiable
0xff,   # 0x58 : not user-modifiable
0x01,   # 0x59 : not user-modifiable
0x00,   # 0x5a : not user-modifiable
0x08,   # 0x5b : not user-modifiable
0x00,   # 0x5c : not user-modifiable
0x00,   # 0x5d : not user-modifiable
0x01,   # 0x5e : not user-modifiable
0xdb,   # 0x5f : not user-modifiable
0x0f,   # 0x60 : not user-modifiable
0x01,   # 0x61 : not user-modifiable
0xf1,   # 0x62 : not user-modifiable
0x0d,   # 0x63 : not user-modifiable
0x01,   # 0x64 : Sigma threshold MSB (mm in 14.2 format for MSB+LSB), use SetSigmaThreshold(), default value 90 mm 
0x68,   # 0x65 : Sigma threshold LSB
0x00,   # 0x66 : Min count Rate MSB (MCPS in 9.7 format for MSB+LSB), use SetSignalThreshold()
0x80,   # 0x67 : Min count Rate LSB
0x08,   # 0x68 : not user-modifiable
0xb8,   # 0x69 : not user-modifiable
0x00,   # 0x6a : not user-modifiable
0x00,   # 0x6b : not user-modifiable
0x00,   # 0x6c : Intermeasurement period MSB, 32 bits register, use SetIntermeasurementInMs()
0x00,   # 0x6d : Intermeasurement period
0x0f,   # 0x6e : Intermeasurement period
0x89,   # 0x6f : Intermeasurement period LSB
0x00,   # 0x70 : not user-modifiable
0x00,   # 0x71 : not user-modifiable
0x00,   # 0x72 : distance threshold high MSB (in mm, MSB+LSB), use SetD:tanceThreshold()
0x00,   # 0x73 : distance threshold high LSB
0x00,   # 0x74 : distance threshold low MSB ( in mm, MSB+LSB), use SetD:tanceThreshold()
0x00,   # 0x75 : distance threshold low LSB
0x00,   # 0x76 : not user-modifiable
0x01,   # 0x77 : not user-modifiable
0x0f,   # 0x78 : not user-modifiable
0x0d,   # 0x79 : not user-modifiable
0x0e,   # 0x7a : not user-modifiable
0x0e,   # 0x7b : not user-modifiable
0x00,   # 0x7c : not user-modifiable
0x00,   # 0x7d : not user-modifiable
0x02,   # 0x7e : not user-modifiable
0xc7,   # 0x7f : ROI center, use SetROI()
0xff,   # 0x80 : XY ROI (X=Width, Y=Height), use SetROI()
0x9B,   # 0x81 : not user-modifiable
0x00,   # 0x82 : not user-modifiable
0x00,   # 0x83 : not user-modifiable
0x00,   # 0x84 : not user-modifiable
0x01,   # 0x85 : not user-modifiable
0x00,   # 0x86 : clear interrupt, use ClearInterrupt()
0x00    # 0x87 : start ranging, use StartRanging() or StopRanging(), If you want an automatic start after self.init() call, put 0x40 in location 0x87
]
###############################################################################
###############################################################################


# From vL53l1_error_codes.h Header File
###############################################################################
###############################################################################
# @brief Error Code definitions for VL53L1 API.
#=======================================================================
# PRIVATE define do not edit
#=======================================================================

# @defgroup VL53L1_define_Error_group Error and Warning code returned by API
# The following DEFINE are used to identify the PAL ERROR

VL53L1_ERROR_NONE =                                                           0
VL53L1_ERROR_CALIBRATION_WARNING =                                           -1
# """Warning invalid calibration data may be in used
#   \a VL53L1_InitData()
#   \a VL53L1_GetOffsetCalibrationData
#   \a VL53L1_SetOffsetCalibrationData"""
VL53L1_ERROR_MIN_CLIPPED =                                                   -2
# """Warning parameter passed was clipped to min before to be applied"""

VL53L1_ERROR_UNDEFINED =                                                     -3
# """Unqualified error"""
VL53L1_ERROR_INVALID_PARAMS =                                                -4
# """Parameter passed is invalid or out of range"""
VL53L1_ERROR_NOT_SUPPORTED =                                                 -5
# """Function is not supported in current mode or configuration"""
VL53L1_ERROR_RANGE_ERROR =                                                   -6
# """Device report a ranging error interrupt status"""
VL53L1_ERROR_TIME_OUT =                                                      -7
# """Aborted due to time out"""
VL53L1_ERROR_MODE_NOT_SUPPORTED =                                            -8
# """Asked mode is not supported by the device"""
VL53L1_ERROR_BUFFER_TOO_SMALL =                                              -9
# """..."""
VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL =                                       -10
# """Supplied buffer is larger than I2C supports"""
VL53L1_ERROR_GPIO_NOT_EXISTING =                                            -11
# """User tried to setup a non-existing GPIO pin"""
VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED =                             -12
# """unsupported GPIO functionality"""
VL53L1_ERROR_CONTROL_INTERFACE =                                            -13
# """error reported from IO functions"""
VL53L1_ERROR_INVALID_COMMAND =                                              -14
# """The command is not allowed in the current device state (power down)"""
VL53L1_ERROR_DIVISION_BY_ZERO =                                             -15
# """In the function a division by zero occurs"""
VL53L1_ERROR_REF_SPAD_INIT =                                                -16
# """Error during reference SPAD initialization"""
VL53L1_ERROR_GPH_SYNC_CHECK_FAIL =                                          -17
# """GPH sync interrupt check fail - API out of sync with device"""
VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL =                                      -18
# """Stream count check fail - API out of sync with device"""
VL53L1_ERROR_GPH_ID_CHECK_FAIL =                                            -19
# """GPH ID check fail - API out of sync with device"""
VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL =                                 -20
# """Zone dynamic config stream count check failed - API out of sync"""
VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL =                                       -21
# """Zone dynamic config GPH ID check failed - API out of sync"""

VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAI =                               -22
# """Thrown when run_xtalk_extraction fn has 0 succesful samples when using
# the full array to sample the xtalk. In this case there is not enough
# information to generate new Xtalk parm info. The function will exit and
# leave the current xtalk parameters unaltered"""
VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL =                            -23
# """Thrown when run_xtalk_extraction fn has found that the avg sigma
# estimate of the full array xtalk sample is > than the maximal limit
# allowed. In this case the xtalk sample is too noisy for measurement.
# The function will exit and leave the current xtalk parameters unaltered."""


VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL =                                    -24
# """Thrown if there one of stages has no valid offset calibration
# samples. A fatal error calibration not valid"""
VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL =                             -25
# """Thrown if there one of stages has zero effective SPADS Traps the case
# when MM1 SPADs is zero. A fatal error calibration not valid"""
VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL =                                      -26
# """Thrown if then some of the zones have no valid samples. A fatal error
# calibration not valid"""
VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH =                                     -27
# """Thrown if the tuning file key table version does not match with
# expected value. The driver expects the key table version to match the 
# compiled default version number in the define
# #VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT*"""
VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS =                             -28
# """Thrown if there are less than 5 good SPADs are available."""
VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH =                                -29
# """Thrown if the final reference rate is greater than the upper reference
# rate limit - default is 40 Mcps. Implies a minimum Q3 (x10) SPAD (5)
# selected"""
VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW =                                 -30
# """Thrown if the final reference rate is less than the lower reference
# rate limit - default is 10 Mcps. Implies maximum Q1 (x1) SPADs selected"""


VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES =                                 -31
# """Thrown if there is less than the requested number of valid samples."""
VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH =                                  -32
# """Thrown if the offset calibration range sigma estimate is greater than
# 8.0 mm. This is the recommended min value to yield a stable offset
# measurement"""
VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH =                                   -33
# """Thrown when VL53L1_run_offset_calibration() peak rate is greater than
# that 50.0Mcps. This is the recommended max rate to avoid pile-up
# influencing the offset measurement"""
VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW =                              -34
# """Thrown when VL53L1_run_offset_calibration() when one of stages range
# has less that 5.0 effective SPADS. This is the recommended min value to
# yield a stable offset"""


VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES =                                   -35
# """Thrown if one of more of the zones have less than the requested number
# of valid samples"""
VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH =                                    -36
# """Thrown if one or more zones have sigma estimate value greater than
# 8.0 mm. This is the recommended min value to yield a stable offset
# measurement"""
VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH =                                     -37
# """Thrown if one of more zones have peak rate higher than that 50.0Mcps.
# This is the recommended max rate to avoid pile-up influencing the offset
# measurement"""


VL53L1_WARNING_XTALK_MISSING_SAMPLES =                                      -38
# """Thrown to notify that some of the xtalk samples did not yield valid
# ranging pulse data while attempting to measure the xtalk signal in
# vl53l1_run_xtalk_extract(). This can signify any of the zones are missing
# samples, for further debug information the xtalk_results struct should be
# referred to. This warning is for notification only, the xtalk pulse and
# shape have still been generated"""
VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT =                              -39
# """Thrown to notify that some of teh xtalk samples used for gradient
# generation did not yield valid ranging pulse data while attempting to
# measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
# that any one of the zones 0-3 yielded no successful samples. The
# xtalk_results struct should be referred to for further debug info. This
# warning is for notification only, the xtalk pulse and shape have still
# been generated."""
VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT =                             -40
# """Thrown to notify that some of the xtalk samples used for gradient
# generation did not pass the sigma limit check while attempting to
# measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
# that any one of the zones 0-3 yielded an avg sigma_mm value > the limit.
# The xtalk_results struct should be referred to for further debug info.
# This warning is for notification only, the xtalk pulse and shape have
# still been generated."""
VL53L1_ERROR_NOT_IMPLEMENTED =                                              -41
# """Tells requested functionality has not been implemented yet or not
# compatible with the device"""
VL53L1_ERROR_PLATFORM_SPECIFIC_START =                                      -60
# """Tells the starting code for platform
#    @} VL53L1_define_Error_group"""

Class

QwiicVL53L1X() or QwiicVL53L1X(i2caddr)
This Python package operates as a class object, allowing new instances of that type to be made. An __init__() constructor is used that creates a connection to an I2C device over the I2C bus using the default or specified I2C address.

The Constructor

A constructor is a special kind of method used to initialize (assign values to) the data members needed by the object when it is created.

__init__(address=None, i2c_driver=None)

Input: value
The value of the device address. If not defined, the Python package will use the default I2C address (0x77) stored under _AVAILABLE_I2C_ADDRESS variable.
Input: i2c_driver
Loads the specified I2C driver; by default the Qwiic I2C driver is used: qwiic_i2c.getI2CDriver(). Users should use the default I2C driver and leave this field blank.
Output: Boolean

True: Connected to I2C device on the default (or specified) address.
False: No device found or connected.

Functions

A function that is an attribute of the class, which defines a method for instances of that class. In simple terms, they are objects for the operations (or methods) of the class.

.init_sensor(address)
Initialize the sensor with default values

Input: value
The value of the device address. If not defined, the Python package will use the default I2C address (0x77) stored under _AVAILABLE_I2C_ADDRESS variable.
Output: Boolean

True: The initialization was successful.

.sensor_init()
Loads the 135 bytes of default configuration values to initialize the sensor.

Output: Boolean

True: Configuration successful.
False: Configuration failed.

.get_distance()
This function returns the distance measured by the sensor in mm.

Output: Integer

Returns distance measured by the sensor in mm.

.get_sw_version()
This function returns the SW driver version.

Input: List

[major, minor, build, revision]

.set_i2c_address(new_address)
This function sets the sensor I2C address used in case multiple devices application, default address 0x29 (0x52 >> 1).

Input: Value

I2C address to change device to.

.clear_interrupt()
This function clears the interrupt, to be called after a ranging data reading to arm the interrupt for the next data ready event.

.set_interrupt_polarity(NewPolarity)
This function programs the interrupt polarity

Input: Value

0: Active Low
1: Active High (Default)

.get_interrupt_polarity()
This function returns the current interrupt polarity.

Output: Value

0: Active Low
1: Active High (Default)

.start_ranging()
This function starts the ranging distance operation The ranging operation is continuous. The clear interrupt has to be done after each get data to allow the interrupt to raise when the next data is ready:

    0: Active Low
    1: Active High (Default)

use set_interrupt_polarity() to change the interrupt polarity if required.

.stop_ranging()
This function stops the ranging.

.check_for_data_ready()
This function checks if the new ranging data is available by polling the dedicated register.

Output: Value

0: Not Ready
1: Ready

.set_timing_budget_in_ms(TimingBudgetInMs)
This function programs the timing budget in ms.

Input: Value (Predefined)

15
20
33
50
100 (Default)
200
500

.get_timing_budget_in_ms()
This function returns the current timing budget in ms.

Output: Value

Timing budget in ms.

.set_distance_mode(DM)
This function programs the distance mode (1=short, 2=long).

Input: Value

1: Short mode max distance is limited to 1.3 m but better ambient immunity.
2: Long mode can range up to 4 m in the dark with 200 ms timing budget (Default)

.get_distance_mode()
This function returns the current distance mode (1=short, 2=long).

Output: Value

1: Short mode max distance is limited to 1.3 m but better ambient immunity.
2: Long mode can range up to 4 m in the dark with 200 ms timing budget (Default)

.set_inter_measurement_in_ms(InterMeasMs)
This function programs the Intermeasurement period in ms.

Input: Value

Intermeasurement period must be >/= timing budget. This condition is not checked by the API, the customer has the duty to check the condition. Default = 100 ms

.get_inter_measurement_in_ms()
This function returns the Intermeasurement period in ms.

Input: Integer

Intermeasurement period in ms.

.boot_state()
This function returns the boot state of the device (1:booted, 0:not booted)

Output: Integer

0: Booted
2: Not Booted

.get_sensor_id()
This function returns the sensor id, sensor Id must be 0xEEAC

Output: Integer

Sensor ID

.get_signal_per_spad()
This function returns the returned signal per SPAD (Single Photon Avalanche Diode) in kcps/SPAD (kcps stands for Kilo Count Per Second).

Output: Integer

Signal per SPAD (Kilo Count Per Second per Single Photon Avalanche Diode).

.get_ambient_per_spad()
This function returns the ambient per (Single Photon Avalanche Diode) in kcps/SPAD (kcps stands for Kilo Count Per Second).

Output: Integer

Ambient per SPAD.

.get_signal_rate()
This function returns the returned signal in kcps (Kilo Count Per Second).

Output: Value

Signal in kcps.

.get_spad_nb()
This function returns the current number of enabled SPADs (Single Photon Avalanche Diodes).

Output: Value

Number of enabled SPADs.

.get_ambient_rate()
This function returns the ambient rate in kcps (Kilo Count Per Second).

Output: Value

Ambient rate in kcps.

.get_range_status()
This function returns the ranging status error.

Output: Value (Ranging status error)

0: No Error
1: Sigma Failed
2: Signal Failed
7: Wrap-around

.set_offset(OffsetValue)
This function programs the offset correction in mm.

Input: Value

The offset correction value to program in mm.

.get_offset()
This function returns the programmed offset correction value in mm.

Output: Integer

Offset correction value in mm.

.set_xtalk(XtalkValue)
This function programs the xtalk correction value in cps (Count Per Second). This is the number of photons reflected back from the cover glass in cps.

Input: Integer

Xtalk correction value in count per second to avoid float type.

.get_xtalk()
This function returns the current programmed xtalk correction value in cps (Count Per Second).

Output: Value

Xtalk correction value in cps.

.set_distance_threshold(ThreshLow, ThreshHigh, Window, IntOnNoTarget)
This function programs the threshold detection mode.

Input: Value

The threshold under which one the device raises an interrupt if Window = 0.

Input: Value

The threshold above which one the device raises an interrupt if Window = 1.

Input: Value
Window detection mode:

0: Below
1: Above
2: Out
3: In

Input: 1

No longer used - just set to 1

Example:
  • self.set_distance_threshold(100,300,0,1): Below 100
  • self.set_distance_threshold(100,300,1,1): Above 300
  • self.set_distance_threshold(100,300,2,1): Out of window
  • self.set_distance_threshold(100,300,3,1): In window

.get_distance_threshold_window()
This function returns the window detection mode (0=below 1=above 2=out 3=in).

Output: Integer
Window detection mode:

0: Below
1: Above
2: Out
3: In

.get_distance_threshold_low()
This function returns the low threshold in mm.

Output: Integer

Low threshold in mm.

.get_distance_threshold_high()
This function returns the high threshold in mm.

Output: Integer

High threshold in mm.

.set_roi(X, Y, OpticalCenter = 199)
This function programs the ROI (Region of Interest). The height and width of the ROI (X, Y) are set in SPADs (Single Photon Avalanche Diodes); the smallest acceptable ROI size = 4 (4 x 4). The optical center is set based on table below. To set the center, use the pad that is to the right and above (i.e. upper right of) the exact center of the region you'd like to measure as your optical center.

Table of Optical Centers:

128,136,144,152,160,168,176,184,  192,200,208,216,224,232,240,248
129,137,145,153,161,169,177,185,  193,201,209,217,225,233,241,249
130,138,146,154,162,170,178,186,  194,202,210,218,226,234,242,250
131,139,147,155,163,171,179,187,  195,203,211,219,227,235,243,251
132,140,148,156,164,172,180,188,  196,204,212,220,228,236,244,252
133,141,149,157,165,173,181,189,  197,205,213,221,229,237,245,253
134,142,150,158,166,174,182,190,  198,206,214,222,230,238,246,254
135,143,151,159,167,175,183,191,  199,207,215,223,231,239,247,255

127,119,111,103,095,087,079,071,  063,055,047,039,031,023,015,007
126,118,110,102,094,086,078,070,  062,054,046,038,030,022,014,006
125,117,109,101,093,085,077,069,  061,053,045,037,029,021,013,005
124,116,108,100,092,084,076,068,  060,052,044,036,028,020,012,004
123,115,107,099,091,083,075,067,  059,051,043,035,027,019,011,003
122,114,106,098,090,082,074,066,  058,050,042,034,026,018,010,002
121,113,105,097,089,081,073,065,  057,049,041,033,025,017,009,001
120,112,104,096,088,080,072,064,  056,048,040,032,024,016,008,0 Pin 1

(Each SPAD has a number which is not obvious.)
Input: Value

ROI Width

Input: Value

ROI Height

Input: Value

The pad that is to the upper right of the exact center of the ROI (see table above). (Default = 199)

.get_roi_xy()
This function returns width X and height Y.

Output: List [ROI_X, ROI_Y]

Region of Interest Width (X) and Height (Y).

.set_signal_threshold(Signal)
This function programs a new signal threshold in kcps (Kilo Count Per Second).

Input: Value

Signal threshold in kcps (Default=1024 kcps)

.get_signal_threshold()
This function returns the current signal threshold in kcps (Kilo Count Per Second).

Output: Value

Signal threshold in kcps.

.set_sigma_threshold(Sigma)
This function programs a new sigma threshold in mm (default=15 mm).

Input: Value

Sigma threshold in mm (**default=15 mm**)

.get_sigma_threshold()
This function returns the current sigma threshold in mm

Output: Integer

Sigma threshold in mm.

.start_temperature_update()
This function performs the temperature calibration. It is recommended to call this function any time the temperature might have changed by more than 8 deg C without sensor ranging activity for an extended period.

.calibrate_offset(TargetDistInMm)
This function performs the offset calibration. The function returns the offset value found and programs the offset compensation into the device.

Input: Value

Target distance in mm, ST recommended 100 mm. (Target reflectance = grey 17%)

Output: Boolean

0: Success
!0: Failed

.calibrate_xtalk(TargetDistInMm)
This function performs the xtalk calibration. The function returns the xtalk value found and programs the xtalk compensation to the device

Input: Value

Target distance in mm (the distance where the sensor starts to "under range" due to the influence of the photons reflected back from the cover glass becoming strong; also called the inflection point). (Target reflectance = grey 17%)

Output: Boolean

0: Success
!0: Failed

Upgrading the Package

In the future, changes to the Python package might be made. Updating the installed packages has to be done individually for each package (i.e. sub-modules and dependencies won't update automatically and must be updated manually). For the sparkfun-qwiic-vl53l1x Python package, use the following command (use pip for Python 2):

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

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

For the current user:

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

Python Examples

The example code for this product is located in the GitHub repository for the Python package; it is also hosted with the ReadtheDocs documentation:

To run the examples, simple download or copy the code into a file. Then, open/save the example file (if needed) and execute the code in your favorite Python IDE. For example, with the default Python IDLE click Run > Run Module or use the F5 key. To terminate the example use the Ctrl + C key combination.

Example 1

This example prints the distance to an object. If you are getting weird readings, be sure the vacuum tape has been removed from the sensor.

Import Dependencies

The first part of the code, imports the required dependencies to operate.

language:python
import qwiic
import time

Initialize Constructor

These lines instantiates an object for the device and initializes the sensor.

language:python
ToF = qwiic.QwiicVL53L1X()
if (ToF.sensor_init() == None):                  # Begin returns 0 on a good init
    print("Sensor online!\n")

Test Run

This section of the code, illustrates how readings are taken from the sensor and displayed, while being looped. In the first section of the code, sensors readings are initiated, recorded, and then terminated. The second part of the code converts the units of the readings and displays them.

language:python
while True:
    try:
        ToF.start_ranging()                      # Write configuration bytes to initiate measurement
        time.sleep(.005)
        distance = ToF.get_distance()    # Get the result of the measurement from the sensor
        time.sleep(.005)
        ToF.stop_ranging()

        distanceInches = distance / 25.4
        distanceFeet = distanceInches / 12.0

        print("Distance(mm): %s Distance(ft): %s" % (distance, distanceFeet))

    except Exception as e:
        print(e)

Example 2

This example configures the sensor to short distance mode and then prints the distance to an object. If you are getting weird readings, be sure the vacuum tape has been removed from the sensor.

Import Dependencies

The first part of the code, imports the required dependencies to operate.

language:python
import qwiic
import time

Initialize Constructor

These lines instantiates an object for the device and initializes the sensor.

language:python
ToF = qwiic.QwiicVL53L1X()
if (ToF.sensor_init() == None):                  # Begin returns 0 on a good init
    print("Sensor online!\n")

Test Run

This section of the code, illustrates how readings are taken from the sensor and displayed. In the first part of the code, the sensor is configured to read with the short distance mode (the sensor is configured for long distance mode on power up). The second part of the code reads and displays data; as mentioned in the previous example.

language:python
ToF.set_distance_mode(1)    # Sets Distance Mode Short (Long- Change value to 2)


while True:
    try:
        ToF.start_ranging()                      # Write configuration bytes to initiate measurement
        time.sleep(.005)
        distance = ToF.get_distance()    # Get the result of the measurement from the sensor
        time.sleep(.005)
        ToF.stop_ranging()

        distanceInches = distance / 25.4
        distanceFeet = distanceInches / 12.0

        print("Distance(mm): %s Distance(ft): %s" % (distance, distanceFeet))

    except Exception as e:
        print(e)

Resources and Going Further

Now that you've successfully got your Qwiic Distance Sensor up and running, it's time to incorporate it into your own project!

For more information, check out the resources below:

Want a great use case for your ToF sensor? How about integrating one into your AVC submission? Have a look here:

Need even more inspiration for your next project? Check out some of these related tutorials:

Using the PSoC 6 Pioneer Board with the Pioneer IoT Add-on Shield

Cypress's PSoC 6 Pioneer Board is a development tool for the powerful PSoC 6 processor. In this tutorial, we'll show you how to use the PSoC 6 Pioneer Board along with the SparkFun/Digi-Key Pioneer IoT Add-on Shield to send data to a Raspberry Pi via BLE or WiFi.

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!

Qwiic Twist Hookup Guide

Take your volume knob beyond 11 with the Qwiic Twist digital RGB LED encoder via I2C!

Qwiic Joystick Hookup Guide

Looking for an easy way to implement a joystick to your next Arduino or Raspberry Pi project? This hookup guide will walk you through using the Qwiic Joystick with the Arduino IDE on a RedBoard Qwiic and in Python on a Raspberry Pi.

Or check out this blog post for more ideas!


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

Sound Location Part 2 with the Qwiic Sound Trigger and the u-blox ZED-F9x

$
0
0

Sound Location Part 2 with the Qwiic Sound Trigger and the u-blox ZED-F9x a learn.sparkfun.com tutorial

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

Introduction

In the previous tutorial, we showed you how to calculate the location of a sound using the new SparkX Qwiic Sound Trigger and the u-blox ZED-F9P GNSS receiver.

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

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

GPS-16481
$274.95
10
Qwiic Sound Trigger

Qwiic Sound Trigger

SPX-17979
$9.95

The Qwiic Sound Trigger can be used on its own, or as part of your Qwiic system. It is based on the VM1010 from Vesper Technologies and the TI PCA9536 GPIO expander. The VM1010 is a clever little device which can be placed into a very low power "Wake On Sound" mode. When it detects a sound, it wakes up and pulls its TRIG (DOUT) pin high. The VM1010 can then be placed into "Normal" mode by pulling the MODE pin low; it then functions as a regular microphone. The analog microphone signal is available on the AUDIO (VOUT) pin. All of this happens really quickly, within 50 microseconds (much faster than a capacitive MEMS microphone), so you don't miss the start of the audio signal. This makes it ideal for use as a sound trigger!

The u-blox ZED-F9P GNSS receiver is an old friend. It is a top-of-the-line module for high accuracy GNSS location solutions including RTK that is capable of 10mm, three-dimensional accuracy. With this board, you will be able to know where your (or any object's) X, Y, and Z location is within roughly the width of your fingernail! Something that doesn’t get discussed as much as it should is that the ZED-F9P can also capture the timing of a signal on its INT pin with nanosecond resolution! It does that through a UBX message called TIM_TM2.

In this tutorial, we take this to the next dimension. Quite literally! Last time, we used two sound trigger systems to calculate where a sound came from along the line from one trigger to the other. That’s a one-dimensional (1D) system. If we add a third sound trigger, we can triangulate the location of a sound in two dimensions (2D) allowing us to plot the position in X and Y or East and North!

Let's talk first about triangulation….

Sound Source Triangulation

Last time, we learned that we can calculate the location of a sound by measuring the difference in the sound’s time-of-arrival at two sound triggers. In our 1D example, we:

  • Converted the time difference into distance (by multiplying by the speed of sound)
  • Subtracted that distance from the distance between our two sound triggers
  • And then divided by 2 to calculate the distance from the closest trigger (the one that detects the sound first)

In 2D, there is a little more math involved. Let’s call our three sound trigger systems A, B and C. A is our reference or origin. If we position trigger B due East from A, we can call the line that joins A to B our X axis. Remember when you used to draw graphs in math class? You had the origin in the bottom left corner of your graph paper and you drew the X axis horizontally out to the right. We are doing the same thing here. Trigger A is our origin at X = 0 and Y = 0. We write that as (0,0). If Trigger B is 8 metres (8m) away from A, then its location is X = 8 and Y = 0. We write that as (8,0).

Pictured are the coordinates of two points A and B and the line formed between them

So far, so good. Now, where should we position trigger C? In reality, it doesn’t really matter. We could position C so that ABC forms a perfect equilateral triangle (a triangle where all three sides are the same length). That would give us the best coverage of the area. But the coordinates of C would be (4,6.93). Not pleasant.

Pictured is an equilateral triangle formed from points A, B and C

To keep the math simpler for this example, let’s position C 6m due North from A. The coordinates of C are X = 0 and Y = 6. We write that as (0,6).

Pictured is a right triangle formed from points A, B and C.

We know the distance from A to B is 8m, and that the distance from A to C is 6m. But what about the distance from B to C? We need to know that too. If we get out a tape measure and measure it, we’ll find it is exactly 10m. If you remember Pythagoras’ Theorem from your math class, the square on the hypotenuse is equal to the sum of the squares on the other two sides, we can calculate the distance from B to C by:

  • Squaring (multiplying by itself) the distance from A to B: 8 x 8 = 64
  • Squaring (multiplying by itself) the distance from A to C: 6 x 6 = 36
  • Summing (adding) them: 64 + 36 = 100
  • Calculating the square root: √100 = 10

Pictured are squares formed on the three sides of the triangle

Again, to keep the math easier, let’s pretend that the speed of sound is 1 metre per second (1m/s), not 343.42m/s.

Now, let’s suppose our sound trigger system is running and it detects a sound:

  • The time recorded by trigger A is 10:00:03.605551
  • The time recorded by trigger B is 10:00:05.385165
  • The time recorded by trigger C is 10:00:05.000000

Let’s calculate the differences in those times:

  • A records the sound first, so we will use that as our reference
  • B records the sound 10:00:05.385165 - 10:00:03.605551 = 1.779614 seconds later
  • C records the sound 10:00:05.000000 - 10:00:03.605551 = 1.394449 seconds later

With the speed of sound being 1m/s, we now know that the sound travelled an extra 1.779614m when travelling to B compared to A. And we know that the sound travelled an extra 1.394449m when travelling to C compared to A.

What we do not know is how far the sound travelled to get to A. That’s the first thing we need to calculate.

Let’s call the location of the sound: S. Let’s call the coordinates of S: ( x , y ). Let’s call the distance from S to A: D.

If we sketch that - not to scale - it looks like this:

Pictured is right triangle A B C with point S located within the triangle

We know that:

  • The distance from S to A is D metres
  • The distance from S to B is D + 1.779614 metres
  • The distance from S to C is D + 1.394449 metres

In order to find the location of S, we need to use triangles. That’s why this technique is called “triangulation”. In trigonometry and geometry, triangulation is the process of determining the location of a point by forming triangles to it from known points.

If we divide our diagram up into more triangles:

Pictured is the triangle formed from points A B and S

We can use Pythagoras’ Theorem to calculate the distances we need:

  • D2 = x2 + y2
  • (D + 1.779614)2 = (8 - x)2 + y2
  • (D + 1.394449)2 = x2 + (6 - y)2

We can write that as:

  • D2 = x2 + y2
  • y2 = (D + 1.779614)2 - (8 - x)2
  • x2 = (D + 1.394449)2 - (6 - y)2

We need to solve for D. To begin, let’s substitute the value for y2 from the second equation into the first equation:

  • D2 = x2 + (D + 1.779614)2 - (8 - x)2

Multiplying out the brackets, that becomes:

  • D2 = x2 + D2 + 1.779614.D + 1.779614.D + 1.7796142 - ( 82 - 8x - 8x + x2 )

Simplifying, it becomes:

  • D2 = x2 + D2 + 3.559228.D + 3.167026 - (64 - 16.x + x2)

If we remove the brackets:

  • D2 = x2 + D2 + 3.559228.D + 3.167026 - 64 + 16.x - x2

The D2 cancel out and so do the x2 leaving:

  • 0 = 3.559228.D + 3.167026 - 64 + 16.x

One final rearrange leaves:

  • 16.x = -3.559228.D + 60.832974

If we divide through by 16 we are left with:

  • x = -0.222452.D + 3.802061

Now let’s go back to our three triangles:

  • D2 = x2 + y2
  • y2 = (D + 1.779614)2 - (8 - x)2
  • x2 = (D + 1.394449)2 - (6 - y)2

This time, let’s substitute the value for x2 from the third equation into the first equation:

  • D2 = (D + 1.394449)2 - (6 - y)2 + y2

Multiplying out the brackets, that becomes:

  • D2 = D2 + 1.394449D + 1.394449D + 1.944488 - (36 - 6y - 6y + y2) + y2

If we remove the brackets:

  • D2 = D2 + 1.394449D + 1.394449D + 1.944488 - 36 + 6y + 6y - y2 + y2

Again, the D2 cancel out and so do the y2 leaving:

  • 0 = 2.788898.D + 1.944488 - 36 + 12.y

One final rearrange leaves:

  • 12.y = -2.788898.D + 34.055512

If we divide through by 12 we are left with:

  • y = -0.232408.D + 2.837959

Now we can put our values for x and y back into our first equation:

  • D2 = x2 + y2

  • D2 = (-0.222452.D + 3.802061)2 + (-0.232408.D + 2.837959)2

Multiplying out the brackets, we get:

  • D2 = 0.049485.D2 - 1.691552.D + 14.455668 + 0.054013.D2 - 1.319129.D + 8.054011

Simplifying:

  • 0.896502.D2 + 3.010681.D - 22.509679 = 0

Now, I’m sure you will remember quadratic equations from your math class too? We can solve for D using the equation:

  • ( -b +/- √(b2 - 4.a.c ) ) / 2.a

  • a = 0.896502

  • b = 3.010681
  • c = -22.509679

Inserting our values, D is:

  • ( -3.010681 +/- √(9.064200 + 80.719889) ) / 1.793004

Which equals:

  • 3.605550 or -6.963804

We can ignore the negative value since it is not within our triangle. Now we know that D is 3.605550m !

Looking back at our equations for x and y:

  • x = -0.222452.D + 3.802061
  • y = -0.232408.D + 2.837959

If we insert the value for D, we can finally calculate the x and y coordinates of S:

  • ( -0.802062 + 3.802061 , -0.837959 + 2.837959 )

Which is:

  • ( 3.000 , 2.000 )

Pictured are the calculated coordinates of point S

Fancy that!

This technique can be used on any configuration of trigger locations. They don’t have to be positioned in a neat right angle triangle. If you would like proof of that and would like to see the math to solve it, have a look at the section called Here There Be Dragons!

Now, The Good News

Thanks for sticking with us. The good news is that we’ve written more Python code to do that math for you!

The GitHub Hardware Repo contains two examples for the Sound Trigger. You can run these in the Arduino IDE. The second example is the crowd pleaser! It runs on the MicroMod Data Logging Carrier Board together with the Artemis Processor Board but it should work just fine with any of our processor boards. It communicates with our ZED-F9P Breakout and the Qwiic Sound Trigger to capture sound events and log them to SD card as u-blox UBX TIM_TM2 messages.

SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$21.50
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95

Once you have your three sound event UBX TIM_TM2 files, our Sound_Trigger_Analyzer_2D.py will process the files for you and calculate the location of the sound events!

  • Copy the TIM_TM2.ubx file from the SD card from the first system. Rename the file so you know which system it came from. You might want to call it TIM_TM2_A.ubx.
  • Do the same for the TIM_TM2.ubx files from the second and third systems. Again, rename them so you know which system they came from.
  • Place all three files in the same folder / directory as the Sound_Trigger_Analyzer_2D.py Python file

Run the Python code by calling:

language:python
python Sound_Trigger_Analyzer_2D.py TIM_TM2_A.ubx TIM_TM2_B.ubx TIM_TM2_C.ubx 8.0 6.0 10.0 20.0
  • Replace TIM_TM2_A.ubx with the name of the file from the first system (A)
  • Replace TIM_TM2_B.ubx with the name of the file from the second system (B)
  • Replace TIM_TM2_C.ubx with the name of the file from the third system (C)
  • Replace the 8.0, 6.0 and 10.0 with the distances between your sound triggers in metres
    • You must enter them in the correct order: A-B then A-C then B-C
  • The 20.0 is optional. It is the temperature in Celcius (Centigrade). Change this to your actual temperature for added accuracy

The Python code will calculate and display the (x,y) coordinates of any valid sound events it finds. The coordinate system uses the location of A as the origin, and the line running from A to B as the X axis. The Y axis is (of course) 90 degrees counterclockwise from X.

The calculation code assumes that the X coordinate of C is between A and B. If C lies to the left of A, or the right of B, then you need to rename your points. If C is to the left of A, then B becomes A, C becomes B, and A becomes C:

Pictured are two triangles

Enjoy your coordinates!

Here There Be Dragons!

Sound_Trigger_Analyzer_2D.py can work with any configuration of the trigger positions (so long as the X coordinate of C is between A and B). They do not need to be arranged in a nice right-angled triangle with A-C pointing North. Don’t believe me? Want proof? Good for you! OK. Brace yourself. Here we go… Here is the actual math used in Sound_Trigger_Analyzer_2D.py.

Sensor Coordinates

Let’s suppose our three sound triggers are arranged such that they form a triangle ABC:

Pictured is the triangle formed from points A B C

We know the length of the sides: AB, AC and BC.

We know the coordinates of A and B. A is our origin and is located at (0,0). B is due ‘East’ of A and defines our X axis. So we say that B is located at (AB,0). But we don’t yet know the location of C. We need to calculate it. Let’s call the location of C (CX,CY).

If we draw a line from C so it meets line A-B at right angles:

Pictured is the triangle divided into two smaller right triangles

Pythagoras’ Theorem tells us that:

  • Equation 1: AC2 = CX2 + CY2
  • Equation 2: BC2 = ( AB - CX )2 + CY2

If we rearrange those equations, bringing CY2 to the left and multiplying out the brackets, we get:

  • CY2 = AC2 - CX2
  • CY2 = BC2 - AB2 + 2.AB.CX - CX2

Because those two equations are equal, we can arrange them as:

  • AC2 - CX2 = BC2 - AB2 + 2.AB.CX - CX2

The two -CX2 cancel out. Rearranging, we get:

  • CX = ( AC2 - BC2 + AB2 ) / 2.AB

We can find CY by inserting the value for CX into one of our earlier equations:

  • CY2 = AC2 - CX2

So:

  • CY = √ ( AC2 - CX2 )

We now have the coordinates for C: ( CX , CY )

Sound Event Timings

Now, let’s suppose our sound trigger system is running and it detects a sound. Let’s call the location of the sound S and give it coordinates ( SX , SY ):

Pictured are the coordinates of point S and the triangles formed from it

Our three systems are logging the time the sound arrives at each sensor (very accurately!).

The time taken for the sound to reach A is: the distance from S to A divided by the speed of sound. Likewise for B and C.

If all three systems hear the sound at the exact same time, then we know that the sound took an equal time to travel from S to A, B and C. That’s a special case where the distances SA, SB and SC are equal (equidistant). But usually sensors B and C will hear the sound at different times to A due to the distances SB and SC being different to SA. We need to include those differences in distance in our calculation. To save some typing, let’s call the distance SA: D

  • SB = D + DdiffB
  • SC = D + DdiffC

DdiffB is the difference between SB and D. Likewise, DdiffC is the difference between SC and D. Note that DdiffB or DdiffC could be negative if the source of the sound is closer to B or C than A.

Sensors B and C will hear the sound earlier or later than A depending on DdiffB and DdiffC.

What we do not know is how long the sound took to travel from S to A, because we do not know the distance D. That’s what we need to calculate,

What we do know is the difference in the time of arrival of the sound at our three sensors. If we bring the three sets of sensor data together, we can calculate the difference in the time of arrival at each sensor. Let’s say that:

  • The time recorded by trigger A is timeA
  • The time recorded by trigger B is timeB
  • The time recorded by trigger C is timeC

Let’s calculate the differences in those times:

  • TdiffB = timeB - timeA
  • TdiffC = timeC - timeA

Again, TdiffB and TdiffC could be negative if the source of the sound is closer to B or C than A.

Sound Event Coordinates

We can convert those differences in time into differences in distance by multiplying by the speed of sound:

  • DdiffB = TdiffB * speed_of_sound
  • DdiffC = TdiffC * speed_of_sound

Now we can use Pythogoras’ Theorem as before to study our triangles:

  • D2 = SX2 + SY2
  • (D + DdiffB)2 = (AB - SX)2 + SY2

We need to add an extra triangle to include SC:

Pictured are additional right triangles formed around point S

The width of the new triangle is:

  • CX - SX

The height of the new triangle is:

  • CY - SY

So, using Pythagoras’ Theorem again:

  • (D + DdiffC)2 = (CX - SX)2 + (CY - SY)2

We now have our three equations:

  • Equation 3: D2 = SX2 + SY2
  • Equation 4: (D + DdiffB)2 = (AB - SX)2 + SY2
  • Equation 5: (D + DdiffC)2 = (CX - SX)2 + (CY - SY)2

We need to solve for D. To begin, let’s substitute the value for SY2 from the second equation into the first equation, so we can find the relationship between D and SX:

  • D2 = SX2 + (D + DdiffB)2 - (AB - SX)2

Multiplying out the brackets, that becomes:

  • D2 = SX2 + D2 + 2.DdiffB.D + DdiffB2 - AB2 + 2.AB.SX - SX2

As before, the D2 cancel and so do the SX2 leaving:

  • 0 = 2.DdiffB.D + DdiffB2 - AB2 + 2.AB.SX

Rearranging:

  • 2.AB.SX = AB2 - 2.DdiffB.D - DdiffB2

Divide through by 2.AB:

  • SX = ( AB2 - 2.DdiffB.D - DdiffB2 ) / 2.AB

Let’s make life easier for ourselves and say that:

  • Equation 6: SX = SXa.D + SXb

Where:

  • SXa = ( -2.DdiffB ) / 2.AB
  • SXb = ( AB2 - DdiffB2 ) / 2.AB

We can calculate both values because we know AB and can calculate DdiffB:

  • DdiffB = TdiffB * speed_of_sound = ( timeB - timeA ) * speed_of_sound

Looking at equation 3 again:

  • D2 = SX2 + SY2

If we replace SX with ( SXa.D + SXb ), we get:

  • D2 = ( SXa.D + SXb )2 + SY2

Rearranging:

  • SY2 = D2 - ( SXa.D + SXb )2

Multiplying out the bracket, it becomes:

  • SY2 = D2 - SXa2.D2 - 2.SXa.SXb.D - SXb2

Simplifying:

  • SY2 = ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2

So:

  • Equation 7: SY = √ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 )

That’s ever so slightly horrible, but let’s go with it…

Now we have values for SX and SY in terms of D, which we can plug into equation 5:

  • (D + DdiffC)2 = (CX - SX)2 + (CY - SY)2

Substituting for SX and SY we get:

  • (D + DdiffC)2 = (CX - ( SXa.D + SXb ) )2 + (CY - √ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 ) )2

Multiplying out the brackets gives (brace yourself!):

  • D2 + 2.DdiffC.D + DdiffC2 = CX2 - 2.CX.SXa.D - 2.CX.SXb + SXa2.D2 + 2.SXa.SXb.D + SXb2 + CY2 - 2.CY.√ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 ) + ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2

Simplifying and moving everything but the root to the left gives:

  • ( 1 - SXa2 - ( 1 - SXa2 )).D2 + ( 2.DdiffC + 2.CX.SXa - 2.SXa.SXb + 2.SXa.SXb).D + DdiffC2 - CX2 + 2.CX.SXb - SXb2 - CY2 + SXb2 = -2.CY.√ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 )

Fortunately the D2 term cancels out completely, which is good news. If it didn’t, we’d have a quartic equation to solve instead of a quadratic…

Simplifying:

  • ( 2.DdiffC + 2.CX.SXa).D + DdiffC2 - CX2 + 2.CX.SXb - CY2 = -2.CY.√ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 )

Dividing through by -2.CY gives:

  • ( ( 2.DdiffC + 2.CX.SXa ).D + DdiffC2 - CX2 + 2.CX.SXb - CY2 ) / -2.CY = √ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 )

We now need to square both sides to get rid of the root. Painful… But we need to do it… But first, to make life easier for ourselves, let’s simplify further and say:

  • da.D + db = √ ( ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2 )

Where:

  • da = ( 2.DdiffC + 2.CX.SXa ) / -2.CY
  • db = ( DdiffC2 - CX2 + 2.CX.SXb - CY2 ) / -2.CY

Remember that we can already calculate values for da and db because we know or can calculate values for: DdiffC; CX; SXb; and CY.

Square both sides:

  • da2.D2 + 2.da.db.D + db2 = ( 1 - SXa2 ).D2 - 2.SXa.SXb.D - SXb2

Moving the terms on the right over to the left:

  • ( da2 - ( 1 - SXa2 ) ).D2 + ( 2.da.db + 2.SXa.SXb ).D + db2 + SXb2 = 0

That’s a quadratic equation which we can solve in the usual way. Let’s make:

  • qa = da2 - 1 + SXa2
  • qb = 2.da.db + 2.SXa.SXb
  • qc = db2 + SXb2

Remember that we can already calculate values for qa, qb and qc because we already know: da; SXa; db; and SXb.

Solving the quadratic::

  • D = ( -qb +/- √( qb2 - 4.qa.qc ) ) / 2.qa

That gives us two possible values for D. One will be negative or otherwise invalid, leaving us with a value for D.

We can then plug the value for D into equation 6 to find the X coordinate of S because we already know the values of SXa and SXb:

  • SX = SXa.D + SXb

We can then calculate the Y coordinate of S using equation 3:

  • D2 = SX2 + SY2
  • SY = √( D2 - SX2 )

Enjoy your coordinates!


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

Sound Location with the Qwiic Sound Trigger and the u-blox ZED-F9x

$
0
0

Sound Location with the Qwiic Sound Trigger and the u-blox ZED-F9x a learn.sparkfun.com tutorial

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

Introduction

In this tutorial, we show you how to calculate the location of a sound using the SparkX Qwiic Sound Trigger and the u-blox ZED-F9P GNSS receiver.

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

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

GPS-16481
$274.95
10
Qwiic Sound Trigger

Qwiic Sound Trigger

SPX-17979
$9.95

The Qwiic Sound Trigger can be used on its own, or as part of your Qwiic system. It is based on the VM1010 from Vesper Technologies and the TI PCA9536 GPIO expander. The VM1010 is a clever little device which can be placed into a very low power "Wake On Sound" mode. When it detects a sound, it wakes up and pulls its TRIG (DOUT) pin high. The VM1010 can then be placed into "Normal" mode by pulling the MODE pin low; it then functions as a regular microphone. The analog microphone signal is available on the AUDIO (VOUT) pin. All of this happens really quickly, within 50 microseconds (much faster than a capacitive MEMS microphone), so you don't miss the start of the audio signal. This makes it ideal for use as a sound trigger! If you turn the Qwiic Sound Trigger over, you will see a small hole ringed in white. That’s the opening for the microphone. You need to have the rear of the board pointing towards your sound source, not the front.

Pictured is the rear of the Qwiic Sound Trigger showing the microphone hole

The u-blox ZED-F9P GNSS receiver is an old friend. It is a top-of-the-line module for high accuracy GNSS location solutions including RTK that is capable of 10mm, three-dimensional accuracy. With this board, you will be able to know where your (or any object's) X, Y, and Z location is within roughly the width of your fingernail! Something that doesn’t get discussed as much as it should is that the ZED-F9P can also capture the timing of a signal on its INT pin with nanosecond resolution! It does that through a UBX message called TIM_TM2.

Together, these two boards form the heart of our noise source location system. Want to figure out where a sound came from? These boards let you do that!

We are also going to show you how to log the TIM_TM2 data from the ZED-F9P to SD card using the MicroMod Data Logging Carrier Board and Artemis Processor Board. But our example code can be adapted to any board if required. Then we’ll go on to show how you can use our example Python code to process the data and calculate the location of the sound!

But first, let's talk about sound itself….

The Speed Of Sound

We all know that sound travels slower than light. If you see a flash of lightning, it can be several seconds before you hear the clap of thunder. It’s roughly 5 seconds for every mile. Count 15 seconds and the storm is 3 miles away from you. But let’s go metric.

The speed of sound is about 343.42 metres per second (767 mph). But it changes with both temperature and humidity. It is 343.42 m/s at 20 °C (68 °F) at 0% humidity. On a hot, cold or wet day, it changes. It changes with pressure / altitude too because the temperature of air is linked to its pressure through the Ideal Gas Law. You might remember that from your chemistry lessons at school.

The equation we are going to use for the speed of sound is:

Speed of Sound (m/s) = 331.3 + 0.606T

where T is the temperature in Celcius (Centigrade), not Kelvin.

So, the speed changes by approx. 0.6 metres per second or 0.2% for every degree change in temperature. We’ll include that in our calculations.

Calculating the Location of a Sound

Now that we know how fast sound travels, we can talk about how we go about calculating the location of the sound.

Let’s say that we have two sound triggers, one at each end of a corridor, and we want to calculate where the sound of footsteps came from. If the sound triggers are 10 metres (10m) apart and the footstep came from 3m away from one, 7m away from the other, then:

  • It takes 3 / 343.42 = 8.74x10-3 seconds (8.74 milliseconds) for the sound to reach the first sound trigger
  • It takes 7 / 343.42 = 20.38x10-3 seconds (20.38 milliseconds) for the sound to reach the second sound trigger

But how do we calculate the location if all we have is the time each sound trigger hears the footstep? Like this:

  • We have a ZED-F9P at each end and timestamp each trigger event very accurately
  • The difference between the two timestamps will be 11.65ms (20.38ms - 8.74ms)
  • We can use the time difference to calculate the location, because we know how far apart the sound triggers are
  • In 11.65ms sound travels 343.42 * 0.01165 = 4.0m
  • We can calculate the distance from the first sound trigger by subtracting 4.0m from 10.0m and then dividing by 2
  • Our sound came from 3.0m away from the first sound trigger

If we want to calculate the location of a sound in two dimensions, X and Y, or East and North, then we need three sound triggers so we can triangulate the location. We will show you how to do that in the next tutorial!

Accuracy and Sources of Error

Looking at the datasheet for the ZED-F9P high precision GNSS module, we see that it quotes a 99% accuracy for its time pulse signal of 60 nanoseconds. If we look at the datasheet for the ZED-F9T high accuracy timing module, we see that it offers a big improvement: 5 nanosecond accuracy for the time pulse in absolute timing mode; and 8 nanosecond time-mark resolution. So, really, if we want the highest accuracy, we should be using the ZED-F9T.

SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic)

SparkFun GNSS Timing Breakout - ZED-F9T (Qwiic)

GPS-18774
$299.95

Now 60ns is really not very long. It is 0.00000006 of a second. But how far does sound travel in 60ns? If we multiply 343.42 by 0.00000006, we get 20.6 x 10-6 metres. Or 0.02 mm. OK. That’s pretty good! So we don’t need to worry too much about the timing accuracy of the ZED-F9P. And don’t forget that the TIM_TM2 message, which captures our time-mark or interrupt, has nanosecond resolution.

But what about our VM1010 sound trigger? Well, the datasheet doesn’t contain the numbers we really need, which is the minimum and maximum delay from the sound crossing the detection threshold to the TRIG (DOUT) signal going high. But, so long as there is not a big difference from chip to chip, the delay doesn’t really matter. If the time delay is fixed, it will cancel out in our calculations. But if one chip has a different delay to another, that will affect the accuracy. So let’s measure it!

Here is an oscilloscope trace of 100 sound events detected on two VM1010’s. The oscilloscope is being triggered by one VM1010 on the yellow trace. The purple trace is the TRIG (DOUT) signal from the second VM1010. They were being triggered by a short ‘click’ sound from a dog training aid. And, yes, we were careful to make sure they were both the same distance from the click!

Pictured is the oscilloscope screen showing the sound events

One of the interesting things I noticed is that when I press the button on the dog training aid, to produce the first of a pair of clicks, the output signal from the second VM1010 follows the rising edge group at ~140 microseconds before the first. When I release the button on the training aid, to make a second click, the output from the second VM1010 follows the group ~50 microseconds after the first. I don’t yet have a theory about why it does that… But it must have something to do with slight differences in the intensity or frequency spectrum of each click.

Anyway, if we take 140 microseconds to be the worst case error between these two VM1010’s, that corresponds to a distance of 343.42 * 0.00014 = 0.048m or 4.8cm. That’s still pretty respectable and not too far away from the accuracy we could expect if we were to survey-in the position of each sensing point.

In summary, we can make a hand-waving argument that we can expect the accuracy of our sound location system to be better than 10cm. Happy days!

Example Code

The GitHub Hardware Repo contains two examples for the Sound Trigger. You can run these in the Arduino IDE.

The first example, as the name suggests, is very simple. It uses the Qwiic (I2C / Wire) bus to communicate with the PCA9536 on the Sound Trigger. If a sound event is detected, you see a serial message showing how long it was since the last sound event. Then the event is cleared (reset) ready for the next one. The red LED on the sound trigger will light up briefly on each event. The LED on your board (LED_BUILTIN) will flash for a full second on each event.

The second example is the crowd pleaser! It runs on the MicroMod Data Logging Carrier Board together with the Artemis Processor Board but it should work just fine with any of our processor boards. It communicates with our ZED-F9P Breakout and the Qwiic Sound Trigger to capture sound events and log them to SD card as u-blox UBX TIM_TM2 messages.

SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$21.50
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95

Hardware Connections

  • Solder a 6-way row of header pins to the Qwiic Sound Trigger so you can access the TRIG pin.
  • Please see the Data Logging Hookup Guide
  • Insert the Artemis Processor into the MicroMod Data Logging Carrier Board and secure with the screw.
  • Connect your ZED-F9P GNSS breakout to the Carrier Board using a Qwiic cable.
  • Connect an antenna to your GNSS board. The antenna must have a clear view of the sky. Extend and feed the cable through a window if you need to.
  • Insert a formatted micro-SD card into the socket on the Carrier Board.
  • Connect the Qwiic Sound Trigger to the ZED-F9P using a second Qwiic cable.
  • Use a jumper cable to connect the TRIG pin on the Qwiic Sound Trigger to the INT pin on the ZED-F9P breakout.
  • Connect the Carrier Board to your computer using a USB-C cable.

Pictured is the Qwiic Sound Trigger connected to the ZED-F9P and Micro Mod data logging carrier board

To minimise I2C bus errors, it is a good idea to open the I2C pull-up split pad links on the MicroMod Data Logging Carrier Board and the u-blox module breakout and the Qwiic Sound Trigger.

Software Setup

  • Ensure you have the SparkFun Apollo3 boards installed
  • This code has been tested using version 1.2.1 of the Apollo3 boards on Arduino IDE 1.8.13.
  • Select "SparkFun Artemis MicroMod" as the board type.
  • Press upload to upload the code onto the Artemis.
  • Open the Serial Monitor at 115200 baud to see the output.

Each time the Qwiic Sound Trigger detects a sound, it pulls its TRIG pin high. The ZED-F9P will detect this on its INT pin and generate a TIM_TM2 message. The Artemis will log the TIM_TM2 messages to SD card. You can then study the timing of the sound pulse with nanosecond resolution and calculate the location of the sound!

The code will "debounce" the sound event and reset the VM1010 for the next event after 250ms.

Note: TIM_TM2 can only capture the timing of one rising edge and one falling edge per navigation solution. So with setNavigationFrequency set to 4Hz, we can only see the timing of one rising edge every 250ms. The code "debounces" each sound event to make sure there will only be one rising edge event per navigation solution.

TIM_TM2 messages are only produced when a rising or falling edge is detected on the ZED-F9P’s INT pin. If you disconnect your TRIG to INT jumper wire, the messages will stop.

Data is logged in u-blox UBX format. Please see the u-blox protocol specification for more details. You can replay and analyze the data using u-center should you want to.

Analyzing the TIM_TM2 Data

Our Python Examples will process the UBX files for you to calculate the location of the sound events!

For the simplest two-sound-trigger set-up:

  • Copy the TIM_TM2.ubx file from the SD card from the first system. Rename the file so you know which system it came from. You might want to call it TIM_TM2_1.ubx.
  • Do the same for the TIM_TM2.ubx file from the second system. Again, rename it so you know which system it came from.
  • Place both files in the same folder / directory as the Sound_Trigger_Analyzer_1D.py Python file

Run the Python code by calling:

language:python
python Sound_Trigger_Analyzer_1D.py TIM_TM2_1.ubx TIM_TM2_2.ubx 10.0 20.0
  • Replace TIM_TM2_1.ubx with the name of the file from the first system as necessary
  • Replace TIM_TM2_2.ubx with the name of the file from the second system as necessary
  • Replace the 10.0 with the distance between your two sound triggers in metres
  • The 20.0 is optional. It is the temperature in Celcius (Centigrade). Change this to your actual temperature for added accuracy

The Python code will open and analyze the two UBX files and extract the times of the sound events from the TIM_TM2 data. It will then look for pairs of events which are close enough together in time. For each pair it finds, it will calculate the distance of the sound from sensor 1. If you are testing this in a corridor, walking away from sensor 1 towards sensor 2, you will see the distance gradually increase with each footstep.

Next time, we take this to the next level with three systems doing 2D sound location! Stay tuned…


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

MicroMod mikroBUS™ Carrier Board Hookup Guide

$
0
0

MicroMod mikroBUS™ Carrier Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Advanced Product: Novice users, may find the amount information contained in this tutorial somewhat daunting. This board is relatively complex and involves compatibility with three separate ecosystems and can be utilize two different development environments.

Introducing the our most versatile development board, the MicroMod mikroBUS™ Carrier Board! This new board takes advantage of the MicroMod, Qwiic, and the mikroBUS™ ecosystems and allows users to take advantage of the growing number of 7 MicroMod processor boards, 83 Qwiic (add-on) boards, and 1079 availableClick boards™(as of September 2021), which equates to +51M different board combinations.

SparkFun MicroMod mikroBUS Carrier Board

SparkFun MicroMod mikroBUS Carrier Board

DEV-18710
$19.95

The mikroBUS™ standard was developed by MikroElektronika. Similar to our Qwiic and MicroMod interfaces, mikroBUS™ provides a standardized connection for add-on Click boards™ to be hooked up to a microcontroller based development board.

1000clicks-logo.png
Image source: https://www.mikroe.com/1000-click-boards

For more details, check out their blog post on the 1000th Click board™ and the origins of the mikroBUS™ standard and mikroBUS™ standard specifications.

Required Materials

To get started, users will need a few of items listed below. (You may already have a some of these items; read through the guide and modify your cart accordingly.)

MicroMod Processor Board

Like other MicroMod Carrier Boards, a Processor Board is required for the product to operate. Users will need a Processor Board (of their choice) to attach to the MicroMod M.2 connector; since, one is not included with this product. Below, are few options; however, we recommend the STM32 processor board. Currently, it is the only processor board supported by Necto Studio and the Arduino IDE.

SparkFun MicroMod STM32 Processor

SparkFun MicroMod STM32 Processor

DEV-17713
$16.50
SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$16.95
1
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$18.95
1
SparkFun MicroMod nRF52840 Processor

SparkFun MicroMod nRF52840 Processor

WRL-16984
$21.50
SparkFun MicroMod RP2040 Processor

SparkFun MicroMod RP2040 Processor

DEV-17720
$12.95

Required Hardware

A Phillips screw driver is necessary to attach the Processor board to the Carrier Board.

MicroMod Screwdriver

MicroMod Screwdriver

TOL-19012
$0.50
SparkFun MicroMod mikroBUS Carrier Board

SparkFun MicroMod mikroBUS Carrier Board

DEV-18710
$19.95
JTAG Programming

To program the STM32 processor board(recommended) through Necto Studio(preferred), users will need a JTAG programmer. Below are programmers that are compatible with the Necto Studio software.

Apple Mac/Linux: Users with a Mac or Linux OS, should purchase the CODEGRIP programmer. The mikroProg is only compatible with Windows PCs.
MIKROE mikroProg for STM32

MIKROE mikroProg for STM32

PGM-19104
$49.95
MIKROE CODEGRIP for STM32

MIKROE CODEGRIP for STM32

PGM-19105
$99.95

Users will also need some soldering equipment and a JTAG header to connect the programmer to the board. Additionally, with the (recommended) programmers, an adapter is needed to convert the .1" (100 mil) header spacing of the programmer's cable to the .05" (50 mil) header spacing of the JTAG pins on the MicroMod mikroBUS™ carrier board.

Note: Users should verify that the pinout for the programmer and adapter match up to the corresponding pins of the MicroMod mikroBUS™ carrier board to avoid damaging the MCU.
Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$9.95
7
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$67.95
2
Header - 2x5 Pin (Male, 1.27mm)

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.75
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$8.95
4
Header - 2x5 Pin (Female, 1.27mm)

Header - 2x5 Pin (Female, 1.27mm)

PRT-15363
$1.75
MIKROE 50-100mil Adapter

MIKROE 50-100mil Adapter

PGM-19220
$14.95
USB Programming

To program a MicroMod processor through the Arduino IDE (not the preferred method), a USB-C cable is needed to connect the Carrier Board to a computer.

USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3
Click Board™

We recommend purchasing a Click board™ to utilize the mikroBUS™ socket. Feel free to choose from any of the available Click boards™ in our catalog. Below are a few options.

Note: If users intend to use the Arduino IDE, we recommend that novice users select a Click board™ that is supported with an Arduino library. Otherwise, users will have difficulties programming their board to utilize the associated Click board™.
MIKROE 6LoWPAN C Click

MIKROE 6LoWPAN C Click

WRL-18815
$25.95
MIKROE SpeakUp Click

MIKROE SpeakUp Click

DEV-18876
$39.95
MIKROE MOTION Click

MIKROE MOTION Click

SEN-18953
$12.95
MIKROE Ambient 9 Click

MIKROE Ambient 9 Click

SEN-19407
$9.95

Note: If users intend to use Click board™, with code that requires a serial data output, there are no serial pins broken out on the board besides the mikroBUS™ socket. Therefore, it is recommended that users also purchase the MIKROE Terminal Click, a 3.3V serial-to-UART adapter, jumper wires, and corresponding USB cable to access the serial data pins from the mikroBUS™ socket. Below, are a few options from our catalog:


SparkFun FTDI Basic Breakout - 3.3V

SparkFun FTDI Basic Breakout - 3.3V

DEV-09873
$16.95
66
SparkFun Serial Basic Breakout - CH340C and USB-C

SparkFun Serial Basic Breakout - CH340C and USB-C

DEV-15096
$9.95
7
SparkFun Serial Basic Breakout - CH340G

SparkFun Serial Basic Breakout - CH340G

DEV-14050
$8.95
6
MIKROE Terminal Click

MIKROE Terminal Click

DEV-18961
$6.95
Jumper Wires Premium 6" M/F Pack of 10

Jumper Wires Premium 6" M/F Pack of 10

PRT-09140
$4.50
1
USB Micro-B Cable - 6"

USB Micro-B Cable - 6"

CAB-13244
$2.10
3
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3
USB Mini-B Cable - 6"

USB Mini-B Cable - 6"

CAB-13243
$2.10
4

Optional Hardware

To connect Qwiic breakout boards for your MicroMod project, Qwiic cables are required.

Note: If users intend to use Necto Studio, we recommend that novice users select Qwiic products that are supported with a MIKROE library. Otherwise, users will have difficulties programming their board to utilize the associated Qwiic board.

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

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

GPS-15712
$69.95
2
SparkFun Qwiic Mini ToF Imager - VL53L5CX

SparkFun Qwiic Mini ToF Imager - VL53L5CX

SEN-19013
$24.95
SparkFun Environmental Sensor Breakout - BME680 (Qwiic)

SparkFun Environmental Sensor Breakout - BME680 (Qwiic)

SEN-16466
$22.50
3
SparkFun Micro OLED Breakout (Qwiic)

SparkFun Micro OLED Breakout (Qwiic)

LCD-14532
$18.50
6
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50
SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$8.95
13
Flexible Qwiic Cable - 200mm

Flexible Qwiic Cable - 200mm

PRT-17258
$1.60
Flexible Qwiic Cable - Breadboard Jumper (4-pin)

Flexible Qwiic Cable - Breadboard Jumper (4-pin)

PRT-17912
$1.60

A single-cell Lithium-ion battery can be connected to the Qwiic Carrier Board for portability.

Lithium Ion Battery - 1Ah

Lithium Ion Battery - 1Ah

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

Lithium Ion Battery - 2Ah

PRT-13855
$13.95
7
Lithium Ion Battery - 400mAh

Lithium Ion Battery - 400mAh

PRT-13851
$5.50
10
Lithium Ion Battery - 110mAh

Lithium Ion Battery - 110mAh

PRT-13853
$5.50
2

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

Hobby Knife

Hobby Knife

TOL-09200
$3.50
2

Suggested Reading

The MicroMod ecosystem is a unique way to allow users to customize their project to their needs. The Qwiic connect system is a simple method for interfacing with I2C devices. The mikroBUS™ socket is a standardized interface for the MIKROE Click boards™. Click on the banners below for more information on each ecosystem.

MicroMod Logo

Qwiic Logo

mikroBUS Logo


For users who aren't familiar with the following concepts, we also recommend reading the following 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!

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.

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.

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!

Designing with MicroMod

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

MicroMod STM32 Processor Hookup Guide

Get started with the MicroMod Ecosystem and the STM32 Processor Board!
New!

Getting Started with Necto Studio

Necto Studio is a user friendly development environment for users looking to get started with MikroElektronika's MIKROE products.

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.

ARM Programming

How to program SAMD21 or SAMD51 boards (or other ARM processors).

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.

Hardware Overview

Board Dimensions

The MicroMod mikroBUS™ carrier board dimensions are approximately 3.35" x 1.40" with four mounting holes compatible with 4-40 screws or standoffs.

MicroMod mikroBUS carrier board dimensions
Dimensions of the MicroMod mikroBUS™ carrier board. (Click to enlarge)

The board also includes a mikroBUS™ socket for MikroElektronika's Click boards™.

Photo highlighting
mikroBUS™ socket to attach Click boards™. (Click to enlarge)

Common Components

Most SparkFun MicroMod Carrier Boards will have some common components and all MicroMod Carrier Boards will have the keyed M.2 MicroMod connector for a Processor board. The photo and list below outline the common components between the mikroBUS™ carrier board and other MicroMod Carrier Boards.

  • M.2 MicroMod Connector - This special keyed M.2 connector lets you install your MicroMod Processor of choice to the mikroBUS Carrier Board.
  • USB-C Connector - Connect to your computer to program your processor and provide power to the board.
  • 3.3V Regulator - Provides a regulated 3.3V and sources up to 1A.
  • Qwiic Connectors - The standard Qwiic connectors to connect other Qwiic devices for your MicroMod project.
  • Boot/Reset Buttons - Push buttons to enter boot mode on processors and to reset your MicroMod circuit.

Annotated photo for common components on the carrier board
Common MicroMod components featured on the MicroMod mikroBUS™ Carrier Board. (Click to enlarge)

Battery Charger

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

Photo highlighting the charging circuit
Batery charger for the mikroBUS™ carrier board. (Click to enlarge)

Status LEDs

The carrier board has two status LEDs:

  • 3V3 - This LED indicates when 3.3V power is available top the board.
  • CHG - This LED indicates the status of the charging circuit operation.

Photo highlighting the status LEDs
Status LEDs on the mikroBUS™ carrier board. (Click to enlarge)

Solder Jumpers

Users who have never worked with soldering jumpers and cutting PCB traces before (or for a quick refresher), check out our How to Work with Solder Jumpers and PCB Traces tutorial for detailed instructions and tips.

There are four adjustable solder jumpers on the mikroBUS™ carrier board labeled MEAS, BYP, 3.3V_VE and 3.3V. The table below briefly outlines their functionalities:

Jumper Name/LabelDescriptionDefault State
Measure/MEASOpen this jumper to probe the current draw at the 3.3V output of the regulator. For help measuring current, take a look at our How to Use a Multimeter tutorial.CLOSED
Bypass/BYPThe "penny-in-the-fuse" jumper. Bypasses the 6V/2A fuse and nets VIN and V_USB together. Close only if you know what you are doing!OPEN
Voltage Regulator Enable/VEVoltage regulator control. Close this jumper to control the VREG in low-power applications.OPEN
3.3V LED Power/3V3 LEDConnects the 3.3V LED to 3.3V via a 1K Ohm resistor. Open to disable the LED.CLOSED

Jumpers
Jumpers on the mikroBUS™ carrier board. (Click to enlarge)

MicroMod Pinout

Since this carrier board is designed to work with all of the MicroMod Processors we've included the table below to outline which pins are used so, if you would like, you can compare them to the pinout tables in their respective Hookup Guides.

AUDIOUARTGPIO/BUSI2CSDIOSPIDedicated
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_VINI USB VIN compliant to USB 2.0 specification.
Connect to pins on Processor Board that require 5V for USB functionality.
4.8-5.2V
RTC_3V_BATTI 3V 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/3I Carrier 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 range
3.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
M.2 Pin# MicroMod Pin Name Board Connections Description
1GND GND
mikroBUS™ Socket - GND
Ground plane
23.3V 3.3V
mikroBUS™ Socket - +3.3V
Regulated 3.3V via USB-C
3USB_D+--USB D+ connection for Processor Board
43.3V_EN--Voltage regulator enable input
5USB_D---USB D- connection for Processor Board
6RESETRESET Button Connected to RESET Button
Reset is active LOW
9USB_VINmikroBUS™ Socket - +5VInput voltage from USB
10D0 D0
mikroBUS™ Socket - INT
Digital I/O pin
11BOOTBOOT Button Connected to BOOT Button
Boot is active LOW
12I2C_SDA SDA
Qwiic Connector - SDA
mikroBUS™ Socket - SDA
I2C data signal for Qwiic devices
14I2C_SCL SCL
Qwiic Connector - SCL
mikroBUS™ Socket - SCL
I2C clock signal for Qwiic devices
16I2C_INTINTI2C interrupt pin
17UART_TX1mikroBUS™ Socket - TXUART transmit data pin
18D1 D1
mikroBUS™ Socket - RST
Digital I/O pin
19UART_RX1mikroBUS™ Socket - RXUART receive data pin
32PWM0mikroBUS™ Socket - PWMPWM output pin
34A0mikroBUS™ Socket - ANADC input pin
55SPI_CSCS
mikroBUS™ Socket - CS
SPI Chip Select
57SPI_SCK SCK
mikroBUS™ Socket - SCK
SPI Clock signal
59SPI_COPI COPI
mikroBUS™ Socket - MOSI
SPI Controller Out/Peripheral In signal
61SPI_CIPO CIPO
mikroBUS™ Socket - MISO
SPI Controller In/Peripheral Out signal

Breakout Pins

The mikroBUS™ carrier board features a 3.3V, a ground, seven I/O breakout pins. The functionality of these pins are detailed in the table above.

breakout pins
Breakout pins on the mikroBUS™ carrier board. (Click to enlarge)

JTAG Pins

The mikroBUS™ carrier board includes JTAG PTH pins for a JTAG header, to be used with one of the recommended MikroElektronica mikroProg programmers. The JTAG pins breakout the SWD (software debug) pins to the MicroMod processor board.

JTAG pins
JTAG pins on the mikroBUS™ carrier board. (Click to enlarge)

mikroBUS™ Socket

The most significant feature of this board, is the addition of the mikroBUS™ socket, which provides a drop-in interface for MikroElektronka's ecosystem of Click boards™ (over 1079 as of September 2021).

The mikroBUS™ socket comprises a pair of 8-pin female headers with a standardized pin configuration. The pins consists of three groups of communications pins (SPI, UART and I2C), six additional pins (PWM, Interrupt, Analog input, Reset and Chip select), and two power groups (3.3V and 5V).

mikroBUS™ socket
Standardized pin connections for the mikroBUS™ scoket. (Click to enlarge)
mikroBUS™ Socket
Pin Name
Carrier Board's
Processor Pin
mikroBUS™ Socket
I/O Direction
Description
5VUSB_VINInputPower supply: 4.75~5.5V
3.3V3.3VInputPower supply: 3.3V
GND--Ground
SCKSCK (57)InputSPI - Clock signal
CIPOCIPO (59)OutputSPI - Data from mikroBUS™ socket
COPICOPI (61)InputSPI - Data to mikroBUS™ socket
CSCS0 (55)InputSPI - Chip select for mikroBUS™ socket
SCLSCL (14)Input/OutputI2C - Clock signal
SDASDA (12)Input/OutputI2C - Data signal to/from mikroBUS™ socket
TXTX1 (17)InputTX - Serial data to mikroBUS™ socket
RXRX1 (19)OutputRX - Serial data from mikroBUS™ socket
RSTD1 (18)InputReset signal to mikroBUS™ socket
INTD0 (10)OutputInterrupt trigger from mikroBUS™ socket
ANA0 (34)OutputAnalog output from mikroBUS™ socket
PWMPWM0 (32)InputPWM signal to mikroBUS™ socket

*For more information about the mikroBUS™ socket, click here for the mikroBUS™ standard specifications.

Qwiic Connector

The Qwiic connectors are provided for users to seamlessly integrate with SparkFun's Qwiic Ecosystem.

qwiic connectors
Qwiic connector on the MicroMod Qwiic carrier board. (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.

Hadware Assembly

For those unfamiliar with the MicroMod ecosystem, be sure to review the Getting Started with MicroMod guide.

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!

MicroMod Processor Board

To get started users will need a compatible processor board. Insert the MicroMod processor board into the M.2 socket for the processor board at an angle, with its edge connector aligned to the matching slots.

Note: The dimensions of the processor board's edge connector prevents it from mating with the slots of the M.2 socket in reverse. As an extra safeguard, the screw insert is spaced to only match the screw key of MicroMod processor boards.

When inserted properly, the processor board will rest at an angle:

MicroMod processor board inserted into the carrier board
Inserting a processor board into the M.2 socket. (Click to enlarge)

To secure the processor board, gently hold down on the board and attach the M.2 screw with a Phillip's head (PH0 or PH1) screw driver. Below, is an example of an assembled MicroMod system:

MicroMod processor board attached to the carrier board
A processor board attached to the MicroMod mikroBUS™ carrier board. (Click to enlarge)

JTAG Programming (preferred)

To program the processor board on the MicroMod mikroBUS™ carrier board, users will need a JTAG adapter to convert the .1" (100 mil) header spacing on the programmer cable to the .05" (50 mil) header spacing of the JTAG pins on the MicroMod mikroBUS™ carrier board. Additionally, users will need to solder on a compatible JTAG header to their board.

Note: Users should verify that the connections from the programmer matches up to the correct pins on the MicroMod mikroBUS™ carrier board to avoid damaging the MCU of the processor board.

CODEGRIP programmer
mikroProg programmer

Programming the MicroMod mikroBUS™ carrier board through the JTAG pins. (Click to enlarge)

JTAG Header

With the preferred programming method, Necto Studio, users will program the processor board on the MicroMod mikroBUS™ carrier board through the JTAG pins. Therefore, users will need to solder on a JTAG header for the programmer to connect to.

Note: Users should double check for solder bridges and clean off any flux residue to avoid potential issues with programming.

Soldering a JTAG header
Soldering a JTAG header to the MicroMod mikroBUS™ carrier board. (Click to enlarge)

JTAG Adapter

With the recommended programmer, users will need an adapter to convert the .1" (100 mil) header spacing on the programmer cable to the .05" (50 mil) header spacing of the pins on board, .

Note: Users should verify that the pinout for the programmer and adapter match up to the corresponding pins of the MicroMod mikroBUS™ carrier board to avoid damaging the MCU of the processor board. Additionally, preventative measures should be taken if there is a risk that the pins from the adapter could contact the processor board.

JTAG adapter
The JTAG adatpter with pins exposed over the processor board. (Click to enlarge)
tape used as protection
Tape used to prevent shorts on the processor board. (Click to enlarge)

USB Programming (not preferred)

A processor board utilized on the MicroMod mikroBUS™ carrier board, can also be connect to a computer with a USB-C cable and programmed with the Arduino IDE. Depending on the processor board, users may need to install drivers (if they have not done so already).

Note: Make sure that the correct board definitions are installed in the Arduino IDE, for the selected processor board. For help installing board definitions, use the MicroMod processor boards landing page and review the associated hookup guide for that hardware.

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.

To upload a sketch to the STM32 processor board (recommended), users will need to:

  1. Connect a USB-C cable between the board and the computer
  2. Hold down the BOOT button
  3. Toggle the RESET button
  4. Hit the upload button in the Arduino IDE, to program the sketch
    • Make sure to use the correct setting in the Tools menu for the processor board
  5. Once the upload process has completed in the Arduino IDE, the BOOT button can be released

Programming steps
Steps for programming the STM32 processor board with the Arduino IDE. (Click to enlarge)

Battery

For remote applications, the MicroMod mikroBUS™ carrier board can be powered through its 2-pin JST battery connector. Additionally, users may be interested in utilizing a solar panel and USB-C cable to recharge their battery.

Battery connected to the MicroMod mikroBUS™ carrier board
The MicroMod mikroBUS™ carrier board with a battery attached. (Click to enlarge)
Solar Panel Charger - 10W

Solar Panel Charger - 10W

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

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3

Note: DO NOT remove batteries by pulling on their wires. Instead, it is recommended that pair of dikes (i.e. diagonal wire cutters), pliers, or tweezers be used to pull on the JST connector housing, to avoid damaging the battery wiring.

Disconnect battery w/ dikes
Using a pair of dikes to disconnect a battery. (Click to enlarge)

mikroBUS™ Socket

The MicroMod mikroBUS™ carrier board has a mikroBUS™ Socket, where a Click board™ can be inserted.

Attached click board
A Click board™ inserted into the mikroBUS™ socket of the MicroMod mikroBUS™ carrier board.

Note: To remove a Click board™, slowly and carefully wiggle it out of the mikroBUS™ socket to avoid bending the header pins on their Click board™.

The header also allows users to connect jumper wires to devices that may not have the mikroBUS™ pin layout to interface with.

jumper wiring
A device connected to the mikroBUS™ socket of the MicroMod mikroBUS™ carrier board with jumper wires.

Serial Data Output

Note: Some of the examples for the Click board™ libraries in Necto Studio, utilize a serial data output to verify functionality. In order to access the serial data output from the mikroBUS™ socket, users can use a Terminal Click Board™, serial-to-UART adapter, and jumper wires.

terminal click stack on
Weather and Terminal Click boards™ inserted into the mikroBUS™ socket of the MicroMod mikroBUS™ carrier board and connected to a serial-to-UART adapter. (Click to enlarge)

To breakout the pins of the mikroBUS socket™, a Terminal Click board™ can be stacked between a Click board™ and the mikroBUS socket™.

terminal click stack on
Weather and Terminal Click boards™ inserted into the mikroBUS™ socket of the MicroMod mikroBUS™ carrier board. (Click to enlarge)

Once the serial pins have been broken out with the Terminal Click board™, users can access the serial pins with a serial-to-UART adapter and some jumper wire. The pin connections are summarized in the table below and illustrated in the following images.

Terminal Click™Serial BreakoutDescription
RXRXISerial data output from Click board™ to MCU
TXTXOSerial data output from MCU to Click board™
3.3VVCCPower input to mikroBUS socket™
GNDGNDGround

Top view of jumper wire connections. (Click to enlarge)

Front view of the jumper wire connections. (Click to enlarge)

Qwiic Devices

To connect Qwiic devices to the carrier board, users will need Qwiic cables; most of these devices can also be daisy chained together. For more information, check out our Qwiic ecosystem page.

Attaching Qwiic devices to carrier board
Attaching Qwiic devices to the MicroMod mikroBUS™ carrier board. (Click to enlarge)

Software Overview

Necto Studio

Necto Studio is a productive cross-platform integrated developing environment provided by MikroElektronika and is available on Windows, Linux, and macOS. It includes C compilers, mikroSDK 2.0, package manager, and USB or WiFi Debugger capabilities with flexible licensing options. The development environment features intelligent code completion, auto-close brackets, and drag and drop visual elements.

Users can find their favorite Click Board library and working example through the Package Manager. Users will also be notified about new versions of installed packages, and easily update in one click.


Source: MikroElektronika blog post

MikroElektronika even provides first-time users with the longest time trial on the market - Get fully unlocked, feature-rich NECTO for three months, and explore it to the most delicate details before purchase!

For more information about NECTO Studio, please visit the product page.

mikroSDK

mikroSDK 2.0 makes application code portable and reusable on many different platforms and architectures, with virtually no code changes. It is a collection of open-source software libraries with unified API and software development tools. Everything you need to start developing, and prototyping cross-platform embedded applications, including Click board™ applications and GUIs for embedded devices.

mikroSDK 2.0 is open-source, and it’s natively supported in NECTO Studio. The video below, is a brief overview of how to use the mikroSDK:

Additional Resources:

For more details on Necto Studio, check out our getting started guide below:

New!

Getting Started with Necto Studio

February 25, 2022

Necto Studio is a user friendly development environment for users looking to get started with MikroElektronika's MIKROE products.
  • When creating a hardware setup, users will want to select:
    • mikroC AI for ARM compiler
    • mikroSDK(latest)
    • MicroMod Carrier Board
    • STM32F4045RG-Tx(should be only option)
    • No display
    • CODEGRIP Programmer(recommended)
      • To be able to debug and program the MCU from Necto Studio, users will want to configure the following target option parameters:
        target options
        Target options for the CODEGRIP programmer in Necto Studio. (Click to enlarge)
      • Erase Type:Erase and unlock
      • Connection:Under reset
      • Hold on Connect:Enabled
    • For more details, check out the Setups section of the Necto Studio getting started guide.
  • For the CODEGRIP programmer (recommended), users will need to link with the programmer and configure the programming target in the CODEGRIP Suite:
    • MCU:STM32F4045RG
    • Protocol:SWD
    • Connection:Under reset
    • Halt on Connect:Enabled
    • For more details, check out the Programmer Configuration section of the Necto Studio getting started guide.

Arduino IDE

Note: If users intend to use the Arduino IDE, we recommend that novice users select a Click board™ that is supported with an Arduino library. Otherwise, users will have difficulties programming their board to utilize the associated Click board™.

While not the preferred method for programming their board, users can use the Arduino IDE to upload sketches to the MicroMod mikroBUS™ carrier board. We recommend that users select a Click board™ with a supporting Arduino library for their processor board. Below, are a few tips to get users started.

Getting Started with MicroMod

For those unfamiliar with the MicroMod ecosystem, be sure to review the Getting Started with MicroMod guide. Also, make sure that the correct board definitions are installed in the Arduino IDE, for the associated processor 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!

Board Definitions

Make sure that the correct board definitions are installed in the Arduino IDE, for the connected processor board. Depending on the processor board, users may need to install drivers (if they have not done so already). For help installing board definitions, use the MicroMod processor boards landing page and review the associated hookup guide for that hardware.

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.

Arduino Library

Users will need to add the supporting Arduino library for their Click board™. If there isn't a supporting Arduino library, users will need to write a sketch to utilize that device; we DO NOT provide or offer support on custom code.

Note: We DO NOT provide or offer support for custom code. We highly recommend that novice users verify that there is a compatible Arduino library for the processor board and the device or Click board™ they wish to connect.

Note: This tutorial assumes users have the latest version of the Arduino IDE installed. 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:

Installing an Arduino Library

January 11, 2013

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.

Necto Studio Example

In this example, we will be using the Weather Click board™ and outputting the BME280 sensor's data to the UART Terminal. To get started, follow the instructions below.

Required Materials

For this example, users will need a MicroMod mikroBUS™ carrier board, STM32 processor board, phillips head screwdriver, Weather Click, MIKROE CODEGRIP for STM32 programmer, 50-100mil JTAG adapter, and access to a computer with the Necto Studio and the CODEGRIP Suite installed:

SparkFun MicroMod STM32 Processor

SparkFun MicroMod STM32 Processor

DEV-17713
$16.50
MicroMod Screwdriver

MicroMod Screwdriver

TOL-19012
$0.50
SparkFun MicroMod mikroBUS Carrier Board

SparkFun MicroMod mikroBUS Carrier Board

DEV-18710
$19.95
MIKROE Weather Click

MIKROE Weather Click

SEN-18823
$21.95
MIKROE CODEGRIP for STM32

MIKROE CODEGRIP for STM32

PGM-19105
$99.95
MIKROE 50-100mil Adapter

MIKROE 50-100mil Adapter

PGM-19220
$14.95

Users will also need some soldering equipment and a JTAG header to connect the programmer to the board:

Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$9.95
7
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$67.95
2
Header - 2x5 Pin (Male, 1.27mm)

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.75
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$8.95
4

To read the data output from the Weather Click example code, users will also need a Terminal Click, serial breakout board, jumper wires, and a USB cable:

SparkFun Serial Basic Breakout - CH340C and USB-C

SparkFun Serial Basic Breakout - CH340C and USB-C

DEV-15096
$9.95
7
Jumper Wires Premium 6" M/F Pack of 10

Jumper Wires Premium 6" M/F Pack of 10

PRT-09140
$4.50
1
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3
MIKROE Terminal Click

MIKROE Terminal Click

DEV-18961
$6.95

For users who haven't soldered before and/or need to install the CH340 driver for the Serial Basic breakout, the following tutorials should be reviewed before proceeding further:

How to Solder: Through-Hole Soldering

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

SparkFun Serial Basic CH340C Hookup Guide

SparkFun Serial Basic Breakout takes advantage of USB-C and is an easy-to-use USB-to-Serial adapter based on the CH340C IC from WCH. With USB-C you can get up to three times the power delivery over the previous USB generation and has the convenient feature of being reversable.

How to Install CH340 Drivers

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.
New!

Getting Started with Necto Studio

Necto Studio is a user friendly development environment for users looking to get started with MikroElektronika's MIKROE products.

Hardware Assembly

Hardware assembly is relatively straight forward, attach the STM32 processor board to the MicroMod slot, solder on the JTAG header, insert the Click boards™ into the mikroBUS™ socket, connect the carrier board to the programmer, connect the Serial Basic breakout, and then link the programmer to the computer.

MicroMod processor board attached to the carrier board
The STM32 processor board attached to the MicroMod mikroBUS™ carrier board. (Click to enlarge)

If users haven't done so, solder the JTAG header to the board.

Soldering a JTAG header
Soldering a JTAG header to the MicroMod mikroBUS™ carrier board. (Click to enlarge)

To breakout the serial pins of the mikroBUS™ socket, the Terminal Click board™ needs to be stacked between the Weather Click board™ and the mikroBUS™ socket.

Attached click boards
The Weather and Terminal Click boards™ inserted into the mikroBUS™ socket of the MicroMod mikroBUS™ carrier board. (Click to enlarge)

Once the serial pins have been broken out with the Terminal Click board™, users can access the serial pins with a Serial Basic breakout and some jumper wire.

Connected serial-to-UART adapter
The Serial Basic breakout connected to the Terminal Click board™. (Click to enlarge)

The pin connections are summarized in the table below and illustrated more closely in the images (click to enlarge).

Terminal Click™Serial BreakoutDescription
RXRXISerial data output from Click board™ to MCU
TXTXOSerial data output from MCU to Click board™
3.3VVCCPower input to mikroBUS socket™
GNDGNDGround

Wiring between the Serial Basic breakout and the Terminal Click board™. (Click to enlarge)

Finally, connect the CODEGRIP programmer with a JTAG adapter. Then, connect both the programmer and Serial Basic breakout to the computer.

CODEGRIP Programmer
Connecting the MicroMod mikroBUS™ carrier board to the computer. (Click to enlarge)

If everything was connected properly, the POWER and ACTIVE, and USB LINK LED indicators on the programmer will turn on. Once the ACTIVE LED indicator stops blinking, the CODEGRIP programmer is ready to be used.

programmer LEDs
Indicator LEDs on the CODEGRIP programmer. (Click to enlarge)

Software Setup

On the computer, users should have Necto Studio and the CODEGRIP Suite installed.

  • In the CODEGRIP Suite, users will need to link with the programmer and configure the programming target:

    • MCU:STM32F4045RG
    • Protocol:SWD
    • Connection:Under reset
    • Halt on Connect:Enabled
    NOTE: Users won't need to enable the power output on the programmer because the power connection from the Serial breakout board. This will provide enough power for the carrier board.

    After the programmer has been linked and the MCU target has been configured, users should be able to perform a target verification with the detect function.

    target detected
    Detecting the target MCU in the CODEGRIP Suite. (Click to enlarge)

    For more details, check out the Programmer Configuration section of the Necto Studio getting started guide.

  • In Necto Studio, if users should have already created a hardware configuration through the Setups page. The hardware configuration should include the following options:

    • mikroC AI for ARM compiler
    • mikroSDK(latest)
    • MicroMod Carrier Board
    • STM32F4045RG-Tx(should be only option)
    • No display
    • CODEGRIP Programmer
      • To be able to debug and program the MCU from Necto Studio, users will want to configure the following target option parameters:
        target options
        Target options for the CODEGRIP programmer in Necto Studio. (Click to enlarge)
      • Erase Type:Erase and unlock
      • Connection:Under reset
      • Hold on Connect:Enabled

    setup example
    Hardware configuration in Setups page of Necto Studio. (Click to enlarge)

    For more details, check out the Setups section of the Necto Studio getting started guide.

  • In the package manager of Necto Studio, users will need to install the Weather Click library.

    library installation
    The Weather Click library installed through the Package Manager page of Necto Studio. (Click to enlarge)

    For more details, check out the Package Manager section of the Necto Studio getting started guide.

  • Once the Weather Click library has been installed, users will have access the associated example for the library. From the Package Manager page, users should be able to create a new project by clicking on the Open Example button.

Running the Example Code

After the project has been created for the Weather Click example, users will be able to program the example onto their carrier board. This can be done either of two methods; however, the simplest method would be to use the Program button in Necto Studio.

To receive and display the serial data output from the example, users will need to open the UART Terminal in Necto Studio by selecting Tools>UART Terminal from the drop down menu.

In the UART Terminal, users will need to:

  • Select the Port for the Serial Basic breakout
  • Set the Baud rate to 115200 bps
  • Click on the Connect button

    UART Terminal
    UART Terminal configuration to connect to the Serial Basic breakout. (Click to enlarge)

If the connection succeeds, users should then see data from the BME280 sensor being displayed in the Receive text box.

data output
The BME280 sensor data being displayed in the UART Terminal. (Click to enlarge)
NOTE: If the data doesn't output immediately, try power cycling the carrier board, by disconnecting and reconnecting the power from the Serial Basic breakout.

Troubleshooting Tips

Below, we have also included some troubleshooting tips for issues that you may come across.

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

Hardware

For users looking for technical assistance specifically related to the hardware, click on this link. There you will find, basic troubleshooting tips and instructions to get started with posting a topic in our forum. Our technical support team will do their best to assist you.

Software

For users looking for technical assistance specifically related to the software, click on this link. There users can get started with posting a topic in MikroElektronika forum.

For commercial businesses, MikroElektronika also offers a Premium Technical Support package, which can be purchased from their website.

Sign-in or CODEGRIP Installation Issues

On Windows 10 PCs, if users experience an issues signing in to Necto Studio or come across an Error:UnknownNetworkError error message, their computer may be missing a Microsoft Visual C++ 2010 Runtime Library.

UnknownNetworkError
Failure to download CODEGRIP Suite and Error:UnknownNetworkError error message. (Click to enlarge)

To install the missing Microsoft Visual C++ 2010 Runtime Library, download the vcredist_x64.zip file(or click the button below), extract the folder, and execute the contained installation setup file vcredist_x64.exe.

Example Code Compilation Error

Users who select a Generic board in their hardware setup, may run into a compilation error. This error is because the pins for the Generic board are undefined, by default. Users will need to declare the pins utilized by their code for the build to compile.

generic board error
Compilation error message. (Click to enlarge)

Programming Issues

To detect a target MCU, it must be at least powered and have the SWD pins connected to the programmer.

Power

The carrier board has to be powered by in order for the programmer to detect the target MCU on the processor board. Users can power the carrier board externally or through the CODEGRIP programmer (by enabling it through the CODEGRIP Suite).

CODEGRIP Suite

Users should verify that they configure the target MCU properly.

Users can also manually program the MCU through the CODEGRIP Suite, by loading the compiled *.hex file of the project, built in Necto Studio and the writing it to the target MCU.

For more details, check out the Programmer and Debugger Configuration section of the Necto Studio getting started guide.

Necto Studio - Target Options

In order to program a MCU through Necto Studio, users will need to configure the Target options of the CODEGRIP programmer when creating their setup:

  • Erase Type:Erase and unlock
  • Connection:Under reset
  • Hold on Connect:Enabled

target options
Target options for the CODEGRIP programmer. (Click to enlarge)

No Data Output

If the data doesn't output immediately, try power cycling the carrier board, by disconnecting and reconnecting the power from the Serial Basic breakout.

Otherwise, verify that the MCU is being powered sufficiently. If the MCU isn't being powered sufficiently, it may not run or output data at the appropriate logic levels.

  • Users can double check the voltage through the CODEGRIP programmer in the CODEGRIP Suite. Open the POWER menu and select the newly unfolded Outputs menu item. Users should see the the voltage provided to the target MCU in the Measurements section:

    voltage measurement
    Voltage measurement for power to the target MCU through the CODEGRIP Suite. (Click to enlarge)

Resources and Going Further

For more on the MicroMod mikroBUS™ carrier board, check out the links below:

MicroMod mikroBUS Carrier Documentation

MicroMod Documentation:

For more project inspirations, check out these other MIKROE Click Boards™:

MIKROE Temp&Hum 15 Click

MIKROE Temp&Hum 15 Click

SEN-18800
$6.95
MIKROE Touchkey Click

MIKROE Touchkey Click

SEN-18882
$11.95
MIKROE BATT-MAN Click

MIKROE BATT-MAN Click

PRT-18900
$26.95
MIKROE Fan 8 Click

MIKROE Fan 8 Click

PRT-19004
$21.95
MIKROE Accel 20 Click

MIKROE Accel 20 Click

SEN-19106
$24.95
MIKROE Charger 6 Click

MIKROE Charger 6 Click

TOL-19272
$11.95
MIKROE H-Bridge 6 Click

MIKROE H-Bridge 6 Click

ROB-19341
$29.95
MIKROE Air Quality 7 Click

MIKROE Air Quality 7 Click

SEN-19403
$31.95

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

RP2040 mikroBUS™ Development Board Hookup Guide

$
0
0

RP2040 mikroBUS™ Development Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The RP2040 mikroBUS™ Development Board is our latest RP2040 microcontroller (MCU) development board. This new board takes advantage of the Qwiic and the mikroBUS™ ecosystems and allows users to take advantage of the growing number of 94 Qwiic boards and 1079 Click boards™(as of September 2021) to develop with the Raspberry Pi RP2040 microcontroller.

SparkFun RP2040 mikroBUS Development Board

SparkFun RP2040 mikroBUS Development Board

DEV-18721
$14.95

The Raspberry Pi RP2040 (the first MCU from the Raspberry Pi Foundation) is a low cost, dual-core Arm® Cortex® M0+ microcontroller with 264kB of SRAM, running at 133MHz. It includes USB host functionality, a timer with 4 alarms, a real time counter (RTC), six dedicated IO pins for Quad-SPI flash (supporting execute in place), and thirty multifunction GPIO

(*18 of which are broken out on the board), with the following capabilities:

  • Four 12-bit Analogue to Digital Converter (ADC) channels
  • Two UART buses
  • Two I2C buses
  • Two SPI buses
  • Up to 16 PWM channels
  • Can emulate interfaces such as SD Card and VGA

The mikroBUS™ standard was developed by MikroElektronika and provides a standardized connection to interface with Click boards™.

1000clicks-logo.png
Image source: https://www.mikroe.com/1000-click-boards

For more details, check out their blog post on the 1000th Click board™ and the origins of the mikroBUS™ standard and mikroBUS™ standard specifications.

Required Materials

To get started, users will need a few of items listed below. (You may already have a some of these items; read through the guide and modify your cart accordingly.)

Required Hardware

A USB-C cable is needed to connect the RP2040 mikroBUS™ Development Board to a computer.

USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3
SparkFun RP2040 mikroBUS Development Board

SparkFun RP2040 mikroBUS Development Board

DEV-18721
$14.95
Click Board™

We recommend purchasing a Click board™ to utilize the mikroBUS™ socket. We also suggest novice users select a Click board™ that is supported with an Arduino library. Otherwise, users will have difficulties programming their board to utilize the associated Click board™. Below, is a sample of the options available in our catalog:

MIKROE Spectrometer Click

MIKROE Spectrometer Click

SEN-18785
$24.95
MIKROE LightRanger 8 Click

MIKROE LightRanger 8 Click

SEN-18803
$11.95
MIKROE Thunder Click

MIKROE Thunder Click

SEN-18821
$34.95
MIKROE Weather Click

MIKROE Weather Click

SEN-18823
$21.95
MIKROE Load Cell Click

MIKROE Load Cell Click

SEN-18824
$11.95
MIKROE Servo Click

MIKROE Servo Click

ROB-18867
$24.95
MIKROE Accel Click

MIKROE Accel Click

SEN-18925
$19.95
MIKROE Air Quality 4 Click

MIKROE Air Quality 4 Click

SEN-18928
$31.95

Optional Hardware

To connect Qwiic breakout boards for your MicroMod project, Qwiic cables are required.

Qwiic Cable - Breadboard Jumper (4-pin)

Qwiic Cable - Breadboard Jumper (4-pin)

PRT-14425
$1.50
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95
SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$8.95
13
Flexible Qwiic Cable - Breadboard Jumper (4-pin)

Flexible Qwiic Cable - Breadboard Jumper (4-pin)

PRT-17912
$1.60
SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)

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

GPS-15712
$69.95
2
SparkFun RTK Facet

SparkFun RTK Facet

GPS-19029
$699.95
7
SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic)

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

GPS-16481
$274.95
10
SparkFun Triad Spectroscopy Sensor - AS7265x (Qwiic)

SparkFun Triad Spectroscopy Sensor - AS7265x (Qwiic)

SEN-15050
$69.95
6

A single-cell Lithium-ion battery can be connected to the Qwiic Carrier Board for portability.

Lithium Ion Battery - 1Ah

Lithium Ion Battery - 1Ah

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

Lithium Ion Battery - 2Ah

PRT-13855
$13.95
7
Lithium Ion Battery - 400mAh

Lithium Ion Battery - 400mAh

PRT-13851
$5.50
10
Lithium Ion Battery - 110mAh

Lithium Ion Battery - 110mAh

PRT-13853
$5.50
2

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
$9.95
7
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$67.95
2
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$8.95
4
Hobby Knife

Hobby Knife

TOL-09200
$3.50
2

Suggested Reading

The MicroMod ecosystem is a unique way to allow users to customize their project to their needs. The Qwiic connect system is a simple method for interfacing with I2C devices. Click on the banners below for more information on each system.

Qwiic Logo

mikroBUS Logo

For users who aren't familiar with the following concepts, we also recommend reading the following tutorials before continuing.

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.

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.

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.

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.

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

UF2 Bootloader

The RP2040 mikroBUS™ Development Board is easy to program, thanks the UF2 bootloader. With the UF2 bootloader, the RP2040 Thing Plus shows up on your computer as a USB storage device without having to install drivers for Windows 10, Mac, and Linux!

USB storage device
Board being recognized as a USB device. (Click to enlarge)

What is UF2?

UF2 stands for USB Flashing Format, which was developed by Microsoft for PXT (now known as MakeCode) for flashing microcontrollers over the Mass Storage Class (MSC), just like a removable flash drive. The file format is unique, so unfortunately, you cannot simply drag and drop any compiled binary or hex file onto the board. Instead, the format of the file must have specific information to tell the processor where the data goes, in addition to the data itself. For more information about UF2, you can read more from the MakeCode blog, as well as the UF2 file format specifiation.

BOOTSEL Mode

Users can enter BOOTSEL mode by holding down the BOOT button, when the USB connection is made to a computer. The board will remain in this mode until it power cycles (happens automatically after uploading a .uf2 firmware file) or the RESET button is pressed. The board will appear as a USB mass storage device under the name RPI-RP2.

Enter BOOTSEL Mode
Hold down BOOT button to enter BOOTSEL mode.

Note: As another option, with the USB-C cable already connected to the board and the computer, users can hold down the BOOT button and toggle the RESET button to enter BOOTSEL mode. However, this method does require a little bit of finger dexterity.

Hardware Overview

Note: Users may notice similarities between the RP2040 Thing Plus and the RP2040 mikroBUS™ development board. These boards are nearly identical, apart from the board dimensions and the mikroBUS™ socket. Please refer to the RP2040 Thing Plus hookup guide for more details on the board design.

RP2040 Thing Plus Hookup Guide

January 21, 2021

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

Board Dimensions

The RP2040 mikroBUS™ Development Board's pin layout has a feather form factor with a mikroBUS™ socket above. The board dimensions are illustrated in the drawing below.

Board Dimensions
Board dimensions (PDF) for the RP2040 mikroBUS™ development board, in inches. (Click to enlarge)

Power

The RP2040 mikroBUS™ Development Board only requires 3.3V to power the board. However, the simplest method to power the board is through the USB-C connector.

Power Connections
RP2040 mikroBUS™ development board power connections. (Click to enlarge)

The power pins that are available on the board, are detailed below:

  • 3V3 - A regulated 3.3V voltage source (600mA).
    • Regulated from the USB 5V power and/or battery connection by a AP2112 LDO.
    • Used to power the RP2040 MCU, WS2812 RGB LED, W25Q128 16MB flash chip, µSD card slot, +3.3V pin of the mikroBUS™ socket, and the Qwiic bus (I2C).
    • Serves as the reference voltage for the RP2040 ADC (ADC_VDD).
    • Pin can also operate as an input from an external power source.
  • USB - The voltage from the USB-C connector, usually 5V.
    • Used to provide a regulated 3.3V source through the AP2112 LDO (see above).
    • Serves as the power supply for the MCP73831 linear charge management controller to the JST battery connector.
    • Serves as the power supply for the +5V pin of the mikroBUS™ socket.
    • Utilizes a P-channel MOSFET to control the power source for the AP2112 LDO.
    • Utilizes a BAT20J protection diode for the USB-C connection.
  • VBAT - The voltage from the JST battery connector; meant for single cell LiPo batteries.
    • Used to provide a regulated 3.3V source through the AP2112 LDO (see above).
    • Connected to the MCP73831 linear charge management controller.
  • GND - The common ground or the 0V reference for the voltage supplies.

Power Pins
RP2040 mikroBUS™ development board power pins. (Click to enlarge)

Note: The RP2040 microcontroller has two low power states:

  • SLEEP - All the processors are asleep and most of the clocks in the chip are stopped
  • DORMANT - All clocks in the chip are stopped
The real-time clock (RTC) can wake the RP2040 chip up from both of these modes. However, to wake the chip from dormant mode, the RTC must be configured to use an external reference clock, supplied by a GPIO pin.

Power Status LED

The red, POWER LED will light up once 3.3V is supplied to the board; however, for most users, it will light up when 5V is supplied through the USB connection or when a LiPo battery is connected to the JST connector.

Power LED
RP2040 mikroBUS™ development board POWER status LED indicator. (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 and 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, pleas refer to the MCP73831 datasheet.

Power Control

The power source to the AP2112 LDO voltage regulator is controlled by a P-channel MOSFET. In addition, the 3.3V regulated output from the AP2112 is controlled by the enable (EN) pin, broken out on the board. By default, the chip enable pin (EN) is pulled high, to enable the 3.3V output, supply voltage. To disable and shutdown the output voltage from the AP2112, the chip enable pin (EN) needs to be pulled low (i.e. shorted to ground (GND)). For more information, pleas refer to the AP2112 datasheet.

Enable Pin
Enable pin on the RP2040 mikroBUS™ development board. (Click to enlarge)

RP2040 Microcontroller

The Raspberry Pi RP2040 is a low-cost, high-performance microcontroller with flexible digital interfaces. It features:

  • Dual Arm® Cortex®-M0+ processors, up to 133 MHz
  • 264 kB of embedded SRAM in 6 banks
  • 6 dedicated IO for additional storage
    • Connects to QSPI Flash
    • Supports execute in place (XIP))
  • 30x 3.3V user-programmable high-speed IO (only 18 are broken out on the board)
    • 4x 12-bit 500ksps Analogue to Digital Converter (ADC)
    • Various digital peripherals
    • 2x UART, 2x I2C, 2x SPI, up to 16 PWM channels
    • 1x Timer with 4 alarms, 1x Real Time Counter
  • USB 1.1 Host/Device compatible

RP2040 MCU
RP2040 on the RP2040 mikroBUS™ development board. (Click to enlarge)

The processor implements the ARMv6-M Thumb instruction set and provides programmable (multifunction) IO (PIO), which is unique to the RP2040. For more information, pleas refer to the RP2040 datasheet.

USB Functionality

The RP2040 contains a USB 2.0 controller that can operate as either:

  • Full Speed device (12 Mbit/s)
  • Host that can communicate with both Low Speed (1.5 Mbit/s) and Full Speed devices. This includes multiple downstream devices connected to a USB hub.

USB Mass Storage Interface
The Bootrom provides a standard USB bootloader that emulates a writeable drive available for loading firmware to the RP2040 using UF2 files. Once a UF2 file is loaded onto the drive, it is written to the flash or RAM and the device automatically reboots.

  • The bootrom source code is hosted on GitHub.

RPI-RP2 Drive
The RP2040 appears as a standard 128MB flash drive named RPI-RP2 formatted as a single partition with FAT16. There are only ever two actual files visible on the drive specified.

  • INFO_UF2.TXT - contains a string description of the UF2 bootloader and version.
  • INDEX.HTM - redirects to information about the RP2040 device.
Note: Any type of files may be written to the USB drive from the host computer, however in general these are not stored, and only appear to be so because of caching on the host side. When a .uf2 file is written to the device however, the special contents are recognized and data is written to specified locations in RAM or Flash. On the completed download of an entire valid .uf2 file, the RP2040 automatically reboots to run the newly downloaded code.

Flash Memory

RP2040 has embedded ROM and SRAM, and access to external flash via a QSPI interface. On the RP2040 mikroBUS™ development board, an additional 16MB (128Mbit) of 133MHz memory is provided by a W25Q128JVPIM chip. The flash memory is required for the RP2040 to store program code, which it can boot and run from through its dedicated QSPI pins:

  • Pin 52: CLK
  • Pin 56: CS
  • Pin 53: DATA 0/DI
  • Pin 55: DATA 1/DO
  • Pin 54: DATA 2/WP
  • Pin 51: DATA 3/HOLD

Flash Memory
W25Q128JVPIM flash memory on the RP2040 mikroBUS™ development board. (Click to enlarge)
Note: The RP2040 is able to access up to a 16MB memory window starting at 0x10000000.

Indicator LEDs

There are 4 indication LEDs on the RP2040 mikroBUS™ development board for:

  • PWR: Power (Red)
  • CHG: Battery Charging (Yellow)
  • 25:GPIO 25 (Blue)
  • WS2812:GPIO 08 (RGB)

Power LED

The red, PWR LED will light up once 3.3V is supplied to the board. For most users, it will light up when 5V is supplied through the USB connection and/or when a LiPo battery is attached to the JST connector.

Power LED
RP2040 mikroBUS™ development board PWR status LED indicator. (Click to enlarge)

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 (*or dimmed), when the charge management controller is in standby (after the battery charging has been completed), or when the charge management controller is shutdown (thermal shutdown or when the input voltage is lower than the battery voltage). 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 RP2040 mikroBUS™ development board. (Click to enlarge)
Charge Cycle StateSTAT1
Shutdown
  • Thermal Shutdown
  • VDD< VBAT
Off (High Z)
No Battery Present*Dimmed (High Z)
Charge Complete – StandbyOff (H)
PreconditioningOn (L)
Constant-Current Fast ChargeOn (L)
Constant VoltageOn (L)

*The charge LED may appear dimmed due a trickle charge from the MAX17048 fuel gauge. Normally, the LED should be OFF.

Status LED

The blue, 25 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 25.

Status LED
The status/test (25) LED indicator on the RP2040 mikroBUS™ development board. (Click to enlarge)

WS2812 RGB LED

The WS2812 RGB LED is controlled with a 24-bit (GRB) data signal. This indicator is connected to GPIO 08 and the digital output pin from the LED is broken out as the WS2812 pin on the board. For more information, please refer to the WS2812C datasheet.

RGB LED
WS2812 LED indicator on the RP2040 mikroBUS™ development board. (Click to enlarge)

Buttons

The RP2040 mikroBUS™ dev. board has two buttons on the board for uploading and running code.

Reset Button

The RESET button is connected to the reset pin and is used to reset the microcontroller without needing to unplug the board.

Reset Button
RESET button on the RP2040 mikroBUS™ development board. (Click to enlarge)

Boot Button

The BOOT button is used to force the board into BOOTSEL mode, by holding down the BOOT button while connecting the board to a computer through its USB-C connector. Users can then, upload firmware files to the emulated RPI-RP2 USB mass storage device.

Boot Button
BOOT button on the RP2040 mikroBUS™ development board. (Click to enlarge)

BOOTSEL Mode: Users can enter BOOTSEL mode by holding down the BOOT button, when the USB connection is made to a computer. The board will remain in this mode until it power cycles (happens automatically after uploading a .uf2 firmware file) or the RESET button is pressed. The board will appear as a USB mass storage device under the name RPI-RP2.

Holding down BOOT button on SparkFun Thing Plus - RP2040
Hold down BOOT button to enter BOOTSEL mode on The SparkFun Thing Plus - RP2040. (Click to enlarge)

MikroBUS™ Socket

The most significant feature of this board, is the addition of the MikroBUS™ socket, which provides a drop-in interface for MikroElectronka&apo;s ecosystem of Click boards™ (over 1079 as of September 2021).

The mikroBUS™ socket comprises a pair of 8-pin female headers with a standardized pin configuration. The pins consists of three groups of communications pins (SPI, UART and I2C), six additional pins (PWM, Interrupt, Analog input, Reset and Chip select), and two power groups (3.3V and 5V).

mikroBUS™ socket
Standardized pin connections for the mikroBUS™ scoket. (Click to enlarge)
  • GPIO 02: SCK
  • GPIO 03: MOSI (COPI)
  • GPIO 04: MISO (CIPO)
  • GPIO 05: CS
  • GPIO 06: SDA
  • GPIO 07/23: SCL
  • GPIO 0: TX
  • GPIO 01: RX
  • GPIO 13: RST
  • GPIO 16: PWM
  • GPIO 17: INT
  • GPIO 26: AN
mikroBUS™ socket
MikroBUS™ socket on the RP2040 mikroBUS™ development board. (Click to enlarge)

*For more information about the mikroBUS™ socket, click here for the mikroBUS™ standard specifications.

µSD Slot

Note: To comply with the latest OSHW design practices, on the RP2040 Thing Plus we have replaced the MOSI/MISO nomenclature with SDO/SDI; the terms Master and Slave are now referred to as Controller and Peripheral. The MOSI signal on a controller has been replaced with the title SDO. Please refer to this announcement on the decision to deprecate the MOSI/MISO terminology and transition to the SDO/SDI naming convention.

The RP2040 mikroBUS™ development board includes an µSD card slot. This is great for data logging applications or storing files. The µSD card slot is connected to the following dedicated GPIO:

  • GPIO 09: DATA 3/CS
  • GPIO 10: DATA 2
  • GPIO 11: DATA 1
  • GPIO 12: DATA 0/CIPO (or Peripheral's SDO)
  • GPIO 14: CLK/SCK
  • GPIO 15: CMD/COPI (or Peripheral's SDI)

SD card slot
µSD card slot on the RP2040 mikroBUS™ development board. (Click to enlarge)

Primary I2C Bus

A (battery) fuel gauge and a Qwiic connector are attached to the primary I2C bus I2C1. The primary I2C bus for this board utilizes the GPIO connections, detailed in the table below:

Connection VDDGNDSCLSDA
Pin Number3.3VGND Pin 9
Pin 35
Pin 8
GPIO3.3VGNDGPIO 07
GPIO 23
GPIO 06

I2C bus
I2C bus components on the RP2040 mikroBUS™ development board. (Click to enlarge)

Note: The clock line of the I2C bus is tied between pins 9 and 35 (GPIO 07 and GPIO 23). This allows GPIO 16 - GPIO 23 to be aligned on the board's edge, for a consecutive, eight pin bus; useful for things like HDMI.

Shared GPIO pin
Shared pin for GPIO 07 and GPIO 23 on the RP2040 mikroBUS™ development board. (Click to enlarge)

*Since the two GPIO pins are tied together, they cannot operate simultaneously.

Battery Fuel Gauge

The MAX17048 fuel gauge measures the approximate charge or discharge rate, state of charge (SOC) (based on ModelGauge algorithm), and voltage of a connected battery. Additionally, there is a configurable alert pin functionality for low SOC, 1% SOC, reset, overvoltage, or undervoltage. For more information, pleas refer to the MAX17048 datasheet.

MAX17048 Fuel Gauge
The MAX17048 fuel gauge on the RP2040 mikroBUS™ development board. (Click to enlarge)
I2C Address0x36 (7-bit)
0x6C (write)/0x6D (read)
Voltage Measurement Range: 2.5 - 5 V
Precision: &PlusMinus;7.5 mV/Cell
Resolution 1.25 mV/Cell
Current Consumption Sleep: .5 - 2 µA
Hibernate: 3 - 5 µA
Active: 23 - 40 µA
Alert Indicators: Low SOC
1% Change in SOC
Battery Undervoltage/Overvoltage
VRESET Alert
Alert PinGPIO 24

Qwiic Connector

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

Qwiic Connector
Qwiic connector on the RP2040 mikroBUS™ development board. (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.

I2C Jumper

Cutting the I2C jumper will remove the 4.7kΩ pull-up resistors from the I2C bus. If you have many devices on your I2C bus you may want to remove these jumpers.

I2C jumper
I2C pull-up resistor jumper. (Click to enlarge)

Hadware Assembly

USB Programming

The USB connection is utilized for programming and serial communication. Users only need to plug their RP2040 mikroBUS™ development board into a computer using a USB-C cable.

RP2040 mikroBUS™ development board connected with a USB cable
A USB-C cable attached to the RP2040 mikroBUS™ development board. (Click to enlarge)

BOOTSEL Mode

Users can enter BOOTSEL mode by holding down the BOOT button, when the USB connection is made to a computer. The board will remain in this mode until it power cycles (happens automatically after uploading a .uf2 firmware file) or the RESET button is pressed. The board will appear as a USB mass storage device under the name RPI-RP2.

Holding down BOOT button on RP2040 mikroBUS™ development board
Hold down BOOT button to enter BOOTSEL mode on the RP2040 mikroBUS™ development board. (Click to enlarge)

Battery

For remote applications, the RP2040 Thing Plus can be powered through its 2-pin JST battery connector. Additionally, users may be interested in utilizing a solar panel and USB-C cable to recharge their battery.

Battery connected to the SparkFun Thing Plus - RP2040
The RP2040 mikroBUS™ development board with a battery attached. (Click to enlarge)
Solar Panel Charger - 10W

Solar Panel Charger - 10W

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

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3

Note: DO NOT remove batteries by pulling on their wires. Instead, it is recommended that pair of dikes (i.e. diagonal wire cutters), pliers, or tweezers be used to pull on the JST connector housing, to avoid damaging the battery wiring.

Disconnect battery w/ dikes
Using a pair of dikes to disconnect a battery. (Click to enlarge)

Headers

The pins for the RP2040 mikroBUS™ development board are broken out to 0.1"-spaced pins on the outer edges of the board. When selecting headers, be sure you are aware of the functionality you need. If you have never soldered before or need a quick refresher, check out our How to Solder: Through-Hole Soldering guide.

Soldering headers
Soldering headers to the RP2040 mikroBUS™ development board.

The Feather Stackable Header Kit is a great option as it allows users to stack shields (w/ Feather footprint) or it can be placed on the a breadboard; while, the pins are still accessible from the female/male headers.

mikroBUS™ Socket

The RP2040 mikroBUS™ development board has a mikroBUS™ Socket, where a Click board™ can be inserted.

Attached click board
A Click board™ inserted into the mikroBUS™ socket of the RP2040 mikroBUS™ development board.

Note: To remove a Click board™, slowly and carefully wiggle it out of the mikroBUS™ socket to avoid bending the header pins on your Click board™.

The header also allows users to connect jumper wires to devices that may not have the mikroBUS™ pin layout to interface with.

jumper wiring
A device connected to the mikroBUS™ socket of the RP2040 mikroBUS™ development board with jumper wires.

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 RP2040 mikroBUS™ development board
Qwiic devices connected to the RP2040 mikroBUS™ development board.

Software Overview

The Raspberry Pi foundation provides excellent documentation for the RP2040 on their website. This includes information for users to program the RP204 with MicroPython and C/C++ through the Pico SDK. Arduino, has also announced the release of their Mbed RP2040 Arduino core. The instructions below, are meant to help users setup and utilize the RP2040 mikroBUS™ Development Board with the Arduino IDE.

Note: We recommend that users program their RP2040 mikroBUS™ development board through the Arduino IDE. Additionally, we recommend that users select Click boards™ based on available and compatible Arduino libraries.

If users wish to use another development platform/environment or utilize a Click board™ without an Arduino library, it is expected that the user is experienced enough port the necessary resources on their own.

For utilizing the Pico SDK (C/C++) and MicroPython, users can follow the instructions provided by the Raspberry Pi Foundation documentation:

To utilize the mikroSDK™, users can refer to instructions provided by MikroElektronika:

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 will be familiar with the Arduino IDE and it's use. As a point of reference for professional developers who aren't aware, the Arduino IDE is an open-source development environment, written in Java, that makes it easy to write code and upload it to a supported board. For more details, feel free to check out the Arduino website.

To get started with the Arduino IDE, check out the following 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.

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.

Installing the RP2040 Board Definition

Install the latest Arduino Mbed OS RP2040 board definitions in the Arduino IDE. Users unfamiliar with the board definition installation process can reference our tutorial below.

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.

Installation Instructions:

  1. Search for RP2040 in the Boards Manager.

    board manager
    Arduino Mbed OS RP2040 listed in the Boards Manager. (Click to enlarge)
  2. To complete the installation process, selected the Arduino Mbed OS RP2040 core and click on the INSTALL button that appears in the lower, right-hand corner. The board definition and upload tools will be installed automatically; users will notice that this may take a while.

    Note: Users may need to disable their anti-virus software when installing the Arduino Mbed OS RP2040 board definition. We ran into issues, where the installation of the upload tools for the Arduino core were blocked by the anti-virus software. Arduino is already aware of the issue, they are working to get their files white-listed. For more information, users can reference this GitHub issue.
  3. Programming Tip:

    The board may not show up on a COM port, if users who have already programmed their board through a different method. A simple solution is to:

    1. Download the picoprobe.uf2 file from the Raspberry Pi foundation's Pico board documentation page
    2. Copy the picoprobe.uf2 firmware file to the board (while it is in BOOTSEL mode)
    3. If the board isn't automatically listed on a COM port users should reset (or unplug and re-plug in the board to the computer)

    Note: If users have the Arduino IDE's Tools drop down menu open looking for a new COM port to be added, the Arduino IDE doesn't automatically repopulate and update the listed COM ports. To update the available COM ports list, users should close and then re-open the Tools drop down menu and navigate to the available COM ports.

Note: Users trying to access the SD card slot will need to modify the pins_arduino.h file to reconfigure the SPI bus pins. However, this will make the SPI bus inaccessible through the breakout pins (when utilizing the SPI library).

  • On a Windows 10 computer, with the Arduino IDE installed through the App store, the location of the pins_arduino.h file is:

    C:\Users\<username>\Documents\ArduinoData\packages\arduino\hardware\mbed_rp2040\<package_version>\variants\RASPBERRY_PI_PICO

    Arduino folder for file modification
    pins_arduino.h file in the RASPBERRY_PI_PICO folder. (Click to enlarge)
  • Users will need to modify lines 45 - 47 of the pins_arduino.h file to the following:

    // SPI
    #define PIN_SPI_MISO  (12u) //(4u)
    #define PIN_SPI_MOSI  (15u) //(3u)
    #define PIN_SPI_SCK   (14u) //(2u)
        
    line modifications
    Line modifications to the pins_arduino.h file. (Click to enlarge)
Note:GitHub user earlephilhower has ported an unofficial Arduino core for the RP2040, which is based on the Pico SDK. This is useful for customers who want the functionality of the Pico SDK in the Arduino IDE. Installation instructions are available in the GitHub repository.

Arduino Example

Note: The example for this tutorial assumes users have the latest version of the Arduino IDE installed. 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:

Installing an Arduino Library

January 11, 2013

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.

For this example, users will need a USB-C cable, a RP2040 mikroBUS development board, a Weather Click, and access to a computer with the Arduino IDE installed.

USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
3
SparkFun RP2040 mikroBUS Development Board

SparkFun RP2040 mikroBUS Development Board

DEV-18721
$14.95
MIKROE Weather Click

MIKROE Weather Click

SEN-18823
$21.95

Hardware assembly is straight forward, insert the Click board into the mikroBUS socket and then connect the RP2040 development board to the computer in BOOTSEL mode.

Attach click board
The Weather Click inserted into the mikroBUS™ socket of the RP2040 development board. (Click to enlarge)

On the computer, users should have the MBed OS RP2040 Arduino core installed through the Board Manager. The Weather Click utilizes the BME280 PTH sensor; therefore, users will need to install a compatible Arduino library in the Arduino IDE. We recommend the SparkFun BME280 Arduino Library.

arduino library
The SparkFun BME280 Arduino Library in the library manager. (Click to enlarge)

Once installed, users will have access to basic examples for the sensor. The examples can be found under the File>Examples>SparkFun BME280 menu options. We recommend trying the Example1_BasicReadings sketch first. Users will need to modify the sketch in the setup() loop for it to function properly:

language:c
Serial.begin(115200);


while (!Serial){
    ; // wait for serial port
}

// Set I2C address
mySensor.settings.I2CAddress = 0x76;


Serial.println("Reading basic values from BME280");
  • The while statement allows the RP2040 to sync properly with a terminal emulator
  • The default I2C address of the library is 0x77; however, it must be changed to the address configured on the Weather Click

Once these changes have been made, users can upload the program. After the upload process has completed, users can open the Serial Monitor to see the sensor data:

example_demo
Uploading the example sketch to the RP2040 mikroBUS™ development board and the Weather Click sensor's data displayed in the Serial Monitor. (Click to enlarge)

Resources and Going Further

For more on the RP2040 mikroBUS™ development board, check out the links below:


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

Getting Started with Necto Studio

$
0
0

Getting Started with Necto Studio a learn.sparkfun.com tutorial

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

Introduction

Necto Studio

Necto Studio is a productive cross-platform integrated developing environment provided by MikroElektronika and is available on Windows, Linux, and macOS. It includes C compilers, mikroSDK 2.0, package manager, and USB or WiFi Debugger capabilities with flexible licensing options. The development environment features intelligent code completion, auto-close brackets, and drag and drop visual elements.

Users can find their favorite Click Board library and working example through the Package Manager. Users will also be notified about new versions of installed packages, and easily update in one click.


Source: MikroElektronika blog post

MikroElektronika even provides first-time users with the longest time trial on the market - Get fully unlocked, feature-rich NECTO for three months, and explore it to the most delicate details before purchase!

For more information about NECTO Studio, please visit the product page.

mikroSDK

mikroSDK 2.0 makes application code portable and reusable on many different platforms and architectures, with virtually no code changes. It is a collection of open-source software libraries with unified API and software development tools. Everything you need to start developing, and prototyping cross-platform embedded applications, including Click board™ applications and GUIs for embedded devices.

mikroSDK 2.0 is open-source, and it’s natively supported in NECTO Studio. The video below, is a brief overview of how to use the mikroSDK:

Additional Resources:

Required Materials

To get started, users will need a few of items listed below. (You may already have a some of these items; read through the guide and modify your cart accordingly.)

To program a STM32 processor board(recommended) through Necto Studio, users will need a JTAG programmer. Below are programmers that are compatible with the Necto Studio software.

Apple Mac/Linux: Users with a Mac or Linux OS, should purchase the CODEGRIP programmer. The mikroProg is only compatible with Windows PCs.
MIKROE mikroProg for STM32

MIKROE mikroProg for STM32

PGM-19104
$49.95
MIKROE CODEGRIP for STM32

MIKROE CODEGRIP for STM32

PGM-19105
$99.95

Optional Hardware

Users may also need some soldering equipment and a JTAG header to connect the programmer to the board.

Note: Users should verify that the pinout for the programmer and adapter match up to the corresponding pins to avoid damaging their MCU.
Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$9.95
7
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$67.95
2
Header - 2x5 Pin (Male, 1.27mm)

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.75
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$8.95
4
Header - 2x5 Pin (Female, 1.27mm)

Header - 2x5 Pin (Female, 1.27mm)

PRT-15363
$1.75
MIKROE 50-100mil Adapter

MIKROE 50-100mil Adapter

PGM-19220
$14.95

Suggested Reading

Like our Qwiic connect system, mikroBUS™ socket is a standardized interface for the MIKROE Click boards™. Click on the banner below for more information.

mikroBUS Logo


For users who aren't familiar with the following concepts, we also recommend reading the following tutorials before continuing.

ARM Programming

How to program SAMD21 or SAMD51 boards (or other ARM processors).

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!

Designing with MicroMod

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

Software Installation

NOTE: Users will need administrative privileges on their computer's OS to install Necto Studio and the associated software for the MCU programmers.

To install Necto Studio, users will need to download the installation software for their computer's OS from MikroElektronika's Necto Studio product page. *(Users can also find link to the installation software from the mikroSDK GitHub repository's wiki page.)

Necto product page
Click here to head to the Necto Studio product page and download the installation software. (Click to enlarge)

Once downloaded, execute the installation software and go through the setup steps (Click on images to enlarge):

  1. Execute the installation software from the location that the file was downloaded to
    execute installation software
    Executing the downloaded installation file. (Click to enlarge)
  2. Click the Next > button to configure the software installation
    Start Page
  3. Enter the directory for the Necto Studio to be installed; then click Next >
    Program Directory
  4. Select the components to install; then click Next >
    Program Components
    • We recommend, at minimum, selecting the following components:
      • Necto Studio IDE
      • Compilers
        • ARM
      • mikroSDK
        • 2.4.0 (or latest)
  5. Read the License Agreement, accept or decline the license, and then click Next >
    License Agreement
    Note: Users will need to accept the terms, if they wish to continue the installation process
  6. Enter the where the software shortcut should be saved; then click Next >
    Shortcut Directory
  7. Once the setup has been configured, users can initiate the installation by clicking the Install button
    Installation Page
  8. Once the installation has completed; click the Finish button
    Installation Complete

CODEGRIP Suite

The first time users run Necto Studio, it will attempt to download and install the CODEGRIP Suite. (The computer will need to be connected to the internet for the installation software to be downloaded.)

Installation Prompt
Installation prompt for CODEGRIP Suite in Necto Studio. (Click to enlarge)

Click the Ok button to proceed and then follow the prompts below (Click images to enlarge):

  1. Enter the directory for the Necto Studio to be installed; then click Next >
    Program Directory
  2. Read the License Agreement, accept or decline the license, and then click Next >
    License Agreement
    Note: Users will need to accept the terms, if they wish to continue the installation process
  3. Once the installation has completed; click the Finish button
    Installation Complete

Installation Error

On Windows PCs, if users experience an issue downloading CODEGRIP Suite due to a Error:UnknownNetworkError error, their computer may be missing a Microsoft Visual C++ 2010 Runtime Library.

UnknownNetworkError
Failure to download CODEGRIP Suite and Error:UnknownNetworkError error message. (Click to enlarge)

To install the missing Microsoft Visual C++ 2010 Runtime Library, download the vcredist_x64.zip file(or click the button below), extract the folder, and execute the contained installation setup file vcredist_x64.exe.

Then, follow the installation prompts. After the Microsoft Visual C++ 2010 Runtime Library installation is complete, users can restart Necto Studio. The prompt for the CODEGRIP Suite installation will pop up again.

Alternatively, users can install the CODEGRIP Suite separately. However, the Microsoft Visual C++ 2010 Runtime Library is still necessary for users to login to their account in the User Account and Compiler License section.

Download CODEGRIP Suite

Users can still download and install the CODEGRIP Suite installation software separately:

  • www.mikroe.com/setup/codegrip
    hyperlink download
    Click on the link above this image. If successful, a thank you page will be displayed. (Click to enlarge)
  • CODEGRIP programmer product page
    product page download
    Scroll down to the Downloads section of the product page for the associated programmer. (Click to enlarge)

Once downloaded, execute the installation software and go through the setup steps mentioned above.

mikroProg Suite

Users with a Windows OS, will have the option to utilize the mikroProg programmer instead of the CODEGRIP programmer (the mikroProg is only compatible on Windows PCs). The installation software for the mikroProg Suite can be downloaded from the product page of the associated programmer:

product page download
Scroll down to the Downloads section of the product page for the associated programmer. (Click to enlarge)

Once downloaded, extract and execute the installation software and go through the setup steps (Click on images to enlarge):

  1. Execute the installation software from the location that the file was downloaded to
    execute installation software
    Executing the downloaded installation file. (Click to enlarge)
  2. Click the Next > button to configure the software installation
    Start Page
  3. Read the License Agreement, accept or decline the license, and then click Next >
    License Agreement
  4. Select the user access; then click Next >
    User access
  5. Enter the directory for the mikroProg Suite to be installed; then click Next >
    Directory
  6. Once the installation has completed; click the Finish button
    Installation Complete

Home Page Layout

When users open the Necto Studio application, they will be brought to the Home Page. Below is a brief overview of the page layout:

home page layout
Home page layout. (Click to enlarge)

The numbers below correspond with the numbers in the image above:

  1. Home button - Brings users back to the **Home Page*
  2. Sign In button
    • Displays the login page for users to enter their account credentials.
    • Users can also register a new account from this page.
    • Once users are logged in, this button will be replaced by their profile name.
  3. Licenses drop down menu - Location of the Manage licenses menu option, where users can activate, deactivate, and purchase compiler licenses
  4. New Project button - Use to create a new project
  5. Open Project button - Open a project
  6. Examples button - Open a project from available examples of installed libraries
  7. Packages button - Find and install libraries from the Package Manager page
  8. Planet Debug button - Allows users to debug a project from a remote hardware setup (paid service)
  9. Setups button - Create, manage, and configure hardware setup(s) from the My Setups page
  10. List of recent projects - Opens recently saved projects
  11. Build button - Used to build opened project and will output a compiled *.hex file for the selected hardware setup
  12. Program button - Used to program a project to a hardware setup, once it has been successfully built and compiled, through a compatible programmer
  13. Debugger button - Used to debug a project on a hardware setup with a compatible programmer
  14. Web button - Opens internal web browser
  15. Help button - Opens Help page

User Account and Compiler License

To utilize Necto Studio, users will need to register an account and activate a compiler license.

User Account

Users will need an account to activate their compiler license. These user accounts are also tied to the MikroElektronika forum. From the Necto Studio home page, click on the Sign In button and a dialog box will pop up; where users can sign in or register as a new user.

home page
Sign In button on the home page. (Click to enlarge)

New Users

To register as a new user account, click on the Create Account button. Then enter your user information in to the registration form and click the Register button to create your account.

registration form
New user registration form. (Click to enlarge)

Sign In

Enter your credentials into the sign in dialog box; then, click on the Sign In button.

  • Make sure to enter your username and not the email address registered to the account.

login page
Login page for user credentials. (Click to enlarge)

NOTE: On Windows 10 PCs, if users experience the following, their computer may be missing a Microsoft Visual C++ 2010 Runtime Library.

  • Aren't able to sign-in due to a network issue while they are connected to the internet.
  • Aren't able to download CODEGRIP Suite due to a Error:UnknownNetworkError error:
    UnknownNetworkError
    Error:UnknownNetworkError error. (Click to enlarge)

To install the missing Microsoft Visual C++ 2010 Runtime Library, download the vcredist_x64.zip file(or click the button below), extract the folder, and execute the contained installation setup file vcredist_x64.exe.

Compiler License

MikroElectronika offers new users 90-day trial license, but users will eventually need to purchase a compiler license if they wish to continue utilizing Necto Studio after the trial period has ended.

Purchase License

A compiler license can be purchased from MikroElektronika's Necto Studio product page, from the Manage licenses drop down menu on Necto Studio, or from the product category page of available compiler licenses.

Necto studio product page
Click here to head to the Necto Studio product page and purchase a compiler license. (Click to enlarge)
Necto Studio - purchase license
Users can also purchase a compiler license through Necto Studio. (Click to enlarge)
Compiler license page
Click here to view the available compiler licenses. (Click to enlarge)

Activate Trial License

To activate a compiler license, click on License>Manage licenses from the drop down menu and a dialog box will appear. From the dialog box, find the appropriate compiler license and select the activation method. Users will be given the following options:

Manage licenses page
Manage licenses page listing the available compiler licenses. (Click to enlarge)
  • To activate a permanent license click on the Activate via key button. Enter your license key and then click on the Activate button.
    activation by key
    Activation key entry, when the Activate via key option is selected. (Click to enlarge)
  • To activate a floating (or network) license, click on the Activate floating button. Enter the network address and port for the license; then click on the Activate button.
    activation by floating key
    Network key entry, when the Activate floating option is selected. (Click to enlarge)
    • If users are accessing the license remotely, they may need to VPN onto the network hosting the license.
  • New users can activate a trial license, click on the Activate trial button; then click on the Activate button.
    activation by trial
    Activation button, when the Activate trial option is selected. (Click to enlarge)
  • Users can also purchase a compiler license by clicking on the Buy License button.
    Necto Studio - purchase license
    Necto Studio's internal web browser, displaying the compiler license purchase options from the Necto Studio product page. (Click to enlarge)

Setup - Hardware Configuration

Similar to selecting a board from the Board Manager in the Arduino IDE, users will create a Setup for a specific board and processor configuration in Necto Studio. Users will need to sign in and activate a compiler license for the SDK to build a Setup. MikroElektronika has a tutorial video on their Youtube channel for this process:

Otherwise, users can also follow the steps below to create their setup (Click images to enlarge):

  1. From the Home page, select the Setups box
    home page
  2. Click the New button on the My Setups page
    my setups page
  3. Select a compiler on the Compiler page
    compiler page
  4. Select the SDK on the SDK page
    SDK page
  5. Select the board on the Board page
    board page
  6. Select the microcontroller on the MCU page
    MCU page
  7. Select display on the Display page
    display page
  8. Select the appropriate programmer on the Programmer page
    codegrip programmer
    CODEGRIP (recommended hardware)
    mikroprog programmer
    mikroProg for MCU
    • We recommend users select the following target options for the CODEGRIP programmer, if they wish to program the target MCU directly from Necto Studio:
      target options
  9. Click the Done and then Finish buttons

Users will then see the progress configuration and SDK build:

build progress
Configuration build progress. (Click to enlarge)

Once completed, users will be taken back to the My Setups page:

  • Users should now see that their hardware configuration has been added to the setup list on the left column.
  • These setups can be copied, modified, removed, and renamed (we recommend users rename their setup for organization purposes).
  • In the right column, users will find a summary of the hardware configuration for the selected setup (from the left column).

my setups
Layout of the My Setups page. (Click to enlarge)

Package Manager - Click Libraries

Similar to using a library from the Library Manager in the Arduino IDE, users will need to install a library for their Click Board™ through the Package Manager in Necto Studio. MikroElektronika has a tutorial video on their Youtube channel for this process:

Otherwise, users can also follow the steps below to install a library (Click images to enlarge):

  1. From the Home page, select the Packages box
    home page
  2. This will take users to a blank project page with the Package Manager window open the righthand side. Within the Package Manager window, users can search, upload, create, open libraries that are hosted on MikroElektronic's Libstock repository. Once found, users can install a library into Necto Studio by clicking the Install button
    Package manager window
  3. Like Arduino's libraries, MikroElektronika's libraries also contain an example file. To open an example for a library, click on the Open Example button after the library has been installed in Necto Studio
    Open example
  4. Opening an example will create a new project. Therefore, users will need to select a hardware setup for the project
    select hardware setup

Projects - Start and Build

Starting a Project

Similar to a sketch in the Arduino IDE, a project is used to organize the code and hardware configuration in Necto Studio. Users can start a new project, open an existing project, open a recently saved project, and use a project from a library example through the home page.

Below, are the options for starting a project (Click on the images to enlarge):

  • New Project
    1. Click on the New Project button
      home page
    2. Give the project a name and select a directory to save it on the Name page; then click on the Next button
      name and directory
    3. Select the project type from the Type page; then click on the Next button
      type
    4. Select an SDK from the Template page; then click on the Next button
      template
    5. Select a hardware configuration from the Setup page; then click the Finish button
      setup
      • Alternatively, use the Manage setups to create or modify a hardware configuration from the My Setups page
  • Open Project
    1. Click on the Open Project button
    2. Find and open the project file
  • Examples
    1. Click on the Examples button
    2. Select the example project from one of the available library examples
    3. Select a hardware configuration from the Choose setup page and then click the Choose button
      • Alternatively, use the Manage setups to create or modify a hardware configuration from the My Setups page

Modifying the Hardware Setup

Just as in the Arduino IDE, users can change the hardware configuration. From the project page, users can modify the project's hardware configuration by clicking on highlighted the Active setup.

change setup
Click on the highlighted Active setup to change the hardware configuration for the project. (Click to enlarge)

Build - Compiling a *.hex File

In order to compile a *.hex file to program a MCU, users will need to build the project. Users just need to click on the Build button, but it would be best to run meMake to optimize the project build (Click the images to enlarge):

  1. meMake is a simplified build system designed to get the most out of your CPU designed by parallelizing jobs to decrease the compile and linking times. Run meMake to optimize your project build
    Run meMake
  2. To compile the project code, users only need to click the Build button. Once the build is complete, the compiled *.hex file can be found in the directory (it might be located in a hidden folder) listed under the General Output tab
    build output

NOTE: Users who select a Generic board in their hardware setup, may run into a compilation error. This error is because the pins for the Generic board are undefined, by default. Users will need to declare the pins utilized by their code for the build to compile.

generic board error
The compile error for a generic board with undeclared pins. (Click to enlarge)

Programmer and Debugger Configuration

CODEGRIP Suite

The CODEGRIP Suite is the software application associated with the CODEGRIP programmer product line. It is used to:

  • Find and connect with available programmers through USB and/or WiFi
  • Configure the target MCU
  • Enable the power on a programmer to a target
  • Detect, write, read, erase, reset, and flash a target MCU

To get started with your CODEGRIP programmer, it is recommended you reference the Quick Start Guide linked on the associated product page. For more details on the programmer, users can refer to the User Manual, also linked on the associated product page.

Installation

The first time users run Necto Studio, it will attempt to download and install the CODEGRIP Suite.

NOTE: On Windows PCs, if users experience an issue downloading CODEGRIP Suite due to a Error:UnknownNetworkError error, their computer may be missing a Microsoft Visual C++ 2010 Runtime Library.

UnknownNetworkError
Error:UnknownNetworkError error. (Click to enlarge)

To install the missing Microsoft Visual C++ 2010 Runtime Library, download the vcredist_x64.zip file(or click the button below), extract the folder, and execute the contained installation setup file vcredist_x64.exe.

Users can also download the CODEGRIP Suite installation software from:

For more information, check out the Software Installation section.

Scan and Connect

Connect the CODEGRIP programmer to a computer using the included USB-C cable (and adapter, in necessary). If everything is connected properly, the POWER, ACTIVE, and USB LINK LED indicators on the device will turn on. When the ACTIVE LED indicator stops blinking, the CODEGRIP is ready.

CODEGRIP programmer LEDs
LED indicators on the CODEGRIP programmer. (Click to enlarge)

Open the CODEGRIP menu and select the newly unfolded Scanning menu item. Click the SCAN DEVICES button to get a list of available CODEGRIP devices.

scan for devices
Scanning for connected programmers. (Click to enlarge)

To connect with your CODEGRIP through a USB cable click the USB Link (icon) button. The USB Link indicator will turn yellow upon successful connection.

connect to device
Connect to a programmer. (Click to enlarge)

Target Configuration

Open TARGET menu and select the Options menu item. Set up target MCU either by selecting Vendor: first or by directly entering MCU: name in the drop-down list. To narrow down the list of available MCUs, start typing the name of the MCU manually. The list will be dynamically filtered while typing.

target selection
Selecting the target MCU for the programmer. (Click to enlarge)

Then select the programming protocol to match your hardware setup. Options are SWD or JTAG.

protocol selection
Selecting the programming protocol. (Click to enlarge)

Enabling Power

Open the POWER menu and select the newly unfolded Outputs menu item. Click the Set Voltage button to configure the power output of the programmer.

alt text
(Click to enlarge)

alt text
(Click to enlarge)

Once the output voltage has been configured, users can toggle the button to the right to enable the power output. If configured and enabled properly, Board Voltage (V): under the Measurements section will display the voltage output from the programmer.

enable power output
Programmer's power output enabled. (Click to enlarge)
Detect

Confirm the communication with the target MCU by clicking the Detect button located on the Shortcuts bar. A small pop-up window will display the confirmation message.

detect MCU
Verifying communication with the target MCU. (Click to enlarge)

Programming

Load the *.bin or *.hex file by using the Browse button.

load file
Selecting the source file to be uploaded to the MCU. (Click to enlarge)

Click the WRITE button to program the target MCU. The progress bar will indicate the programming process, while the programming status will be reported in the message area.

programming
Programming the target MCU and verification output. (Click to enlarge)

Debugging in Necto Studio

Instead of programming the MCU separately through CODEGRIP Suite, users can also program a project directly from Necto Studio.

  • Users will need to configure the programmer through CODEGRIP Suite, up until the detect step above
  • When creating the hardware configuration, the CODEGRIP programmer's target options must set to the following parameters:
    target options
  • The target MCU must be powered, this can be configured through the CODEGRIP Suite or the MCU can be powered from an external power source

If setup properly, users only need to click on the Program button. This target option configuration, also allows users to access the debugger in Necto Studio. Like most debuggers, users can step trough instruction steps, set breakpoints, step-in/out of loops, check values, etc. to help locate issues in the project's code execution.

debugging output
Debugging an example project at a breakpoint. (Click to enlarge)

Troubleshooting Tips

Below, we have also included some troubleshooting tips for issues that you may come across.

Sign-in or CODEGRIP Installation Issues

On Windows 10 PCs, if users experience an issues signing in to Necto Studio or come across an Error:UnknownNetworkError error message, their computer may be missing a Microsoft Visual C++ 2010 Runtime Library.

UnknownNetworkError
Failure to download CODEGRIP Suite and Error:UnknownNetworkError error message. (Click to enlarge)

To install the missing Microsoft Visual C++ 2010 Runtime Library, download the vcredist_x64.zip file(or click the button below), extract the folder, and execute the contained installation setup file vcredist_x64.exe.

Example Code Compilation Error

Users who select a Generic board in their hardware setup, may run into a compilation error. This error is because the pins for the Generic board are undefined, by default. Users will need to declare the pins utilized by their code for the build to compile.

generic board error
Compilation error message. (Click to enlarge)

No Power from the CODEGRIP Programmer

To detect a target MCU, it must be at least powered and have the SWD pins connected to the programmer. If the MCU has to be powered by the CODEGRIP programmer, users can enable it through the CODEGRIP Suite.

power enabled
CODEGRIP power output enabled. (Click to enlarge)

Remote Debugging

To learn more about configuring a remote debugging setup at your home, check out this blog post. For more information on Planet Debug, check out MikroElektronika's Planet Debug services page.


Source: Planet Debug services page

Resources and Going Further

For more on the Necto Studio and the mikroSDK, check out the links below:


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


MicroMod Ethernet Function Board - W5500 Hookup Guide

$
0
0

MicroMod Ethernet Function Board - W5500 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Integrate your MicroMod project into an Ethernet network including Power-over-Ethernet with the SparkFun MicroMod Ethernet Function Board - W5500. This Function Board uses the W5500 Ethernet control module from WIZnet and a DC/DC converter to configure a MicroMod assembly as a connected and powered device into an Ethernet network with Power-over-Ethernet (PoE) capabilities.

SparkFun MicroMod Ethernet Function Board - W5500

SparkFun MicroMod Ethernet Function Board - W5500

COM-18708
$29.95

The W5500 is a TCI/IP embedded Ethernet controller from WIZnet that uses SPI and supports up to 80 MHz speeds. We designed this Function Board to use the IEEE802.3af Alternative B power scheme which uses the spare pairs for power delivery, isolated from the data pairs. In this guide we'll highlight the capabilities of the W5500 and demonstrate how to use the MicroMod Ethernet Function Board to create an Ethernet network that can also be used for PoE.

Required Materials

Following along with this tutorial requires a few items along with the MicroMod Ethernet Function Board. Depending on what you already have, you may not need all of the items listed below.

MicroMod Processor

All MicroMod systems require a Processor board to operate. SparkFun carries a variety of Processor boards suited for different applications. Select the Processor board that best suits your Ethernet projects' needs:

SparkFun MicroMod STM32 Processor

SparkFun MicroMod STM32 Processor

DEV-17713
$16.50
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$18.95
1
SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$16.95
1
SparkFun MicroMod Teensy Processor

SparkFun MicroMod Teensy Processor

DEV-16402
$21.50
2

Note: Currently the Artemis and nRF52840 do not have built in Ethernet libraries in their Arduino cores. An external Arduino Ethernet library may work but at this time Ethernet is not supported on those Processors.

MicroMod Main Board

MicroMod Function Boards require at least one Main Board to work.

SparkFun MicroMod Main Board - Double

SparkFun MicroMod Main Board - Double

DEV-18576
$17.95
SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-18575
$14.95

Peripheral Items

You'll also need a PoE power supply like a network hub or router, Ethernet cable, network hub/router or endpoint as well as a few other peripheral items to get your MicroMod Ethernet system up and running. If needed, add these items to your cart:

USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

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

Reversible USB A to C Cable - 2m

CAB-15424
$8.95
CAT 6 Cable - 3ft

CAT 6 Cable - 3ft

CAB-08915
$2.10

Tools

Assembling MicroMod systems requires a Phillips head screwdriver.

Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$4.50
5
SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$1.05
3

Recommended Reading

The MicroMod ecosystem is a unique way to allow users to customize their project to their needs. If you aren't familiar with the MicroMod system, click on the banner below for more information.

MicroMod Logo


You may also want to read the tutorials below if you are not 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.

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.

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

Let's take a closer look at the hardware on the Ethernet Function Board - W5500 and how it interacts with the rest of the MicroMod ecosystem.

WIZnet W5500 Ethernet Controller

The W5500 Ethernet Controller from WIZnet is a TCP/IP embedded Ethernet controller that uses SPI communication protocol to allow up to eight independent sockets operate simultaneously.

Highlighting the W5500 IC
The W5500 supports the following hardwired TCP/IP protocols:
  • TCP
  • UDP
  • ICMP
  • IPv4
  • ARP
  • IGMP
  • PPPoE

The W5500 SPI interface operates at up to 80MHz and supports fast SPI for high speed Ethernet communication. The chip also includes a Wake on Lan (WOL) operation and power down mode to help conserve power. The W5500 operates at 3.3V but has 5V-tolerant I/O. For detailed information on the W5500, refer to the datasheet.

The Function Board includes three solder jumpers connected to the three network mode selection pins to allow users to configure the W5500 network operation mode. By default, the board sets the W5500 to operates in 10/100Base-T with Auto-Negotiation enabled. Read on to the Solder Jumpers portion of this section or refer to the pin descriptions in the datasheet for more information on adjusting the operation mode.

Power

The Ethernet Function Board - W5500 features several power input options including PoE and USB (via the Main Board). By default, the board acts as a PoE Powered Device (PD), receiving voltage over the Ethernet connection using the IEEE802.3af Alternative B power scheme.

Highlighting Power Components and M2 Connector

The Alternate B power scheme uses the spare pairs (pins 4/5 and 7/8) in the Ethernet cable for positive and negative DC voltage, keeping things simple if any troubleshooting is needed. The board includes a pair of PoE isolation jumpers that allows users to isolate these pins from the DC/DC converter input. When opened, the MicroMod assembly can receive power over USB, LiPo battery or through the DC/DC converter input PTH pins. The USB and LiPo power inputs are isolated from the PoE circuit.

DC/DC Converter Circuit

The board uses an Ag9905M Power-over-Ethernet (PoE) DC/DC converter to provide 5V from an Ethernet connection. For complete information on the Ag9905M, refer to the datasheet.

The Ag9905 accepts an input voltage between 36V and 57V but a voltage of 48V or greater is recommended on initial powerup to ensure the module functions properly. After power up, input voltage can be reduced to 36V if needed.

The Ag9905 provides 9 Watts of power for the MicroMod system and any peripheral devices connected to it (i.e. Qwiic breakouts, etc.). The 5V output from the converter is filtered to reduce noise for 5V circuits on the board and is also regulated down to 3.3V.

RJ45 Connector

The RJ45 connector on this function board includes embedded magnetics for PoE applications and is MagJack®-Compatible.

The Function Board uses all pairs on the RJ45 connector by default as the PoE configuration uses the spare pair for power inputs. Users who do not wish to use PoE can isolate these pins for other use by opening the PoE Isolation Jumpers. Reminder, if the PoE pairs are disconnected, power must be supplied from another source, either USB, LiPo battery or via the DC/DC converter input PTH pins on the other side of the PoE Isolation Jumpers.

LEDs

The board has a pair of status LEDs indicating general power and PoE power as well as the pair of LEDs on the RJ45 connector for Link and Activity statuses.

Highlighting LEDs

Solder Jumpers

There are thirteen solder jumpers on the Function Board. The table below outlines their labels and functions:

Highlighting solder jumpers
Having trouble seeing the detail in this image? Click on it for a larger view.
LabelDefault StateFunctionNotes
PWRCLOSEDCompletes Power LED circuit.Open to disable Power LED.
MEASCLOSEDCompletes VCC circuit tying VCC to 5V input.Open to measure current drawn by the Function Board.
WPOPENPulls EEPROM Write Protect pin to 3.3V/HIGHClose to pull this pin to 0V/LOW to disable write protect.
Dummy LoadCLOSEDCreates a dummy load of 100mA on the DC/DC converter output.Open to disable the dummy load.
Power CarrierCLOSEDSelects power configuration (PoE or USB).Open to disable PoE for VCC_In.
LNKCLOSEDCompletes the RJ45 Link LED circuit.Open to disable the Link LED.
ACTCLOSEDCompletes the RJ45 Activity LED circuit.Open to disable the Activity LED.
POECLOSEDCompletes the PoE Status LED circuit.Open to disable the PoE Status LED.
POE Power (Pair)CLOSEDTies the PoE +/- pins to DC/DC converter input.Open both to isolate Ethernet pairs used for PoE from the DC/DC converter input.
PMODE0OPENTies PMODE0 to 3.3V/HIGH.Adjust this in tandem with the other two PMODE jumpers to switch network modes on the W5500.1
PMODE1OPENTies PMODE1 to 3.3V/HIGH.Adjust this in tandem with the other two PMODE jumpers to switch network modes on the W5500.1
PMODE2OPENTies PMODE2 to 3.3V/HIGH.Adjust this in tandem with the other two PMODE jumpers to switch network modes on the W5500.1


1: Refer to the pin description table in section 1.1 of the datasheet for a detailed overview of setting the network mode.

MicroMod Function Board Pinout

This Function Board uses the following pins on a connected Processor Board:

  • 3.3V & VCC
  • Power Enable
  • SPI - W5500 Communication
  • I2C - EEPROM Communication
  • G0 - W5500 Interrupt
  • G1 - W5500 Chip Select (SPI)
  • G2 - W5500 Reset

For the complete MicroMod Pinout and pins used by this function board, take a look at the tables below:

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
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
DescriptionFunctionBottom
Pin
   Top   
Pin
FunctionDescription
(Not Connected)75GND
-74733.3VPower Supply: 3.3-6V
-7271Power ENPower Enable
-7069-
-6665-
-6463-
-6261-
-6059-
-5857-
-5655-.
-5453-
-5251ETH_RSTW5500 Reset.
-5049ETH_CSW5500 Chip Select
-4847ETH_INTW550 Interrupt Pin
-4645GND
-4443-
-4241-
Write protection pin for the EEPROM. Pull low to enable.EEPROM_WP4039GND
-3837-
EEPROM I2C address configuration.EEPROM_A03635-
EEPROM I2C address configuration.EEPROM_A13433GND
EEPROM I2C address configuration.EEPROM_A23231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423-
-2221I2C_SCLI2C - Clock signal for EEPROM
-2019I2C_SDAI2C - Data signal for EEPROM
-1817-
-1615-
-1413-
-1211-
-109-
-87POCISPI Peripheral Output/Controller Input.
-65PICOSPI Peripheral Input/Controller Output.
-43SCKSPI Clock Signal
-21GND
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_PICOOSPI Peripheral Input/Controller Output.3.3V
SPI_POCIISPI Peripheral Output/Controller Input.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_PICO1/SDIO_CMDI/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO command interface.3.3V
SPI_POCI1/SDIO_DATA0I/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The MicroMod Ethernet Function Board matches the MicroMod Function Board standard and measures 1.50" x 2.56" (38.1mm x 65.024mm).

Board Dimensions

Hardware Assembly

If you're not familiar with assembling boards using the MicroMod connection system, head over to the Getting Started with MicroMod tutorial for information on inserting and securing your MicroMod Processor and Function Boards to the Main 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!

PoE Assembly

After securing the Processor and Function Board to the Main Board, connect the MicroMod Main Board to your computer with a USB-C cable to program the Processor. Once programmed, connect the Function Board to your Ethernet hub (router, network switch, etc.) with an Ethernet cable connected to the RJ45 connector.

Completed Assembly

Software Installation

Note: The Ethernet Arduino 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 the following tutorials.

Processor Arduino Board Definitions and Driver

Make sure you go through the Hookup Guide for your chosen Processor Board to install the Arduino board definitions and any necessary drivers:

MicroMod ESP32 Processor Board Hookup Guide

October 21, 2020

A short hookup guide to get started with the SparkFun MicroMod ESP32 Processor Board.

MicroMod STM32 Processor Hookup Guide

May 13, 2021

Get started with the MicroMod Ecosystem and the STM32 Processor Board!

MicroMod Teensy Processor Hookup Guide

July 1, 2021

Add the processing power and versatility of the Teensy to your MicroMod project following this guide for the SparkFun MicroMod Teensy Processor.
Note on Artemis and nRF52840 Processors: Currently the Artemis and nRF52840 do not have built in Ethernet libraries in their Arduino cores. An external Arduino Ethernet library may work but at this time Ethernet is not supported on those Processors. We will update the tutorial in the future if Ethernet support is added to these cores.

Main Board Example - Pin Connection Table

The table below helps show what pins the Function Board connects to depending on the slot it is connected to on a Main Board (Note: The Single Main Board connection is Slot 0):

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
Function Board
Pin Name
I/O
Direction
Main Board's
Processor Pin
Slot 0Slot 1
VCCInput-
3.3VInput-
GND--
ETH_INTD0D1
CSCS0CS1
ETH_RSTPWM0PWM1

Arduino Example

Now that our MicroMod system is fully assembled, we'll use a slightly modified version of the "Ethernet - Web Client" example included with Arduino to make sure everything is connected and working properly. This modified version simply updates the options for the SPI Chip Select pin to match those used on supported MicroMod Processor Boards:

language:c
void setup() {
  //Ethernet.init(CS); //SAMD51
  Ethernet.init(10); //Teensy
  //Ethernet.init(5); //ESP32
  //Ethernet.init(A4); //STM32    
Note: The code defaults to use the CS pin used with the Function Board connected in Slot 0. If the board is in Slot 1, switch to the CS1 pin on your Processor.

Open the Arduino IDE and either copy the code below or navigate to the example by going to File > Examples > Ethernet > Web Client. Reminder, if you open the default example in Arduino, make sure to set the correct Chip Select pin for the Processor Board used as listed above. Upload the code and open the serial monitor with the baud set to 115200 and you should see the example initialize the W5500 and ping Google.com.

language:c
/*
  Web client
 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield.
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen
 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

// Variables to measure the speed
unsigned long beginMicros, endMicros;
unsigned long byteCount = 0;
bool printWebData = false;  // set to false for better speed measurement

void setup() {
  //Ethernet.init(CS); //SAMD51
  Ethernet.init(10); //Teensy
  //Ethernet.init(5); //ESP32
  //Ethernet.init(A4); //STM32

  Serial.begin(115200);

  delay(4000);

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1000);
        Serial.println("Not detected");
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.print("connecting to ");
  Serial.print(server);
  Serial.println("...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.print("connected to ");
    Serial.println(client.remoteIP());
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  beginMicros = micros();
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  int len = client.available();
  if (len > 0) {
//    byte buffer[80];
    byte buffer[512 * 4];
    if (len > sizeof(buffer)) len = sizeof(buffer);
    client.read(buffer, len);
    if (printWebData) {
      Serial.write(buffer, len); // show in the serial monitor (slows some boards)
    }
    byteCount = byteCount + len;
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    endMicros = micros();
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    Serial.print("Received ");
    Serial.print(byteCount);
    Serial.print(" bytes in ");
    float seconds = (float)(endMicros - beginMicros) / 1000000.0;
    Serial.print(seconds, 4);
    float rate = (float)byteCount / seconds / 1000.0;
    Serial.print(", rate = ");
    Serial.print(rate);
    Serial.print(" kbytes/second");
    Serial.println();

    // do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
}

Troubleshooting

Artemis and nRF52840 Processor Support

Reminder, the Artemis and nRF52840 currently do not have built in Ethernet libraries in their Arduino cores. An external Arduino Ethernet library may work with these Processors but at this time Ethernet is not supported. We will update the tutorial in the future if Ethernet support is added to these cores.

General Troubleshooting

Resources and Going Further

That'll a wrap for this tutorial. By now your MicroMod Ethernet network should be up and running. Take a look at the resources below for more information about the MicroMod Ethernet Function Board - WIZnet W5500:

For more information about the SparkFun MicroMod system, take a look here:

MicroMod Logo


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

Analog MEMS Microphone Breakout - SPH8878LR5H-1 Hookup Guide

$
0
0

Analog MEMS Microphone Breakout - SPH8878LR5H-1 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Note: This tutorial covers the latest version of the SparkFun Analog MEMS Microphone Breakout (BOB-19389). We designed the updated version as a drop-in replacement so users with the previous versions of this breakout board (BOB-9868 or BOB-18011) can follow along with this tutorial. For specific details regarding the microphone ICs, refer to the Documents tab on their product pages or the previous release of this Hookup Guide:

The SparkFun Analog MEMS Microphone Breakout - SPH8878LR5H-1 is a simple and easy-to-use microphone for a variety of sound-sensing projects. The on-board microphone is a low-power, omnidirectional microphone with an analog output. It works for both near and long-range uses and is particularly good for portable applications due to its low power consumption. Possible applications include: smartphones, digital video cameras, and keeping an "ear" on your pets while you're away.

SparkFun Analog MEMS Microphone Breakout - SPH8878LR5H-1

SparkFun Analog MEMS Microphone Breakout - SPH8878LR5H-1

BOB-19389
$6.95

Read this guide to get an overview of the breakout board and how to use it, including its technical specifications, how to hook it up to a microcontroller, and example code to get started!

Required Materials

You'll need these items along with the MEMS Microphone Breakout to follow along with this tutorial. First up, you'll want a microcontroller to power the microphone and monitor its output:

SparkFun Thing Plus - ESP32-S2 WROOM

SparkFun Thing Plus - ESP32-S2 WROOM

WRL-17743
$21.50
SparkFun RedBoard Qwiic

SparkFun RedBoard Qwiic

DEV-15123
$21.50
13
SparkFun RedBoard Turbo - SAMD21 Development Board

SparkFun RedBoard Turbo - SAMD21 Development Board

DEV-14812
$26.95
6
SparkFun Qwiic Micro - SAMD21 Development Board

SparkFun Qwiic Micro - SAMD21 Development Board

DEV-15423
$22.50
5

Building a circuit using this breakout requires some assembly and soldering. You may already have a few of these items but if not, the tools and hardware below help with that assembly:

Break Away Headers - Straight

Break Away Headers - Straight

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

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

PRT-11375
$22.50
19
Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

TOL-14456
$16.50
15
Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.95
3

Recommended Reading

To successfully use the SparkFun MEMS microphone breakout board, you'll need to be familiar with Arduino microcontrollers, analog (aka ADC) input, and sound waves. For folks new to these topics, check out the following resources to get a feel for the concepts and verbiage used throughout this tutorial.

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.

Analog vs. Digital

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

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.

Hardware Overview

The SparkFun Analog MEMS Microphone Breakout uses the SPH8878LR5H-1 microphone and amplifies the signal with an OPA344 OpAmp. Let's take a closer look at the SPH8878LR5H-1 and the other hardware on the board.

SPH8878LR5H-1 Microphone

The SPH8878LR5H-1 microphone from Knowles Electronics is a bottom port analog microphone that supports both single-ended and differential modes.

MEMS Microphone Breakout - SPH8878LR5H-1

We opted for a single-ended output design on this breakout so it can act as a drop-in replacement for users with previous versions of the SparkFun MEMS microphone breakouts. The Left Out- pin is connected to a test point so savvy users who wish to use this microphone in differential mode can tap into that signal with some careful soldering.

The table below outlines some relevant specifications of the SPH8878LR5H-1. For a complete technical overview of the microphone, refer to the datasheet.

ParameterMinTypMaxUnitsNotes
Sensitivity-45-44-43dBV/Pa94 dB SPL @ 1kHz, Single-Ended Mode
Signal-to-Noise Ratio ("SNR")-66-dBV/Pa94 dB SPL @ 1kHz, A-weighted Single-Ended Mode
Frequency Range7-36Hz(min)/kHz(max)
Acoustic Overload Point-134-dB SPL

The microphone receives audio input from the bottom of the board. The board breaks out the power pins (VCC and Ground) and the audio output (AUD) from the microphone:

MEMS Microphone Breakout - Back
  • AUD - Audio signal output.
  • VCC - Voltage input (2.3V to 3.6V). Supply current of about 265µA.
  • GND - Ground.

OpAmp

The SparkFun breakout board includes an OPA344 operational amplifier with a gain of *64 and a frequency response range of 7.2Hz-19.7KHz. The amplifier's AUD output floats at one-half VCC when the mic detects no sound. When held at arms length and talked into, the amplifier will produce a peak-to-peak output of just about 200 mV.

Board Dimensions

The board measures 0.50"x 0.40" (12.70mm x 10.16mm).

Board Dimensions

Hardware Assembly

Now that we're familiar with the microphone breakout, let's connect it to a microcontroller and monitor some sound!

Microphone Breakout Connections

For a permanent connection, we recommend soldering three wires (or headers) to the PTHs on the breakout. We opted for soldering wires to the PTH connectors for a quick permanent connection to the breakout. For a temporary connection during prototyping, you can use IC hooks like these.

We recommend using the following colors of wire to easily distinguish the signals but you can always select a different color if you prefer (or do not have the colors used available).

  • Red for VCC
  • Black for GND
  • Yellow (or some other color not Red or Black) for AUD

Wires soldered to MEMS Microphone Breakout

Connecting to a Microcontroller

Next up we'll connect the breakout to a microcontroller we can use to monitor the audio signal output. For this tutorial, we used a SparkFun RedBoard Qwiic. Make the following connections between the breakout and RedBoard Qwiic (or whichever microcontroller you choose):

RedBoard/ArduinoMEMS Microphone
A0AUD
GNDGND
3.3VVCC


The completed circuit should look something like the photo below:

Completed MEMS Microphone Breakout Circuit with RedBoard

Read on to the next section for Arduino example code to monitor sound volume with the microphone breakout.

Arduino Software Example

Note: If this is your first time using Arduino IDE or board add-on, please review the following tutorials.

Interpreting the Audio Output Signal

The SPH8878LR5H-1 signal output is a varying voltage. When all is quiet, the AUD output floats at one-half the power supply voltage. For example, with a 3.3V power supply, the AUD output will be about 1.65V. In the photo below, the yellow marker on the left side of the oscilloscope screen marks the zero axis for the voltage (aka V = 0). The pulse is the AUD output of a finger snap close to the mic.

TestingSensor_Oscilloscope

Converting ADC to Voltage

The microcontroller analog (ADC) input converts our audio signal into an integer. The range of possible ADC values depends on which microcontroller you are using. For an Arduino microcontroller with an ATmega328P, the analog resolution is 10-bits. This range is between 0 and 1023, so the resolution of our ADC measurement is 1024. To convert our analog measurement into a voltage, we use the following equation:

equation

In our case, the ADC Resolution is 1024, and the System Voltage 3.3 V. We'll need to add this equation in our code to convert our ADC Reading into a voltage.

But Wait, What Are We Actually Measuring??

For many applications that deal with sound (which is a wave), we're mostly interested in the amplitude of the signal. In general, and for the sake of simplicity, a larger amplitude means a louder sound, and a smaller amplitude means a quieter sound (and the sound wave frequency roughly corresponds to pitch). Knowing the amplitude of our audio signal allows us to build a sound visualizer, a volume unit ("VU") meter, set a volume threshold trigger, and other cool and useful projects!

To find the audio signal amplitude, take a bunch of measurements in a small time frame (e.g. 50 ms, the lowest frequency a human can hear). Find the minimum and maximum readings in this time frame and subtract the two to get the peak-to-peak amplitude. We can leave it at that, or divide the peak-to-peak amplitude by a factor of two to get the wave amplitude. We can use the ADC integer value, or convert this into voltage as described above.

MEMS_OutputTable

Example Code

Below is a simple example sketch to get you started with the MEMS microphone breakout board. You can find the code in the GitHub repo as well. The code, written for an Arduino microcontroller, includes a conversion equation from the ADC Reading to voltage, a function to find the audio signal peak-to-peak amplitude, and a simple VU Meter that outputs to the Arduino Serial Monitor. For a more visual output, you can also use the Serial Plotter.

Be sure to read the comments in the code to understand how it works and to adapt it to fit your needs. Select your Arduino board, COM port, and hit the upload button.

language:c
/***************************
 * Example Sketch for the SparkFun MEMS Microphone Breakout Board
 * Written by jenfoxbot <jenfoxbot@gmail.com>
 * Code is open-source, beer/coffee-ware license.
 */

// Connect the MEMS AUD output to the Arduino A0 pin
int mic = A0;

// Variables to find the peak-to-peak amplitude of AUD output
const int sampleTime = 50; 
int micOut;

//previous VU value
int preValue = 0; 

void setup() {
  Serial.begin(9600);
}

void loop() {
   int micOutput = findPTPAmp();
   VUMeter(micOutput);   
}   


// Find the Peak-to-Peak Amplitude Function
int findPTPAmp(){
// Time variables to find the peak-to-peak amplitude
   unsigned long startTime= millis();  // Start of sample window
   unsigned int PTPAmp = 0; 

// Signal variables to find the peak-to-peak amplitude
   unsigned int maxAmp = 0;
   unsigned int minAmp = 1023;

// Find the max and min of the mic output within the 50 ms timeframe
   while(millis() - startTime < sampleTime) 
   {
      micOut = analogRead(mic);
      if( micOut < 1023) //prevent erroneous readings
      {
        if (micOut > maxAmp)
        {
          maxAmp = micOut; //save only the max reading
        }
        else if (micOut < minAmp)
        {
          minAmp = micOut; //save only the min reading
        }
      }
   }

  PTPAmp = maxAmp - minAmp; // (max amp) - (min amp) = peak-to-peak amplitude
  double micOut_Volts = (PTPAmp * 3.3) / 1024; // Convert ADC into voltage

  //Uncomment this line for help debugging (be sure to also comment out the VUMeter function)
  //Serial.println(PTPAmp); 

  //Return the PTP amplitude to use in the soundLevel function. 
  // You can also return the micOut_Volts if you prefer to use the voltage level.
  return PTPAmp;   
}

// Volume Unit Meter function: map the PTP amplitude to a volume unit between 0 and 10.
int VUMeter(int micAmp){

  // Map the mic peak-to-peak amplitude to a volume unit between 0 and 10.
   // Amplitude is used instead of voltage to give a larger (and more accurate) range for the map function.
   // This is just one way to do this -- test out different approaches!
  int fill = map(micAmp, 23, 750, 0, 10); 

  // Only print the volume unit value if it changes from previous value
  while(fill != preValue)
  {
    Serial.println(fill);
    preValue = fill;
  }
}

Resources and Going Further

Now that you've connected your MEMS microphone breakout, it's time to incorporate it into your own project! For more information on the board, check out the resources below:

If you run into trouble getting, or understanding, an audio signal output from the MEMS mic breakout board, try using a multimeter and/or an oscilloscope to measure the voltage output of the signal in quiet and loud settings. If you're still stuck, check out our forums and we'll help you troubleshoot.

After you've read in the MEMS microphone and have a good handle on the signal output, you're ready to start using it for practical microphone applications! Here are a few ideas to get you started:

  1. Build a music visualizer! Here's a sample sketch for the music visualizer shown in the SparkFun Simple Sketches example.

  2. Record sounds and play them back! You'll also need a speaker, an amplifier transistor, some pushbuttons, and some code. Here's an open-source mbed example. (The example was initially written for the ADMP401 but should work just fine with the latest release).
  3. Make a sound-reactive EL Wire costume and replace the Sound Detector with the MEMS Microphone!
  4. Make a Bark Back Pet Monitor with a Raspberry Pi to record the sound levels in your home, upload the data MQTT, and trigger an audio player to when the volume reaches a threshold.

Or check out these other audio related tutorials below.

My Drunk Kitchen Apron

A fun project that uses the LilyPad MP3 trigger. This apron will dispense helpful kitchen advice and humor from the host of My Drunk Kitchen, Hannah Harto!

Making Music with the FreeSoC2

Create a synth keyboard with the FreeSoC2 from SparkFun.

BadgerHack: Synth Add-On Kit

Make a tiny synth with BadgerStick.

SIK Keyboard Instrument

We can use the parts and concepts in the SparkFun Invetor's Kit to make a primitive keyboard instrument.

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

Getting Started with the MyoWare® 2.0 Muscle Sensor Ecosystem

$
0
0

Getting Started with the MyoWare® 2.0 Muscle Sensor Ecosystem a learn.sparkfun.com tutorial

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

Introduction

Note: This tutorial is for the MyoWare V2.0 Muscle Sensor and its ecosystem. If you are using the previous version, please refer to the older MyoWare Muscle Sensor V1 tutorial.

Using our muscles to control things is the way that most of us are accustomed to doing it. We push buttons, pull levers, move joysticks... but what if we could take the buttons, levers and joysticks out of the equation and control it with our muscles? The MyoWare 2.0 Muscle Sensor is an Arduino-compatible, all-in-one electromyography (EMG) sensor from Advancer Technologies that allows you to do just that! The MyoWare 2.0 Muscle Sensor has been redesigned from the ground up with a new, easy-to-use, compact design and upgraded with the latest and greatest chipset improving sensor performance and reliability. The innovative snap connector system eliminates the need to solder connections for the MyoWare 2.0 ecosystem. It's that easy: stick on a few electrodes (not included), read the output voltage and flex some muscles! In this tutorial, we will go over the features and related shields to connect the sensor to a muscle group.

MyoWare 2.0 Muscle Sensor

MyoWare 2.0 Muscle Sensor

DEV-18977
$39.95
MyoWare 2.0 Cable Shield

MyoWare 2.0 Cable Shield

DEV-18386
$5.95
MyoWare 2.0 LED Shield

MyoWare 2.0 LED Shield

DEV-18387
$26.95
MyoWare 2.0 Link Shield

MyoWare 2.0 Link Shield

DEV-18425
$12.95
MyoWare 2.0 Arduino Shield

MyoWare 2.0 Arduino Shield

DEV-18426
$9.95
MyoWare 2.0 Power Shield

MyoWare 2.0 Power Shield

DEV-18427
$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. You'll need at least three biomedical sensor pads per muscle sensor each time you connect to a muscle group.

Minimum Parts

At a minimum, you will need the following parts to connect and power the muscle sensor. You can view the muscle signal from the ENV LED.

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

SEN-12969
$8.95
4
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$8.95
MyoWare 2.0 Power Shield

MyoWare 2.0 Power Shield

DEV-18427
$14.95
MyoWare 2.0 Muscle Sensor

MyoWare 2.0 Muscle Sensor

DEV-18977
$39.95

Displaying the Magnitude of the Muscle Signal with LED Segments

You will need the following parts to connect and power the muscle sensor. You can view the magnitude of the muscle signal from the LED segments.

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

SEN-12969
$8.95
4
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$8.95
MyoWare 2.0 LED Shield

MyoWare 2.0 LED Shield

DEV-18387
$26.95
MyoWare 2.0 Muscle Sensor

MyoWare 2.0 Muscle Sensor

DEV-18977
$39.95

Connecting to an Arduino

You will need the following to connect an 5V Arduino without the need to solder any wires between boards. Connecting to an Arduino allows you to process sensor data to control a device or viewing the signal on the Arduino Serial Plotter.

SparkFun RedBoard Plus

SparkFun RedBoard Plus

DEV-18158
$21.50
2
Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

SEN-12969
$8.95
4
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$8.95
Audio Cable TRS - 1m

Audio Cable TRS - 1m

CAB-18983
$1.95
MyoWare 2.0 Link Shield

MyoWare 2.0 Link Shield

DEV-18425
$12.95
MyoWare 2.0 Arduino Shield

MyoWare 2.0 Arduino Shield

DEV-18426
$9.95
MyoWare 2.0 Muscle Sensor

MyoWare 2.0 Muscle Sensor

DEV-18977
$39.95

Transmitting Wirelessly

You will need the following to transmit sensor data wirelessly through an Arduino. Of course, you will need 2x RedBoard Artemis boards and 2x USB cables. You'll need 1x battery pack and 4x AA batteries for each RedBoard Artemis that is battery powered.

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

SEN-12969
$8.95
4
SparkFun RedBoard Artemis

SparkFun RedBoard Artemis

DEV-15444
$21.50
9
Battery Holder - 4xAA to Barrel Jack Connector

Battery Holder - 4xAA to Barrel Jack Connector

PRT-09835
$2.75
Reversible USB A to C Cable - 2m

Reversible USB A to C Cable - 2m

CAB-15424
$8.95
Panasonic Alkaline Battery - AA

Panasonic Alkaline Battery - AA

PRT-15201
$0.55
MyoWare 2.0 Link Shield

MyoWare 2.0 Link Shield

DEV-18425
$12.95
MyoWare 2.0 Arduino Shield

MyoWare 2.0 Arduino Shield

DEV-18426
$9.95
MyoWare 2.0 Muscle Sensor

MyoWare 2.0 Muscle Sensor

DEV-18977
$39.95
Audio Cable TRS - 1m

Audio Cable TRS - 1m

CAB-18983
$1.95

Accessories

Depending on your setup, you may need the following accessories to add an extension between the hardware and muscle group.

Sensor Cable - Electrode  Pads (3 connector)

Sensor Cable - Electrode Pads (3 connector)

CAB-12970
$5.50
9
MyoWare 2.0 Cable Shield

MyoWare 2.0 Cable Shield

DEV-18386
$5.95
MyoWare 2.0 Reference Cable

MyoWare 2.0 Reference Cable

CAB-19244
$1.25

Tools

To easily disconnect the boards, we recommend using a flathead screwdriver. The following screwdriver can be used to remove the stack of boards from each other. Depending on the Arduino that you choose, we recommend getting a hobby knife, solder, and soldering iron when changing the jumper pad for the logic levels.

Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.95
3
Soldering Iron - 30W (US, 110V)

Soldering Iron - 30W (US, 110V)

TOL-09507
$10.95
7
SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$1.05
3
Hobby Knife

Hobby Knife

TOL-09200
$3.50
2

You Will Also Need

You will also need the following.

  • Alcohol Swab (Isopropyl alcohol and a cotton ball)
  • USB isolator circuit (optional)

Suggested Reading

If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing. Depending on the Arduino development board that you are using, you may need to install drivers. The RedBoards use a different USB-to-serial converter compared to the Arduino Uno. Both the Arduino Uno and the RedBoard Plus use 5V for the logic levels.

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.

How to Install CH340 Drivers

How to install CH340 drivers (if you need them) on Windows, Mac OS X, and Linux.

RedBoard Plus Hookup Guide

This tutorial covers the basic functionality of the RedBoard Plus. This tutorial also covers how to get started blinking an LED and using the Qwiic system.

For users interested in using a Bluetooth® connection to wirelessly transmit the sensor data, we recommend getting the RedBoard Artemis and installing the board definitions. Note that the RedBoard Artemis uses 3.3V for the logic levels.

Hookup Guide for the SparkFun RedBoard Artemis

Get started with the RedBoard Artemis - all the functionality of the SparkFun Artemis module wrapped in the familiar Uno footprint

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.

New Features

The MyoWare 2.0 ecosystem builds upon the previous muscle sensor designs. The major changes to the ecosystem include:

  • Updated Circuitry - The MyoWare 2.0 Muscle Sensor has been redesigned from the ground up! The circuitry is updated with the latest and greatest chipset improving sensor performance and reliability.
  • Innovative Snap Connector System - The built-in male and female snap connectors on the sensor and its shields eliminates the need to solder connections! Topside connectors link the shields to the power and the EMG envelope output of the sensor. Bottom side link to the input electrodes for the Cable Shield.
  • Compact - The snap connectors also allow for a lower profile when stacking shields to the MyoWare 2.0 Muscle Sensor.
  • Keyed - The ground and reference snap connectors on the boards are slightly offset and designed to be "keyed." Since the muscle sensor and shields are keyed, there's only one way to connect the boards together!
  • New Shields - The MyoWare 2.0 Link and Arduino Shields were designed to easily connect up to six MyoWare 2.0 Muscle Sensors to a development board with the Arduino Uno R3 footprint. This also eliminates the need to solder connections when connecting the muscle sensors to an Arduino. You'll just need one TRS-to-TRS cable for each muscle sensor.
  • MyoWare Power Shield - The previous version of the Power Shield used coin cell batteries. The updated MyoWare 2.0 Power Shield includes a built-in rechargeable LiPo battery.
  • MyoWare Proto Shield (Depreciated) - With a solderless system in mind, the MyoWare Proto Shield is depreciated in the MyoWare 2.0 ecosystem.
V1 and V2 Shields Stacked for ComparisionShield Incorrectly Stacked
V1 and V2 Shields Stacked for ComparisionKeyed Connectors Prevent Incorrect Stacking of Boards

What is electromyography (EMG)?

"The MyoWare measures muscle activity through the electric potential of the muscle, commonly referred to as surface electromyography (EMG or sEMG for short). When your brain tells your muscle to flex, it sends an electrical signal to your muscle to start recruiting motor units (the bundles of muscle fibers that generate the force behind your muscles).

The harder you flex, the more motor units are recruited to generate greater muscle force. The greater the number of motor units, the more the electrical activity of your muscle increases. The MyoWare will analyze this electrical activity and output an analog signal that represents how hard the muscle is being flexed. The harder you flex, the higher the MyoWare output voltage will go." -Advancer Technologies

EMG Signal Raw and Envelope Flexed

Image Courtesy of Advancer Technologies taken from the MyoWare 2.0 Advanced Guide

MyoWare 2.0 Muscle Sensor

The MyoWare 2.0 Muscle Sensor is an Arduino-compatible, all-in-one electromyography (EMG) sensor from Advancer Technologies! The innovative snap connector system eliminates the need to solder connections for the MyoWare 2.0 ecosystem. It's that easy: stick on a few electrodes (not included), read the output voltage and flex some muscles! The muscle sensor’s snap connector system makes it easier to stack shields together. The top side connectors link to power and the sensor’s EMG envelope output while the bottom side links to the input electrodes. Measuring muscle activity by detecting its electric potential has traditionally been used for medical research. However, with the advent of ever shrinking yet more powerful microcontrollers and integrated circuits, EMG circuits and sensors have found their way into all kinds of control systems such as video games, robotics, and prosthetics!

MyoWare 2.0 Muscle Sensor

MyoWare 2.0 Muscle Sensor

DEV-18977
$39.95

The embedded snap connectors mate well with our biomedical sensor pad (10 pack).

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

SEN-12969
$8.95
4

Hardware Overview

The top side of the board is populated with the circuit and male snap connectors. The bottom of the board has the female snap connectors.

Top View of the MyoWare 2.0 Muscle SensorBottom View of the MyoWare 2.0 Muscle Sensor
Top SideBottom Side

Amplifiers and Adjustable Gain

The MyoWare 2.0 Muscle Sensor measures a small EMG reading from the muscle group. This signal goes through an amplifier, bandpass filter, rectifier, and envelope detector so that users can easily read the muscle activity through a microcontroller's ADC pin.

Circuit Diagram MyoWare 2.0

Image Courtesy of Advancer Technologies taken from the MyoWare 2.0 Advanced Guide

The ICs highlighted below are amplifiers used to help process the raw EMG signal. As stated from the MyoWare 2.0 Advanced Guide, some of the muscle sensor's technical specifications are as follows:

  • Input Bias Current
    • 250 pA, max 1 nA
  • Input Impedance
    • 800
  • Common Mode Rejection Ratio (CMRR)
    • 140dB
  • Filters
    • High-pass Filter: Active 1st order, fc = 20.8 Hz, -20dB
    • Low-pass Filter: Active 1st order, fc = 498.4 Hz, -20dB
  • Rectification Method
    • Full-wave
  • Envelope Detection
    • Linear: Passive 1st order, fc = 3.6 Hz, -20 dB

Amp ICs

The board includes a potentiometer (trim pot) to manually adjust the gain of the envelope signal. You will need a screwdriver to adjust. Of course the top shield will need to be disconnected to access the potentiometer. The gain (G) for the following signals are as follows:

  • Raw (RAW): G = 200
  • Rectified (RECT): G = 200
  • Envelope (ENV): G = 200 * (R / 1 k&ohm;), where R is the resistance of the gain potentiometer in k&ohm;

trim pot

The image below shows the waveforms for the raw, rectified, and envelope outputs. The graph to the right of the outputs show the raw output's power spectrum. The MyoWare 2.0 Muscle Sensor has a first-order bandpass filter ranging between 20Hz - 500Hz. This range is ideal for capturing the the raw EMG signal and removing any unwanted signals such as motion artifacts. Note that the data shown is for illustration purposes only and not the actual data.

Raw, Rectified, and Envelope Signal Output, Power Spectrum

Image Courtesy of Advancer Technologies taken from the MyoWare 2.0 Advanced Guide

PTH Pads

Flipping the board to the bottom side, you will see PTH pads labeled. For those that need to solder wire to connect VIN, GND, and ENV, we have included a 1x3 row of 0.1" spaced PTH pads on the board. Additionally, the RAW, RECT, REF, MID, and END pins are broken out throughout the board. When soldering wire to the REF, RECT, and RAW pins, care must be taken to avoid adding excessive solder to the pins as this may prevent the MyoWare 2.0 Link Shield's pogo pins from connecting properly to the PTH pads.

PTH Pads

LEDs

The board includes two status LEDs.

  • VIN - The VIN LED lights up when the power switch is flipped to the ON position to indicate when the board is providing power for the MyoWare 2.0 Muscle Sensor through the VIN snap pin.
  • ENV - The ENV pin lights up when there is activity from the MyoWare 2.0 Muscle Sensor's ENV pin.

LEDs

Snap Connectors

The board includes snap connectors to easily stack shields on the MyoWare 2.0 Muscle Sensor. The top of the board is slightly offset and designed to act like a key so there's only one way to connect the boards together. Align the GND or REF snap connectors before stacking the boards together. Otherwise, the three snap connectors will fail to connect.

The following male snap connectors are on the top side of the board. These are also broken out on the 1x3 header on the bottom of the board. Flip the board over to view the pin labels.

  • GND - Ground for the MyoWare 2.0 Muscle Sensor.
  • VIN - Voltage input for the MyoWare 2.0 Muscle Sensor. This voltage depends on what shield is stacked on top when using the snap connectors. Make sure to leave the VIN pin's PTH pad open when stacking a shield on top to avoid conflicting voltages from two power sources.
    • When using it with the MyoWare 2.0 Power Shield or LED Shield, it will depend on how much the LiPo battery is charged up. When plugged in to a power source for charging, the charge IC may start charging the LiPo battery and system voltage will be about 4.2V. For safety reasons, we recommend that users always disconnect this shield from the sensor when charging the battery.
    • When using it with the MyoWare 2.0 Link Shield and MyoWare 2.0 Arduino Shield, it depends on the position of the Power Jumper on the MyoWare 2.0 Arduino Shield. This sets VIN to 5V (default) or 3.3V.
  • ENV - Envelope signal ranging between 0-VIN. Connect this to an ADC on your microcontroller.

Top Snap Connectors

The following female snap connectors are on the bottom side of the board. These are broken out onto a PTH pad next to each snap connector.

  • REF - Reference electrode snap connector. Connect this to a separate section of the body such as a bony portion of the elbow or a nonadjacent muscle near the muscle group.
  • MID - Middle muscle electrode snap connector. Connect to the middle of the muscle group.
  • END - End muscle electrode snap connector. Connect to the end of the muscle group.

Bottom Snap Connectors

Reference Electrode Port

The board has a housing to insert the reference cable's crimped pin. By inserting the pin to its housing and placing a biomedical sensor pad into the electrode snap, you can stick the reference cable to a separate section of the body such as a bony portion of the elbow or a nonadjacent muscle near the targeted muscle where the built-in reference pin is unable to reach.

Reference Connector

Jumper

There is a small jumper beside the reference pin labeled "R". This jumper is closed by default and connects to the reference electrode connector. Make sure to cut this trace when using the reference cable. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

Reference Jumper

Board Dimensions

The MyoWare 2.0 Muscle Sensor board dimension is 37.57mm x 35.90mm (1.48” x 1.41”).

Board Dimensions

MyoWare 2.0 Sensor Cover

The MyoWare 2.0 Sensor Cover comes pre-installed with each MyoWare 2.0 Muscle Sensor. The cover should remain on the sensor to protect the circuitry unless you decide to stack shields on top.

Sensor Cover Stacked on Muscle Sensor

Hardware Overview

There's not much going on with this board besides the snazzy design. It looks similar to a fidget spinner... well, that is without the press fit skateboard bearings built into the board. There is no circuitry populated on the board. On the top of the board, you will find the MyoWare logo from Advancer Technologies. On the bottom, you will find a QR code on the bottom of the board. Feel free to take out your smartphone and scan the QR code to head on over MyoWare's official site!

Top View of the MyoWare 2.0 Power ShieldBottom View of the MyoWare 2.0 Power Shield
Top SideBottom Side

Board Dimensions

The sensor cover uses the MyoWare 2.0 Muscle Sensor form factor and has board dimensions of 37.57mm x 35.90mm (1.48” x 1.41”).

Board Dimensions

MyoWare 2.0 Reference Cable

The MyoWare 2.0 Reference Cable is meant as an extension for the MyoWare 2.0 Muscle Sensor's reference pin. By inserting the pin to its housing and placing a biomedical sensor pad into the electrode snap, you can stick the reference cable to a separate section of the body such as a bony portion of the elbow or a nonadjacent muscle near the targeted muscle where the built-in reference pin is unable to reach.

MyoWare 2.0 Reference Cable

MyoWare 2.0 Reference Cable

CAB-19244
$1.25

Hardware Overview

One end of the MyoWare 2.0 Reference Cable has a crimped pin with a tab. This is meant to be inserted into its respective pin housing on the MyoWare 2.0 Muscle Sensor. The tab will lock the pin in place. The other end has a snap pin to connect to a biomedical sensor pad. The cable is about 3 inches long.

Reference Cable

MyoWare 2.0 Cable Shield

The MyoWare 2.0 Cable Shield is designed for cases where you would want to mount the sensor pads away from the MyoWare 2.0 Muscle Sensor. This allows the users to test and use the muscle sensor without actually attaching the board to the target muscle. The shield includes a 3.5mm TRS jack where you can attach a traditional three electrode sensor cable. The board is also equipped with snap connectors on the board so you can easily stack it. Unlike the other shields in the MyoWare 2.0 ecosystem, this board snaps to the bottom side of the MyoWare 2.0 Muscle Sensor. You'll want to use this shield for non-wearable projects that are housed in an enclosure or that target muscles that are too small or situated such that the on-board electrode sockets would not be suitable.

MyoWare 2.0 Cable Shield

MyoWare 2.0 Cable Shield

DEV-18386
$5.95

Of course, you will need a 3.5mm TRS connector to access the mid, end, and reference ground pins along with a few biomedical sensor pads. Make sure to grab the following products if you do not have them already.

Sensor Cable - Electrode  Pads (3 connector)

Sensor Cable - Electrode Pads (3 connector)

CAB-12970
$5.50
9
Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)

SEN-12969
$8.95
4

Or you could grab a TRS plug to make an adapter using conductive material.

TRS Audio Plug - 3.5mm (Metal)

TRS Audio Plug - 3.5mm (Metal)

COM-15438
$0.95
1

Hardware Overview

While the default image for the MyoWare 2.0 Cable Shield's product page shows the side with the 3.5mm TRS connector as the first image, the "top" of this board is the side with male snap connectors. Compared to the other shields in the MyoWare 2.0 ecosystem, this is the only shield that stacks to the bottom side of the MyoWare 2.0 Muscle Sensor.

Top View of the MyoWare 2.0 Cable ShieldBottom View of the MyoWare 2.0 Cable Shield
Top SideBottom Side

The cable color codes can vary depending on the manufacturer. If you are seeing unusual sensor readings and the MyoWare 2.0 Muscle Sensor is not responding to a muscle group, try testing the pinout by using a multimeter set to measure continuity. Below is a table that references the connections between the male snap pins, TRS connector, and cable. The male snap pins allow users to easily stack to the bottom of the MyoWare 2.0 Muscle Sensor

Snap ConnectorTRS PinoutElectrode Pin Color
[CAB-12970]
Notes
Reference [REF]SleeveBlackReference electrode connection. Connect this to a separate section of the body such as a bony portion of the elbow or a nonadjacent muscle near the muscle group.
End [END]RingBlueEnd muscle electrode connection. Connect to the end of the muscle group.
Middle [MID]TipRedMiddle muscle electrode connection. Connect to the middle of the muscle group.

Board Dimensions

The shield uses the MyoWare 2.0 Muscle Sensor form factor and has board dimensions of 37.57mm x 35.90mm (1.48” x 1.41”).

Board Dimensions

MyoWare 2.0 Power Shield

The MyoWare 2.0 Power Shield is designed to easily power the MyoWare 2.0 Muscle Sensor for remote applications. The MyoWare Power Shield is equipped with snap connectors on the board so you can easily stack it to the top side of the MyoWare Muscle Sensor. Flip the switch to the ON position to give the sensor all the power it needs to work its myoelectric magic. Connecting the MyoWare 2.0 Muscle Sensor to battery power allows for a cleaner signal while also eliminating the possibility of creating a dangerous current path to the power grid. Use it to power your sensor in portable applications.

MyoWare 2.0 Power Shield

MyoWare 2.0 Power Shield

DEV-18427
$14.95

Hardware Overview

The top side of the board has the LiPo battery and the USB connector. The bottom side has the female snap connectors and a power switch.

Top View of the MyoWare 2.0 Power ShieldBottom View of the MyoWare 2.0 Power Shield
Top SideBottom Side

USB C Connector

Included on the board is a USB Type C connector. Plug in a USB C cable to a 5V power source to charge the single cell, LiPo battery.

USB C Connector

Power Switch

The board includes a power switch. Flip the switch to the ON position to provide power to the MyoWare 2.0 Muscle Sensor via the VIN female snap connector. When not in use, flip the switch to the OFF position.

Power Switch

LiPo Charger

The board includes the MCP73831 LiPo charger IC (the little black IC with 5 pins) to safely charge a single cell, LiPo battery. In this case, the charge rate is set to 40mA to charge the built-in 40mAh LiPo battery. The charge status of your battery is indicated by the charge (CHG) and full (FULL) LEDs.

LiPo Charger IC and LiPo

Snap Connectors

The board includes three female snap connectors to easily stack on top of the MyoWare 2.0 Muscle Sensor:

  • GND - Ground for power.
  • VIN - Voltage input for power. This voltage depends on how much the LiPo battery is charged up. When plugged in to a power source for charging, the charge IC may start charging the LiPo battery and will be about 4.2V. For safety reasons, we recommend that users always disconnect this shield from the sensor when charging the battery.
  • ENV - Envelope signal ranging between 0-VIN. Connect this to an ADC on your microcontroller.

Snap Connectors

LEDs

The board includes four LEDs on the top side of the board:

  • FULL - The FULL LED lights up to indicate when the battery is fully charged. This will be off when the LiPo is not charging or when the charger is not connected to the board.
  • CHG - The CHG LED lights up to indicate when the LiPo battery is charging. This will be off when the LiPo is fully charged or when the charger is not connected to the board.
  • VIN - The VIN LED lights up when the power switch is flipped to the ON position to indicate when the board is providing power for the MyoWare 2.0 Muscle Sensor through the VIN snap pin.
  • ENV - The ENV pin lights up when there is activity from the MyoWare 2.0 Muscle Sensor's ENV pin.

LEDs lighighted

Board Dimensions

The shield uses the MyoWare 2.0 Muscle Sensor form factor and has board dimensions of 37.57mm x 35.90mm (1.48” x 1.41”).

Board Dimensions

MyoWare 2.0 LED Shield

The MyoWare 2.0 LED Shield is designed to display the magnitude of a target muscle's signal and power the MyoWare 2.0 Muscle Sensor with its built-in battery. The blue 10-segment bar graph shows the magnitude of the measured signal. The more muscle activation measured, the higher up the board LEDs will go! With this shield, you will be provided with a visual representation of the signals provided by the MyoWare 2.0 Muscle Sensor. The LED shield is equipped with snap connectors on the board so you can easily stack it on the top side of the MyoWare 2.0 Muscle Sensor and flip the switch to the ON position to give the sensor all the power it needs to work its myoelectric magic. Connecting the MyoWare 2.0 Muscle Sensor to the battery power allows for a cleaner signal while also eliminating the possibility of creating a dangerous current path to the power grid. Use it to gauge how hard you’re working a muscle during a workout, as a teaching tool, or add some myoelectric flair to your Halloween costume!

MyoWare 2.0 LED Shield

MyoWare 2.0 LED Shield

DEV-18387
$26.95

Hardware Overview

The top side of the board has the LEDs and LiPo battery. The bottom side has the female snap pins, power switch, and USB connector.

Top View of the MyoWare 2.0 LED ShieldBottom View of the MyoWare 2.0 LED Shield
Top SideBottom Side

USB C Connector

Included on the board is a USB Type C connector. Plug in a USB C cable to a 5V power source to charge the single cell, LiPo battery.

USB C Connector

Power Switch

The board includes a power switch. Flip the switch to the ON position to provide power to the MyoWare 2.0 Muscle Sensor via the VIN's female snap connector. When not in use, flip the switch to the OFF position.

Power Switch

LiPo Charger

The board includes the MCP73831 LiPo charger IC to safely charge a single cell LiPo battery. In this case, the charge rate is set to 40mA to charge the 40mAh LiPo battery on the board. The charge status of your battery is indicated by the charge (CHRG) and full (FULL) LEDs.

Top View of the MyoWare 2.0 LED ShieldBottom View of the MyoWare 2.0 LED Shield
Top SideBottom Side

LM3914 Dot/Bar Driver

The black square IC is the LM3914 Dot/Bar Driver. This IC takes the output from the muscle sensor and outputs it to the 2x5 segment LEDs.

LM3914 Dot/Bar Driver

LEDs

The board includes three status LEDs.

  • FULL - The FULL LED lights up to indicate when the battery is fully charged. This will be off when the LiPo is not charging or when the charger is not connected to the board.
  • CHRG - The CHRG LED lights up to indicate when the LiPo battery is charging. This will be off when the LiPo is fully charged or when the charger is not connected to the board.
  • VIN - The VIN LED lights up when the power switch is flipped to the ON position to indicate when the board is providing power for the MyoWare 2.0 Muscle Sensor through the VIN snap pin.

Status LEDs

Of course, this board would not be called the MyoWare 2.0 LED Shield if it did not have the large segment LEDs. The bar graph lights up corresponding to the level of the muscle signal measured. The minimum is closest to the dot bar driver IC. As there is more muscle activity, the voltage will increase from the ENV pin. As a result, the LEDs will continue to light up until the last one on the other side is lit. The LEDs are bright enough to be seen in full light, but really glow nice in low light.

2x5 segment bar graph LEDs

Snap Connectors

The board includes three female snap connectors to easily stack on top of the MyoWare 2.0 Muscle Sensor:

  • GND - Ground for power.
  • VIN - Voltage input for power. This voltage depends on how much the LiPo battery is charged up. When plugged in to a power source for charging, the charge IC may start charging the LiPo battery and will be about 4.2V. For safety reasons, we recommend that users always disconnect this shield from the sensor while charging the battery.
  • ENV - Envelope signal ranging between 0-VIN. Connect this to an ADC on your microcontroller.

Snap Connectors

Jumper

The board includes one jumper for the MODE that is closed by default. The MODE is wired directly to LM3914 Dot/Bar Driver's V+ pin for bar graph mode. In this mode, the LED segments will continue to light up based on the magnitude of the muscle signal until the last one on the other side is lit. Opening the MODE jumper will turn the board into dot mode. When dot mode is enabled, a leading LED bar (i.e. "dot") will light up and traverse the segments. Any trailing LEDs behind it will be turned off instead of filling in with light. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

Jumpers

Board Dimensions

The shield uses the MyoWare 2.0 Muscle Sensor form factor. The board dimension is different than the other boards: 46.15mm x 38.00mm (1.82” x 1.50”).

Board Dimensions

The MyoWare 2.0 Link Shield is designed to easily connect a MyoWare 2.0 Muscle Sensor to your Arduino microcontroller. The shield provides a 3.5mm TRS jack so that you can use a 3.5mm TRS-to-TRS cable to link the boards together. The MyoWare 2.0 Link Shield is equipped with snap connectors on the board so you can easily stack it to the top side of the MyoWare 2.0 Muscle Sensor. You'll need the MyoWare 2.0 Arduino Shield and a development board with the Arduino Uno R3 footprint to link each MyoWare 2.0 Muscle Sensor and Link Shield stack.

MyoWare 2.0 Link Shield

MyoWare 2.0 Link Shield

DEV-18425
$12.95

Hardware Overview

The top side of the board has the TRS connector, power and output switches. The bottom side of the board includes the female snap connectors.

Bottom View of the MyoWare 2.0 Link ShieldTop View of the MyoWare 2.0 Link Shield
Top SideBottom Side

Power Switch

The power switch turns MyoWare 2.0 Muscle Sensor on and off. Power is provided by your Arduino and the Arduino Shield. By default, power is set to 5V on the Arduino Shield. The ring pin of your TRS-to-TRS cable will connect the 5V to VIN when the switch is flipped to the ON position.

Power Switch

Output Switch

The OUTPUT switch selects the signal to provide for the Arduino's analog input.

  • ENV - Envelope output.
  • REC - Rectified output.
  • RAW - Raw output.

Output switch

3.5mm TRS Connector

The 3.5mm TRS connector is connected to the following pins.

PinoutTRS Pin
Ground [GND]Sleeve
Voltage Input [VIN]Ring
ENV/RECT/RAW [OUTPUT]Tip

TRS Connector

LEDs

The board includes two LEDs.

  • VIN - The VIN LED lights up when the power switch is flipped to the ON position to indicate when the board is providing power for the MyoWare 2.0 Muscle Sensor through the VIN snap pin.
  • ENV - The ENV pin lights up when there is activity from the MyoWare 2.0 Muscle Sensor's ENV pin.

LEDs

Snap Connectors

The board includes three female snap connectors to easily stack on top of the MyoWare 2.0 Muscle Sensor:

  • GND - Ground for power.
  • VIN - Voltage input for power. This voltage depends on the the the jumper that was set on the MyoWare 2.0 Arduino Shield. This voltage can be 5V (default) or 3.3V depending on the position of the PWR jumper on the MyoWare 2.0 Arduino Shield.
  • ENV - Envelope signal ranging between 0-VIN. Connect this to an ADC on your microcontroller.

Snap Connectors

Pogo Pins

There are three pogo pins on the bottom of the board. These have a much lower profile than the other pogo pins that you may have seen in our storefront. These connect to the MyoWare 2.0 Muscle Sensor's PTH pads. Note that the MyoWare 2.0 Link Shield does not have any labels for the pins. The pogo pin closest to the GND snap connector is the reference pin. The pogo pin just next to the switch is the rectified output pin. The pogo pin just above the VIN snap connector is the raw output.

  • REF - Reference pin.
  • RECT - Rectified output pin.
  • RAW - Raw output pin.
Pogo Pins MyoWare 2.0 Link ShieldPTH Pads MyoWare 2.0 Muscle Sensor
Pogo Pins on the MyoWare 2.0 Link ShieldPTH Pads on the MyoWare 2.0 Muscle Sensor

Jumper

The board includes a 3-way jumper on the top of the board. The point of this jumper is to allow users to change the relative ground point for the output and Arduino. By default, the RAW output will be centered around VIN/2, which is what REF is. Some users might want to change this so that it is centered around 0V, which would require changing the relative ground point to REF. Cutting the trace connected to GND and adding a solder jumper between the REF and center pad will connect the REF pogo pin to the muscle sensor's REF. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

Jumper

Board Dimensions

The shield uses the MyoWare 2.0 Muscle Sensor form factor and has board dimensions of 37.57mm x 35.90mm (1.48” x 1.41”).

Board Dimensions

MyoWare 2.0 Arduino Shield

The MyoWare 2.0 Arduino Shield is designed to easily connect up to six MyoWare 2.0 Muscle Sensors and Link Shields using 3.5mm TRS-to-TRS audio cables. The board comes pre-populated with male headers so all you need to do is stack it on your Arduino and connect the sensors to read up to six muscle groups! The Arduino shield form-factor mates directly with development boards that have the Arduino Uno R3 standard footprint. You'll need a MyoWare 2.0 Link Shield and TRS-to-TRS cable for each MyoWare 2.0 Muscle Sensor.

MyoWare 2.0 Arduino Shield

MyoWare 2.0 Arduino Shield

DEV-18426
$9.95

You'll need a TRS-to-TRS cable to link the boards together. Of course, you could solder wire to a TRS connector as well to make your own. Just make sure to solder wires to the correct pins.

Audio Cable TRS - 1m

Audio Cable TRS - 1m

CAB-18983
$1.95
TRS Audio Plug - 3.5mm (Metal)

TRS Audio Plug - 3.5mm (Metal)

COM-15438
$0.95
1

Hardware Overview

The top side of the board includes the TRS connectors and the QR code. Feel free to take out your smartphone and scan the QR code to head on over MyoWare's official site! The bottom side has the male headers to mate with female headers on Arduino development boards with an R3 footprint.

Top View of the MyoWare 2.0 Arduino ShieldBottom View of the MyoWare 2.0 Arduino Shield
Top SideBottom Side

3.5mm TRS Connectors

On the top side of the board you will find six 3.5mm TRS jacks. Each connector is connected to power and your Arduino's analog pins ranging from A0 to A5.

TRS Connectors

The 3.5mm TRS Connector is connected to the following electrode pins.

Electrode PinTRS Pin
Ground [GND]Sleeve
Voltage [VIN]Ring
ENV/RECT/RAW [OUTPUT]Tip

Reserved Pins

The 5V, 3.3V, GND net, and analog pins (A0 - A5) are reserved for the shield.

Reserved Pins

Jumpers

There's not too much going on the bottom of the board. On the back, there is a jumper labeled as PWR. By default, the 3-way jumper connects the 5V pin and the 5V plane on the back of the board. The center pad is connected to the TRS connectors to power any MyoWare 2.0 Muscle Sensors through the Link Shield. Cut the trace and add a solder blob between the center pad and 3.3V for an alternative voltage. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

Power Jumper

Board Dimensions

The shield uses the Arduino Uno R3 form factor and has board dimensions of 53.34mm x 59.69mm (2.10” x 2.35”).

Board Dimensions

Hardware Hookup

Advancer Technologies has provided a Quick Start and Advanced Guide for the MyoWare 2.0 Muscle Sensor. Feel free to check them out with this guide.

Selecting a Muscle Group

Select a muscle group to place the MyoWare 2.0 Muscle Sensor. Placement of the sensor is critical when measuring the muscle activity. You will need to connect the MID electrode to the middle of the muscle body with the END electrode lined up in the direction of the muscle length. The REF electrode will be adjacent to the muscle body.

Muscle Sensor Placement on Muscle

Image Courtesy of Advancer Technologies taken from the MyoWare 2.0 Advanced Guide

We'll be using the forearm as an example. For more other muscle groups, check out the MyoWare 2.0 Advanced Guide. Make sure to zoom in on the image for a closer look at the muscle group. The positions shown in the image are approximate.

Muscle Group Sensor Placement

Image Courtesy of Advancer Technologies taken from the MyoWare 2.0 Advanced Guide

Preparing the Skin

Grab an alcohol swab to clean the skin where the MyoWare 2.0 Muscle Sensor will be placed. Cleaning the skin with soap can leave a residue on the skin and should be avoided.

Alcohol Swab

Clean the skin where the EMG pads will stick using an alcohol swab. A cotton ball soaked in isopropyl alcohol is also sufficient to remove any oils or surface contaminants on the skin. Allow the isopropyl alcohol to evaporate before sticking the EMG pads on the skin

Clean Skin where Sensor Pad will Stick

Stacking Shields

Since the shields are keyed, there's only one way to stack the boards together! Just look for the snap connector labeled as GND or REF. Align the snap connectors. Make sure the power switch is flipped to the OFF position for shields.

Stack Shields Together while Aligning the GND or REF Snap Connectors

Push down on the snap connectors using your thumb and index finger. Make sure to avoid pressing down on the built-in LiPo battery.

Pushing snap pins together on Power ShieldPushing snap pins together on LED Shield

Connecting to a Muscle Group

Snap the EMG pads to the bottom of the MyoWare 2.0 Muscle Sensor. For users using the MyoWare 2.0 Cable Shield, you'll be snapping it to the sensor cable's snap connectors.

Attach EMG Pads

Peel and carefully remove the backs of the electrodes to expose the adhesive.

Remove Adhesive

Attach the pads to the target muscle. In this case, we are using our right forearm.

Attaching to a Target Muscle

Ensure that power is disconnected when stacking shields on the top side of the MyoWare 2.0 Muscle Sensor. Once everything is connected, flip the power switch to the ON position on the Power Shield or LED Shield. For users connecting the sensor to an Arduino and computer, check to make sure that your computer is not connected to the wall outlet. Then flip the power switch to the ON position on the Link Shield.

Connecting Shields to Arduino

For users using a 3.3V Arduino, we recommend adjusting the PWR jumper by cutting the default trace and adding a solder jumper between the center pad and the 3.3V side. For users using a 5V Arduino, you can leave the jumper connected to the 5V side. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

Cut trace and solder on the 3.3V Side

Stack the Arduino Shield on your chosen development board with the Arduino Uno R3 footprint.

Stacking the Arduino Shield on the Arduino Development Board with Arduino Uno R3 Footprint

Insert the TRS cable between the MyoWare 2.0 Link Shield and Arduino Shield's TRS connector. In this case, we will be using the connector labeled as A0. Make sure to adjust the code when using the other channels.

TRS Cable Between the Link Shield and Arduino

For remote applications, we recommend using a battery pack. In this case, we used AA batteries (NiMH) and a 4xAA battery pack to power the system.

Battery Pack Connected to the System

Make sure to remove the power supply from your computer before connecting your Arduino with the MyoWare 2.0 Muscle Sensor to your USB port. This is to prevent noise and safeguard against electrical shock when connected to the power grid. This includes any computer docks and external monitors.

Remove Power from a Laptop that was Connected to the Main Outlet

Removing power from a laptop before connecting the MyoWare.

When ready, insert the USB cable between your Arduino and computer's USB port.

Connecting USB

For users transmitting sensor data via Bluetooth, attach a battery pack to the RedBoard Artemis acting as the Bluetooth peripheral device. This is assuming that it has the Bluetooth peripheral example code uploaded. Connect the RedBoard Artemis acting as the Bluetooth central device to your computer's USB port. Since the Bluetooth peripheral device is disconnected, you could connect your laptop to a power supply since the MyoWare 2.0 Muscle Sensor is not connected to the main outlet. You just need to make sure to unplug the power supply every time you need to reprogram the RedBoard Artemis acting as the peripheral device.

Bluetooth Example

External Cable

For muscles that require you to mount the sensor pads away from the sensor, snap the MyoWare 2.0 Cable Shield on the bottom of the MyoWare 2.0 Muscle Sensor. Then insert the sensor cable into the 3.5mm TRS connector.

Sensor Cable and Cable Shield

Attach the EMG pads to the snap connectors. After cleaning the skin and selecting the muscle, peel and remove the backs of the electrodes to expose the adhesive. Then attach the pads to the target muscle group based on the MID, END, and REF.

Snap ConnectorTRS PinElectrode Pin
[CAB-12970]
Reference [REF]SleeveBlack
End [END]RingBlue
Middle [MID]TipRed

Reference Cable

With a hobby knife, slice the reference jumper pad closest to the GND pin. There are traces near the jumper so you will need to make sure to avoid cutting traces that are adjacent to jumper pad. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

Cutting Reference Jumper Pad with Hobby Knife

Then insert the reference cable into the MyoWare 2.0 Muscle Sensor, slide the pin into the housing with the tab facing away from the board.

Reference Cable Pin Inserting into Jumper Pad

When stacking a shield on top of the MyoWare 2.0 Muscle Sensor, make sure carefully pull the cable away from the shield's snap pin.

Pull Away Reference Cable Wire While Stacking Shields on Top

To remove the reference cable, push the tab into the housing with the end of a flathead screwdriver and gently pull the pin out of the housing.

Push Down Tab and Pull Reference Cable Out of SocketPull Pin Out of Socket

To close the jumper pad, add a small amount of solder on the jumper pad.

Close Reference JUmper

Disconnecting the MyoWare Shield

When prototyping, you will want to test out different shields or you may need to adjust the trim pot. To remove the boards, you will need a flathead screwdriver. With power off, insert the flathead between the snap connectors and ensure that there are no components in the way of the flathead. Gently slide the flathead between the snap connectors.

Flathead Between Snap Connectors

Angle the flathead against the connectors until the boards disconnect.

Flathead Prying the Shield Off

With one side disconnected, pull the boards away from each other so that the other two snap connectors disconnect.

Remove Shield from Muscle Sensor

Standalone Example 0: LED(s)

To test the MyoWare 2.0 Muscle Sensor without an Arduino, you could use the MyoWare 2.0 Power Shield or the LED Shield. Both shields have a built-in battery removing the need to solder a power source to the sensor. After stacking the boards together and sticking it to a muscle group, flip the power switch to the ON position. Start flexing the muscle to see if you can light up the ENV LED on the Power Shield or the LED segments on the LED Shield!

If you are using the MyoWare 2.0 Power Shield, observe the ENV LED. The LED will be off. As you flex, the voltage from the ENV pin increases. As a result, the ENV LED will start to light up and increase in intensity as you flex the muscle. If you look closely between the stacked boards, you will also notice the ENV LED on the MyoWare 2.0 Muscle Sensor light up.

Flexing the muscle and lighting up the MyoWare 2.0 Power Shield ENV LED

If you are using the MyoWare 2.0 LED Shield, observe the LED segments. The LED segments will be off. As you flex, the voltage from the ENV pin increases. As a result, the LED segments will start to light up. The more you flex the muscle, the more LED segments will light up. When fully flexed, all 10x LED segments will be on.

Flexing the muscle and lighting up the MyoWare 2.0 LED Shield Bar Graph Mode

For users that cut the jumper labeled as MODE (i.e. enabling dot mode) on the MyoWare 2.0 LED Shield, you will see a different effect. A leading LED bar (i.e. "dot") will light up and traverse the segments. Any trailing LEDs behind it will be turned off instead of filling in with light. When fully flexed, one LED segment should be on.

Flexing the muscle and lighting up the MyoWare 2.0 LED Shield in Dot Mode

Arduino Example 1: Analog Read - Single Sensor

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 are using the RedBoard Artemis, please check out our guide on installing board definitions.

Example 1: Analog Read - Single

The following example uses an analog input on the RedBoard Plus with an Atmega328P to read the muscle sensor's analog signal. However, you could also use any microcontroller with the Arduino Uno R3 footprint.

Analog Read with One Muscle Sensor

If you have not already, select your Board (in this case the Arduino Uno), and associated COM port. Upload the code to the board.

language:c
/*
  MyoWare Example_01_analogRead_SINGLE
  SparkFun Electronics
  Pete Lewis
  3/24/2022
  License: This code is public domain but you buy me a beverage if you use this and we meet someday.
  This code was adapted from the MyoWare analogReadValue.ino example found here:
  https://github.com/AdvancerTechnologies/MyoWare_MuscleSensor

  This example streams the data from a single MyoWare sensor attached to ADC A0.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).

  *Only run on a laptop using its battery. Do not plug in laptop charger/dock/monitor.

  *Do not touch your laptop trackpad or keyboard while the MyoWare sensor is powered.

  Hardware:
  SparkFun RedBoard Artemis (or Arduino of choice)
  USB from Artemis to Computer.
  Output from sensor connected to your Arduino pin A0

  This example code is in the public domain.
*/

void setup() 
{
  Serial.begin(115200);
  while (!Serial); // optionally wait for serial terminal to open
  Serial.println("MyoWare Example_01_analogRead_SINGLE");
}

void loop() 
{  
  int sensorValue = analogRead(A0); // read the input on analog pin A0

  Serial.println(sensorValue); // print out the value you read

  delay(50); // to avoid overloading the serial terminal
}

Once uploaded, open the Arduino Serial Plotter (Tools>Serial Plotter) to 115200 baud. Flip the power switch on the MyoWare 2.0 Link Shield to provide power and start flexing! You should see something similar to the output below with the envelope signal. In this case, the MyoWare 2.0 Muscle Sensor was attached to my right forearm. For those that are interested in viewing the serial output, you can also open the Arduino Serial Monitor to see the values.

Serial Plotter with Envelop Signal

Serial Plotter with Envelope Signal

To view the Rectified or Raw signals, flip the power switch to the OFF position on the Link Shield, adjust the OUTPUT switch to either the Rectified or Raw position and then turn the power switch to the ON position. Reopen the Serial Plotter and you will see a smaller signal output when flexing your forearm.

The images below show the forearm being flexed at around 300ms when the signal increases by a value of about 22 for the rectified output and about 20 for the raw output. Note that the raw signal will be centered around a voltage offset of about +VIN/2. Make sure that the +VIN is the maximum voltage of your microcontroller's ADC to ensure that you can see the positive and negative portions of the waveform. The output shown in the graphs are values and have not been converted to voltages.

Serial Plotter with Rectified SignalSerial Plotter with Raw Signal
Serial Plotter with Rectified SignalSerial Plotter with Raw Signal

Arduino Example 2: Transmitting Sensor Data via Bluetooth® - Single Sensor

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. Since this example uses the RedBoard Artemis for Bluetooth, please check out our guide on installing board definitions.

The following example requires two RedBoard Artemis boards to send and receive sensor data from one muscle sensor. This is useful for users that need a clean signal or want to transmit the sensor data wirelessly.

Peripheral and Central Example

For an explanation of how the Bluetooth peripheral and central devices works, we recommend looking at the Arduino reference language under the ArduinoBLE Library for a quick introduction.

Example 2a: Bluetooth Peripheral "Send"

The following example uses a RedBoard Artemis to transmit the analog reading wirelessly via Bluetooth. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Copy the code below and paste into your Arduino IDE. Then upload the code to the board.

language:c
/*
  MyoWare Sensor BLE Peripheral SINGLE SENSOR Example
  SparkFun Electronics
  Pete Lewis
  3/17/2022

  This example reads a single MyoWare Muscle Sensor, and then gets that data from this RedBoard Artemis 
  (the peripheral) to a second RedBoard Artemis (the central) over BLE.

  This Artemis, aka the "BLE Peripheral", will read the sensor on A0.
  It will then update the value to the "bluetooth bulletin board."

  Note, in BLE, you have services, characteristics and values.
  Read more about it here:

  https://www.arduino.cc/reference/en/libraries/arduinoble/

  Note, before it begins reading the ADC and updating the data,
  It first sets up some BLE stuff:
    1. sets up as a peripheral
    2. sets up a service and characteristic (the data)
        -Note, Services and characteristics have custom 128-bit UUID,
        -These must match the UUIDs in the code on the central device.
    3. advertises itself

  In order for this example to work, you will need a second Artemis, and it will
  need to be programmed with the provided code specific to being a central device, 
  looking for this specific peripheral/service/characteristic.

  Note, both the service and the characteristic get unique UUIDs 
  (even though they are extremely close to being the same thing in this example)

  The second Artemis, aka the "BLE Central," will subscribe to the first board's 
  characteristic, and check to see if the value has been updated. When it has been 
  updated, it will print the value to the serial terminal.

  Hardware:
  MyoWare Sensor with Link Shield snapped on top.
  TRS cable from Link Shield to A0 port of Arduino Shield.
  Arduino Shield pressed into RedBoard Artemis.
  USB from Artemis to Computer.

  ** For consistent BT connection follow these steps:
  ** 1. Reset Peripheral
  ** 2. Wait 5 seconds
  ** 3. Reset Central
  ** 4. Enjoy BT connection
  **
  ** ArduinoBLE does not support RE-connecting two devices.
  ** If you loose connection, you must follow this hardware reset sequence again.

  This example code is in the public domain.
*/

#include <ArduinoBLE.h>

BLEService sensorDataService("19b10000-e8f2-537e-4f6c-d104768a1214"); // BLE Service named "sensorDataService"

// BLE Data Characteristic - custom 128-bit UUID, readable, writable and subscribable by central
// Note, "BLENotify" is what makes it subscribable
BLEByteCharacteristic dataCharacteristic("19b10001-e8f2-537e-4f6c-d104768a1214", BLERead | BLEWrite | BLENotify); 

const int ledPin = LED_BUILTIN; // pin to use for the LED

void setup() 
{
  Serial.begin(115200);
  while (!Serial); // optionally wait for serial terminal to open, useful with micros that have native USB
  Serial.println("MyoWare Single Sensor Example - BLE Peripheral");

  pinMode(ledPin, OUTPUT); // set LED pin to output mode

  if (!BLE.begin()) { // begin initialization
    Serial.println("starting BLE failed!");
    while (1);
  }
  Serial.println("BLE initiallized successfully");

  BLE.setLocalName("MYOWARE1"); // set advertised local name
  BLE.setAdvertisedService(sensorDataService); // set advertised service UUID
  sensorDataService.addCharacteristic(dataCharacteristic); // add the characteristic to the service
  BLE.addService(sensorDataService); // add service
  dataCharacteristic.writeValue(0); // set the initial value for the characeristic
  BLE.advertise(); // start advertising
}

void loop() 
{
  BLEDevice central = BLE.central(); // listen for BLE peripherals to connect

  if (central) // if a central is connected to peripheral
  {
    Serial.print("Connected to central: ");
    Serial.println(central.address()); // print the central's MAC address

    Serial.println("Reading Sensor and writing BLE characteristic values now...");

    // while the central is still connected to peripheral:
    while (central.connected()) 
    {
      int val_int = analogRead(A0); // Read the sensor attached to Analog Pin A0
      byte val_byte = map(val_int, 0, 1023, 0, 255); // map the int to a byte
      delay(10);
      dataCharacteristic.writeValue(val_byte); // "post" to "BLE bulletin board"
      // Note, because our second Artemis in this example (the central) is subscribed to this characteristic,
      // it can simply call Characteristic.valueUpdated() to see if it has been updated.
      // valueUpdated() will return True if updated, or false if no update has happened.
      // If it has been updated, the central Artemis can read the latest value using Characteristic.readValue();
    }
    Serial.print(F("Disconnected from central: ")); // when the central disconnects, print it out
    Serial.println(central.address());
  }
}

Example 2b: Bluetooth Central "Receive"

The following example uses a RedBoard Artemis to receive the analog reading from the peripheral RedBoard Artemis wirelessly via Bluetooth. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Copy the code below and paste into your Arduino IDE. Then upload the code to the board.

language:c
/*
  MyoWare Receiver BLE Central SINGLE SENSOR Example
  SparkFun Electronics
  Pete Lewis
  3/17/2022

  This example sets up a SparkFun RedBoard Artemis as a BLE central device,
  Then, it connects to a second Artemis peripheral device that is reading a single MyoWare
  Muscle sensor. It then streams the data on the Serial Terminal.

  Note, in BLE, you have services, characteristics and values.
  Read more about it here:

  https://www.arduino.cc/reference/en/libraries/arduinoble/

  Note, before it begins checking the data and printing it,
  It first sets up some BLE stuff:
    1. sets up as a central
    2. scans for any peripherals
    3. Connects to the device named "MYOWARE1"
    4. Subscribes MYOWARE1's data characteristic

  In order for this example to work, you will need a second Artemis, and it will
  need to be programmed with the provided code specific to being a peripheral device, 
  and advertising as MYOWARE1 with the specific characteristic UUID.

  Note, both the service and the characteristic get unique UUIDs 
  (even though they are extremely close to being the same thing in this example)

  This Artemis, aka the "BLE Central," will subscribe to the peripheral board's 
  characteristic, and check to see if the value has been updated. When it has been 
  updated, it will print the value to the serial terminal.

  Hardware:
  SparkFun RedBoard Artemis
  USB from Artemis to Computer.

  ** For consistent BT connection follow these steps:
  ** 1. Reset Peripheral
  ** 2. Wait 5 seconds
  ** 3. Reset Central
  ** 4. Enjoy BT connection
  **
  ** ArduinoBLE does not support RE-connecting two devices.
  ** If you loose connection, you must follow this hardware reset sequence again.

  This example code is in the public domain.
*/

#include <ArduinoBLE.h>

void setup() 
{
  Serial.begin(115200);
  while (!Serial); // optionally wait for serial terminal to open, useful with micros that have native USB
  Serial.println("MyoWare Single Sensor Example - BLE Central");

  if (!BLE.begin()) // initialize the BLE hardware
  { 
    Serial.println("starting BLE failed!");
    while (1);
  }
  Serial.println("BLE initiallized successfully");

  BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214"); // start scanning for peripherals
}

void loop() 
{
  BLEDevice peripheral = BLE.available(); // check if a peripheral has been discovered

  if (peripheral) // discovered a peripheral, print out its info
  {
    Serial.print("Found ");
    Serial.print(peripheral.address());
    Serial.print(" '");
    Serial.print(peripheral.localName());
    Serial.print("' ");
    Serial.print(peripheral.advertisedServiceUuid());
    Serial.println();

    if (peripheral.localName() != "MYOWARE1")
    {
      return;
    }

    BLE.stopScan();

    checkUpdate(peripheral);

    Serial.println("Starting to scan for new peripherals again...");
    BLE.scanForUuid("19b10000-e8f2-537e-4f6c-d104768a1214"); // peripheral disconnected, scan again
    Serial.println("Scan has begun...");
  }
}

// Connect to peripheral
// Then continue to check if the data has been updated,
// If so, print it to terminal
void checkUpdate(BLEDevice peripheral) 
{
  Serial.println("Connecting ..."); // connect to the peripheral

  if (peripheral.connect()) 
  {
    Serial.println("Connected");
  } else {
    Serial.println("Failed to connect!");
    return;
  }

  Serial.println("Discovering attributes ..."); // discover peripheral attributes
  if (peripheral.discoverAttributes()) 
  {
    Serial.println("Attributes discovered");
  } else {
    Serial.println("Attribute discovery failed!");
    peripheral.disconnect();
    return;
  }

  // retrieve the data characteristic
  BLECharacteristic dataCharacteristic = peripheral.characteristic("19b10001-e8f2-537e-4f6c-d104768a1214");

  if (!dataCharacteristic) 
  {
    Serial.println("Peripheral does not have that characteristic!");
    peripheral.disconnect();
    return;
  } else if (!dataCharacteristic.canWrite()) 
  {
    Serial.println("Peripheral does not have a writable characteristic!");
    peripheral.disconnect();
    return;
  } else if (!dataCharacteristic.canRead()) 
  {
    Serial.println("Peripheral does not have a readable characteristic!");
    peripheral.disconnect();
    return;
  } else if (!dataCharacteristic.canSubscribe()) 
  {
    Serial.println("Characteristic is not subscribable!");
    peripheral.disconnect();
    return;
  } else if (!dataCharacteristic.subscribe()) 
  {
    Serial.println("subscription failed!");
    peripheral.disconnect();
    return;
  }

  while (peripheral.connected()) // while the peripheral is connected
  {
    if (dataCharacteristic.valueUpdated()) // Check to see if the value of the characteristic has been updated
    {
      byte received_val = 0;
      dataCharacteristic.readValue(received_val); // note, readValue returns nothing, and needs the variable to be passed by reference
      Serial.println(received_val);
    }
    delay(1);
  }
  Serial.println("Peripheral disconnected");
}

What You Should See

With two instances of the Arduino IDE open with a COM port selected for each respective board, you should see the following output in the Serial Monitor set to 115200 baud. If the Bluetooth fails to connect, try pushing the reset button on the Peripheral first, wait about 5 seconds, then hit the reset button on the Central. Once connected, the muscle sensor readings will be transmitted wirelessly to the central. Try flexing your arm to see if you can see the values increase.

Debug Output from Peripheral DeviceDebug Output from Central Device
Debug Output from Peripheral DeviceDebug Output from Central Device

For users looking for a graphical view of the output, close the Arduino Serial Monitor for the Bluetooth set as the Central device (i.e. the RedBoard Artemis receiving the sensor data). Then open the Arduino Serial Plotter. You should see something similar to the output below. In this case, we flexed our forearm muscle causing the values to increase. Relaxing the muscle caused the values to decrease.

Serial Plotter from the Debug Output from the Central Device

More Examples!

Looking for more examples? Try checking out the GitHub Repository to use multiple analog channels via BLE! There's also a project example that connects to the Tsunami Super WAV Trigger (Qwiic) and speaker.

Troubleshooting

For your convenience, the following troubleshooting tips are provided from the MyoWare 2.0 Quick Start Guide.

  • The Vin LED should remain on constantly as long as the sensor is powered.
  • The ENV LED might immediately turn on when power is turned on but it should turn off after a second or two; afterwards, it should only turn on when the sensor detects muscle flexion.
  • The ENV LED might sporadically turn on and off or simply remain on if the sensor (or external cables) is not connected to electrodes on the skin. This is normal behavior.
  • The ENV LED lighting up seemingly at random while connected to electrodes on the skin usually indicates poor contact between the electrodes and the skin. Try cleaning the area and applying new electrodes.
  • The ENV LED not lighting up during flexion could be caused by various issues with the sensor setup. Double check the steps and tips of this guide to ensure proper setup.
  • Most of the time the sensor gain does not need to be adjusted at all.
  • Recommended that you do not adjust the sensor’s gain until you get a consistent, quality signal from the sensor.

Resources and Going Further

Now that you've successfully got your MyoWare 2.0 Muscle Sensor up and running, it's time to incorporate it into your own project! Try embedding the sensor in a prosthetic arm, controlling a servo to grip something, Halloween costume, video game, or turning on LEDs in a dance performance! For more information, check out the resources below:

[1] Note: This product is patent protected. To prevent counterfeit boards, the Eagle design files and GitHub hardware repository are not shared for boards in the MyoWare 2.0 ecosystem.

Need some inspiration for your next project? Check out some of these related tutorials tagged with biometrics.

Hackers in Residence - Hacking MindWave Mobile

Review, teardown, and hacking tutorial for the MindWave Mobile, a $99 commercial grade EEG sensor.

Teardown: Misfit Shine Activity Tracker

A quick tear down of the popular fitness tracking device, the Misfit Shine.

AD8232 Heart Rate Monitor Hookup Guide

Learn how to create your very own heart rate monitor.

SparkFun Photodetector (MAX30101) Hookup Guide

The SparkFun Photodetector - MAX30101 (Qwiic) is the successor to the MAX30105 particle sensor, a highly sensitive optical sensor. This tutorial will get you started on retrieving the raw data from the MAX30101 sensor.

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

Qwiic dToF Imager (TMF882X) Hookup Guide

$
0
0

Qwiic dToF Imager (TMF882X) Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Qwiic dToF Imager - TMF8820/TMF8821 are a direct time-of-flight (dToF) sensors that includes single modular package with associated Vertical Cavity Surface Emitting Laser (VCSEL) from AMS. The dToF device is based on Single Photon Avalanche Photodiode (SPAD), time-to-digital converter (TDC) and histogram technology and achieves 5000 mm detection range. Due to its lens on the SPAD, the TMF8820 supports 3x3 multizone output data while the TMF8821 supports 3x3, 4x4, and 3x6 multizone output data. The lens on each dToF Imager provides a very wide, dynamically adjustable, field of view. A multi-lens-array (MLA) inside the package above the VCSEL widens up the FoI (field of illumination). All processing of the raw data is performed on-chip and the TMF8820/TMF8821 provide distance information together with confidence values on its I2C interface. The high performance on-chip optical filter blocks most of the ambient light, and enables distance measurements in dark and sunlight environments.

These sensors are great for projects that such as distance measurement for camera autofocus - Laser Detect Autofocus - LDAF (mobile phone), presence detection (computing and communication), object detection and collision avoidance (robotics), and light curtain (industrial).

SparkFun Qwiic dToF Imager - TMF8820

SparkFun Qwiic dToF Imager - TMF8820

SEN-19036
$19.95
SparkFun Qwiic Mini dToF Imager - TMF8820

SparkFun Qwiic Mini dToF Imager - TMF8820

SEN-19218
$19.95
SparkFun Qwiic dToF Imager - TMF8821

SparkFun Qwiic dToF Imager - TMF8821

SEN-19037
$20.95
SparkFun Qwiic Mini dToF Imager - TMF8821

SparkFun Qwiic Mini dToF Imager - TMF8821

SEN-19451
$20.95

Required Materials

Note: We recommend a microcontroller with enough flash to run your program code. Sorry, Uno's (or any development board using the ATmega328P) are out. But didn't you want an excuse to try out something new? We recommend choosing either an Artemis Thing Plus or an ESP32 Thing Plus board as your development board.

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. Note that the following wishlist includes the RedBoard Artemis and the TMF8821. Depending on your application, you can adjust the cart for a different processor board or sensor version.

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.

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.

Hookup Guide for the SparkFun RedBoard Artemis

Get started with the RedBoard Artemis - all the functionality of the SparkFun Artemis module wrapped in the familiar Uno R3 footprint

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.

Hardware Overview

First, let's check out some of the characteristics of the TMF8820 and TMF8821 we're dealing with, so we know what to expect out of the board. Below is a comparison table for both sensors taken from the datasheet. Both are the pretty much the same except for the zone operation. Typically, the each board is powered at 3.3V via the Qwiic connector.

CharacteristicTMF8820TMF8821
Operating Voltage2.7V to 3.6V, typically 3.3V via Qwiic Connector
I/O Voltage1.62V to 3.3V, typically 3.3V via Qwiic Connector
Current Consumption (Standby)8µA
Current Consumption (Active)57mA
Measurement Range10mm to 5000mm, better accuracy detects reliably closest object
Zone Operation3x33x3, 4x4 and 3x6
Light SourceClass 1 940nm VCSEL
I2C Address0x41
Field of Viewup to 63°
Max Read Rate up to 30 Hz
Operating Temperature-30°C to 70°C

The layout for both the Qwiic dToF Imagers standard and mini sizes are the same. The only difference is the IC that is populated on the boards. The boards can be distinguished by the solder blob on the top side of the board. Below shows the image of the TMF8820 populated boards for the standard and mini size.

Qwiic dToF Imager - TMF8820/TMF8821 - LabelQwiic Mini dToF Imager - TMF8820/TMF8821 - Label
Qwiic dToF Imager - TMF8820/TMF8821 - LabelQwiic Mini dToF Imager - TMF8820/TMF8821 - Label

Illuminator and Receiver

The TMF8820 and TMF8821 consists of an illuminator (VCSEL + MLA) and receiver (lens + SPADs). The illuminator emits a infrared laser at a frequency of 940nm. By taking a smartphone camera or DSLR out, you should be able to see the IR through the illuminator by aiming the camera at an angle when the board is powered and running the example code! The internal processor (ARM M0+ ®) executes the ams algorithm to calculate the target distance of the object.

940nm VSCEL Illuminating through DSLR Camera

The orientation of the TMF8820/8821 IC's illuminator (VCSEL + MLA) and receiver (lens + SPAD) can be referenced by the IC's polarity marker. You'll need to orient the board based on the marker for your project's needs. While the image below shows the TMF8820, this applies to both the TMF8820 and TMF8821 when using a 3x3 SPAD. The TMF8820 is limited to only a 3x3 SPAD.

Qwiic dToF Imager - TMF8820 - ICQwiic Mini dToF Imager - TMF8820 - ICQwiic Mini dToF Imager - 3x3 SPAD
TMF8820 - ICTMF8820 - IC3x3 SPAD Reference
spad_map_id=1
(3x3 mode, 33°x32° FoV)

Below are SPAD map configurations for the 3x3 modes taken from the datasheet. Note that the datasheet recommends that users use the checkerboard SPAD masks for high ambient light conditions.

SPAD Map for 3x3 Mode Operation

The orientation of the TMF8821 IC's illuminator (VCSEL + MLA) and receiver (lens + SPAD) can be reference by the IC's polarity marker. You'll need to orient the board based on the marker for your project's needs. The image below shows the TMF8821 and only applies to TMF8821 when using a 4x4 and 3x6 SPAD. The TMF8821 can support a 3x3, 4x4, or 3x6 SPAD. Make sure to configure the IC to set the size of the SPAD.

Qwiic dToF Imager - TMF8820 - ICQwiic Mini dToF Imager - TMF8820 - ICQwiic Mini dToF Imager - TMF8820 - 4x4 SPAD
TMF8821 - ICTMF8821 - ICTMF8821 - 4x4 SPAD Reference
spad_map_id=7
(4x4 mode, 41°x52° FoV)

Below are SPAD map configurations for the 4x4 and 3x6 modes taken from the datasheet. These configurations are possible with the TMF8821.

SPAD Map for 4x4 and 3x6 Mode Operations

Broken Out Pins

The pins that are broken out are listed out as follows. Note that the pins are rearranged for the Mini version. Most likely you will be using the Qwiic cable to access the sensor. However, you can still solder header pins or wires to the PTHs.

PinDescriptionDirection
GNDGroundIn
3.3VPowerIn
SDADataIn/Out
SCLClockIn/Out
INTInterrupt, goes low when data is ready.Out
GP0/SYNCGeneral purpose input/output. This pin can also be used to connect to a SYNC signal to interrupt the TMF8820/TMF8821 if the high power illuminator is operating or sync the sensor to a camera operation. Make sure to not On SYNC assertion, the VCSEL is immediately switched off (typically after 10 µs), on SYNC de-assertion the VCSEL operation is resumed.In/Out
GP1General purpose input/output.In/Out
ENEnable input active high; setting to low forces the device into shutdown and all memory content is lost; this is connected to 3.3V via a 10k&ohm; pull-up resistor when not being used In
Qwiic dToF Imager - TMF8820/TMF8821 - Breakout PinsQwiic Mini dToF Imager - TMF8820/TMF8821 - Breakout Pins
Qwiic dToF Imager - TMF8820/TMF8821 - Breakout PinsQwiic Mini dToF Imager - TMF8820/TMF8821 - Breakout Pins

Qwiic and I2C

The breakout boards include 2x Qwiic connectors to easily access the I2C data lines and power. Note that the standard size uses the right angle Qwiic connecgtors The Qwiic ecosystem is made for fast prototyping by removing the need for soldering. All you need to do is plug a Qwiic cable into the Qwiic connector and voila! The I2C address for each sensor is 0x41 as stated earlier.

Qwiic dToF Imager - TMF8820/TMF8821Qwiic Mini dToF Imager - TMF8820/TMF8821
Qwiic dToF Imager - TMF8820/TMF8821Qwiic Mini dToF Imager - TMF8820/TMF8821

LED

The power LED will light up when the board is powered. To disable, cut the trace on the back of the board.

Qwiic dToF Imager - TMF8820/TMF8821 - LEDQwiic Mini dToF Imager - TMF8820/TMF8821 - LED
Qwiic dToF Imager - TMF8820/TMF8821 - LEDQwiic Mini dToF Imager - TMF8820/TMF8821 - LED

Jumper

There are two jumpers on the back of the board. For more information on modifying the jumpers, check out our tutorial on working with jumper pads and PCB traces.

  • I2C - This three way jumper labeled I2C connects two 2.2k&ohm; pull-up resistors to the I2C data lines by default. If you have many devices on your I2C data lines, then you may consider cutting these.
  • LED - This connects to the power LED by default. Cut the trace to disable the LED.
Qwiic dToF Imager - TMF8820/TMF8821 - JumpersQwiic Mini dToF Imager - TMF8820/TMF8821 - Jumpers
Qwiic dToF Imager - TMF8820/TMF8821 - JumpersQwiic Mini dToF Imager - TMF8820/TMF8821 - Jumpers

Board Dimensions

The Qwiic dToF Imager TMF8820/TMF8821 use the standard Qwiic size 1.0"x1.0". The mini uses versions has a footprint that is half the size 0.5" x 1.0".

Qwiic dToF Imager - TMF8820/TMF8821 - Board DimensionsQwiic Mini dToF Imager - TMF8820/TMF8821 - Board Dimensions
Qwiic dToF Imager - TMF8820/TMF8821 - Board DimensionsQwiic Mini dToF Imager - TMF8820/TMF8821 - Board Dimensions

Hardware Hookup

Note: We recommend a microcontroller with enough flash to run your program code. Sorry, Uno's (or any development board using the ATmega328P) are out. But didn't you want an excuse to try out something new? We recommend choosing either an Artemis Thing Plus or an ESP32 Thing Plus board as your development board.

The following Arduino-compatible processor boards are compatible with the Qwiic dToF TMF8820/TMF8821.

  • Artemis
  • SAMD21/51
  • ESP32
  • Teensy
  • STM32
  • nRF52840

To connect your Qwiic dToF Imager, insert a Qwiic cable between an Arduino-compatible development board and the sensor. Then insert the associated cable for power and programming the microcontroller. In this case, we used the RedBoard Artemis and a USB type C cable. 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. Make sure to orient the sensor with respect to the TMF8820/TMF8821's SPADs and your application. In this case, the sensor was rotated 90° counterclockwise for reference.

RedBoard Artemis Connected to the Qwiic dToF

For the Qwiic Mini versions, you would follow the same steps to connect to the sensor. The only difference is that the board is smaller. The image below shows the RedBoard Artemis connecting to the sensor. However, you could use an Arduino-compatible development board that has a smaller form factor. Make sure to orient the sensor with respect to the TMF8820/TMF8821's SPADs and your application.

RedBoard Artemis Connected to the Qwiic Mini dToF

Software Installation

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 IDE, library, or board add-on, please review the following tutorials.


If you've never connected an CH340 device to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our section on How to Install CH340 Drivers" for help with the installation.

The SparkFun TMF882X dToF Arduino library can be downloaded with the Arduino library manager by searching 'SparkFun TMF882X dToF Arduino Library' or you can grab the zip here from the GitHub repository to manually install:

Arduino Examples

Below are a few examples that are highlighted from the Arduino library.

Example 1: Basic

The following example uses the RedBoard Artemis. However, you could also use any Arduino-compatible microcontroller listed earlier in this tutorial if it has enough memory.

RedBoard Artemis connected to dToF TMF8821

After installing the library, open the sketch in Arduino: File>Examples>SparkFun Qwiic TMF882X Arduino Library>Example-01_Basic. The following code was copied from the Arduino Library for your convenience. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Upload the code to the board.

language:c
/*

  Example-01_Basic.ino

  This demo shows a basic use of a TMF882X device. The device is connected to, 
  and a single reading is taken for each loop iteration. 

  Supported Boards:

   SparkFun Qwiic dToF Imager - TMF8820        https://www.sparkfun.com/products/19036
   SparkFun Qwiic Mini dToF Imager - TMF8820   https://www.sparkfun.com/products/19218
   SparkFun Qwiic Mini dToF Imager - TMF8821   https://www.sparkfun.com/products/19451
   SparkFun Qwiic dToF Imager - TMF8821        https://www.sparkfun.com/products/19037

  Written by Kirk Benell @ SparkFun Electronics, April 2022

  Repository:
     https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library

  Documentation:
     https://sparkfun.github.io/SparkFun_Qwiic_TMF882X_Arduino_Library/

  SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/

#include "SparkFun_TMF882X_Library.h" //http://librarymanager/All#SparkFun_Qwiic_TMPF882X

SparkFun_TMF882X  myTMF882X;

// Structure to hold the measurement results - this is defined by the TMF882X SDK.

static struct tmf882x_msg_meas_results myResults;

void setup()
{

    delay(1000);
    Serial.begin(115200);
    Serial.println("");

    Serial.println("In setup");
    Serial.println("==============================");

    // Initialize the TMF882X device
    if(!myTMF882X.begin())
    {
        Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
        while(1);
    }else
        Serial.println("TMF882X started.");

    // The device is now ready for operations
}

void loop()
{
    delay(2000);

    // get a Measurement
    if(myTMF882X.startMeasuring(myResults))
    {
        // print out results
        Serial.println("Measurement:");
        Serial.print("     Result Number: "); Serial.print(myResults.result_num);
        Serial.print("  Number of Results: "); Serial.println(myResults.num_results);       

        for (int i = 0; i < myResults.num_results; ++i) 
        {
            Serial.print("       conf: "); Serial.print(myResults.results[i].confidence);
            Serial.print(" distance mm: "); Serial.print(myResults.results[i].distance_mm);
            Serial.print(" channel: "); Serial.print(myResults.results[i].channel);
            Serial.print(" sub_capture: "); Serial.println(myResults.results[i].sub_capture);   

        }
        Serial.print("     photon: "); Serial.print(myResults.photon_count);    
        Serial.print(" ref photon: "); Serial.print(myResults.ref_photon_count);
        Serial.print(" ALS: "); Serial.println(myResults.ambient_light); Serial.println();

    }

}

Open the Arduino Serial Monitor set to 115200 baud. Place an object like your finger or a flat, rigid object in front of the dToF Imager's IC. You should see something similar in the output below. The readings show a high confidence value [.confidence values are between 0 and 255, with 255 being the highest] and the distance measurements in millimeters [.distance_mm] for each channel [.channel]. The output also provides information about the total photons received [.photon_count], reference photon [.ref_photon_count], and tutorial ambient light [.ambient_light]received by the channels.

Basic Reading

Try positioning the object so that channel 1 through 3 is covered and close to the TMF8820/TMF8821. In this case, we used a piece of cardboard to partially cover the sensor. Make sure to orient the board with respect to the SPADs as shown in the image below to easily view the changes in the output.

Sensor Partially Covered using Cardboard

With the Serial Monitor still open, should see something similar to the output below. You will notice that the sensor was able to detect an object over channels 1 through 3 with a high confidence. The values for the other channels that were not covered by the cardboard showed a low confidence and longer distance values. The TMF8820/TMF8821 may not display a result if the SPAD does not receive a reflected pulse.

Basic Partial Object Detection

Example 5: Verbose

With the library installed, open the sketch in Arduino: File>Examples>SparkFun Qwiic TMF882X Arduino Library>Example-05_Verbose. The following code was copied from the Arduino Library for your convenience. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Upload the code to the board.

language:c
/*

  Example-05_Verbose.ino

  The TMF882X Arduino library uses the TMF882X Software Development Kit (SDK) from
  AMS to interface with the sensor. 

  The AMS SDK is able to print out informational messages during normal operation, as 
  well as debug messages. This example shows how to enable those messages and direct 
  them to a Serial device for output.

  Supported Boards:

   SparkFun Qwiic dToF Imager - TMF8820        https://www.sparkfun.com/products/19036
   SparkFun Qwiic Mini dToF Imager - TMF8820   https://www.sparkfun.com/products/19218
   SparkFun Qwiic Mini dToF Imager - TMF8821   https://www.sparkfun.com/products/19451
   SparkFun Qwiic dToF Imager - TMF8821        https://www.sparkfun.com/products/19037

  Written by Kirk Benell @ SparkFun Electronics, April 2022

  Repository:
     https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library

  Documentation:
     https://sparkfun.github.io/SparkFun_Qwiic_TMF882X_Arduino_Library/

  SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/

#include "SparkFun_TMF882X_Library.h"    //http://librarymanager/All#SparkFun_Qwiic_TMPF882X

SparkFun_TMF882X  myTMF882X;

static struct tmf882x_msg_meas_results myResults;

void setup()
{

    delay(1000);
    Serial.begin(115200);
    Serial.println("");

    Serial.println("In setup");
    Serial.println("==============================");

    // The underlying TMF882X SDK can output a wide variety of information during 
    // normal operation. It's very verbose.
    //
    // Enable this output as part of this demo.
    //
    // Pass in our output device - Serial

    myTMF882X.setOutputDevice(Serial);

    // Enable Info messages
    myTMF882X.setInfoMessages(true);

    // Enable Debug mode. Set this before calling begin to get initialization debug 
    // information.

    myTMF882X.setDebug(true);

    if(!myTMF882X.begin())
    {
        Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
        while(1);
    }else
        Serial.println("TMF882X started.");


}

void loop()
{
    delay(2000);

    // get a myResultsurment
    if(myTMF882X.startMeasuring(myResults))
    {
        // print out results
        Serial.println("Measurement:");
        Serial.print("     Result Number: "); Serial.print(myResults.result_num);
        Serial.print("  Number of Results: "); Serial.println(myResults.num_results);       

        for (uint32_t i = 0; i < myResults.num_results; ++i) 
        {
            Serial.print("       conf: "); Serial.print(myResults.results[i].confidence);
            Serial.print(" distance mm: "); Serial.print(myResults.results[i].distance_mm);
            Serial.print(" channel: "); Serial.print(myResults.results[i].channel);
            Serial.print(" sub_capture: "); Serial.println(myResults.results[i].sub_capture);   

        }
        Serial.print("     photon: "); Serial.print(myResults.photon_count);    
        Serial.print(" ref photon: "); Serial.print(myResults.ref_photon_count);
        Serial.print(" ALS: "); Serial.println(myResults.ambient_light); Serial.println();

    }

}

Open the Arduino Serial Monitor set to 115200 baud. The output is similar to the Basic example. However, there is additional information displayed. This information is useful for those debugging with the TMF8820 or TMF8821. The measurements were taken when an object was covering the IC completely.

Verbose Output

Example 8: Factory Calibration

This example is suggested when placing the TMF8820 and TMF8821 its final application and when adjusting the SPAD mask selection. As suggested in the datasheet under 7.3 Calibration, "the calibration test shall be done in a housing with minimal ambient light and no target within 40 cm in field of view of the TMF8820/21."

With the library installed, open the sketch in Arduino: File>Examples>SparkFun Qwiic TMF882X Arduino Library>Example-08_FactoryCal. The following code was copied from the Arduino Library for your convenience. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Upload the code to the board.

language:c
/*

  Example-08_FactoryCal.ino

  This example shows how to peform a Factory Calibration on the connected 
  TMF882X device. Details on the calibration and it's use are contained in
  the TMF882X datasheet.

  Supported Boards:

   SparkFun Qwiic dToF Imager - TMF8820        https://www.sparkfun.com/products/19036
   SparkFun Qwiic Mini dToF Imager - TMF8820   https://www.sparkfun.com/products/19218
   SparkFun Qwiic Mini dToF Imager - TMF8821   https://www.sparkfun.com/products/19451
   SparkFun Qwiic dToF Imager - TMF8821        https://www.sparkfun.com/products/19037

  Written by Kirk Benell @ SparkFun Electronics, April 2022

  Repository:
     https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library

  Documentation:
     https://sparkfun.github.io/SparkFun_Qwiic_TMF882X_Arduino_Library/

  SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/


#include <SparkFun_TMF882X_Library.h>    //http://librarymanager/All#SparkFun_Qwiic_TMPF882X

SparkFun_TMF882X  myTMF882X;

void setup()
{

    delay(1000);
    Serial.begin(115200);
    Serial.println("");

    Serial.println("In setup");
    Serial.println("==============================");

    if(!myTMF882X.begin())
    {
        Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
        while(1){}
    }else
        Serial.println("TMF882X started.");


    Serial.println();
    Serial.println("Performing a Factory Calibration.");
    Serial.println();
    // Perform a factory calibration of the connected device.

    // First set some config parameters to support the calibration
    struct tmf882x_mode_app_config tofConfig;
    if (!myTMF882X.getTMF882XConfig(tofConfig)) 
    {
        Serial.println("Error - unable to get device configuration.");
        while(1){}
    }

    // Change the APP configuration
    //  - set the reporting period to 500 milliseconds
    //  - set the iterations to 4,000,000 (4M) to perform factory calibration
    tofConfig.report_period_ms = 500;
    tofConfig.kilo_iterations = 4000;

    if (!myTMF882X.setTMF882XConfig(tofConfig)) 
    {
        Serial.println("Error - unable to set device configuration.");
        while(1){}
    }

    struct tmf882x_mode_app_calib factoryCal;

    // Peform the calibration
    if (!myTMF882X.factoryCalibration(factoryCal)) 
    {
        Serial.println("Error - Factory Calibration Failed.");
        while(1){}
    }

    // Output the calibration
    Serial.println("Calibration Complete"); 
    Serial.println();
    Serial.print("Calibration Data Length: ");
    Serial.println(factoryCal.calib_len);

    Serial.println("Calibration Data:");
    for (int i = 0; i < factoryCal.calib_len; i++)
    {
        Serial.print(""); Serial.print(factoryCal.data[i]);

        if ( (i + 1) % 16 == 0 )
            Serial.println();
    }
    Serial.println();

}

void loop()
{
    delay(2000);

    // Nothing - just here for the calibration example
}

Open the Arduino Serial Monitor set to 115200 baud. You will see an output similar to the image below. You will need to follow the datasheet to calibrate the sensor properly.

Calibration

Example 9: SPAD Map

With the library installed, open the sketch in Arduino: File>Examples>SparkFun Qwiic TMF882X Arduino Library>Example-09_SPADMap. The following code was copied from the Arduino Library for your convenience. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Upload the code to the board.

language:c
/*

  Example-09_SPADMap.ino

  The Optical performance of the TMF882X is controled by a SPAD (Single Photon
  Avalanche Photodiode) Map. 

  SPAD Maps are set using a SPAD Map ID, which are detailed in the TMF882X datasheet.

  This example shows how to determine the current SPAD Map on the device and change 
  it to a desired map.

  Supported Boards:

   SparkFun Qwiic dToF Imager - TMF8820        https://www.sparkfun.com/products/19036
   SparkFun Qwiic Mini dToF Imager - TMF8820   https://www.sparkfun.com/products/19218
   SparkFun Qwiic Mini dToF Imager - TMF8821   https://www.sparkfun.com/products/19451
   SparkFun Qwiic dToF Imager - TMF8821        https://www.sparkfun.com/products/19037

  Written by Kirk Benell @ SparkFun Electronics, April 2022

  Repository:
     https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library

  Documentation:
     https://sparkfun.github.io/SparkFun_Qwiic_TMF882X_Arduino_Library/

  SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/

#include <SparkFun_TMF882X_Library.h>    //http://librarymanager/All#SparkFun_Qwiic_TMPF882X

static struct tmf882x_msg_meas_results myResults;


SparkFun_TMF882X  myTMF882X;

// What SPAD map to change to

#define NEW_SPAD_MAP 2

void setup()
{

    delay(1000);
    Serial.begin(115200);
    Serial.println("");

    Serial.println("In setup");
    Serial.println("==============================");

    if(!myTMF882X.begin())
    {
        Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
        while(1){}
    }else
        Serial.println("TMF882X started.");


    // Let's change the SPAD map in use on this device.
    //
    // Get the current SPAD Map ID
    int spadMap =  myTMF882X.getCurrentSPADMap();
    Serial.println();
    Serial.print("Current SPAD Map ID: ");
    Serial.println(spadMap);

    // Now switch
    Serial.println("Switching SPAD Map to ID 2 - 3x3 Macro 1 off center");
    Serial.println();

    if (!myTMF882X.setCurrentSPADMap(NEW_SPAD_MAP))
    {
        Serial.println("Error -  Failed to set the SPAD Map - halting");
        while(1){}
    }

    // Let's make sure it worked
    spadMap =  myTMF882X.getCurrentSPADMap();

    if(spadMap != NEW_SPAD_MAP)
    {
        Serial.println("Error -  Failed to set the SPAD Map - halting");
        while(1){}
    }

    Serial.print("The new SPAD Map ID: ");
    Serial.println(spadMap);

    // Now set some config parameters to support the spad map
    struct tmf882x_mode_app_config tofConfig;

    if (!myTMF882X.getTMF882XConfig(tofConfig)) 
    {
        Serial.println("Error - unable to get device configuration.");
        while(1){}
    }

    // Change the APP configuration
    //  - set the reporting period to 500 milliseconds
    tofConfig.report_period_ms = 500;

    if (!myTMF882X.setTMF882XConfig(tofConfig)) 
    {
        Serial.println("Error - unable to set device configuration.");
        while(1){}
    }

}

void loop()
{
    delay(2000);

    // get a myResultsurment
    if(myTMF882X.startMeasuring(myResults))
    {
        // print out results
        Serial.println("Measurement:");
        Serial.print("     Result Number: "); Serial.print(myResults.result_num);
        Serial.print("  Number of Results: "); Serial.println(myResults.num_results);       

        for (int i = 0; i < myResults.num_results; ++i) 
        {
            Serial.print("       conf: "); Serial.print(myResults.results[i].confidence);
            Serial.print(" distance mm: "); Serial.print(myResults.results[i].distance_mm);
            Serial.print(" channel: "); Serial.print(myResults.results[i].channel);
            Serial.print(" sub_capture: "); Serial.println(myResults.results[i].sub_capture);   

        }
        Serial.print("     photon: "); Serial.print(myResults.photon_count);    
        Serial.print(" ref photon: "); Serial.print(myResults.ref_photon_count);
        Serial.print(" ALS: "); Serial.println(myResults.ambient_light); Serial.println();

    }
}

This example allows you to select the operating mode of the SPAD. The datasheet under "8.5.17 SPAD_MAP_ID Register" provides a list of acceptable values and modes. Note that certain values are reserved and zone configurations may not be available to use for the TMF8820 (i.e. limited to 3x3) or TMF8821 (i.e. limited to 3x3, 4x4, 3x6).

Once uploaded, open the Arduino Serial Monitor at 115200 baud and cover channels 1 through 3. The spad_map_id was changed to 2. The readings are similar to example 1 when the SPAD was using the default 3x3 Normal Mode. However, SPAD uses a different FOV and slightly offset.

SPAD Map configured to 3x3 Offset with Partial Object Detection

If you have a TMF8821, try adjusting the SPAD to 4x4 normal mode with a 41°x52° FoV by changing spad_map_id to 7 (i.e. change the line #define NEW_SPAD_MAP 2 to #define NEW_SPAD_MAP 7). Then upload the code to the board.

Open the Arduino Serial Monitor at 115200 baud and try to cover channels 9 through 16. You will see an output similar to the image below indicating that the respective channels were covered.

SPAD Map configured to 4x4 with Partial Object Detection

Example 11: Histogram

With the library installed, open the sketch in Arduino: File>Examples>SparkFun Qwiic TMF882X Arduino Library>Example-11_Histogram. The following code was copied from the Arduino Library for your convenience. If you have not already, select your Board (in this case the RedBoard Artemis), and associated COM port. Upload the code to the board.

language:c
/*

  Example-11_Histogram.ino

  This example shows how to enable and recieve raw histogram data from the 
  connected TMF882X device

  Supported Boards:

   SparkFun Qwiic dToF Imager - TMF8820        https://www.sparkfun.com/products/19036
   SparkFun Qwiic Mini dToF Imager - TMF8820   https://www.sparkfun.com/products/19218
   SparkFun Qwiic Mini dToF Imager - TMF8821   https://www.sparkfun.com/products/19451
   SparkFun Qwiic dToF Imager - TMF8821        https://www.sparkfun.com/products/19037

  Written by Kirk Benell @ SparkFun Electronics, April 2022

  Repository:
     https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library

  Documentation:
     https://sparkfun.github.io/SparkFun_Qwiic_TMF882X_Arduino_Library/

  SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/

#include "SparkFun_TMF882X_Library.h"  //http://librarymanager/All#SparkFun_Qwiic_TMPF882X

SparkFun_TMF882X  myTMF882X;

#define NUMBER_OF_SAMPLES_TO_TAKE  4

int nSample = 0;

// For our histogram printout 
#define MAX_BIN_LEN 128

// Define our histogram callback function

void onHistogramCallback(struct tmf882x_msg_histogram *myHistogram)
{

    nSample++;

    Serial.print("Histogram Number: ");
    Serial.println(nSample);

    uint8_t zone_count = 0;
    for (int tdc_idx = 0; tdc_idx < myHistogram->num_tdc; ++tdc_idx) 
    {
        // Histogram tag for zones, #HLONG01,#HLONG02....
        Serial.println();
        Serial.print("#HLONG");
        Serial.print(zone_count++);

        for (int bin_idx = 0; bin_idx < myHistogram->num_bins; ++bin_idx) {

            Serial.print((unsigned long)myHistogram->bins[tdc_idx][bin_idx]);

            if ((bin_idx + 1) == MAX_BIN_LEN) 
            {
                Serial.println();
                Serial.print("#HLONG");
                Serial.print(zone_count++);

            } else if ((bin_idx + 1) % MAX_BIN_LEN != 0)
                Serial.print(",");
        }
    }
    Serial.println();
}

void setup()
{

    delay(500);
    Serial.begin(115200);
    Serial.println("");


    if(!myTMF882X.begin())
    {
        Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
        while(1){}
    }

    // set our call back function that handles histograms
    myTMF882X.setHistogramHandler(onHistogramCallback);

    // Set our delay between samples  - 1 second - note it's in ms
    myTMF882X.setSampleDelay(1000);

    // First config parameter to enable output of histogram data.

    struct tmf882x_mode_app_config tofConfig;
    if (!myTMF882X.getTMF882XConfig(tofConfig)) 
    {
        Serial.println("Error - unable to get device configuration.");
        while(1){}
    }

    // Change the APP configuration
    //  - set the reporting period to 500 milliseconds
    //  - Enable Histogram mode
    tofConfig.report_period_ms = 500;
    tofConfig.histogram_dump = 1;

    if (!myTMF882X.setTMF882XConfig(tofConfig)) 
    {
        Serial.println("Error - unable to set device configuration.");
        while(1){}
    }
}

void loop()
{
    delay(2000);

    // get a measurment
    // Have the sensor take 4 measurements, the results are sent to the above callback

    Serial.println("---------------------------------------------------------");    
    Serial.print("Taking "); 
    Serial.print(NUMBER_OF_SAMPLES_TO_TAKE);
    Serial.println(" data samples."); 
    Serial.println();

    nSample=0;
    myTMF882X.startMeasuring(NUMBER_OF_SAMPLES_TO_TAKE);

    Serial.println("---------------------------------------------------------\n\n");    

}

Open the Arduino Serial Monitor at 115200 baud to view the raw histogram data for your TMF8820 and TMF8821. Note that the example code is currently set to take a 4 data samples at a time. You should see an output similar to the image below if you are covering the sensor.

Histogram

More Examples!

This tutorial highlights a few examples listed in the Arduino Library to get you started. Additional examples can be found in the library.

Troubleshooting

Resources & Going Further

Now that you've successfully got your Qwiic dToF Imager up and running, it's time to incorporate it into your own project! For more information, check out the resources below:

Need some inspiration for your next project? Check out some of these other tutorials using sensors.

Getting Started with Load Cells

A tutorial defining what a load cell is and how to use one.

MPU-9250 Hookup Guide

Get up and running with the MPU-9250 9-axis MEMS sensor.

LIDAR-Lite v3 Hookup Guide

A tutorial for connecting the Garmin LIDAR-Lite v3 or the LIDAR-Lite v3HP to an Arduino to measure distance.

Wireless Remote Weather Station with micro:bit

Monitor the weather without being exposed to it through wireless communication between two micro:bits using the radio blocks! This is useful if your weather station is installed in a location that is difficult to retrieve data from the OpenLog. We will also explore a few different ways to send and receive data.

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

MicroMod Alorium Sno M2 Processor Board Hookup Guide

$
0
0

MicroMod Alorium Sno M2 Processor Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The MicroMod Alorium Sno M2 Processor Board features the Snō System on Module (SoM) from Alorium Technology adapted to the MicroMod M.2 processor form factor. Snō's FPGA provides a reconfigurable hardware platform that hosts an 8-bit AVR instruction set, compatible with the ATmega328, making Snō fully compatible with the Arduino IDE. Snō SoM has a compact footprint, making it ideal for space-constrained applications and an obvious addition to our MicroMod form factor for prototyping.

Alorium Technology provides a library of custom logic called Xcelerator Blocks (XBs) through the Arduino IDE that accelerate specific functionality that is slow, problematic, or even impossible for an 8-bit microcontroller. This library includes XBs such as Servo Control, Quadrature, Floating Point Math, NeoPixel, and Enhanced Analog-to-Digital Converter. Alorium also notes a XB roadmap where future XBs will be implemented based on feedback from early adopters and new potential customers.

SparkFun MicroMod Alorium Sno M2 Processor

SparkFun MicroMod Alorium Sno M2 Processor

DEV-18030
$49.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 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
$5.50
3
SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$1.05
3
SparkFun MicroMod Alorium Sno M2 Processor

SparkFun MicroMod Alorium Sno M2 Processor

DEV-18030
$49.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

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

Getting Started with MicroMod

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

How Does an FPGA Work?

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

MicroMod All The Pins (ATP) Carrier Board

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

Hardware Overview

M.2 Connector

All of our MicroMod Processor Boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor Board on your choice of carrier board. Most of the pins use a common pinout to ensure cross platform compatibility.

M.2 Edge Connector Pins Highlighted

Alorium Technology Sno M2 Processor

The Alorium Technology Sno FPGA provides a reconfigurable hardware platform that hosts an ATmega328 instruction set compatible microcontroller. The FPGA also provides the ability to implement custom logic that accelerates specific functionality that is slow, problematic or even impossible for an 8-bit microcontroller.

The Alorium Sno Processor is the giant chip in the middle of the board

JTAG

The JTAG interface on Sno M2 is primarily used during manufacturing to load the production FPGA image. For advanced users, JTAG can be used for creating bare-metal FPGA designs and directly flashing a new image to the FPGA.

JTAG is highlighted on the upper left corner of the MicroMod board, with the M.2 connectors facing down.

FTDI

The FTDI facilitates USB communication - drivers for the FTDI chip may need to be installed. Please see the How to Install FTDI drivers tutorial if you need help installing these drivers.

FTDI chip is highlighted - it is the small square chip on the lower right side of the front of the board when the M2 connector is pointing down

LEDs

There are two LEDs on the Sno Processor Board. An RX LED and a STAT LED.

The RX LED is along the upper left side of the board, the STAT LED is on the upper right side of the board
  • RX LED - The RX LED indicates activity on the USB serial port.

  • STAT LED - A STAT LED is added to the top side of the board. This is useful debugging or as a status indicator.

MicroMod Alorium Sno M2 Processor Pin Functionality

The complete pin map is shown here or you can refer to the schematic. You can also download the PDF version of the pin map here.

Alorium's pin map

Click on image for a closer view of the pin map.
Pin Map courtesy of Alorium Technology

Board Dimensions

The board takes advantage of the standard MicroMod form factor.

Board Measures 1" x 1"

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 Alorium Sno M2 processor board into a carrier board, your setup may look like the following.

MicroMod Alorium Sno M2 Inserted Into a Carrier Board

Click on image for a closer view.

Go ahead and secure the Processor Board by gently pressing it down and tightening the screw (not too much though).

Screwing down the processor board

Click on image for a closer view.

For simplicity, we'll be using the MicroMod ATP Carrier Board to program the board. At a minimum, your setup should look like the image below with the MicroMod Alorium Sno M2 Processor Board.

MicroMod Sno Alorium in ATP Carrier

Click on image for a closer view.

Software Installation

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.

Install Arduino Board Definitions

In your Arduino IDE menu bar, go to File>Preferences and locate the ‘Additional Boards Manager URLs’ input field. Paste the following URL into the “Additional Boards Manager URLs” input field:

language:json
https://raw.githubusercontent.com/AloriumTechnology/Arduino_Boards/master/package_aloriumtech_index.json

It should look something like the following:

Adding Alorium link to Preferences

Click on image for a closer view.

Install Alorium's XLR8 Board Package

Start by going to Tools>Board>Boards Manager. Type “Alorium,” in the search field and you will see an option to install board files for Alorium Arduino compatible boards. Select the “Alorium XLR8 Boards” package and then click “Install”.

Type in Alorium, and you should see Alorium XLR8 Family package. Install that.

Click on image for a closer view.

Go to Tools>Board. You should see that a new section titled “Alorium XLR8 Family” now exists. Under this new heading should be the Sno M2 board. You can select the "Sno M2" board just like you would normally select the “Arduino/Genuino Uno” board.

Choosing the M2 Board

Click on image for a closer view.

After selecting the Sno M2, you will find a new menu item at Tools>FPGA Image, where you will find a number of FPGA images that provide different operating speeds and different XB configurations.

Choosing FPGA Image

Click on image for a closer view.

XLR8 Libraries

Installing the XLR8 board support will also install a default set of libraries that are needed to take advantage of the extra capabilities of Snō. You can see these libraries listed in the Sketch>Include Library menu.

There are additional libraries available that can be installed using the Library Manager. In the Arduino IDE, go to the menu Sketch>Include Library>Manage Libraries, which will open the Library Manager in a new window. Enter "Alorium" in the search bar and you will find the entries for the various XLR8 and Snō libraries available.

There are many libraries you can install to support a variety of our board functions and Xcelerator Blocks. For the purposes of this getting started guide, find the “XLR8Info” library and click on it.

Install XLR8Info Library

Click on image for a closer view.

An Install button will appear for it. Click on the Install button, and when the installation is complete you will see that the library is now tagged as Installed.

After adding the library, you’ll find it in the menu Sketch>Include Library, under Contributed Libraries (You may need to re-start the IDE if you don’t see it).

You’ll also find some examples sketches in the File>Examples menu, under the library name.

With the Sno Processor Board inserted into the M.2 slot and secured, plug your ATP board to your computer with a USB cable. Make sure you have the correct Board, FPGA Image, Upload Action, and Port as you see below.

Sno M2 board selected, 16MHz FPGA Image, and Send sketch to Snow M2 USB, are selected

Click on image for a closer view.

Go to Tools>Board and select the Sno M.2. Then go to File>Examples>01. Basics and select Blink.

Select the Blink Example from the basics menu

Click on image for a closer view.

Upload the sketch as you see here:

Smash that upload button

Click on image for a closer view.

If all goes well, you should see something like the gif below:

LED on the processor board should be blinking

Example 2: Running with an Xcelerator Block (XB)

To run with the XLR8Info XB and library, do the following:

Connect Snō to your computer with a USB cable, and set up the Port and Serial Monitor as you normally would. Go to Tools>Port and verify that Arduino IDE is connected to the XLR8 USB serial port.

Go to Tools>Board and select the XLR8 board. Then go to File>Examples>XLR8Info and select "GetXLR8Version".

Find Examples, then XLR8Info, then GetXLR8Version

Click on image for a closer view.



In the GetXLR8Version sketch window, click on the Upload button

Upload Button

Click on image for a closer view.

Check the Serial Monitor window for the output, which should look like the output below. Note that you will need to set the baud rate for the Serial Monitor to 115200 for this sketch to display output correctly.

Get Info Example Output

Click on image for a closer view.

Troubleshooting

General Troubleshooting Help & Technical Support

Resources and Going Further

For more information, check out the resources below:

For more information about the SparkFun MicroMod Ecosystem, take a look at the links below:

Need some inspiration for a project using your Alorium Sno Processor? The tutorials below may help you get started!

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 RP2040 Processor Board Hookup Guide

This tutorial covers the basic functionality of the MicroMod RP2040 Processor Board and highlights the features of the dual-core ARM Cortex-M0+ processors development board. Get started with the first microcontroller from the Raspberry Pi Foundation!

MicroMod Main Board Hookup Guide

The MicroMod Main Board - Single and Double are specialized carrier boards that allow you to interface a Processor Board with a Function Board(s). The modular system allows you to add an additional feature(s) to a Processor Board with the help of a Function Board(s). In this tutorial, we will focus on the basic functionality of the Main Board - Single and Main Board - Double.

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>