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

Qwiic pHAT Extension for Raspberry Pi 400 Hookup Guide

$
0
0

Qwiic pHAT Extension for Raspberry Pi 400 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Qwiic pHAT extension for the Raspbery Pi 400 is the quick and easy solution to access the GPIO, stack your favorite pHAT right-side up, or connect a Qwiic-enabled device to the I2C bus (GND, 3.3V, SDA, and SCL).

SparkFun Qwiic pHAT Extension for Raspberry Pi 400

SparkFun Qwiic pHAT Extension for Raspberry Pi 400

DEV-17512
$4.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.

Raspberry Pi 400

You'll need a Raspbery Pi 400s. There are two options available. One that is just the Raspberry Pi 400 sold individually. Another that is sold in a kit with everything but the monitor.

Raspberry Pi 400 Personal Computer (Unit Only)

Raspberry Pi 400 Personal Computer (Unit Only)

DEV-17376
$70.00
Raspberry Pi 400 Personal Computer Kit

Raspberry Pi 400 Personal Computer Kit

KIT-17377
$100.00
10

Qwiic-Enabled Device

Now you probably didn't buy the Qwiic pHAT if you didn't have any Qwiic products to use with it, right? If you don't have any Qwiic products, the following might not be a bad place to start.

SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic)

SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic)

SEN-14348
$35.95
18
SparkFun GPS Breakout - XA1110 (Qwiic)

SparkFun GPS Breakout - XA1110 (Qwiic)

GPS-14414
$49.95
5
SparkFun Qwiic Adapter

SparkFun Qwiic Adapter

DEV-14495
$1.50
1
SparkFun Spectral Sensor Breakout - AS7262 Visible (Qwiic)

SparkFun Spectral Sensor Breakout - AS7262 Visible (Qwiic)

SEN-14347
$25.95
2

Finally, you'll need our handy Qwiic cables to easily connect sensors to your Qwiic pHAT. Below are a few options.

Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - 50mm

Qwiic Cable - 50mm

PRT-14426
$0.95
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428
$1.50

Required Setup Tools

As a desktop, these devices are required. If you received the Raspberry Pi 400 Kit, you'll just need a display and cable. Depending on your display, you may need an HDMI converter to connect to older monitors and TVs.

Suggested Reading

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

Qwiic Connect System
Qwiic Connect System

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

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

Serial Terminal Basics

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

Raspberry gPIo

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

Hardware Overview

2x20 Raspberry Pi Header

The Qwiic pHAT extension connects to the Raspberry Pi 400's 2x20 port via the right angle header.

Right Angle 2x20 Header

The Raspberry Pi 400's horizontal headers are rerouted and extends out to the vertical headers at the top of the board. Each pin includes a label with their associated pin function.

Vertical Header Pins with Labels

Qwiic Connectors

The Qwiic pHAT extension includes Qwiic connectors on both sides of the board.

Qwiic Connectors

Mounting Holes

There are 10 mounting holes on the board. Below is the board highlighted for boards designed with the Pi Zero footprint. You can add standoffs to the mounting holes where the arrows are pointing.

Mounting Holes for pHATs with Pi Zero Footprint

For boards designed with the Raspberry Pi footprint, you can add standoffs to the mounting holes where the arrows are pointing.

Mounting Holes with Raspberry Pi Footprint

For Qwiic-enabled devices utilizing the standard 1.0"x1.0" sized boards, you can add two standoffs for each Qwiic-enabled device where the arrows are pointing.

Mounting Holes for Standard Sized 1.0"x1.0" Qwiic-Enabled Device

Board Dimensions

The board is about 65mm x 78.42mm (~2.55in x ~3.08in).

Board Dimensions

By adding two large silicone bumpers under the board for stability, the height comes to about ~21.32mm (~0.84in) between the header pin and the bottom of the Silicon bumper.

Hardware Assembly

Included with the Qwiic pHAT extension board is a set of large silicone bumpers. These are meant to hold the board up when it is attached to a Raspberry Pi 400 and placed on a table. You only need 2 out of the 4 silicone bumpers so you can use the left over bumpers for other projects.

Large Silicone Bumpers

To attach the two silicone bumpers, peel one bumper and attach it to the bottom of the board between the mounting holes of the Pi Zero's footprint. Repeat for the second bumper. Your setup should look similar to the image below.

Large Silicone Bumpers Attached to the Bottom of the Qwiic pHAT Extension Board

At this point, we'll assume that you have flashed an image and inserted the microSD card into the Raspberry Pi 400. With the straight header pins facing up, slide the Qwiic pHAT extension into the Raspberry Pi 400's GPIO port. The right angle connector is keyed so there's only one way to insert the board into the GPIO port.

Qwiic pHAT Extension being Inserted into a Raspberry Pi 400

When removing the pHAT extension, simply wiggle the board slowly up and down as the board is being pulled away from the Raspberry Pi 400.

Qwiic-Enabled Devices

If you have a Qwiic-enabled device, simply insert a Qwiic cable of your choice between the Qwiic board and the Qwiic pHAT extension. While you can connect to either Qwiic connector, the right side of the Qwiic pHAT extension will provide more space since most of the Pi's peripherals will be inserted to the left of the board.

Qwiic-Enabled Device Connected to the Qwiic pHAT Extension

Breadboard Prototyping

Connecting to the Raspberry Pi 400's GPIO is easy with the pin functions printed on the board for reference. We recommend using M/F jumper wires to connect when prototyping your circuit on a breadboard.

Prototyping on a Breadboard using the Qwiic pHAT Extension

Stacking pHATs

Boards designed with the Raspberry Pi or Pi Zero footprint can be stacked on top of the Qwiic pHAT Extension allowing it to be viewed right-side up. Below is an image of the Top pHAT connected to the Raspberry Pi 400.

Top pHAT Stacked on the

Depending on the design of the pHAT, you may require additional height if there are any wires being attached to the the bottom of the pHAT. If this is the case, you can add additional height using an extended GPIO headers.

Extended GPIO Female Header - 2x20 Pin (16mm/7.30mm)

Extended GPIO Female Header - 2x20 Pin (16mm/7.30mm)

PRT-16763
$1.95
Extended GPIO Female Header - 2x20 Pin (13.5mm/9.80mm)

Extended GPIO Female Header - 2x20 Pin (13.5mm/9.80mm)

PRT-16764
$1.95

Mounting with Standoffs

You can attach standoffs to two of the Qwiic mounting holes to secure an Qwiic-enabled device.

Qwiic 9DoF secured to the Qwiic pHAT Extension

Got a wobbly pHAT on the Qwiic pHAT extension? You can attach standoffs to two of the mounting holes across from the vertical header pins on the Qwiic pHAT extension. Of course, you can always use all four mounting holes depending on your personal preference. Below is a Top pHAT using the Raspberry Pi's footprint but you can also mount a board that uses a Raspberry Pi Zero's footprint as well.

pHAT secured to the Qwiic pHAT Extension

Raspberry Pi 400 Peripherals

If you have not already, connect your peripherals (e.g. display cable, mouse, power, etc) to the Raspberry Pi 400! Your setup will look similar to the image below.

Peripherals Connected to the Raspberry Pi 400

Getting an OS

We recommend checking out the Raspberry Pi 4 Hookup Guide to install the operating system to flash the image to your microSD card for detailed instructions.

Raspberry Pi 4 Kit Hookup Guide

March 14, 2020

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

If you're starting from scratch with a blank microSD card, you'll want to install Raspbian. If you've already got a working Raspbian system, skip ahead to the next section. Be patient — each of these steps can take a while depending on the speed of your microSD card.

  1. Download an Image— Download your favorite Linux distribution. For beginners, we recommend getting NOOBS image.
  2. Flashing the Image— Follow the instructions from the Raspberry Pi 4 Kit Hookup Guide to flash your microSD card. You can also follow the official Raspberry Pi installation instructions.

Configuring the Pi

The peripherals are not turned on by default. For those using Qwiic-enabled devices, you will want to enable I2C port. There are two methods to adjust the settings. This is outlined in our Raspberry Pi I2C tutorial.

Raspberry Pi SPI and I2C Tutorial

October 29, 2015

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.

We've included the following instructions from the tutorial. To enable it, follow the steps below.

Raspberry Pi Configuration via Desktop GUI

You can use the Desktop GUI by heading to the Pi Start Menu>Preferences>Raspberry Pi Configuration.

Raspberry Pi Configuration via GUI

Click on image for a closer view.

A window will pop up with different tabs to adjust settings. What we are interested is the Interfaces tab. Click on the tab and select Enable for I2C. At this point, you can enable additional interfaces depending on your project needs. Click on the OK button to same.

Adjusting Interfaces via Interface Tab

Click on image for a closer view.

We recommend restarting your Pi to ensure that the changes to take effect. Click on the Pi Start Menu>Preferences>Shutdown. Since we just need to restart, click on the Restart button.

ShutdownTurn Off, Restart, Log Off

Click on images for a closer view.

raspi-config Tool via Terminal

Again, we can use raspi-config to enable it.

  1. Run sudo raspi-config.
  2. Use the down arrow to select 5 Interfacing Options
  3. Arrow down to P5 I2C.
  4. Select yes when it asks you to enable I2C
  5. Also select yes if it asks about automatically loading the kernel module.
  6. Use the right arrow to select the <Finish> button.
  7. Select yes when it asks to reboot.

Enabling I2C on the Raspberry Pi

Raspi-config for I2C

The system will reboot. When it comes back up, log in and enter the following command

language:bash
ls /dev/*i2c*

The Pi should respond with

language:bash
/dev/i2c-1

Which represents the user-mode I2C interface.

Scanning for I2C Devices

If you are using the Raspberry Pi to quickly connect to I2C devices, the best place to start would be to scan for an I2C device on the bus.

Utilities

There is a set of command-line utility programs that can help get an I2C interface working. You can get them with the apt package manager. Enter the following command.

language:bash
sudo apt-get install -y i2c-tools

In particular, the i2cdetect program will probe all the addresses on a bus, and report whether any devices are present. Enter the following command in the command line. The -y flag will disable interactive mode so that you do not have to wait for confirmation. The 1 indicates that we are scanning for I2C devices on I2C bus 1 (e.g. i2c-1).

language:bash
i2cdetect -y 1

You will get an output from your Raspberry Pi similar to the output below.

language:bash
pi@raspberrypi:~/$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

This map indicates that there is a peripheral at address 0x60. Your address may vary depending on what is connected to the I2C bus. For advanced users, you can try to read and write its registers using the i2cget, i2cset and i2cdump commands.

Qwiic Py Drivers

Now that you have I2C set up on your Pi, you can start programming your Qwiic devices on your Pi or if you'd like to start with some examples, we have a host of Python drivers for Qwiic breakouts available in the GitHub repository linked below. You can read more about Python for the SparkFun Qwiic system in this blog post.

GPIO Pins

The Raspberry Pi 400 uses the standard 2x20 GPIO pins. With the help of the Qwiic pHAT extension, the Pi 400's horizontal GPIO pins are rerouted to a vertical position. There are several programming languages available to use on the Raspberry Pi. We recommend Python to control the pins. Check the following tutorials below to get started.

Python Programming Tutorial: Getting Started with the Raspberry Pi

June 27, 2018

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

Raspberry gPIo

October 29, 2015

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

Stack a Hat

With the Pi 400 2x20 pins rerouted to a vertical position, you can stack on a HAT. Check out a few of the HATs below from the SparkFun catalog.

LCD Touchscreen HAT for Raspberry Pi - TFT 3.5in. (480x320)

LCD Touchscreen HAT for Raspberry Pi - TFT 3.5in. (480x320)

LCD-17520
$24.95
SparkFun GPS-RTK Dead Reckoning pHAT for Raspberry Pi

SparkFun GPS-RTK Dead Reckoning pHAT for Raspberry Pi

GPS-16475
$249.95
SparkFun Pulsed Radar Breakout - A111

SparkFun Pulsed Radar Breakout - A111

SEN-15577
$59.95
4
PiJuice HAT - Raspberry Pi Portable Power Platform

PiJuice HAT - Raspberry Pi Portable Power Platform

PRT-14803
$64.95
4

Resources and Going Further

For more information, check out the resources below:

Now that you have your Qwiic pHAT extension ready to go, it's time incorporate it into a project! Check out any tutorials that are tagged with Raspberry Pi for ideas.

Raspberry gPIo

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

Computer Vision and Projection Mapping in Python

Use computer vision to detect faces and project images on top of them.

Qwiic Kit for Raspberry Pi Hookup Guide

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 enviroment and display them on the microOLED, serial terminal, or the cloud with Cayenne!

SparkFun Auto pHAT Hookup Guide

The pHAT to get your projects moving. This guide will help you get started using the Auto pHAT.

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


MicroMod Artemis Processor Board Hookup Guide

$
0
0

MicroMod Artemis Processor Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Leveraging the ultra powerful Artemis Module, the SparkFun MicroMod Artemis Processor is the brain board of your dreams. With a Cortex-M4F with BLE 5.0 running up to 96MHz and with as low power as 6uA per MHz (less than 5mW), the M.2 MicroMod connector allows you to plug in a MicroMod Carrier Board with any number of peripherals. Let's have a look at what this processor board has to offer!

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95

Required Materials

In addition to your MicroMod Artemis Processor Board, you'll need a carrier board to get started. Here we use the Machine Learning Carrier Board, but there are a number of others you can choose from.

SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$19.95
SparkFun MicroMod Machine Learning Carrier Board

SparkFun MicroMod Machine Learning Carrier Board

DEV-16400
$19.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95

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

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

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

USB 3.1 Cable A to C - 3 Foot

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

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Depending on which Carrier Board you choose, you may need a few extra peripherals to take full advantage of them. Refer to the Carrier Boards' respective Hookup Guides for specific peripheral recommendations.

Suggested Reading

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

MicroMod Logo
MicroMod Ecosystem

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

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 Machine Learning Carrier Board Hookup Guide

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

Hardware Overview

While the Artemis module is pretty self-contained, let's have a look at a few of the unique features of this MicroMod Processor Board.

Power

Power is supplied by the carrier board, but it should be noted that all pins are 3.3V.

M.2 Connector

All of our MicroMod Processor boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor board on your choice of carrier board.


M.2 Connector from the FrontM.2 Connector from the Back

Artemis Processor

The SparkFun Artemis Processor provides a Cortex-M4F with BLE 5.0 running up to 96MHz and with as low power as 6uA per MHz (less than 5mW). This module is powerful enough to run TensorFlow, Machine Learning, and all sorts of voice recognition software. A deep dive into all of Artemis's delightful features can be found in the Designing with the SparkFun Artemis tutorial.

Artemis Module on the MicroMod Artemis Processor Board

Op Amp

Incoming analog voltages over 2V will saturate the Artemis's analog to digital converter. We've integrated an OpAmp to scale the incoming 0-3.3V voltages down to the 0-2V range that the Artemis can handle.

Highlighted OpAmp

RTC

An onboard RTC crystal has been integrated.

Highlighted RTC

Status LED

We've also included a Status LED for all your blinky needs.

Highlighted status LED

Artemis MicroMod Processor Pin Functionality

Note: You may not recognize the COPI/CIPO labels for SPI pins. SparkFun is working to move away from using MISO/MOSI to describe signals between the controller and the peripheral. Check out this page for more on our reasoning behind this change.
AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
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
Alternate
Function
Alternate
Function
Primary
Function
Bottom
Pin
   Top   
Pin
Primary
Function
Alternate
Function
Alternate
Function
73G5
71G6
QSPI3SPI_CS17069G7
QSPI268
QSPI16665TX1ADC_D-
QSPI0SPI_CIPO16463ADC_D+
QSPI_CSSPI_COPI16261SPI_CIPO
QSPI_SCKSPI_SCK16059SPI_COPI
CAM_MCLK5857SPI_SCK
CAM_MCLK5655SPI_CS
CAM_PCLK5453SCL1
PDM_DATA5251SDA1
PDM_CLK5049BATT_VIN / 3
G44847PWM1
G346
G244
G142
G04039GND
ADC138
ADC034
PWM032
23SWDIO
21SWDCK
19RX1
D11817TX1ADC_D-
I2C_Interrupt1615CTS1
SCL1413RTS1
SDA1211BOOT
D0109
7GND
RESET65USB_D-
3USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The board measures 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.

MicroMod Processor Board Dimensions

Hardware Hookup

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

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

MicroMod Processor Board inserted into the carrier board

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

MicroMod Processor Board inserted into the carrier board

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

screwing in the machine screw

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

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

Connecting Everything Up

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

Note: If you've never connected a CH340 device to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our section on "How to Install CH340 Drivers" for help with the installation.

How to Install CH340 Drivers

August 6, 2019

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

Software Setup

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

Installing the Arduino Core for Apollo3

To get started with the Artemis MicroMod Processor Board, you'll need to install the SparkFun Apollo3 Arduino Core. Open the Arduino IDE (must be v1.8.13 or later) and navigate to File->Preferences, like so:

Arduino Preferences, under File

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

In the "Additional Board Manager URL" box, make sure you have the following json file:

language:c
https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

If you have more than one json file, you can click on the button outlined in red and add the json link at the end. It'll look something like the following:

Additional Boards Manager URL location in the Preferences Dialog

Having a hard time seeing? Click the image for a closer look.
  • Go to Tools ->Board and select the Boards Manager

Arduino Boards Manager Dialog, under Tools

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

Search for "Apollo3", and you should find the SparkFun Apollo3 Boards board package. Make sure the Version 1.2.1 is selected and click Install.

Board manager showing SparkFun Apollo3 Artemis install

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

Installation may take a few minutes -- included in the install are all necessary source files for the Arduino core and Apollo3 libraries, plus all of the compiler and software-upload tools you'll need to use the Artemis with Arduino.

Once the board definitions have been installed, you should see the Artemis MicroMod Processor board under your Tools -> Board -> SparkFun Apollo3 menu.

Artemis MicroMod processor dropdown
Having a hard time seeing? Click the image for a closer look.
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

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

Arduino Board Select

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


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

Port Selection for the Artemis MicroMod Processor Board

Loading Blink

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

Blink Basics Example in the pulldown

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


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

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

Look at all the blinks!

blink blink blink

Example 2: PDM

We've built the Arduino core for Artemis from the ground up and a large number of our built-in examples will work out of the box with the Artemis MicroMod Processor Board. You'll find them under File->Examples->'Examples for SparkFun Artemis MicroMod'.

Let's run a quick one from the examples here and take advantage of the two built in microphones on the Machine Learning Carrier Board we're using. Go to File->Examples->PDM->Example1_MicrophoneOutput

Arduino sub menu showing Artemis examples

Click above image for full menu context

Make sure you have the correct board and port selected, and then upload the code. Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. You should see something like the following:

PDM Microphone example serial output

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

Notice that if you hoot and holler, the output changes.

Within the 'Examples for SparkFun Artemis Micromod' menu, we've got examples for setting up multiple I2C ports (it's amazingly easy), writing to EEPROM, using SoftwareSerial (all 48 pins can be serial!), using the the onboard microphone, and using servos (up to 32!). We're adding more all the time so be sure to keep your core up to date.

Further Examples

With the MicroMod system, the possibilities for examples with all the processor/carrier board are endless, and we just can't cover them all. You'll notice that in this tutorial, we've selected the Machine Learning Carrier Board, but have focused our examples on the Artemis Processor Board. If you're interested in examples specifically for our carrier board, head on over to our Machine Learning Carrier Board Hookup Guide.

Troubleshooting

Resources and Going Further

Want more information on the Artemis MicroMod Processor Board? Check out these links!

MicroMod Documentation:

Artemis Documentation:

Looking for some project inspiration using your Artemis Processor Board? The tutorials below can help you get started!

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 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 Machine Learning Carrier Board Hookup Guide

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

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

MicroMod Weather Carrier Board Hookup Guide

$
0
0

MicroMod Weather Carrier Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

Introducing the MicroMod Weather Carrier Board! This nifty little weather station board works with all SparkFun MicroMod Processors so you can customize your weather station project to fit your needs.

SparkFun MicroMod Weather Carrier Board

SparkFun MicroMod Weather Carrier Board

SEN-16794
$44.95

The Weather Carrier Board includes three sensors: the BME280 Temperature, Pressure and Humidity sensor, the VEML6075 UV light sensor and the AS3935 lightning detector. Along with these on-board sensors there is a 3-pin latch terminal to add an external soil moisture sensor as well as a pair of RJ11 jacks to plug in the wind and rain sensors included with our Weather Meter Kit. To top it all off there is a microSD card slot so you can plug in an SD card to log all of that glorious weather data!

Required Materials

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

SparkFun MicroMod ESP32 Processor

SparkFun MicroMod ESP32 Processor

WRL-16781
$14.95
SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod nRF52840 Processor

SparkFun MicroMod nRF52840 Processor

WRL-16984
$14.95

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

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
9
Flexible Qwiic Cable - 100mm

Flexible Qwiic Cable - 100mm

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

USB 3.1 Cable A to C - 3 Foot

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

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

If you want to take full advantage of the features of the Weather Carrier Board you will also need a SparkFun Soil Moisture Sensor, the Weather Meter Kit and a microSD card:

Weather Meter Kit

Weather Meter Kit

SEN-15901
$64.95
1
microSD Card - 16GB (Class 10)

microSD Card - 16GB (Class 10)

COM-15051
$19.95
SparkFun Soil Moisture Sensor (with Screw Terminals)

SparkFun Soil Moisture Sensor (with Screw Terminals)

SEN-13637
$6.95
4
SparkFun Soil Moisture Sensor

SparkFun Soil Moisture Sensor

SEN-13322
$5.95
15

Suggested Reading

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

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

MicroMod Logo

Before you get started with the Weather Carrier Board, you may want to read through the Hookup Guide for your chosen MicroMod Processor. MicroMod Processor Hookup Guides can be found on the processors' product pages. We also recommend reading through the following tutorials 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.

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.

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!

If you're interested in learning more about each of the sensors included on the Weather Carrier Board, take a look at their dedicated Hookup Guides:

Qwiic UV Sensor (VEML6075) Hookup Guide

Learn how to connect your VEML6075 UV Sensor and figure out just when you should put some sunscreen on.

SparkFun AS3935 Lightning Detector Hookup Guide (v20)

Are you worried about the looming clouds in the distance, how far away is that storm exactly? Add lightning detection with the AS3935 to your next weather station or your next bike ride!

Qwiic Atmospheric Sensor (BME280) Hookup Guide

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

Hardware Overview

In this section we'll cover the various hardware, sensors and adjustable solder jumpers on the MicroMod Weather Carrier Board, the external sensor connections and the pinout of the Carrier Board for a detailed look at how it connects to your chosen MicroMod Processor.

Common Components

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

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

Annotated photo for common components on the Weather Carrier Board.

Weather Station Sensors and External Sensor Connections

As we mentioned in the introduction, the board comes with a BME280 Temperature, Pressure and Humidity Sensor, a VEML6075 UV Light Sensor and a AS3935 Lightning Detector. Along with those on board sensors there is a three pin latch terminal for a soil moisture sensor as well as a pair of RJ11 jacks for connecting wind and rain meters.

The three on board sensors paired with the external sensors allows for a powerful and customizable weather tracking tool.

BME280 Temperature, Pressure and Humidity Sensor

The BME280 Atmospheric Sensor from Bosch is the heavy lifter of the Weather Carrier Board. The BME280 is a highly-accurate, digital environmental sensor that measures ambient temperature, relative humidity and barometric pressure.

Weather Carrier Board with BME280 Highlighted.

The BME280 measures humidity from 0 to 100% with an absolute accuracy of ±3 %RH (from 20-80%RH), temperatures between 0°C to 65°C with an absolute accuracy of ±0.5-1.5°C (full temperature range is -40°C to 85°C) and atmospheric pressures between 300 to 1100hPa with an absolute accuracy of ±1hPa (relative accuracy of ±0.12hPa). The I2C address of the BME280 is 0x77.

For detailed information on the sensor's functionality and characteristics, refer to the BME280 Datasheet or our Hookup Guide for the SparkFun Qwiic Atmospheric Sensor (BME280).

VEML6075 UV Sensor

The VEML6075 UV light sensor from Vishay Semiconductors measures UVA (320-400 nm, peak @365 ±10nm ) and UVB (228-320 nm, peak @330 ±10nm) irradiance so you can calculate the UV Index at your Weather Station. Example 4 - Calculate UVI in the SparkFun VEML6075 Arduino Library demonstrates how to calculate that index using this sensor.

Weather Carrier Board with VEML6075 Highlighted.

The VEML6075 has a UVA resolution of 0.93 counts/µW/cm2 and a UVB resolution of 2.1 counts/µW/cm2. The I2C address is 0x10.

For more information about this UV sensor, refer to the VEML6075 datasheet or our Hookup Guide for the SparkFun Qwiic UV Sensor (VEML6075).

AS3935 Lightning Detector

The AS3935 Lightning Detector from AMS can detect lightning strikes up to 40km away with an accuracy of up to 1km from the storm front. The specially-tuned antenna picks up lightning events in the 500kHz band and a built-in algorithm helps check the incoming signal pattern to reject potential man-made disturbers such as DC/DC converters in large appliances.

Weather Carrier Board with AS3935 and Antenna Highlighted.

The AS3935 Lightning Detector is connected to the primary SPI bus and Chip Select (CS) for the AS3935 is tied to G1/Bus1 (MicroMod pad 42).

For in-depth information about the sensor, refer to the AS3935 Datasheet or our Hookup Guide for the SparkFun Lightning Detector Breakout.

Soil Moisture Sensor Latch Terminal

The three-pin latch terminal makes it easy to connect a Soil Moisture Sensor to your Weather Carrier Board. The soil moisture sensor is a handy addition to the Weather Carrier Board if you are using it in something like a greenhouse environment to keep an eye on your soil and, with some slick coding, you could even turn an irrigation system on or off depending on the sensor's measurements.

Weather Carrier Board with Soil Moisture Latch Terminal Highlighted.

The Soil Moisture Sensor has two large coated pads that act as prongs for what is essentially a large variable resistor. The sensor takes advantage of a simple concept of moist soil being more conductive than dry soil so as more water is added to the soil, the resistance of the circuit drops and the SIG output increases.

Power (3.3V) for the sensor is provided by G0 (MicroMod pad 40) allowing you to turn it on and off easily (continuous power is not recommended for the soil moisture sensor) and the Signal output is tied to A0 (MicroMod pad 34).

If you are looking for some inspiration for an automated watering project, check out our Product Showcase Video and the Soil Moisture Sensor Hookup Guide.

Wind and Rain RJ11 Connectors

The two RJ11 connectors allow you to connect the wind and rain sensors included with our Weather Meters Kit to monitor wind speed, wind direction and rainfall. These two sensors are great additions to an outdoor Weather Carrier Board setup to get a more complete view of weather in the area.

Weather Carrier Board with Wind and Rain RJ11 Jacks Highlighted.

The Weather Meters Kit includes an anemometer to measure wind speed, a wind vain to determine wind direction and a self-emptying tipping bucket collector to monitor rainfall. The anemometer outputs a digital signal tied to D0 (MicroMod pad 10). The wind vain outputs an analog signal relative to its position tied to A1 (MicroMod pad 38). The rainfall detector outputs a digital signal to D1 (MicroMod pad 18).

For help assembling and testing your Weather Meters Kit, check out our Weather Meter Hookup Guide.

Plated Through-Hole Headers

The Weather Carrier Board also routes several pins from a connected MicroMod Processor to a pair of plated through-hole (PTH) headers.

Weather Carrier Board with PTH Headers highlighted

On the "North"/Top of the board, the primary SPI bus is routed to a PTH header (the CS pin on this header is routed to G2/BUS2), a trio of Ground pins and both PWM1 & PWM0 if users wish to solder components that can use pulse-width modulation.

The "South"/Bottom of the board features both Serial UARTs (UART1 & UART2), another pair of Ground pins as well as 3.3V and SDA/SCL from the primary I2C bus if users prefer to have a soldered connection for I2C devices instead of the Qwiic connector.

Solder Jumpers

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

There are a total of seven adjustable solder jumpers on the MicroMod Weather Carrier Board labeled I2C, MEAS, BYP, VE, UV, 5V and 3V3. The table below briefly outlines their functionalities:

Jumper Name/LabelDescriptionDefault State
I2C Pull-Up/I2CPulls the SDA/SCL lines to 3.3V via two 2.2K Ohm resistorsCLOSED
Measure/MEASOpen this jumper to probe the current draw at the 3.3V output of the regulator. For help measuring current, take a look at our How to Use a Multimeter tutorial.CLOSED
Bypass/BYPThe "penny-in-the-fuse" jumper. Bypasses the 6V/2A fuse and nets VIN and V_USB together. 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
UV Sensor Power/UVConnects VDD of the VEML6075 UV Sensor to 3.3V. Open the jumper to disable power to the UV Sensor.CLOSED
VIN LED Power/VIN LEDConnects the 5V/VIN LED to 5V via a 1K Ohm resistor. Open to disable the LED.CLOSED
3.3V LED Power/3V3 LEDConnects the 3.3V LED to 3.3V via a 1K Ohm resistor. Open to disable the LED.CLOSED
Highlighting the solder jumpers on the front of the Data Logging Carrier BoardHighlighting the solder jumpers on the back of the Data Logging Carrier Board

Having trouble viewing the detail in these photos? Click on them for a larger view.

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
M.2 Connector Pin# MicroMod Pin Name Weather Station Connection Description
1GNDGNDGround plane.
23.3V3.3VRegulated 3.3V via USB-C.
3USB_D+PassthroughUSB D+ connection for Processor Board.
43.3V_EN3.3V EnableVoltage regulator enable input.
5USB_D-PassthroughUSB D- connection for Processor Board.
6RESETRESET ButtonConnected to RESET Button. Reset is active LOW
9USB_VINVINInput voltage from USB.
10D0WSPEEDDigital pin for wind speed.
11BOOTBOOT ButtonConnected to BOOT Button. Boot is active LOW.
12I2C_SDAI2C_SDAI2C data signal for BME280, VEML6075 and other Qwiic/I2C devices.
14I2C_SCLI2C_SCLI2C clock signal for BME280, VEML6075 and other Qwiic/I2C devices.
17UART_TX1TX1UART1 data output. Tied to TX1 PTH header pin.
18D1/CAM_TRIGRAINDigital pin for rain meter signal.
19UART_RX1RX1UART1 data input. Tied to RX1 PTH header pin.
20UART_RX2RX2UART2 data input. Tied to RX2 PTH header pin.
21SWDCKSWDCKSerial Wire Debug Clock.
22UART_TX2TX2UART2 data output. Tied to TX2 PTH header pin.
23SWDIOSWDIOSerial Wire Debug I/O
32PWM0PWM0Dedicated PWM0 pin. Broken out to PTH header pin.
34A0SOIL_MOIST_SIGAnalog input from soil mositure sensor.
38A1WDIRAnalog input for wind direction.
40G0/BUS0SOIL_MOIST_PWRGeneral purpose pin configured for 3.3V output.
42G1/BUS1LIGHTNING_CSAS3935 Chip Select.
44G2/BUS2HEADER_CSGeneral chip select pin. Tied to SPI PTH header.
46G3/BUS3LIGHTNING_INTAS3935 interrupt pin.
47PWM1PWM1Dedicated PWM1 pin. Broken out to PTH header pin.
49BATT_VIN/3VIN/3Divided input voltage for monitoring power supply.
55SPI_CSSD_CSµSD Chip Select.
57SPI_SCKSPI_SCKSPI clock signal.
59SPI_COPISPI_COPISPI Controller Out/Peripheral In signal.
61SPI_CIPOSPI_CIPOSPI Controller In/Peripheral Out signal.
72RTC_3VRTC_3V3V output for backup battery charging.
FunctionBottom
Pin
   Top   
Pin
Function
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO (I)
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
CAM_MCLKPCM_OUTI2S_OUTAUD_OUT5655SPI_CS#
CAM_PCLKPCM_INI2S_INAUD_IN5453I2C_SCL1 (I/O)
PDM_DATAPCM_SYNCI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PDM_CLKPCM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 to 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D-
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0)1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on Processor Board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

Board Dimensions

The Weather Carrier Board measures 2.65" x 2.30" (67.31mm x 58.42mm) and has four mounting holes that fit a standard 4-40 screw.

MicroMod Weather Carrier Board Dimensions

Hardware Assembly

Now that we are familiar with the hardware and sensors on the Weather Carrier Board, it's time to assemble it with your chosen MicroMod Processor and get it connected to your computer.

Inserting your Processor

With the M.2 MicroMod connector, connecting your processor board is a breeze. Simply match up the key on your processor's beveled edge connector to the key on the M.2 connector. At a 45° angle, insert the processor board to the M.2 connector. The processor board will stick up at an angle as seen here:

nRF52840 Processor is inserted to M.2 connector on Weather Carrier board at 45 degree angle.

Once the board is in the socket, gently press the processor board down, grab the set screw and tighten it with a Phillip's head screwdriver:

Securing nRF52840 Processor into place with the MicroMod set screw and a screwdriver.

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

MicroMod nRF52840 Processor secured to the Weather Carrier Board.
Note: There is technically no way to insert the processor backward since the key prevents it from mating with the M.2 connector. As an extra safeguard to prevent inserting a processor improperly or with a poor connection, the mounting screw will not match up if the processor is not plugged in entirely.

Assembling External Sensors

For users with the Soil Moisture Sensor and/or the Weather Meters Kit some extra assembly is required. We have detailed assembly instructions for both of these peripherals in their respective Hookup Guides. You can find them here:

Soil Moisture Sensor Hookup Guide

A quick hookup guide and project to get you started with the Soil Moisture Sensor from SparkFun.

Weather Meter Hookup Guide

How to assemble your very own weather meter!

Once your external sensors are assembled, connecting them is a snap (literally). To connect the Soil Moisture Sensor, simply plug in the three wires to the three-pin latch terminals taking care to match the signals. For the Weather Meters, just plug the connectors for the Wind & Rain signals into their matching RJ11 jacks on the Weather Carrier Board.

Connecting Everything Up

With your processor inserted and secured it's time to connect your MicroMod Weather Carrier Board to your computer using the USB-C connector. Depending on which processor you choose and which drivers you already have installed, you may need to install drivers for your board. Refer to your processor's hookup guide for detailed instructions on how to install them.

Fully assembled MicroMod Weather Carrier Board with external sensors

With your MicroMod Weather Carrier Board, Processor Board, and any external sensors assembled we can now move on to uploading some code to monitor your environment! Head on to the next section for an example to test all the sensors the Weather Carrier Board features.

Weather Station Arduino Example

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

We've written a few examples to get started with the Weather Carrier Board. They can be found in the "Examples" folder of Hardware GitHub Repository and will work with any SparkFun MicroMod Processor you choose. In this section we'll only cover the comprehensive Weather Station example, but you can use the other examples to test each sensor on the Weather Carrier along with the additional soil moisture and weather meter sensors.

Note: Make sure that for whichever MicroMod Processor you choose, you have the correct board definitions installed.

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

If you are using a different processor, go to our MicroMod Processor Boards landing page, find your Processor, and head on over to its tutorial for help installing your board definition.

MicroMod Weather Carrier Board Test Example

Before getting started with the Weather Carrier Board Example you will need to install the Board Definitions for your chosen MicroMod Processor (outlined above) as well as the BME280, VEML6075 and AS3935 Arduino Libraries. You can install them using the Arduino Library manager and searching 'SparkFun BME280', 'SparkFun VEML6075' and 'SparkFun AS3935'. Alternatively, you can download the libraries from their respective GitHub repositories linked above or you can download the .ZIP for each of them by clicking the buttons below:

With the libraries and processor board definitions installed we can go ahead and move on to opening the MicroMod Weather Example sketch and uploading it to our MicroMod Processor. You can open a new blank sketch and copy the code from below or you can download the entire GitHub repository for the Weather Carrier Board which includes all of the examples by clicking the button below:

Navigate to the location the repository downloaded to and open the Examples folder. In that folder you'll find examples for each sensor as well as MM_Weather_CB_Test. Open that example in the Arduino IDE or copy the code below into a blank sketch, select your Board and Port and click "Upload".

language:c
/*
 * MicroMod Weather Carrier Board Example
 * 
 * This sketch tests all of the weather sensors on the carrier board:
 * atmospheric sensor - BME280, UV sensor - VEML6075, lightning detector - AS3935,
 * soil moisture sensor, wind and rain meters.
 * 
 * Priyanka Makin @ SparkX Labs
 * Original Creation Date: August 20, 2020
 * 
 * This code is Lemonadeware; if you see me (or any other SparkFun employee) at the
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Insert MicroMod Processor Board of your choice into the M.2 connector of the SparkFun Weather carrier
 *  Screw into place
 * Connect Weather carrier board to power useing USB-C cable
 * Connect SparkFun Soil Moisture Sensor to Weather carrier using latching terminals
 * Connect both wind and rain meters to Weather carrier using the RJ11 connectors
 */

#include <Wire.h>
#include <SPI.h>
#include "SparkFunBME280.h"
#include <SparkFun_VEML6075_Arduino_Library.h>
#include "SparkFun_AS3935.h"

BME280 tempSensor;
VEML6075 uv;
SparkFun_AS3935 lightning;

#define INDOOR 0x12 
#define OUTDOOR 0xE
#define LIGHTNING_INT 0x08
#define DISTURBER_INT 0x04
#define NOISE_INT 0x01

#if defined(ESP_PLATFORM)
int LED_BUILTIN = 5;
//int A0 = 34;
int G0 = 4;
int D0 = 23;
//int A1 = 35;
int D1 = 27;
const int G3 = 17;
int G1 = 12;
#elif defined(ARDUINO_ARCH_SAMD)
int G0 = 2;
int D0 = 0;
int D1 = 1;
//const int lightningInt = G3;  //SPI does not currently work on the SAMD51 proto
//int spiCS = G1;
#endif

int soilPin = A0;  //Pin number that measures analog moisture signal
int soilPower = G0;  //Pin number that will power the soil moisture sensor
int WSPEED = D0; //Digital I/O pin for wind speed
int WDIR = A1; //Analog pin for wind direction
int RAIN = D1;   //Digital I/O pin for rain fall
const int lightningInt = G3; // Interrupt pin for lightning detection
int spiCS = G1; //SPI chip select pin

volatile bool rainFlag = false;
volatile bool windFlag = false;

//Function is called every time the rain bucket tips
void rainIRQ()
{
  rainFlag = true;
}

//Function is called when the magnet in the anemometer is activated
void wspeedIRQ()
{
  windFlag = true;
}

// This variable holds the number representing the lightning or non-lightning
// event issued by the lightning detector. 
int intVal = 0;
int noise = 2; // Value between 1-7 
int disturber = 2; // Value between 1-10

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

  Serial.println("MicroMod Weather Carrier Board Test");
  Serial.println();

  Wire.begin();
  SPI.begin();

  if (tempSensor.beginI2C() == false) { //Begin communication over I2C
    Serial.println("BME280 did not respond.");
    while(1); //Freeze
  }
  if (uv.begin() == false) {
    Serial.println("VEML6075 did not respond.");
    while(1);
  }

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(soilPower, OUTPUT);
  digitalWrite(soilPower, LOW);
  // When lightning is detected the interrupt pin goes HIGH.
  pinMode(lightningInt, INPUT);

  //Initialization for weather meter
  pinMode(WSPEED, INPUT_PULLUP);  //Input from wind meters windspeed sensor
  pinMode(RAIN, INPUT_PULLUP);    //Input from wind meters rain gauge sensor
  //attach external interrupt pins to IRQ functions
  attachInterrupt(digitalPinToInterrupt(RAIN), rainIRQ, FALLING);
  attachInterrupt(digitalPinToInterrupt(WSPEED), wspeedIRQ, FALLING);
  //turn on interrupts
  interrupts();

  if(lightning.beginSPI(spiCS, 2000000) == false){ 
    Serial.println ("Lightning Detector did not start up, freezing!"); 
    while(1); 
  }
  else
    Serial.println("Schmow-ZoW, Lightning Detector Ready!");

  // The lightning detector defaults to an indoor setting at 
  // the cost of less sensitivity, if you plan on using this outdoors 
  // uncomment the following line:
  lightning.setIndoorOutdoor(OUTDOOR); 
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)

  Serial.println();
  Serial.print("Temperature: ");
  Serial.println(tempSensor.readTempF(), 2);
  Serial.print("Humidity: ");
  Serial.println(tempSensor.readFloatHumidity(), 0);
  Serial.print("Pressure: ");
  Serial.println(tempSensor.readFloatPressure(), 0);
  Serial.print("Altitude: ");
  Serial.println(tempSensor.readFloatAltitudeFeet(), 1);

  Serial.print("UV A, B, index: ");
  Serial.println(String(uv.uva()) + ", " + String(uv.uvb()) + ", "+ String(uv.index()));

  Serial.print("Soil Moisture = ");
  Serial.println(readSoil());

  Serial.print("Wind direction: ");
  Serial.print(getWindDirection());
  Serial.println(" degrees");
  //Check interrupt flags
  if (rainFlag == true){
    Serial.println("Rain click!");
    rainFlag = false;
  }
  if (windFlag == true){
    Serial.println("Wind click!");
    windFlag = false;
  }

  // Hardware has alerted us to an event, now we read the interrupt register
  if(digitalRead(lightningInt) == HIGH){
    intVal = lightning.readInterruptReg();
    if(intVal == NOISE_INT){
      Serial.println("Noise."); 
      // Too much noise? Uncomment the code below, a higher number means better
      // noise rejection.
      //lightning.setNoiseLevel(noise); 
    }
    else if(intVal == DISTURBER_INT){
      Serial.println("Disturber."); 
      // Too many disturbers? Uncomment the code below, a higher number means better
      // disturber rejection.
      //lightning.watchdogThreshold(disturber);  
    }
    else if(intVal == LIGHTNING_INT){
      Serial.println("Lightning Strike Detected!"); 
      // Lightning! Now how far away is it? Distance estimation takes into
      // account any previously seen events in the last 15 seconds. 
      byte distance = lightning.distanceToStorm(); 
      Serial.print("Approximately: "); 
      Serial.print(distance); 
      Serial.println("km away!"); 
    }
  }

  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW

  delay(3000);
}

int readSoil() {
  int moistVal = 0;  //Variable for storing moisture value
  //Power Senor
  digitalWrite(soilPower, HIGH);
  delay(10);
  moistVal = analogRead(soilPin);  //Read the SIG value from sensor
  digitalWrite(soilPower, LOW); //Turn the sensor off
  return moistVal; //Return current moisture value
}

int getWindDirection()
{
  unsigned int adc;
  adc = analogRead(WDIR); //get the current readings from the sensor

  if (adc < 380) return (113);
  if (adc < 393) return (68);
  if (adc < 414) return (90);
  if (adc < 456) return (158);
  if (adc < 508) return (135);
  if (adc < 551) return (203);
  if (adc < 615) return (180);
  if (adc < 680) return (23);
  if (adc < 746) return (45);
  if (adc < 801) return (248);
  if (adc < 833) return (225);
  if (adc < 878) return (338);
  if (adc < 913) return (0);
  if (adc < 940) return (293);
  if (adc < 967) return (315);
  if (adc < 990) return (270);
  return (-1);
}

The code begins by checking which MicroMod Processor was selected in Arduino and adjusts a few pin settings accordingly so it will work with any SparkFun MicroMod Processor. Next, it initializes all the on board sensors and checks for proper responses as well as checking for external sensors (wind, rain and soil).

Once all the sensors initialize, the code prints out data from each sensor. Open your serial monitor and set the baud to 115200 to watch the data print out.

Resources and Going Further

For more information about the MicroMod Weather Carrier Board, check out the following links:

For more information about the SparkFun MicroMod Ecosystem, take a look at the links below:

Looking for some project inspiration using your Weather Station Carrier? The tutorials below can help you get started!

MPL3115A2 Pressure Sensor Hookup Guide

Getting started with the MPL3115A2 Pressure Sensor.

MAX30105 Particle and Pulse Ox Sensor Hookup Guide

The SparkFun MAX30105 Particle Sensor is a flexible and powerful sensor enabling sensing of distance, heart rate, particle detection, even the blinking of an eye. Get ready. Set. Shine!

SparkFun gator:UV Hookup Guide

The gator:UV is an I2C based UV sensor. This tutorial will get you started using the gator:UV with the micro:bit platform.

How to Make a Magic Mirror with Raspberry Pi

Need a great project for your Raspberry Pi 4 kit? Use it to create a command center to display the weather, clock, your calendar, or even a news feed!

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

MicroMod nRF52840 Processor Hookup Guide

$
0
0

MicroMod nRF52840 Processor Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The MicroMod nRF52840 Processor offers a powerful SoC (system on chip) combination of ARM Cortex-M4 CPU and 2.4 GHz Bluetooth transceiver in the MicroMod form-factor so you can easily plug it in to the Carrier Board of your choice. The specific nRF module on this Processor board features an integrated PCB antenna for the Bluetooth transceiver.

SparkFun MicroMod nRF52840 Processor

SparkFun MicroMod nRF52840 Processor

WRL-16984
$14.95

The nRF52840 module includes a BT 5.1 stack and supports Bluetooth 5, Bluetooth mesh, IEEE 802.15.4 (Zigbee & Thread) and 2.4GHz RF wireless protocols (including Nordic's proprietary RF protocol) allowing you to pick which option works best for your application.

On top of the processing power and Bluetooth capability of the nRF52840, this board features two I2C buses, 2 SPI buses, eleven GPIO, dedicated digital, analog, and PWM pins along with multiple serial UARTs to cover all your peripheral needs.

Required Materials

Along with your MicroMod nRF52840 Processor, obviously need a Carrier Board to plug your Processor into. SparkFun offers a variety of MicroMod Carrier Boards to fit your project. Below you can see a few options:

SparkFun MicroMod Input and Display Carrier Board

SparkFun MicroMod Input and Display Carrier Board

DEV-16985
$59.95
2
SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$19.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95
SparkFun MicroMod Weather Carrier Board

SparkFun MicroMod Weather Carrier Board

SEN-16794
$44.95

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

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
9
Flexible Qwiic Cable - 100mm

Flexible Qwiic Cable - 100mm

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

USB 3.1 Cable A to C - 3 Foot

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

Reversible USB A to C Cable - 2m

CAB-15424
$7.95

Depending on which Carrier Board you choose, you may need a few extra peripherals to take full advantage of them. Refer to your Carrier Board's Hookup Guide for specific peripheral recommendations.

Suggested Reading

The SparkFun MicroMod ecosystem offers a unique way to allow users to customize their project to their needs. Do you want to communicate with your MicroMod circuit via a wireless signal (e.g. Bluetooth or WiFi)? There's a MicroMod Processor for that. Looking to instead maximize efficiency and processing power? You guessed it, there's a MicroMod Processor for that. If you are not familiar with the MicroMod ecosystem, take a look here:

MicroMod Logo
MicroMod Ecosystem

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

Serial Communication

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

Serial Peripheral Interface (SPI)

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

Installing Arduino IDE

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

Logic Levels

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

I2C

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

Bluetooth Basics

An overview of the Bluetooth wireless technology.

Hexadecimal

How to interpret hex numbers, and how to convert them to/from decimal and binary.

Getting Started with MicroMod

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

Hardware Overview

In this section we'll cover the nRF52840 SoC in more detail as well as other components included on the MicroMod nRF52840 Processor.

M.2 Connector

All of our MicroMod Processors come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor board on your choice of Carrier Board.


M2 Connector from the FrontM2 Connector from the Back

nRF52840 MDBT50Q Module

This Processor features the nRF52840 SoC from Nordic Semiconductor. The specific module is from Raytac which includes a built-in PCB antenna. Refer to the MDBT50Q Module Datasheet and nRF52840 IC Datasheet for full specifications on the IC and module.

Highlighting the nRF52840 Module.

The nRF52840 combines an ARM Cortex-M4 CPU and 2.4 GHz Bluetooth transceiver to provide a versatile and powerful microcontroller with Bluetooth 5.0 wireless capability. The transceiver also works with Bluetooth mesh, IEEE 802.15.4(Thread & Zigbee), ANT and Nordic's proprietary 2.5 GHz RF protocol to communicate with other Nordic devices.

The nRF52840 Processor board uses the Arduino Nano 33 BLE Bootloader as opposed to the USB Bootloader found on the SparkFun Pro nRF52840 Mini.

Flash IC

Along with the nRF52840 module, the Processor also includes external flash memory in the form of the 128Mb (16M x 8) W25Q128JV SpiFlash IC from Winbond Electronics. The flash IC is connected via SPI on the nRF52840. For full details on the Flash IC, refer to the datasheet.

Highlighting the flash IC.

The flash IC uses the secondary SPI bus (SPI1) and its Chip Select pin is tied to a dedicated pad on the nRF module (P0.12). Writing to the flash IC requires some extra work involving adjusting the SPI definitions in the variant file and is not recommended for anyone but advanced users. Writing to the Flash IC is beyond the scope of this tutorial.

STAT LED

The STAT LED is tied to a dedicated pin on the nRF module (P0.13) and can be used as a status LED or as a built-in LED. Control it directly in Arduino by writing to LED_BUILTIN.

Highlighting the STAT LED.

nRF52840 Processor Pin Functions

The nRF52840 has a ton of awesome features including (but not limited to):

  • ARM Cortex-M4 CPU with floating point unit (FPU), 64MHz
    • 1MB internal Flash -- For all of your program, SoftDevice, and file-storage needs!
    • 256kB internal RAM -- For your stack and heap storage.
  • Integrated 2.4GHz radio with support for:
    • Bluetooth Low Energy (BLE) -- With peripheral and/or central BLE device support
    • Bluetooth 5 -- Mesh Bluetooth!
    • Nordic's proprietary RF protocol -- If you want to communicate securely with other Nordic devices.
  • Interface Options
    • USB -- Turn your nRF52840 into a USB mass-storage device, use a CDC (USB serial) interface, and more.
    • UART -- Serial interfaces with support for hardware flow-control if desired.
    • I2C -- SparkFun's favorite 2-wire bi-directional bus interface
    • SPI -- If you prefer the 3+-wire serial interface
    • Analog-to-digital converters (ADC) -- Six pins on the nRF52840 Processor support analog inputs though four are used for other functionality on the MicroMod Processor.
    • PWM -- Two dedicated Pulse-Width Modulation interface pins.
    • PDM -- Pulse Density Modulation interface. The PDM module generates the PDM clock and supports single and dual channel data input.
    • GPIO -- Eleven dedicated General Purpose I/O pins.
Note: While nRF52840 supports peripheral-multiplexing to alter the functionality of almost any pin on the IC, in order to maintain compatibility with all SparkFun MicroMod Carrier Boards the pins are software defined to specific functions in the Arduino Board Definition. The pinout table at the end of this section outlines these definitions in totality and more detail.
Users who wish to alter pin functionality can modify the default board definition or use their own custom one but these can result in issues interacting with SparkFun Carrier Boards. If you decide to create or use a custom nRF52840 Processor board definition with a SparkFun Carrier Board, take note of the pins used for components (sensors, displays, etc.) to maintain compatibility. The board variant files can be found in the nRF52840 Processor Hardware GitHub Repository.

I2C

As you may have guessed from our extensive Qwiic System, we love communicating with devices using I2C! The nRF52840 Processor features two I2C buses. The main I2C bus has dedicated pins connected to MiroMod pads 12/14, along with a dedicated Interrupt pin connected to MicroMod pad 16. The primary I2C Bus will almost always be connected to a Qwiic connector on your Carrier Board.

If you want a second I2C bus, the nRF52840 has SDA1 and SCL1 on MicroMod pads 51 and 53. To use this second bus, initialize it by calling Wire1.begin();.

UART

The nRF52840 Processor has three UARTs available. The primary UART is tied to USB_D± (MicroMod pads 3 and 5) for serial communication over USB. This is used for your standard serial upload as well as serial prints in Arduino. The secondary UART is a hardware UART tied to MicroMod pads 19 (RX1) and 17 (TX1). The tertiary UART is another hardware UART tied to MicroMod pads 20 (RX2) and 22 (TX2).

In Arduino, use the following calls to send data over the three UARTs:

  • Serial - Communication over USB
  • Serial1 - Communication over RX1/TX1
  • Serial2 - Communication over RX2/TX2

SPI

The nRF52840 Processor features two SPI buses; SPI & SPI1. The primary SPI bus is tied to MicroMod pads listed below:

  • CIPO (Controller In/Peripheral Out) - MicroMod pad 61
  • COPI (Controller Out/Peripheral In) - MicroMod pad 59
  • SCK (Serial Clock) - MicroMod pad 57
  • CS (Chip Select) - MicroMod pad 55

SPI1 is tied to the flash IC and the pins are broken out to the M.2 connector on the MicroMod pads listed below:

  • CIPO1/SDIO_DATA0 - MicroMod pad 64
  • COPI1/SDIO_CMD - MicroMod pad 62
  • SCK1/SDIO_CLK - MicroMod pad 60
  • CS1/SDIO_DATA3 - MicroMod pad 70
  • SDIO_DATA1 - MicroMod pad 66
  • SDIO_DATA2 - MicroMod pad 68
Note: SparkFun has joined with other members of OSHWA in a resolution to move away from using "Master" and "Slave" to describe signals between the controller and the peripheral. This includes changing the traditional MISO/MOSI standard to CIPO/COPI. Check out this page for more on our reasoning behind this change. You can also see OSHWA's resolution here.

Audio

The nRF52840 supports audio input processing through Pulse-Density Modulation (PDM). The pins used are:

  • PDM_DATA - P0.26 , MicroMod pad 52. This is the PDM data signal.
  • PDM_CLOCK - P0.25, MicroMod pad 50. This is the PDM clock signal.

For more information on how to process audio signals using PDM on the nRF52840 Processor, refer to section 6.15 of the nRF52480 Datasheet as well as this example for the MicroMod Machine Learning Carrier Board.

Dedicated Pins/GPIO

Finally, along with all the interface options, the nRF52840 Processor has two pins dedicated for each of the following functionalities: Analog Read/Input, Digital I/O and Pulse Width Modulation. The nRF52840 Processor also has eleven general purpose I/O pins.

Dedicated Pins
  • A0 - ADC0/P0.04 , MicroMod pad 34 (Input Only!)
  • A1 - ADC1/P0.05 , MicroMod pad pad 38 (Input Only!)
  • D0 - P0.27 , MicroMod pad pad 10
  • D1 - P1.08 , MicroMod pad pad 18
  • PWM0 - P0.06 , MicroMod pad pad 32
  • PWM1 - P0.16 , MicroMod pad pad 47
General Purpose I/O pins
  • G0 - GPIO0/P0.29 , MicroMod pad 40
  • G1 - GPIO1/P0.03 , MicroMod pad 42
  • G2 - GPIO2/P1.13 , MicroMod pad 44
  • G3 - GPIO3/P1.12 , MicroMod pad 46
  • G4 - GPIO4/P1.11 , MicroMod pad 48
  • G5 - GPIO5/P0.17 , MicroMod pad 73
  • G6 - GPIO6/P1.06 , MicroMod pad 71
  • G7 - GPIO7/P1.04 , MicroMod pad 69
  • G8 - GPIO8/P1.14 , MicroMod pad 67
  • G9 - GPIO9/P0.09 , MicroMod pad 65 - Shared with NFC1
  • G10 - GPIO10/P0.10 , MicroMod pad 63 - Shared with NFC2

MicroMod Pinout

Users looking for a complete pin map can find it the table below or you can refer to the schematic.

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

Board Dimensions

MicroMod Processor Boards all measure in at 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.

Board Dimensional Drawing

Hardware Assembly

Now that we are familiar with the components on the nRF52840 Processor, it's time to assemble it with your chosen MicroMod Carrier Board and connect it to your computer. For this guide, we'll be using the MicroMod Weather Carrier Board.

Inserting the Processor Board

With the M.2 MicroMod connector, connecting your Processor board is a breeze. Simply match up the key on your Processor's beveled edge connector to the key on the M.2 connector. At a 45° angle, insert the Processor board to the M.2 connector. The Processor will stick up at an angle as seen here:

nRF52840 Processor is inserted to M.2 connector on Carrier board at 45 degree angle.

Once the board is in the socket, gently press the Processor board down, grab the set screw and tighten it with a Phillip's head screwdriver:

Securing nRF52840 Processor into place with the MicroMod set screw and a screwdriver.

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

MicroMod nRF52840 Processor secured to the Weather Carrier Board.
Note: There is technically no way to insert the processor backward since the key prevents it from mating with the M.2 connector. As an extra safeguard to prevent inserting a processor improperly or with a poor connection, the mounting screw will not match up if the Processor is not plugged in correctly.

Connecting Everything Up

Depending on which Carrier Board you are using with your nRF52840 Processor, you may want to plug in any other devices (Qwiic breakouts, UART devices, SD cards, I/O devices, etc.) prior to plugging in your Carrier Board to USB. Refer to your Carrier Board's Hookup Guide for specific instructions for Carrier Board peripheral device Hardware Assembly.

With your nRF52840 Processor inserted and secured and your other devices connected, it's time to connect your MicroMod Carrier Board to your computer using the USB-C connector.

Assembled MicroMod Carrier and Processor connected via USB-C

That's it! Now that our MicroMod circuit is assembled, we can move on to setting up the nRF52840 Processor in Arduino to start coding. Read on for detailed instructions on how to add the board to Arduino.

Arduino Software Setup

In this section we'll outline how to install the MicroMod nRF52840 board definitions and drivers. As we mentioned in the Hardware Overview section, the nRF52840 Processor ships with the same bootloader found on the Arduino Nano 33 BLE and takes advantage of Arduino's Mbed Core but we'll need to modify the board files a bit to add the MicroMod nRF52840 Processor to Arduino.

Arduino Mbed Core Installation

Heads up! If this is your first time using Arduino IDE or board add-ons, please review the following tutorials.

Before we can use the nRF52840 Processor, we need to install the Arduino Mbed Core. The easiest way to do that is to use the Boards Manager tool in Arduino. Open the tool by navigating to the Tools > Boards menu and select Boards Manager at the top of the list. With the Boards Manager tool opened, search for "Arduino Nano 33 BLE", select the board package titled "Arduino mbed-enabled Boards" and click "Install".

Arduino Boards Manager Tool with Arduino Mbed Core shown installed.

Installation may take a few minutes as all necessary source files for the Mbed Core, plus all of the compiler and software-upload tools needed to use the boards package with Arduino, are included with this install.

Once the board definitions have been installed, you should see a new set of Arduino Mbed OS Boards under your Tools > Board menu. However, you won't see an option for the SparkFun MicroMod nRF52840 Processor as we need to manually add the board to the Arduino Mbed OS board package.

Adding the MicroMod nRF52840 Board Definition

Now that the Arduino Mbed Core is installed, we need to modify it to add the MicroMod nRF52840 Processor. To do this we need to add and replace a few files in the Arduino Mbed Core.

If you are familiar with modifying an Arduino boards package with a custom board, you can skip the following instructions and use the links below to get the necessary files from the Hardware GitHub repo.

To modify the Arduino Mbed Core we need the necessary files from the nRF52840 Processor Hardware GitHub Repository. You can download the repository from the GitHub following the link above or you can download the repository in a ZIP by clicking the button below:

With the GitHub repository downloaded we need to open the Arduino Mbed Core folder. If you used the Boards Manager tool to install it, the folder should be in the following location:

  • Windows: %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\mbed\<version>
  • OSX: ~/Library/Arduino15/packages/arduino/hardware/mbed/<version>
  • Linux: ~/.arduino15/packages/arduino/hardware/mbed/<version>

If you installed the core manually into your Arduino sketchbook, it will be in "hardware/arduino/mbed".

Note: Windows users struggling to locate the AppData folder should make sure they have their View settings to show Hidden Items and are logged in as an administrative user.

Open the folder with the version number (v1.3.1 at the time of this writing). We need to replace or modify the boards.txt file and add the SF_MM_nRF52840_PB folder to the Variants folder.

To replace the boards.txt file simply delete the boards.txt file in the mbed/<version> folder and copy/paste the boards.txt file from the nRF Hardware GitHub Repository folder. Alternatively, you can modify the boards.txt in the mbed/<version> folder by opening the file in a text editor, scrolling to the bottom of the file and copy/pasting the below to the file:

language:text
##############################################################

sfnrf52840pb.name=SparkFun MicroMod nRF52840 Processor Board
sfnrf52840pb.build.core=arduino
sfnrf52840pb.build.crossprefix=arm-none-eabi-
sfnrf52840pb.build.compiler_path={runtime.tools.arm-none-eabi-gcc.path}/bin/

sfnrf52840pb.build.variant=SF_MM_nRF52840_PB
sfnrf52840pb.build.mcu=cortex-m4
sfnrf52840pb.build.extra_flags=
sfnrf52840pb.build.architecture=cortex-m4
sfnrf52840pb.build.fpu=fpv4-sp-d16
sfnrf52840pb.build.float-abi=softfp
sfnrf52840pb.build.board=ARDUINO_NANO33BLE
sfnrf52840pb.build.ldscript=linker_script.ld
sfnrf52840pb.compiler.mbed.arch.define=-DARDUINO_ARCH_NRF52840
sfnrf52840pb.compiler.mbed.defines={build.variant.path}/defines.txt
sfnrf52840pb.compiler.mbed.ldflags={build.variant.path}/ldflags.txt
sfnrf52840pb.compiler.mbed.cflags={build.variant.path}/cflags.txt
sfnrf52840pb.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt
sfnrf52840pb.compiler.mbed.includes={build.variant.path}/includes.txt
sfnrf52840pb.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
sfnrf52840pb.compiler.mbed="{build.variant.path}/libs/libmbed.a""{build.variant.path}/libs/libcc_310_core.a""{build.variant.path}/libs/libcc_310_ext.a""{build.variant.path}/libs/libcc_310_trng.a"
sfnrf52840pb.vid.0=0x2341
sfnrf52840pb.pid.0=0x005a
sfnrf52840pb.vid.1=0x2341
sfnrf52840pb.pid.1=0x805a

sfnrf52840pb.upload.tool=bossac
sfnrf52840pb.upload.protocol=
sfnrf52840pb.upload.use_1200bps_touch=true
sfnrf52840pb.upload.wait_for_upload_port=true
sfnrf52840pb.upload.native_usb=true
sfnrf52840pb.upload.maximum_size=983040
sfnrf52840pb.upload.maximum_data_size=262144

sfnrf52840pb.bootloader.tool=openocd
sfnrf52840pb.bootloader.extra_action.preflash=echo INFO:removed_mass-erase
sfnrf52840pb.bootloader.config=-f target/nrf52.cfg
sfnrf52840pb.bootloader.programmer=-f interface/cmsis-dap.cfg
sfnrf52840pb.bootloader.file=nano33ble/bootloader.hex

With the boards file updated or replaced, add the SF_MM_nRF52840_PB folder to mbed/<version>/variants.

Screenshot of SparkFun nRF52840 Variant folder added to Arduino mbed Variant folder.

After completing these steps, restart the Arduino IDE if it was open. After restarting, you should be able to select "SparkFun MicroMod nRF52840 Processor Board" from the Boards menu.

With the SparkFun MicroMod nRF52840 Processor Board Definitions added to the Arduino nRF528X mbed core, let's do some quick code examples to make sure everything went correctly during the Arduino Software Setup.

Selecting and Loading Blink

We'll start off with a basic Blink example to turn the STAT LED on and off just to make sure everything is working properly and your Processor can accept code.

Open up the Arduino IDE and select the "Blink" example by navigating to "File > Examples > 01.Basics > Blink" or by copying the code below into a blank sketch:

language:c
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

With the example opened, select your Board (SparkFun MicroMod nRF52840 Processor Board) and Port using the Tools > Board and Tools > Port menus and click the "Upload" button. Barring any issues during compilation and upload, the STAT LED on your nRF52840 Processor should be blinking on and off every second.

Screenshot showing Processor Board and Port selected in Arduino.
If the STAT LED remains off, the Processor may still be sitting in the bootloader. After uploading a sketch, you may need to tap the reset button to get your nRF52840 Processor to exit bootloader mode and run the sketch.

Arduino Example: Bluetooth Low Energy

Note: This example uses a SparkFun Arduino library that needs to be installed to Arduino. If you have not previously installed an Arduino library, please check out our installation guide for help.

This example demonstrates how to send sensor data (in this case, temperature data from a BME280) over Bluetooth Low Energy (BLE). The code creates a BLE peripheral with the temperature service and reading characteristic. This example can be used as a template for creating BLE peripherals and sending the data to another BLE device.

Prior to uploading the example, we'll need to install a couple of things to use and interact with the code.

BME280 Hardware

First off, we of course need a BME280 Atmospheric sensor. The Weather Carrier Board we used in the Hardware Assembly section includes a BME280 so if you are using that as your Carrier Board you're all set. If you are using a different Carrier Board you can attach a BME280 breakout like this Qwiic version to the Qwiic connector on your Carrier or to the primary I2C bus pins.

SparkFun BME280 Arduino Library

If you wish to use the code as is, you'll need to install the SparkFun BME280 Arduino Library. Install the library using the Arduino Library Manager by searching for "SparkFun BME280 Arduino Library". Users who prefer to manually install the library can download the GitHub Repository or by clicking the button below:

A detailed overview of the library can be found here in our Qwiic Atmospheric Sensor (BME280) Hookup Guide.

BLE Temperature Example

Copy the code below into a blank sketch or you can also find the example included the Hardware GitHub Repository. If you are opening the example from the downloaded repository, navigate to the "Test Sketches/ble_temp" folder and open the sketch.

Select your Board and Port from the Tools menu just as you did for the "Blink" example and click "Upload".

language:c
#include <ArduinoBLE.h>
#include "SparkFunBME280.h"

BME280 tempSensor;

 // BLE Temperature Service
BLEService temperatureService("9feb1060-0814-11eb-adc1-0242ac120002");

// BLE Temperature Reading Characteristic
BLEIntCharacteristic temperatureReadingChar("9feb1060-0814-11eb-adc1-0242ac120002",  // standard 16-bit characteristic UUID
    BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes

int oldTemperatureF = 0; //last temperature reading from BME280

void setup() {
  Serial.begin(115200);    // initialize serial communication
  while (!Serial);

  pinMode(LED_BUILTIN, OUTPUT); // initialize the built-in LED pin to indicate when a central is connected

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1);
  }

  if (tempSensor.begin() == false) { //Connect to BME280
    Serial.println("BME280 did not respond.");
    while(1); //Freeze
  }

  /* Set a local name for the BLE device
     This name will appear in advertising packets
     and can be used by remote devices to identify this BLE device
     The name can be changed but maybe be truncated based on space left in advertisement packet
  */
  BLE.setLocalName("TemperatureReading");
  BLE.setAdvertisedService(temperatureService); // add the service UUID
  temperatureService.addCharacteristic(temperatureReadingChar); // add the temperature reading characteristic
  BLE.addService(temperatureService); // Add the temperature service

  /* Start advertising BLE.  It will start continuously transmitting BLE
     advertising packets and will be visible to remote BLE central devices
     until it receives a new connection */

  // start advertising
  BLE.advertise();

  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {
  // wait for a BLE central
  BLEDevice central = BLE.central();

  // if a central is connected to the peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's BT address:
    Serial.println(central.address());
    // turn on the LED to indicate the connection:
    digitalWrite(LED_BUILTIN, HIGH);

    // check the temperature every second
    // while the central is connected:
    while (central.connected()) {
        updateTemperature();
        delay(1000);
    }
    // when the central disconnects, turn off the LED:
    digitalWrite(LED_BUILTIN, LOW);
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
}

void updateTemperature() {
  /* Read the current temperature from the BME280
  */
  int temperatureF = (int)tempSensor.readTempF();

  if (temperatureF != oldTemperatureF) {
    Serial.print("Temperature in F is now: "); // print it
    Serial.println(temperatureF);
    temperatureReadingChar.writeValue(temperatureF);  // and update the temperature reading characteristic
    oldTemperatureF = temperatureF;
  }
}

Reading the Temperature Data with the nRF Connect App

In order to interact with this example we need another device (phone/computer/tablet) connected to the nRF52840. There are plenty of BLE Central applications out there but for this tutorial we'll use Nordic's helpful (and free) testing tool called nRF Connect for Mobile for interfacing between our two devices. You can find the application on both the Google Play Store or Apple's App Store or you can find them by clicking the buttons below. Go ahead and install the app before moving on with this example.

Open the serial monitor after uploading finishes and set the baud rate to 115200. If there are no failures initializing BLE and the BME280, the code will start advertising the nRF52840 Processor until it receives a new connection.

At this point (if you have not already), open your BLE Central App and scan for devices. The nRF52840 Processor should appear as an available BLE device named "TemperatureReading".

Screenshot of nRF Connect App showing TemperatureReading BLE Device
You can see here we've added a filter for "Temperature" to narrow down the scan results.

Once the nRF52840 connects to the nRF Connect App, the code will print out Connected to central: along with the central Bluetooth's address. The STAT LED on the Processor should also turn on indicating a successful pairing and connection.

Arduino Serial monitor showing Bluetooth connection and BME280 Temperature Data.

In order to receive temperature data from the nRF52840 on your nRF Connect App you will need to enable notifcations by opening the BLE Temperature Reading Characteristic (shown below as Unknown Service with the full UUID set in the example code) and clicking the icon with three downward-facing arrows.

Screenshot of nRF Connect App enabling notifications from the nRF52840

While paired, and if the temperature recorded by the BME280 changes, the code prints the new temperature value to the serial terminal and sends a data packet of the temperature value in Hexadecimal to the paired central device. On the nRF Connect app, swipe to the right to open the data log to see the Hex values for the temperature:

Screenshot of nRF Connect App showing Temperature Data log.

From here, you can take the Hexadecimal values from the BME280 and parse them however you choose to use for your BLE application.

Troubleshooting

We've got some troubleshooting tips for a couple of common "gotchas" you may run into using the nRF52840 Processor.

Force Bootloader Mode

In case your board gets stuck in an unresponsive state you can force the nRF52840 into Bootloader mode by double-tapping the RESET button on your Carrier Board. This can help recover the board from an unknown state or you can use it to directly interact with the board in bootloader mode. You can also use the RESET button to start any code that hangs after upload in case the Processor is still in Bootloader mode.

MicroMod Board Installation

If you run into problems after modifying the Arduino nRF5284X core the easiest way to remedy that is to use the Boards Manager tool in Arduino to switch to an older version of the core and then revert to the current version. Alternatively, you can use the Boards Manager to uninstall and reinstall the Arduino core.

After you have reverted or reinstalled the core go through the steps outlined in the Arduino Software Setup section of this guide to install the custom MicroMod nRF52840 Processor board definition.

General Troubleshooting Help & Technical Support

Resources and Going Further

For more information about the MicroMod nRF52840 Processor, check out the following links:

For more information about the SparkFun MicroMod Ecosystem, take a look at the links below:

Need some inspiration for a project using your nRF52840 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!
New!

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.

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 All The Pins (ATP) Carrier Board

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

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

MicroMod SAMD51 Processor Board Hookup Guide

$
0
0

MicroMod SAMD51 Processor Board Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

With the MicroMod specification, we shrunk down the PCB size for the SAMD51 32-bit ARM Cortex-M4F MCU! This tutorial covers the basic functionality of the MicroMod SAMD51 and highlights its features.

SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95

Required Materials

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

SparkFun MicroMod SAMD51 Processor

SparkFun MicroMod SAMD51 Processor

DEV-16791
$14.95
SparkFun MicroMod ATP Carrier Board

SparkFun MicroMod ATP Carrier Board

DEV-16885
$19.95
SparkFun Mini Screwdriver

SparkFun Mini Screwdriver

TOL-09146
$0.95
3
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2

Suggested Reading

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

MicroMod Logo
MicroMod Ecosystem

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

Serial Communication

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

Serial Peripheral Interface (SPI)

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

Installing Arduino IDE

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

Logic Levels

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

I2C

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

Getting Started with MicroMod

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

Hardware Overview

M.2 Connector

All of our MicroMod Processor Boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor Board on your choice of carrier board. Most of the pins use a common pinout to ensure cross platform compatibility.

M.2 Edge Connector and Mounting

SAMD51 Processor

The brains of the processor board is the ATSAMD51J20 32-bit ARM Cortex M4 processor. An external 32.768kHz crystal is used as the clock for the ATSAMD51. However, the MCU itself has a maximum CPU speed of 120MHz. The SAMD51 should be powered with 3.3V from a carrier board's M.2 connector. The logic levels for the I/O pins are 3.3V.

SAMD51 Processor

Flash Memory

On the back of the board is the W25Q128JVPIM, which adds 128Mb (16MB) of flash memory externally.

Flash Memory

LED

A STAT LED is added to the top side of the board. This is useful debugging or as a status indicator. Additionally, you can use this to determine if the board is in bootloader mode. Pressing the reset button twice will put the board into bootloader mode causing the LED to fade in/out. This is connected to pin 13.

Status LED

MicroMod SAMD51 Processor Pin Functionality

The complete pin map can be found in the table below or you can refer to the schematic.

Heads up! The pin table below and schematic both include the SAMD51 pin associated with each MicroMod pin and this correlation can be used to identify alternate uses for pins on the SAMD51 Processor Board. For many of the General Purpose I/O pins and other pins with multiple signal options, refer to your Carrier Board's Hookup Guide for information on how those pins are configured what they are used for. Not all pins are used on every Carrier Board.
AUDIOUARTGPIO/BUSI2CSDIOSPIDedicated
SAMD51
Pin
Alternate
Function
Primary
Function
Bottom
Pin
   Top   
Pin
Primary
Function
Alternate
Function
SAMD51
Pin
(Not Connected)75GND
D143.3V_IN7473G5D7
3.3V7271G6D8
-7069G7D9
-6867G8D10
-6665G9D11
-6463-
-6261SPI_CIPO47
-6059SPI_COPI45
43I2S_MCLK5857SPI_SCK46
40I2S_SDO5655SPI_CS48
41I2S_SDI5453I2C_SCL1TX236
44I2S_FS5251I2C_SDA1RX237
42I2S_CLK5049A421
D6G44847PWM1A320
D5G34645GND
D4G24443G1038
D3G14241G1139
D2G04039GND
18A13837-
GND3635-
17DACA03433GND
19A2PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
36I2C_SCL1UART_TX22221SWDCK
37I2C_SDA1UART_RX22019UART_RX133
D1D11817UART_TX132
D12I2C_INT1615-
34I2C_SCL1413-
35I2C_SDA1211-
D0D0109-
29HOST_ENABLE87GND
RESET# (Open Drain)65USB_D-USBHOST_D-30
3.3V_EN43USB_D+USB_HOST_D+31
3.3V_IN21GND
FunctionBottom
Pin
   Top   
Pin
Function
(Not Connected)75GND
3.3V7473G5 / BUS5
RTC_3V_BATT7271G6 / BUS6
SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
SDIO_DATA2 (I/O)6867G8
SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO (I)
SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
CAM_MCLKPCM_OUTI2S_OUTAUD_OUT5655SPI_CS#
CAM_PCLKPCM_INI2S_INAUD_IN5453I2C_SCL1 (I/O)
PDM_DATAPCM_SYNCI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
PDM_CLKPCM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 to 3.3V)
G4 / BUS44847PWM1
G3 / BUS34645GND
G2 / BUS24443CAN_TX
G1 / BUS14241CAN_RX
G0 / BUS04039GND
A13837USBHOST_D-
GND3635USBHOST_D+
A03433GND
PWM03231Module Key
Module Key3029Module Key
Module Key2827Module Key
Module Key2625Module Key
Module Key2423SWDIO
UART_TX2 (O)2221SWDCK
UART_RX2 (I)2019UART_RX1 (I)
CAM_TRIGD11817UART_TX1 (0)
I2C_INT#1615UART_CTS1 (I)
I2C_SCL (I/0)1413UART_RTS1 (O)
I2C_SDA (I/0)1211BOOT (I - Open Drain)
D0109USB_VIN
SWOG1187GND
RESET# (I - Open Drain)65USB_D-
3.3V_EN43USB_D+
3.3V21GND
Signal GroupSignalI/ODescriptionVoltage
Power3.3VI3.3V Source3.3V
GNDReturn current path0V
USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
CANCAN_RXICAN Bus receive data.3.3V
CAN_TXO CAN Bus transmit data.3.3V
UARTUART_RX1IUART receive data.3.3V
UART_TX1OUART transmit data.3.3V
UART_RTS1OUART ready to send.3.3V
UART_CTS1IUART clear to send.3.3V
UART_RX2I2nd UART receive data.3.3V
UART_TX2O2nd UART transmit data.3.3V
I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
SPI_SCKOSPI Clock.3.3V
SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
AudioAUD_MCLKOAudio master clock.3.3V
AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
PWMPWM0OPulse width modulated output 0.3.3V
PWM1OPulse width modulated output 1.3.3V
DigitalD0I/O General digital input/output pin.3.3V
D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
G1/BUS1I/O3.3V
G2/BUS2I/O3.3V
G3/BUS3I/O3.3V
G4/BUS4I/O3.3V
G5/BUS5I/O3.3V
G6/BUS6I/O3.3V
G7/BUS7I/O3.3V
G8I/OGeneral purpose pin3.3V
G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V


Board Dimensions

The board takes advantage of the standard MicroMod form factor.

Board Dimensions

Hardware Assembly

If you have not already, make sure to check out the Getting Started with MicroMod: Hardware Hookup for information on inserting your Processor Board into your Carrier Board.

Getting Started with MicroMod

October 21, 2020

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

For simplicity, we'll be using the MicroMod ATP Carrier Board to program the board. At a minimum, your setup should look like the image below with the MicroMod SAMD51 inserted into the MicroMod ATP Carrier Board with a USB-C cable.

Processor Board inserted into Carrier Board with USB cable

Qwiic-Enabled Device

If you decide to use a Qwiic device (because why not?!), simply insert a Qwiic cable between the two connectors.

Qwiic-Enabled Device Connected to MicroMod ATP Carrier Board with Qwiic Cable

UF2 Bootloader & Drivers

The SAMD51 Processor Board is easy to program thanks the UF2 bootloader. With the UF2 bootloader, the MicroMod SAMD51 Processor Board shows up on your computer as a USB storage device without having to install drivers for Windows 10, Mac, and Linux!

What is UF2?

UF2 stands for USB Flashing Format, which was developed by Microsoft for PXT (now known as MakeCode) for flashing microcontrollers over the Mass Storage Class (MSC), just like a removable flash drive. The file format is unique, so unfortunately, you cannot simply drag and drop a compiled binary or hex file onto the Turbo. Instead, the format of the file has extra information to tell the processor where the data goes, in addition to the data itself.

For Arduino users, the UF2 bootloader is BOSSA compatible, which the Arduino IDE expects on ATSAMD boards. For more information about UF2, you can read more from the MakeCode blog, as well as the UF2 file format specifiation.

Double-Tap to Launch the Bootloader

The bootloader is what allows us to load code over a simple USB interface. To upload code, you will need to manually enter bootloader mode by rapidly double-tapping the reset button (after hitting the reset button once, you have about half a second to hit it again). The board will remain in bootloader mode until power cycles (happens automatically after uploading code) or the reset button is hit again (once).

Hit Reset Button Twice to Enter Bootloader Mode

Double-tapping the reset button to enter bootloader mode.

On the SAMD51, the there are a clues to if it is in bootloader mode:

  • The D13 LED indicator will be slowly fading (may appear to be blinking).
  • Board will show up under a different COM port.
  • The board will appear as a USB mass storage device under the name USB Serial Device.

Driver Verification

To verify that your driver is working, you should see the difference in the following pictures after plugging in your SparkFun MicroMod SAMD51 Processor Board. Alternatively, once you have the Arduino IDE installed, you should also see a change in the number of available Serial/COM Ports (you may need to restart the Arduino IDE for the board to populate).

Windows

Check that the board shows up in your device manager. You can click the Start or (Windows) button and type "device" to quickly search for the application. (*On Windows 10, the quick search function is picky on the spelling of the application you are searching for. For example, you may get results using "devi" and none for "device".)

SAMD51 in Windows Device Manager

Screenshot of Window 10 Device Manager with the SAMD51 Processor Board on COM25. Click to enlarge.

Mac OSX

Open the Terminal and run the following command ls /dev/cu.* in the Terminal and check for the following changes (your board may show up under a different device name). To open the Terminal, open your Applications folder, Utilities folder, then double-click on Terminal. Otherwise, press (Command) + space bar (Space Bar) to launch Spotlight and type "Terminal," then double-click the search result.

Mac OSX CLI Command Entry

Screenshot of Mac OSX terminal with the SAMD51 Processor Board on cu.usbmodemFA121. Click to enlarge.
ls /dev/cu.*
Note: If you are still unsure of how to access the Terminal, watch this video or read this Apple support article.

Raspbian

Run the following command ls /dev/ttyACM* in the CLI/Terminal and check for the following changes (your board may show up under a different device name).

Raspbian CLI Command Entry

Screenshot of Raspberry Pi CLI with the SAMD51 Processor Board on ttyACM0. Click to enlarge
ls /dev/ttyACM*

Setting Up the Arduino IDE

Note: If this is your first time using Arduino IDE or board add-on, please review the following tutorials.

Install Arduino SAMD Board Add-Ons

First, you'll need to install a variety of tools, including low-level ARM Cortex libraries full of generic code, arm-gcc to compile your code, and bossa to upload over the bootloader. These tools come packaged along with Arduino's SAMD board definitions for the Arduino Zero.

To install the Arduino SAMD board definitions, navigate to your board manager (Tools>Board>Boards Manager...), then find an entry for Arduino SAMD Boards (32-bits ARM Cortex-M0+) by typing SAMD in the search bar. Select it, and install the latest version (at the time of writing this tutorial, the board definitions work with v1.8.9).

Installing the Arduino SAMD Core  with the Arduino IDE Board Manager

Downloading and installing the tools may take a couple minutes -- arm-gcc in particular will take the longest, it's about 250MB unpacked.

Once installed, Arduino-blue "Installed" text should appear next to the SAMD boards list entry.

Install SparkFun Board Add-On

Now that your ARM tools are installed, one last bit of setup is required to add support for the SparkFun SAMD boards. First, open your Arduino preferences (File>Preferences). Then find the Additional Board Manager URLs text box, and paste the below link in:

https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

Arduino IDE Preferences Additional Moard Manager URLs

Then hit "OK", and travel back to the Board Manager menu. You should (but probably won't) be able to find a new entry for SparkFun SAMD Boards. If you don't see it, close the board manager and open it again. ¯\_(ツ)_/¯.

Installing the SparkFun SAMD Boards

This installation should be much faster; you've already done the heavy lifting in the previous section. When writing this tutorial, the board version used in this tutorial should be v1.7.6. You may have a higher version as the board if there are any updates.

Select the Board and Serial Port

Once the board is installed, you should see a new entry in your Tools>Board list. Select your SparkFun MicroMod SAMD51.

Board and COM Port Selection in the Arduino IDE

Finally, select the SparkFun MicroMod SAMD51's port when the board is connected to your computer. Navigate back up to the Tool>Port menu. The port menu will have the SparkFun MicroMod SAMD51's port, labeled as such here. On a Windows machine, the serial port should come in the form of "COM#". On a Mac or Linux machine, the port will look like "/dev/cu.usbmodem####".

Arduino IDE COM Port Selection

In the picture above my MicroMod SAMD51 is listed under COM25; this is because I've plugged in about as many microcontrollers into my computer, but the one in your port menu should be smaller.

Arduino Examples

The SAMD51 is a powerful microcontroller. Here are a few examples that highlight some of its functionality.

Example 1: Blink and Hello World!

Now that you have a Processor Board secure in the Carrier Board, let's upload a combined sketch to the board. We will combine the blink and Hello World! sketches into one. Copy and paste the following code in the Arduino IDE. Head to Tools>Board to select the correct board definition (in this case, SparkFun MicroMod SAMD51). Select the correct COM port that the board enumerated to. Hit upload.

language:c
/* MicroMod SAMD51 Test Code
   by: Ho Yun "Bobby" Chan
   SparkFun Electronics
   date: October 7, 2020
   license: Public Domain - please use this code however you'd like.
   It's provided as a learning tool.

   This code is provided to show how to control the SparkFun
   MicroMod SAMD51's STAT LED within a sketch. It also serves
   to explain the difference between Serial.print() and
   Serial1.print().

*/

//int LED_BUILTIN = 13;  // The STAT LED has a defined Arduino pin
/* Note: STAT LED is connected to pin 13. This is defined in the
   MicroMod SAMD51 board files already as macros (e.g. PIN_LED, LED_BUILTIN)
   so we can comment this out.
*/


void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);  // Set RX LED as an output
  // TX LED is set as an output behind the scenes

  Serial.begin(9600); //This pipes to the serial monitor
  Serial.println("Initialize Serial Monitor");

  Serial1.begin(9600); //This is the UART, pipes to sensors attached to board
  Serial1.println("Initialize Serial Hardware UART Pins");
}

void loop()
{
  Serial.println("Hello world!");  // Print "Hello World" to the Serial Monitor
  Serial1.println("Hello! Can anybody hear me?");  // Print "Hello!" over hardware UART

  digitalWrite(LED_BUILTIN, LOW);   // set the LED_BUILTIN ON
  delay(1000);              // wait for a second

  digitalWrite(LED_BUILTIN, HIGH);    // set the LED_BUILTIN OFF
  delay(1000);              // wait for a second
}

Check out the MicroMod SAMD51's built-in LED. The LED should blink every second.

MicroMod SAMD51 LED Blink

Open the Arduino IDE's serial monitor set at 9600 baud. You should see every programmer's favorite two-word phrase.

Hello World! with the MicroMod SAMD51 Native Serial

Want to go the extra mile? Grab a 3.3V USB-to-serial converter (in this case, we are using the Serial Basic Breakout CH340). Then connect GND to GND using a M/M jumper wire. Add another M/M jumper wire between TX from the MicroMod ATP Carrier board and the RXI pin of the USB-to-serial converter. Connect the appropriate USB cable to the USB-to-serial converter.

CH340 Connected to SAMD51 via the ATP Carrier Board

Open another serial terminal (in this case, we'll use Tera Term on a Windows) and connect to the USB-to-serial converter at 9600 baud. You should see a different message being sent from the hardware serial pin.

Output from Hardware Serial on Tera Term

Example 2: Qwiic-Enabled Device Qwiic Distance Sensor (VL53L1X)

Note: If you have not previously installed an Arduino library, please check out our installation guide.

There's a plethora of Qwiic-enabled devices available to connect. In this example, we will be using a Qwiic distance sensor to test. If you have not already, head over to the Qwiic Distance Sensor's (VL53L1X) tutorial to install the library.

Qwiic Distance Sensor (VL53L1X) Hookup Guide

June 18, 2018

The Qwiic VL53L1X time of flight sensor is capable of several modes, as well as having a range of 4M. Let's hook it up and find out just how far away that thing over there is.

Connect the distance sensor to the Qwiic connector. Make sure to connect to the one labeled I2C. There is a second port labeled as I2C1. You would need to adjust the code in order to use the second I2C port.

alt text

For simplicity, we'll use the first example just like the tutorial. Open up the first example by heading to File>Examples>SparkFun VL53L1x 4M Laser Distance Sensor>Example1_ReadDistance. If you have not already, head to Tools>Board to select the correct board definition (in this case, SparkFun MicroMod SAMD51). Select the correct COM port that the board enumerated to. Hit upload.

Open a the Arduino Serial Monitor at 9600 baud and start moving your hand over the sensor.

alt text

You should see an output similar to the image below. The values will vary depending on the distance away from the sensor.

VL53L1X Output on the Arduino Serial Monitor

What's next? Try combining the distance sensor example with the HID keyboard/mouse library to wake up a Raspberry Pi from it's screensaver whenever an object is in front of the sensor. Better yet, try adding some buttons and writing code to make a game controller for a computer.

Troubleshooting

Resources and Going Further

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

Need some inspiration for your next project? Check out some of these related tutorials using HID mouse/keyboard or adding more SERCOM Ports for your SAMD51:

Wireless Joystick Hookup Guide

A hookup guide for the SparkFun Wireless Joystick Kit.

Adding More SERCOM Ports for SAMD Boards

How to setup extra SPI, UART, and I2C serial ports on a SAMD-based boards.

Keyboard Shortcut, Qwiic Keypad

A simple project using the Qwiic Keypad and the RedBoard Turbo to create your own custom hotkey-pad.

Qwiic Pro Micro USB-C (ATmega32U4) Hookup Guide

An overview of the ATmega32U4-based Qwiic Pro Micro USB-C, how to install it, and how to use it with Arduino.

Or check out other tutorials with MicroMod:

New!

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 All The Pins (ATP) Carrier Board

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

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board

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

Industrial Fiber Optics Hookup Guide

$
0
0

Industrial Fiber Optics Hookup Guide a learn.sparkfun.com tutorial

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

Getting Started with Fiber Optics

Stock image of fiber optic cables plugged into a piece of network equipment

Image courtesy of Bruno /Germany from Pixabay

Copper is soooo last year. Haven’t you heard? All of the cool kids are transmitting their data over optical fiber with flashes of light! Okay, so fiber optics aren’t going to replace all copper wires any time soon, but they are hard to beat in some situations. For instance, long fiber optic lines don’t act as antennas that introduce noise to your circuit. They also won’t transmit power surges from things like ground faults or lightning strikes. What’s more, they don’t interfere with sensitive RF equipment that might be otherwise disturbed by the EMF radiation from electrical signalling.

Historically, however, fiber has also had some disadvantages. Optical fiber can be fragile and expensive. The connectors can be hard to install and often require specialized tools. Cutting and splicing fiber can entail quite a lot of work, including polishing all of the interfaces for optimal transmission. On top of that, the modems on either end are often expensive and designed for a very particular application. But what if I told you there was an affordable, generic fiber solution that requires no specialized connectors or polishing equipment? And what if I told you that it could easily achieve 1Mbps over hundreds of meters of cable? Well this is exactly what I’m telling you.

an assortment of IFO modules in various states of disassembly

I mean no disrespect when I say this is minimum viable fiber hardware

The Industrial Fiber Optics line of emitters and detectors are by far the most economical way we’ve found to create a simple fiber link between two devices. The IF-E97 emitter is literally just a superbright red LED in a fancy plastic module that makes it easy to insert a piece of optical fiber and lock it in place. On the other end, the IF-D96F is a 5v TTL phototransistor in an identical enclosure. Connect the two with a piece of fiber and you have, basically, the simplest possible fiber link. Speaking of fiber, while you can certainly use glass fiber (in the proper jacket) to connect these modules together, we recommend PMMA plastic fiber! It’s cheap, it’s not at all fragile, and you can cut it with scissors. In our experience, it requires no polishing at all, simply cut it with scissors and jam it into the connector.

So are you sold on Industrial Fiber Optics’ general purpose receivers and transmitters? Great, because we’ve designed three different products to help you incorporate them into your next project…

Serial Fiber Modem

The Serial Fiber Modem combines a USB-to-Serial bridge with a fiber receiver and transmitter and is the easiest way to start playing with fiber right out of the box.

Serial Fiber Modem

Serial Fiber Modem

SPX-17508
$24.95

To get started, use a USB-C cable to connect the Serial Fiber Modem to your computer. It will enumerate as a serial device the same way as our Serial Basic Breakout. The board has one transmitter and one receiver, so it acts as one side of a full duplex link. However, if you just want to test your board, you can create a simple loopback by inserting a piece of fiber optic cable into the transmitter and receiver of the same board.


A Note About Plastic Fiber

These modules are designed to accommodate simplex fiber optic cable with a jacket diameter of 2.2mm, which is commonly available online from several manufacturers. We carry 1 meter lengths of plastic core fiber cable to get you started.

2.2mm Simplex Plastic Fiber - Black Jacket 960/1000um (1m length)

2.2mm Simplex Plastic Fiber - Black Jacket 960/1000um (1m length)

CAB-17511
$2.95

The cable that we sell contains a single 960µm PMMA core with a fluorinated polymer cladding that brings it to 1000µm, and finally a polyethylene jacket that measures 2.2mm in diameter. It is easily cut with a pair of sharp scissors. The cut end requires no polishing in most applications. When cutting the cable, make the cut as perpendicular to the end as possible to create a flat optical surface. There is no need to “strip” any part of the jacket, simply cut it flush with the core.

To insert the cable into the module, first loosen the locking nut and then simply push the cut end of the fiber cable as far into the module as possible. After inserting the cable, tighten the locking nut “finger-tight,” so that the cable cannot easily be tugged free from the module. Careful not to overtighten, as the plastic threads are easy to damage.


Once a piece of fiber is installed between the receiver and transmitter, simply open a serial terminal and start typing. You should see that your text is being transmitted and then received and displayed in the terminal. In our experience, text could be transmitted without error at baud rates up to 1M over at least 50 meters of fiber.

When connecting two Serial Fiber Modems to each other, be sure to connect the transmitter of one board to the receiver of the other and vise-versa (blue to black and black to blue)

Fiber Duplex Breakout

We designed the Fiber Duplex Board for creating simple fiber links to embedded devices. This board has the same pinout as our Serial Breakouts, so they will connect directly to the serial header of many dev boards such as the Arduino Pro or Pro Mini.

Fiber Duplex Breakout

Fiber Duplex Breakout

SPX-17510
$19.95

To create a fiber link between two dev boards, simply connect the Fiber Duplex Breakout to each board, connect them with two pieces of fiber cable, and then use the Serial library to send and receive data as you normally would.

This board also works in concert with the Serial Fiber Modem to create a fiber link from a dev board to a computer. We’ve even had success loading Arduino code over fiber this way (although because the fiber doesn’t carry a DTR signal, we had to manually reset the Arduino board during upload)


What is the CURRENT LIMIT Jumper?

This jumper can be found on both the Fiber Duplex and Simplex Breakouts. Because the boards will operate at both 3.3V and 5V, this jumper is provided to halve the current limiting resistance to the transmitter LED. In most cases, you’ll never need to close this jumper because the LED will simply operate at 3.3V with reduced brightness. If you’re having trouble transmitting over a long distance at 3.3V, however, closing this jumper will allow the LED to operate at it’s full rated current.

BE CAREFUL! Do not close the CURRENT LIMIT jumper and operate at 5V, this will overdrive the LED and could burn it out.

Resources

So that's it, putting your Arduino on fiber can be fun and easy! In the comments, I'd love to hear what application you have in mind for these boards. For your convenience, here are datasheets for the Industrial Fiber Optics parts as well as the plastic fiber that we carry:

Also, it can be helpful to brush up on the basics of serial communication if you're going to be building and troubleshooting serial links. Here's our tutorial on the subject:

Serial Communication

December 18, 2012

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

Happy Hacking!


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

Introduction to the Raspberry Pi GPIO and Physical Computing

$
0
0

Introduction to the Raspberry Pi GPIO and Physical Computing a learn.sparkfun.com tutorial

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

Introduction

Congrats, you’ve picked up your first Raspberry Pi - perhaps the cheapest and smallest computer you’ve ever bought! However, it sure doesn’t look like any computer you’re accustomed to, so let’s talk through the basics to get your Raspberry Pi up and running as a full desktop. We're also going to learn to interact with the GPIO, and hook up an atmospheric sensor to read in some data with Python. Let's start eating up this Pi!

alt text

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 and if you aren't familiar with them.

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.

Qwiic SHIM for Raspberry Pi Hookup Guide

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

Raspberry Pi 4 Kit Hookup Guide

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

Hardware Overview and Hookup

As the Raspberry Pi is a fully functioning computer, it needs the peripherals that a computer you may be accustomed to has to be fully interactive. We’ll need six crucial components to get the Raspberry Pi up and running, but we’ll also take a look at some additional hardware that are often times used with the Pi. Let’s start with what’s required!

General hardware for setup
  • Monitor - A monitor is basically required for the initial setup and configuration of the operating system. If you’ll be using SSH to connect to your Raspberry Pi, then you won’t need the monitor after setup (Check out this tutorial that walks you through SSH and the Pi!) Make sure your monitor has an HDMI input.
  • microSD Card - The microSD Card stores the operating system and files. If you bought a kit, the microSD card might have already been formatted for use. Otherwise, you’ll to manually install an OS’s image onto the mciroSD card to load it on your Pi
  • Keyboard and Mouse - You can either buy these together (the mouse is a part of the keyboard) or seperately
  • HDMI Cables - You’ll need an HDMI cable to connect the Raspberry Pi to a monitor. Different Raspberry Pi models have different HDMI cable requirements, but the newest model (Raspberry Pi 4) requires an HDMI to Micro HDMI Cable.
  • Power Supply - Different Raspberry Pi models have different USB connections and power requirements, but the newest model (Raspberry Pi 4) requires a USB Type C to C Cable and Wall Adapter.
Additional hardware
  • Heat Sink - Heat sinks are popular for users who are overclocking the CPU, so the Pi is running too hot. If the temperature of the CPU becomes too hot, a heat sink will passively cool air near the CPU to assist in cooling the processor. The heat sink can double as somewhat of a protective case as well. If you think you might need a heat sink, you can use the following command in the terminal to see the temperature of your Pi: hot./opt/vc/bin/vcgencmd measure_temp

  • Case - Since the Raspberry Pi comes as an exposed circuit board, you might want to protect it from dust and damage with a case. A variety of companies make cases for the Pi; perhaps the most notable case is the Rasberry Pi 400, which essentially uses a keyboard as a case for the Raspberry Pi. Built by the Raspberry Pi Foundation, it extends the Pi ports through the back of the keyboard as to not limit interactability.

  • Ethernet Cable - Depending on the Raspberry Pi model you have, and if you'd like to bypass wireless connections, pick up an ethernet cable to plug into the world wide web!

  • Speakers - If you'd like to play music or sound from your Pi, you'll need a set of speakers. Any standard set of speakers with a 3.5 mm jack should do...they will connect into the AV jack on the side of the board.

Quick Note on the Different Raspberry Pi Versions

The Raspberry Pi comes in a variety of form factors - Zero, 2, 3, etc. - for different use cases. The layout varies slightly between the boards, but most of the connections are the same. For the purpose of this tutorial, we'll be focusing on the most recent version, the Raspberry Pi 4. Still, if you're using another model, double check the connections required by consulting the hookup guide for the exact model when collecting the hardware you need.

Specific Hardware Required

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

Lucky for us, SparkFun has a kit that practically does the work for you in supplying the appropriate hardware and supporting the least frustrating experience possible - the SparkFun Raspberry Pi 4 Desktop Kit. Besides including the Raspberry Pi 4 (4GB), it comes with the Logitech K400Plus wireless keyboard (with a trackpad), a USB Type C to C Cable and Wall Adapter for power, a metal heatsink case, a 64GB MicroSD Card, and an HDMI to Micro HDMI Cable. All that you need to supply is the monitor.

This kit also comes with the Qwiic SHIM, which a crucial component that we will use to interact with the GPIO.

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

SparkFun Raspberry Pi 4 Desktop Kit - 4GB

KIT-16386
$159.95

SparkFun Atmospheric Sensor Breakout - BME280 (Qwiic)

We will also utilize one of the BME280 environmental breakout because it has a wide variety of precise data to offer and can be connected through Qwiic, which means we won't be hindered by soldering and can get right into coding.

SparkFun Atmospheric Sensor Breakout - BME280 (Qwiic)

SparkFun Atmospheric Sensor Breakout - BME280 (Qwiic)

SEN-15440
$14.95

Putting it All Together

Fortunately, there is very little additional knowledge for putting it all together. Simply connect the mouse and keyboard via USB, the power supply via USB-C (don't forget to plug the other end into a wall adapter), the HDMI into the both the monitor and the Pi, and load the microSD card into its slot. Besides making sure the wires don't criss-cross and make a mess, you're ready to start your desktop computer!

Pi Hooked-Up

GPIO Pins Overview

Okay, so we've hooked up the necessary hardware to the Raspberry Pi, and you're itching to start using it as a general-purpose PC for web surfing and Youtube watching and looking at cat memes. But where the Pi really shines is with its 40-pin GPIO (General Purpose Input & Output). The GPIO enables you to switch devices on and off (output) or receive data from sensors and switches (input). What this really means is that you can connect the Raspberry Pi to everything from a smart mirror to a weather station, to an asset tracking robot that displays its coordinates on a web server. Let's take a deeper dive into what's possible with the GPIO header! We can reference the GPIO Pinout Diagram provided by the Raspberry Pi Foundation below as a visual guide for understanding the pins:

Pi GPIO Pinout
Power Pins

Let's start with the power pins, which include both 3.3V and 5V. These pins transmit power as output to power attached peripherals.

Ground

And if we’re going to be rigging up electrical circuits here with power, then we’ll need a ground. You’ll find plenty of grounds within the pins as well.

Standard GPIO Pins

Take out the power and ground pins, and you’ll be left with the pins that are dedicated to sending output and receiving input. All of these can be used for straightforward input/output tasks!

Chatty Cathy Pins

Some of the standard GPIO pins are used for communication purposes. Here's a quick overview of these communication protocols!

  • SPI pins– The Serial Peripheral Interface (SPI) is a communication protocol used to transfer data between micro-computers like the Raspberry Pi and peripheral devices. The MISO pin receives data, and the MOSI pin sends data from the Raspberry Pi. Furthermore, the serial clock pin sends pulses at a regular frequency between the Raspberry Pi and the SPI device at the same speed in which the devices to transfer data to each other.
  • UART pins– UART stands for universal asynchronous receiver-transmitter, which is a physical circuit designed to send and recieve data.
  • PWM pins– PWM means “pulse width modification,” which is a communication protocol best used with stuff that moves and lights up: motors, LEDs, and so on.
  • I2C pins– I2c is short for inter-integrated circuit (two “inters”). It works similarly to SPI, but it doesn’t force you to use nearly so many pins.
Identifying Pins

There are two ways to identify GPIO pins...the first is by its physical position on the board, or its BOARD name. It also has a Broadcom SOC channel (BCM) name. By opening the terminal and running pinout as a command, it will return a map of the Raspberry Pi GPIO pins and their names based on the Broadcom chip on board.

The image below is the map for the Raspberry Pi 4 based on the pinout command:

alt text

If you really want to get deep into the Raspberry Pi GPIO pinout, there is an incredibly thorough Raspberry Pi GPIO pinout guide that is interactive and steps through each type of pin on-board. This general overview outlined above should be enough to get us started on our project though!

Operating System Setup

Okay, so the hardware is setup properly! If you picked up a kit like we did for this project, the Raspberry Pi OS image should be installed on the microSD card. If you're using a blank microSD card, you'll have to either visit The Raspberry Pi Foundation to install the appropriate image, or you can install a different operating system image on the MicroSD card. Some other notable operating systems are OSMC, RetroPie, Ubuntu, Rokos, and dozens others.

For the purpose of this tutorial, we will stick with Raspberry Pi's official supported operating system, Raspberry Pi OS (formally known as Raspbian).

When the Raspberry Pi receives power and boots up, it will load the desktop with a glorious wallpaper of the sun rising over Bagan, Myanmar.

Desktop

It will quickly have a pop-up that will guide you through setting up the OS, including setting the location, date, time, password, WiFi, and doing a few software updates. The screens should progress like the images below, and then the Raspberry Pi will update.

Set country, language, and timezone

Set Country
Change password to something other than password

Change Password
Select your local WiFi network

Select WiFi Network
The Pi will update the software

Update Software

Once the Pi restarts, it will bring you back to main desktop page once more. The main menu on the lower left is comprised of a lightweight open-source programs packaged within Raspbian.

Main Menu

Also along the top right of the screen, you should see a globe icon for Chromium. This is your Internet browser, and if you set up your network settings you can browse the web here. Next along is the file manager, which allows you to browse the files on your SD card and external USB storage. Finally the black icon opens up Terminal. This allows you to type commands directly, and for advanced users can be a faster and more flexible way to perform certain tasks.

There are other applications within the operating system that will prove useful for us, specifically a text editor so that we can write and run code. For this project, we'll specifically use Thonny, which is a Python(3) IDE that can both write and run code from the application. Another notable application in Raspbian is VNC, which allows you to remotely control the desktop interface of your Pi from another computer.

Python Overview and Reading in Sensor Data

The Raspberry Pi Foundation has specifically selected Python as the main language for Raspberry Pi because of its ease of use, power, versatility, and open-source mentality. Python comes pre-installed on Raspbian, so you can load an IDE like Thonny and quickly start coding.

If you've never coded in Python before, be sure to check out our tutorial on Coding in Python...it will get you up and running with variables, operators, objects, data structures, and much more. It will be important to have a basic understanding of Python to interact with the GPIO, so knowing variables, functions, operators, and classes is good, even if you just understand them at a high level and can't write them yourself!

Using gpiozero to Interact With GPIO

We want to dip our toes into the world of physical computing with the world of Raspberry Pi, and one way to do this is to learn to interact with the GPIO. There's a fantastic Python library called gpiozero that makes it quite easy to interact with the GPIO, and it already comes pre-installed on Raspbian.

In Python, libraries and functions used in a script must be imported by name at the top of the file, so you can either import the entire libray,

import gpiozero

or you can import just a component or two:

from gpiozero import Button

You'll need to set the GPIO pins you're using on the Pi to the respective component chosen with gpiozero. For example, if you have hooked up an LED to pin number 17 on the Pi, you could refer to it a multitude of ways with this Python library (remember how the GPIO pins can have many names?)

led = LED(17)
led = LED("GPIO17")
led = LED("BOARD11")

If you wanted to hook up an LED to a pin 17 and a ground pin, you could blink the LED simply with the code below. It imports the LED component from the library, as well as pause. After letting the board know what pin the LED is connected to, it will call that LED to blink, and then pause.

from gpiozero import LED
from signal import pause

red = LED(17)

red.blink()

pause()

Using a breadboard and wires, you can practically hook up anything to the GPIO and interact with it through gpiozero.

Using the Qwiic Way to Interact With GPIO

For our project, we want to hook up a Qwiic sensor to the Raspberry Pi, so we'll actually use the Qwiic SHIM included in the kit. We can just align the Qwiic SHIM with Pin 1 on the GPIO header, and slide it in. We don't need to assign which pins we're using - the SHIM is aligned with Pin 1 - but we do need import other libraries that are necessary for the additional atmosphere sensor.

sudo pip install sparkfun-qwiic-bme280

Now, we can import the BME280 libary, as well as a time and system libary to read in some basic temperature values. We'll need to ensure that the BME280 set to a variable, connected to the system, and then begin running the sensor like we would with Arduino.

The library that's important here is the qwiic_bme280. As you can see, the sensor itself will be set to mySensor the for the duration of the function, so whenever you see mySensor."something", it is calling an instance variable unique to each instance.

import qwiic_bme280
import time
import sys

def runExample():

    print("\nSparkFun BME280 Sensor + Raspberry Pi Example \n")
    mySensor = qwiic_bme280.QwiicBme280()

    if mySensor.isConnected() == False:
        print("The Qwiic BME280 device isn't connected to the system.", 
            file=sys.stderr)
        return

    mySensor.begin()

    while True:
        print("Humidity:\t%.3f" % mySensor.humidity)

        print("Pressure:\t%.3f" % mySensor.pressure)    

        print("Altitude:\t%.3f" % mySensor.altitude_feet)

        print("Temperature:\t%.2f" % mySensor.temperature_fahrenheit)       

        print("")

        time.sleep(1)

Challenge: How might you change the code above to only print the temperature if it exceeds 80 degrees Fahrenheit? (Hint: Remember your operators!)


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

Pro Micro RP2040 Hookup Guide

$
0
0

Pro Micro RP2040 Hookup Guide a learn.sparkfun.com tutorial

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

Introduction

The Pro Micro RP2040 is a low-cost, high-performance board with flexible digital interfaces featuring the Raspberry Pi Foundation's RP2040 microcontroller. The board uses well known Pro Micro footprint with castellated mounting holes.

SparkFun Pro Micro - RP2040

SparkFun Pro Micro - RP2040

DEV-17717
$9.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.

USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
SparkFun Pro Micro - RP2040

SparkFun Pro Micro - RP2040

DEV-17717
$9.95

Tools

You will need a soldering iron, solder, and general soldering accessories for a secure connection when using the plated through hole pads.

Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

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

Solder Lead Free - 15-gram Tube

TOL-09163
$3.50
2

Prototyping Accessories

Depending on your setup, you may want to use IC hooks for a temporary connection. However, you will want to solder header pins to connect devices to the plated through holes for a secure connection.

Breadboard - Self-Adhesive (White)

Breadboard - Self-Adhesive (White)

PRT-12002
$4.95
41
Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
IC Hook with Pigtail

IC Hook with Pigtail

CAB-09741
$4.95
9
Photon Stackable Header - 12 Pin

Photon Stackable Header - 12 Pin

PRT-14322
$0.50

For those that want to take advantage of the Qwiic enabled devices, you'll want to grab a Qwiic cable.

SparkFun Qwiic Cable Kit

SparkFun Qwiic Cable Kit

KIT-15081
$7.95
10
Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
Qwiic Cable - 500mm

Qwiic Cable - 500mm

PRT-14429
$1.95
1
Qwiic Cable - Breadboard Jumper (4-pin)

Qwiic Cable - Breadboard Jumper (4-pin)

PRT-14425
$1.50

Suggested Reading

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

Qwiic Connect System
Qwiic Connect System

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

How to Solder: Through-Hole Soldering

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

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.

Hardware Overview

Old School to New School

The Pro Micro RP2040 design uses the original Pro Micro and Qwiic Pro Micro USB C's footprint.

Older 5V/16MHz Pro MicroNewer 5V/16MHz Qwiic Pro Micro
Older Pro Micro
with ATmega32U4
Newer Qwiic Pro Micro USB C
with RP2040

The Pinout

All of the Pro Micro RP2040's GPIO and power pins are broken out to two, parallel headers. Some pins are for power input or output, other pins are dedicated GPIO pins. Further, the GPIO pins can have special function depending on how they are multiplexed Here's a map of which pin is where and what special hardware functions it may have.

Power

There are a variety of power and power-related nets broken out to connectors and through hole pads. Each pad has a castellated edge. THe back of the board also has the USB pins broken out for power

Front of Board with Power Nets Highlighted

These nets consist of the following:

  • V is the voltage provided from the USB connector.
  • + is the raw, unregulated voltage input for the Pro Micro RP2040. If the board is powered via USB (i.e. V), the voltage at this pin will be about 4.8V (USB's 5V minus a Schottky diode drop). On the other hand, if the board is powered externally, through this pin, the applied voltage can be up to 5.3V.
  • 3.3V is the voltage supplied to the on-board RP2040. We suggest using regulated 3.3V when connecting to this pin. If the board is powered through the raw "+" pin, this pin can be used as an output to supply 3.3V other devices.
  • RST can be used to restart the Pro Micro RP2040. There is a built-in reset button to reset the board. However, the pin is broken out if you need to access this pin externally. This pin is pulled high by a 10k&ohm; resistor on the board, and is active-low, so it must be connected to ground to initiate a reset. The Qwiic Pro Micro will remain "off" until the reset line is pulled back to high.
  • GND, of course, is the common, ground voltage (0V reference) for the system.

GPIO Pins

THe Pro Micro RP2040 breaks out the GPIO pins to plated through holes pads on the edge of the board. Each pad is castellated as well. On the back, there are additional pads to connect to the USB data and SWD programming pins.

Top of board

The Pro Micro's GPIO pins — 18 in all — are multi-talented. Every pin can be used as a digital input or output, for blinking LEDs or reading button presses. These pins are referenced via an integer value between 0 and 29.

Four pins feature analog to digital converters (ADCs) and can be used as analog inputs. These are useful for reading potentiometers or other analog devices.

All pins can be set with the pulse width modulation (PWM) functionality, which allows for a form of analog output. The RP2040 can only provide a total of up to 16 controllable PWM outputs.

There are hardware UART (serial), I2C, and SPI pins available as well. These can be used to interface with digital devices like serial LCDs, XBees, IMUs, and other serial sensors.

The RP2040 has 26 external interrupts, which allow you to instantly trigger a function when a pin goes either high, low, or changes state.

Qwiic Connector

The board includes a Qwiic connector to easily connect Qwiic enabled I2C devices to the board.

Qwiic Connector

On-Board LEDs.

There are two LEDs on the Pro Micro RP2040. The red LED indicates whether power is present. The other is the addressable WS2812 RGB LED. The addressable LED is connected to GPIO25. You'll need a WS2812 library to control that LED..

Power LED and Addressable WS2812 LED

External Flash Memory

The Pro Micro RP2040 includes a W25Q128JVPIM, which adds 128Mb (16MB) of flash memory externally.

External Flash Memory

Boot Button

The boot button is connected to the external flash memory. Pressing this button forces USB boot mode so that the board shows up as a USB mass storage device.

Boot Button

Reset Button

As explained earlier, there is a reset button to reset the RP2040. This adds the option of forcing the RP2040 into bootloader mode without needing to unplug/replug the board back into your USB port. To keep the board size at a minimum, the buttons are not labeled. To distinguish between the two buttons, just remember that the reset button is on the same side of the board as the reset pin.

Reset Button

Board Dimensions

The board measures 1.3" x 0.7". Keep in mind that the USB-C connector is not flush with the board and will protude about 0.05" from the edge of the board. Not included in the image below is the PCB thickness, which is 0.8mm. This is thinner than a majority of PCBs used for SparkFun original designs.

Board Dimensions

Hardware Hookup

Header pins were left off the Pro Micro RP2040 to allow users the flexibility of connecting any type of 0.1" header to the board. For temporary connections to the I/O pins, you could use IC hooks to test out the pins. However, you'll need to solder headers or wires of your choice to the board for a secure connection. For advanced users, you could also design a PCB to take advantage of the castellated edges for a lower profile. Here are a few tutorials to connect to the pads depending on your personal preference.

How to Solder: Through-Hole Soldering

September 19, 2013

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

Working with Wire

February 8, 2013

How to strip, crimp, and work with wire.

How to Solder: Castellated Mounting Holes

May 12, 2015

Tutorial showing how to solder castellated holes (or castellations). This might come in handy if you need to solder a module or PCB to another PCB. These castellations are becoming popular with integrated WiFi and Bluetooth modules.

In order to power and upload to the board, you will simply need a USB C cable connected to your computer.

Software

There are two methods of programming the RP2040. You can use MicroPython or C/C++ depending your personal preference. Stay tuned for more information!

Resources and Going Further

For more information, check out the resources below:


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


RP2040 Thing Plus Hookup Guide

$
0
0

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

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

Introduction

Introducing the SparkFun Thing Plus - RP2040, featuring the RP2040 microcontroller (MCU) on a Feather (Thing Plus) form-factor. Additionally, this development platform also provides an SD card slot, 16MB (128Mbit) flash memory, a JST single cell battery connector (with a charging circuit and attached fuel gauge sensor), a WS2812 RGB LED, JTAG (PTH) pins, and our signature Qwiic connector.

SparkFun Thing Plus - RP2040

SparkFun Thing Plus - RP2040

DEV-17745
$17.95$16.00

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

Required Materials

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

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

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$4.95
2
SparkFun Thing Plus - RP2040

SparkFun Thing Plus - RP2040

DEV-17745
$17.95$16.00

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

Li-Po Battery

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

Lithium Ion Battery - 400mAh

Lithium Ion Battery - 400mAh

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

Lithium Ion Battery - 2Ah

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

Lithium Ion Battery - 1Ah

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

Lithium Ion Battery - 110mAh

PRT-13853
$4.95
2

Jumper Modification

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

Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

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

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$7.95
3
Weller WLC100 Soldering Station

Weller WLC100 Soldering Station

TOL-14228
$44.95
1
Hobby Knife

Hobby Knife

TOL-09200
$2.95
2

Qwiic Example

If you would like to follow along with the examples below to interact with the physical world, you will also need the following items:

Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
SparkFun Qwiic 12 Bit ADC - 4 Channel (ADS1015)

SparkFun Qwiic 12 Bit ADC - 4 Channel (ADS1015)

DEV-15334
$9.95
Magnetic Screwdriver Set (20 Piece)

Magnetic Screwdriver Set (20 Piece)

TOL-15003
$6.95
1

Headers & Accessories

Headers are great for development purposes, letting users swap parts with just a set of jumper wires. If you would like to add headers to your board, check out some of the options for the Thing Plus or Feather form factor boards:

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
SparkFun Beginner Tool Kit

SparkFun Beginner Tool Kit

TOL-14681
$54.95
Photon Header - 12 Pin Female

Photon Header - 12 Pin Female

PRT-14321
$0.50
Feather Stackable Header Kit

Feather Stackable Header Kit

PRT-15187
$1.50
Header - 8-pin Female (PTH, 0.1")

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

PRT-11895
$0.50

Below is a sample selection of our other headers and soldering tools in our catalog. For a full selection of our available Headers or Soldering Tools, click on the associated link.

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.50
20
Arduino Stackable Header Kit - R3

Arduino Stackable Header Kit - R3

PRT-11417
$1.50
12
Raspberry Pi GPIO Tall Header - 2x20

Raspberry Pi GPIO Tall Header - 2x20

PRT-14017
$1.95
Female Headers

Female Headers

PRT-00115
$1.50
7
Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

TOL-14456
$14.95
11
Insulated Silicone Soldering Mat

Insulated Silicone Soldering Mat

TOL-14672
$9.95
7
Weller WE1010 Soldering Station

Weller WE1010 Soldering Station

TOL-14734
$129.00
4
Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$7.95
7

JTAG Functionality

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

J-Link EDU Base Programmer

J-Link EDU Base Programmer

PGM-15346
$60.00
J-Link EDU Mini Programmer

J-Link EDU Mini Programmer

PGM-15345
$18.00
1
J-Link BASE Compact Programmer

J-Link BASE Compact Programmer

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

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.50

Suggested Reading

Here are a few tutorials that may help users familiarize themselves with various aspects of the board.

How to Solder: Through-Hole Soldering

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

Serial Communication

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

Serial Peripheral Interface (SPI)

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

Battery Technologies

The basics behind the batteries used in portable electronic devices: LiPo, NiMH, coin cells, and alkaline.

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.

Qwiic Connect System

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

UF2 Bootloader

The SparkFun Thing Plus - RP2040 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.

Hardware Overview

Board Dimensions

The SparkFun RP2040 Thing Plus has a feather form factor and the board dimensions are illustrated in the drawing below.

Board Dimensions
Board dimensions (PDF) for the SparkFun RP2040 Thing Plus, in inches. (Click to enlarge)

Power

The SparkFun RP2040 Thing Plus only requires 3.3V to power the board. However, the simplest method to power the board is through the USB-C connector.

Power Connections
SparkFun RP2040 Thing Plus 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, and Qwiic I2C bus.
    • 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.
  • 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
SparkFun RP2040 Thing Plus power pins. (Click to enlarge)

Current Consumption

The Thing Plus - RP2040 consumes about 24mA on average, without any code running. The table below, summarizes the approximate current draw of the SparkFun RP2040 Thing Plus, through the USB-C connector, for various operational conditions.

Operation1st BootBOOTSEL ModeIdleIdleMicroPython
Battery ChargingGPIO 25
LED ON
WS2812 LED
White (max)
.uf2 BootREPL Open
Current Draw (mA) 11 (Idle)
20 (Peak)
11-14 -- -- 25 40-42 22-24 23-24

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
SparkFun RP2040 Thing Plus 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.

Charging Circuit
Charging circuit for the battery connector. (Click to enlarge)

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.

3V3 Power Circuit
Circuit for 3.3V power control. (Click to enlarge)

The P-channel MOSFET operation is based on the voltages at the MOSFET's gate and source pins. Depending on the power sources connected to the board, the MOSFET will act as a switch and control power from the battery to the AP2112 voltage regulator; detailed in the following table.

Power SourceMOSFETPower Control Description
GateSourceVGS MOSFET
Operation
USC-C
VUSB = 5V
Battery
VBatt = 3 - 4.2V
VGate - VSource
VUSB - VBatt
USB OnlyX--VGS = 5V MOSFET Off
RGS = ∞
Switch Open
Power to the AP2112 is supplied by the USC-C connection.
The MOSFET operation doesn't matter in this situation. However, power from the USB-C connection creates a positive gate threshold voltage and the MOSFET would behave as an open switch.
Battery Only--X-3V > VGS> -4.2V MOSFET On
RGS = Low
Switch Closed
Power to the AP2112 is supplied from the battery connection.
Power from the battery creates a negative gate threshold voltage. Therefore, the MOSFET acts like a closed switch and power to the AP2112 is provided from the battery.
USB & BatteryXX.8V < VGS< 2V MOSFET Off
RGS = ∞
Switch Open
Power to the AP2112 is supplied from the USC-C connection.
Power from the USB-C connection and battery would create a positive gate threshold voltage. Therefore, the MOSFET operate as an open switch and only allow power from the USB-C connection to the AP2112. Meanwhile, if the battery wasn't fully charged, the charging circuit would also be powered by the USC-C connection.

The enable pin of the AP2112 LDO also provides an additional amount of control for power to 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 SparkFun RP2040 Thing Plus. (Click to enlarge)
Protection

A BAT20J Schottky diode, in the power circuit, provides reverse current protection to the USB-C (VUSB) connector, from the battery (VBAT) or the board.

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 SparkFun RP2040 Thing Plus. (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.

JTAG Pins

Note: Currently there isn't support for the RP2040, using J-Link ARM programmers. The current recommended debug hardware is a second RP2040 microcontroller.

For users interested in debugging their code, the SWD pins are broken out on JTAG PTH pins. On the RP2040, the debug pins are:

  • Pin 24: SWCLK
  • Pin 25: SWDIO

JTAG PTH pins
JTAG pins on the SparkFun RP2040 Thing Plus. (Click to enlarge)

An individual debug access port (DAP) to each core is attached to a shared multidrop SWD bus. Each DAP will only respond to debug commands if correctly addressed by a SWD TARGETSEL command. In the event that the RP2040 locks up, a Rescue debug port is available to reset the microcontroller. The default address of each debug port is listed below:

  • Core 0: 0x01002927
  • Core 1: 0x11002927
  • Rescue DP: 0xf1002927
Rescue Debug Port Reset: The RP2040 can be reset through a Rescue Debug Port, allowing users to recover the Thing Plus - RP2040 from a locked up state. A Rescue Debug Port reset configures the PSM_RESTART_FLAG of the CHIP_RESET register and resets the RP2040. On startup, the CHIP_RESET register is read by the bootcode and when set, it causes the RP2040 to enter a safe state.

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 SparkFun RP2040 Thing Plus, an additional 16MB (128Mbit) of 133MHz memory is provided by a W25Q128JVPIM chip. The flash memory is required for the RP200 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
  • Pin 55: DATA 1
  • Pin 54: DATA 2
  • Pin 51: DATA 3

Flash Memory
W25Q128JVPIM flash memory on the SparkFun RP2040 Thing Plus. (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 SparkFun RP2040 Thing Plus 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
SparkFun RP2040 Thing Plus 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 on when no battery is present, 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 off 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 SparkFun RP2040 Thing Plus. (Click to enlarge)
Charge Cycle StateSTAT1
Shutdown
  • Thermal Shutdown
  • VDD< VBAT
Off (High Z)
No Battery PresentDimmed (High Z)
Charge Complete – StandbyOff (H)
PreconditioningOn (L)
Constant-Current Fast ChargeOn (L)
Constant VoltageOn (L)

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 SparkFun RP2040 Thing Plus. (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 SparkFun RP2040 Thing Plus. (Click to enlarge)

µSD Slot

The SparkFun RP2040 Thing Plus 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
  • GPIO 10: DATA 2
  • GPIO 11: DATA 1
  • GPIO 12: DATA 0
  • GPIO 14: CLK
  • GPIO 15: CMD

SD card slot
µSD card slot on the SparkFun RP2040 Thing Plus. (Click to enlarge)

Buttons

The Thing Plus -RP2040 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 SparkFun RP2040 Thing Plus. (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 SparkFun RP2040 Thing Plus. (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)

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 buse
I2C bus components on the SparkFun RP2040 Thing Plus. (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 23 - GPIO 26 to be aligned on the board's edge, for a consecutive, eight pin bus.

Shared GPIO pin
Shared pin for GPIO 07 and GPIO 23 on the SparkFun RP2040 Thing Plus. (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 SparkFun RP2040 Thing Plus. (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 SparkFun RP2040 Thing Plus. (Click to enlarge)

What is Qwiic?

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

Features of the Qwiic System

Keep your soldering iron at bay.

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

Qwiic Cable and Board

Qwiic cables connected to Spectral Sensor Breakout

Minimize your mistakes.

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

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

JST Connector

1mm pitch, 4-pin JST connector

Expand with ease.

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

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)

Software Overview

Note: The information contained in this section will be expanded upon as more resources become available.

The Raspberry Pi foundation provides excellent documentation for programming the RP2040 using either MicroPython or C++. Users can find the online documentation resources here.

Pico C/C++ SDK

In order to program the RP2040, users will use the Pico C/C++ SDK (software development kit), provided by the Raspberry Pi Foundation. Additionally, the Raspberry Pi Foundation has written a user manual, which includes software documentation and examples to accompany the Pico C/C++ SDK.

Note: For novice programmers, we recommend starting off with the Getting Started with Raspberry Pi Pico guide, from the Raspberry Pi Foundation. While the guide is intended for their RP2040 microcontroller board, it contains useful information for getting started with the Pico C/C++ SDK, building and uploading a program, debugging, and adapting the SDK to a third-party IDE. The Raspberry Pi Foundation also provides an installation script to install and setup the Pico C/C++ SDK on a Raspberry Pi computer, which can be downloaded from their GitHub repository.

As documented in the user manual, the Pico C/C++ SDK can be used with various integrated development environments (IDEs). In order to utilize the SDK, users will also need to install a few dependencies. The Raspberry Pi Foundation also provides more C/C++ examples for all the basic functionalities of the RP2040 in their GitHub repository.

Note: Users programming with the Pico C/C++ SDK will be creating a project, compiling, and building their code to a .uf2 file, which the SDK generates. The .uf2 firmware file is then copied to the board, when it is in BOOTSEL mode to upload the program.

Pico Python SDK

The Raspberry Pi Foundation has also ported MicroPython to support the RP2040 microcontroller. Additionally, the Raspberry Pi Foundation has written a user manual, which includes documentation and examples for the Pico Python SDK.

Note: For novice programmers, we recommend starting off with the Get Started with MicroPython on Raspberry Pi Pico book, writtten by the Raspberry Pi Foundation. While the book is intended for their RP2040 microcontroller board, it contains useful information for getting started with MircoPython, utilizing the REPL (Read–Eval–Print Loop), and several projects.

As documented in the user manual, the Pico Python SDK can be used with various integrated development environments (IDEs). In order to utilize the SDK, users will also need to install a few dependencies. The Raspberry Pi Foundation also provides MicroPython examples to accompany the book (noted above), which can be downloaded from their GitHub repository.

Read–Eval–Print Loop (REPL)

Users can access the REPL with their favorite serial terminal to instantly program the RP2040 microcontroller. After the MicroPython firmware is copied to the board, it will reset and show up on the computer's serial (or COM) port. Make sure to configure the serial terminal emulator for a baudrate of 115200 bps.

Remote MicroPython Shell on Windows 10: Below is an example of how to connect to a board using rshell on Windows 10:

  1. Install prerequisites
  • Python 3
  • Install Remote MicroPython Shell (rshell)
    • In PowerShell (run as admin), type pip3 install rshell
  • Open rshell
    • In PowerShell (run as admin), type rshell
  • In the remote shell, connect to the COM port for the RP2040 Thing Plus
    • Type connect serial COM[#] [baudrate]
      • To connect to COM3: connect serial COM3 115200
      • *Use the device manager to find the COM port for the RP2040 Thing Plus

    Hardware Assembly

    Note: The information contained in this section will be expanded upon as more resources become available.

    USB Programming

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

    The SparkFun Thing Plus - RP2040 attached to a computer. (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)

    Battery

    For remote applications, the RP2040 Thing Plus can be powered through its 2-pin JST battery connector.

    Battery connected to the SparkFun Thing Plus - RP2040
    The SparkFun Thing Plus - RP2040 with a battery attached. (Click to enlarge)

    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)

    MicroPython Examples

    Note: The information contained in this section will be expanded upon as more resources become available.

    Below, are some MicroPython examples that can be copied and pasted into the REPL.

    LED Control

    This example turns on the GPIO 25 status LED. Try changing the led.value() value to 0.

    language:python
    from machine import Pin
    led = Pin(25, Pin.OUT)
    led.value(1)
    
    # Include blank carriage returns
    

    WS2812 Control

    This example controls the WS2812 RGB LED on the board. Try changing the r, g, and b values (range is 0 - 255).

    language:python
    # Example using PIO to drive a WS2812 LED
    // Copy and paste directly into REPL from TeraTerm
    // Make sure baudrate is set to 115200 bps
    
    import array, time
    from machine import Pin
    import rp2
    
    # Configure the number of WS2812 LEDs.
    NUM_LEDS = 1
    
    
    @rp2.asm_pio(sideset_init=rp2.PIO.OUT_LOW, out_shiftdir=rp2.PIO.SHIFT_LEFT, autopull=True, pull_thresh=24)
    def ws2812():
    T1 = 2
    T2 = 5
    T3 = 3
    wrap_target()
    label("bitloop")
    out(x, 1)               .side(0)    [T3 - 1]
    jmp(not_x, "do_zero")   .side(1)    [T1 - 1]
    jmp("bitloop")          .side(1)    [T2 - 1]
    label("do_zero")
    nop()                   .side(0)    [T2 - 1]
    wrap()
    
    
    
    
    
    
    # Create the StateMachine with the ws2812 program, outputting on Pin(08).
    sm = rp2.StateMachine(0, ws2812, freq=8_000_000, sideset_base=Pin(08))
    
    # Start the StateMachine, it will wait for data on its FIFO.
    sm.active(1)
    
    # Display a pattern on the LEDs via an array of LED RGB values.
    ar = array.array("I", [0 for _ in range(NUM_LEDS)])
    
    # Cycle colours.
    for i in range(4 * NUM_LEDS):
    for j in range(NUM_LEDS):
    r = 255
    b = 255
    g = 255
    ar[j] = r << 16 | g << 8 | b
    sm.put(ar, 8)
    
    
    
    
    # Include blank carriage returns
    

    OLED Control

    This example displays a bitmap and text on two OLED screens. For this example, users will need the Micro OLED Breakout (Qwiic), the Qwiic OLED Display, and a Qwiic cable kit. Users will need to upload a modified version of the MicroPython firmware, which includes the SSD1306 display driver.

    OLED demo
    An example of the Thing Plus - RP2040 running with two OLED displays. (Click to enlarge)
    language:python
    # Display Image & text on I2C driven ssd1306 OLED display 
    from machine import Pin, I2C
    from ssd1306 import SSD1306_I2C
    import framebuf
    
    WIDTH_1  = 64                                             # oled display width
    HEIGHT_1 = 48                                             # oled display height
    WIDTH_2  = 128                                            # oled display width
    HEIGHT_2 = 32                                             # oled display height
    
    i2c = I2C(1)                                            # Init I2C using I2C0 defaults, SCL=Pin(GP9), SDA=Pin(GP8), freq=400000
    print("I2C Address      : "+hex(i2c.scan()[0]).upper()) # Display device address
    print("I2C Configuration: "+str(i2c))                   # Display I2C config
    
    
    oled1 = SSD1306_I2C(WIDTH_1, HEIGHT_1,  i2c, addr=0x3D)      # Init oled_1 display
    
    # SparkFun logo as 32x48 bytearray
    buffer[:] = [\
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, \
    0xFF, 0xFF, 0xFF, 0x0F, 0x07, 0x07, 0x06, 0x06, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x07, 0x0F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, \
    0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xE0, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, \
    0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xFD, 0xFF, \
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, \
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x07, 0x01, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, \
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, \
    0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, \
    0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
    
    
    # Load the SparkFUn logo into the framebuffer (the image is 32x48)
    fb = framebuf.FrameBuffer(buffer, 64, 48, framebuf.MONO_VLSB)
    
    # Clear the oled display in case it has junk on it.
    oled1.fill(0)
    
    # Blit the image from the framebuffer to the oled display
    oled1.blit(fb, 0, 0)
    
    # Finally update the oled display so the image & text is displayed
    oled1.show()
    
    oled2 = SSD1306_I2C(WIDTH_2, HEIGHT_2,  i2c, addr=0x3C)      # Init oled_2 display
    
    # Clear the oled display in case it has junk on it.
    oled2.fill(0)
    
    # Add some text
    oled2.text("SparkFun Thing",5,5)
    oled2.text("Plus - RP2040",5,15)
    oled2.text("(DEV-17745)",5,25)
    
    oled2.show()
    
    # Include blank carriage returns
    

    Resources and Going Further

    For more on the Artemis Development Kit, check out the links below:


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

    MicroMod RP2040 Processor Board Hookup Guide

    $
    0
    0

    MicroMod RP2040 Processor Board Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    The MicroMod RP2040 Processor Board is a low-cost, high-performance board with flexible digital interfaces featuring the Raspberry Pi Foundation's RP2040 microcontroller. The board takes advantage of the MicroMod M.2 connector to easily swap out processor boards on carrier boards.

    SparkFun MicroMod RP2040 Processor

    SparkFun MicroMod RP2040 Processor

    DEV-17720
    $11.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
    SparkFun Mini Screwdriver

    SparkFun Mini Screwdriver

    TOL-09146
    $0.95
    3
    USB 3.1 Cable A to C - 3 Foot

    USB 3.1 Cable A to C - 3 Foot

    CAB-14743
    $4.95
    2
    SparkFun MicroMod RP2040 Processor

    SparkFun MicroMod RP2040 Processor

    DEV-17720
    $11.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.

    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.

    Getting Started with MicroMod

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

    Hardware Overview

    M.2 Connector

    All of our MicroMod Processor Boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and specification to allow you to install your MicroMod Processor Board on your choice of carrier board. Most of the pins use a common pinout to ensure cross platform compatibility.

    M.2 Edge Connector Pins Highlighted

    RP2040 Processor

    The brains of the processor board is the Raspberry Pi Foundation's RP2040 ARM Cortex M0+ processor. An external 12MHz crystal is used as the clock for the RP2040. The RP2040 should be powered with 3.3V from a carrier board's M.2 connector. The logic levels for the I/O pins are 3.3V.

    IC highlighted

    Flash Memory

    On the back of the board is the W25Q128JVPIM, which adds 128Mb (16MB) of flash memory externally.

    flash memory highlighted

    LED

    A STAT LED is added to the top side of the board. This is useful debugging or as a status indicator. This is connected to GPIO25.

    stat LED highlighted

    MicroMod RP2040 Processor Pin Functionality

    The complete pin map can be found in the table below.

    Heads up! The pin table below and schematic both include the RP2040 pin associated with each MicroMod pin and this correlation can be used to identify alternate uses for pins on the RP2040 Processor Board. For many of the General Purpose I/O pins and other pins with multiple signal options, refer to your Carrier Board's Hookup Guide for information on how those pins are configured what they are used for. Not all pins are used on every Carrier Board.

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

    AUDIOUARTGPIO/BUSI2CSDIOSPIDedicated
    Alternate
    Function
    Primary
    Function
    RP2040 GPIO PinBottom
    Pin
       Top   
    Pin
    RP2040 GPIO Pin
    Primary
    Function
    Alternate
    Function
    (Not Connected)*75GND
    3.3V7473GPIO21
    3.3V7271GPIO22
    SPI_CS1SDIO_DATA3GPIO97069GPIO23
    AUD_OUTSDIO_DATA2GPIO106867-
    AUD_INSDIO_DATA1GPIO116665GPIO28G9
    SDIO_DATA0SPI_CIPO1GPIO126463GPIO25G10
    SDIO_CMDSPI_COPI1GPIO156261GPIO20SPI_CIPOG4
    SDIO_SCKSPI_SCK1GPIO146059GPIO23SPI_COPIG7
    AUD_MCLKPWM1GPIO245857GPIO22SPI_SCKG6
    AUD_OUTSDIO_DAT2GPIO105655GPIO21SPI_CSG5
    AUD_INSDIO_DAT1GPIO115453-
    AUD_LRCLKCTS1GPIO25251-
    AUD_BCLKUART_RTS1GPIO35049BATT_VIN
    G4SPI_CIPOGPIO204847GPIO24PWM1AUD_MCLK
    G3GPIO194645GND
    G2GPIO184443-
    G1GPIO174241-
    G0GPIO164039GND
    A1GPIO273837USBHOST_D-
    GND3635USBHOST_D+
    A0GPIO263433GND
    PWM0GPIO133231Module Key
    Module Key3029Module Key
    Module Key2827Module Key
    Module Key2625Module Key
    Module Key2423SWDIO
    I2C_INTUART_TX2GPIO82221SWDCK
    SPI_CS1SDIO_DAT3UART_RX2GPIO92019GPIO1UART_RX1
    D1GPIO71817GPIO0UART_TX1
    TX2I2C_INTGPIO81615GPIO2UART_CTS1AUD_LRCLK
    I2C_SCLGPIO51413GPIO3UART_RTS1AUD_BCLK
    I2C_SDAGPIO41211BOOT
    D0GPIO6109USB_VIN
    -87GND
    RESET65USB_D-
    -43USB_D+
    3.3V_IN21GND
    FunctionBottom
    Pin
       Top   
    Pin
    Function
    (Not Connected)*75GND
    3.3V7473G5 / BUS5
    RTC_3V_BATT7271G6 / BUS6
    SPI_CS1SDIO_DATA37069G7 / BUS7
    SDIO_DATA26867G8
    SDIO_DATA16665G9ADC_D- CAM_HSYNC
    SPI_CIPO1SDIO_DATA06463G10ADC_D+CAM_VSYNC
    SPI COPI1SDIO_CMD6261SPI_CIPO
    SPI SCK1SDIO_SCK6059SPI_COPILED_DAT
    AUD_MCLK5857SPI_SCKLED_CLK
    CAM_MCLKPCM_OUTI2S_OUTAUD_OUT5655SPI_CS
    CAM_PCLKPCM_INI2S_INAUD_IN5453I2C_SCL1
    PDM_DATAPCM_SYNCI2S_WSAUD_LRCLK5251I2C_SDA1
    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_TX22221SWDCK
    UART_RX22019UART_RX1
    CAM_TRIGD11817UART_TX1
    I2C_INT1615UART_CTS1
    I2C_SCL1413UART_RTS1
    I2C_SDA1211BOOT (Open Drain)
    D0109USB_VIN
    SWOG1187GND
    RESET# (Open Drain)65USB_D-
    3.3V_EN43USB_D+
    3.3V21GND
    Signal GroupSignalI/ODescriptionVoltage
    Power3.3VI3.3V Source3.3V
    GNDReturn current path0V
    USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
    RTC_3V_BATTI3V 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 takes advantage of the standard MicroMod form factor.

    Board Dimensions

    Hardware Assembly

    If you have not already, make sure to check out the Getting Started with MicroMod: Hardware Hookup for information on inserting your Processor Board into your Carrier Board.

    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 RP2040 processor board into a carrier board, your setup may look like the following.

    MicroMod RP2040 Inserted Into a Carrier Board

    Software

    There are two methods of programming the RP2040. You can use MicroPython or C/C++ depending your personal preference. Stay tuned for more information!

    Resources and Going Further

    For more information, check out the resources below:


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

    Soil Moisture Sensor Hookup Guide

    $
    0
    0

    Soil Moisture Sensor Hookup Guide a learn.sparkfun.com tutorial

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

    Getting Started

    Have you ever wanted your plants to tell you when they need watered? Or know how saturated the soil in your garden is? With the SparkFun Soil Moisture Sensor, you can do just that! This tutorial will show you how to get started using the Soil Moisture Sensor as well as how to build your own soil moisture sensing project.

    SparkFun Soil Moisture Sensor

    SparkFun Soil Moisture Sensor

    SEN-13322
    $5.95
    15

    If you prefer not to solder, you can purchase the sensor with a 3-pin screw terminal pre-soldered onto the board.

    SparkFun Soil Moisture Sensor (with Screw Terminals)

    SparkFun Soil Moisture Sensor (with Screw Terminals)

    SEN-13637
    $6.95
    4

    And if you're really in a hurry, use our plug-and-play Qwiic Soil Moisture Sensor!

    SparkFun Qwiic Soil Moisture Sensor

    SparkFun Qwiic Soil Moisture Sensor

    SEN-17731
    $8.50

    Required Materials

    To follow along with the project at the end of this tutorial, you will need the following. You may not need everything, though, depending on what you already have and which sensor you prefer. Add it all to your cart with the button below and modify as necessary.

    Suggested Readings

    There isn't much to learning how to use the Soil Moisture Sensor. However, you may find the following concepts useful along the way.

    How to Solder: Through-Hole Soldering

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

    Voltage, Current, Resistance, and Ohm's Law

    Learn about Ohm's Law, one of the most fundamental equations in all electrical engineering.

    Analog to Digital Conversion

    The world is analog. Use analog to digital conversion to help digital devices interpret the world.

    Resistors

    A tutorial on all things resistors. What is a resistor, how do they behave in parallel/series, decoding the resistor color codes, and resistor applications.

    Soil moisture-sensing by hacking a solar light

    How to take a solar powered pathway light from a hardware store and make it into a crude soil moisture sensor.

    Hardware Overview and Assembly

    Our original Soil Moisture Sensor is pretty straightforward when it comes to hookup. There are only three pins to connect: VCC, GND, and SIG.

    soil moisture sensor

    You need to supply power to VCC and GND. We recommend not powering the sensor constantly to prevent corrosion of the probes (more on this in a bit). SIG provides an analog signal out that can be attached to the ADC pin on any microcontroller. The value read on SIG will vary depending on the voltage with which you power the sensor.

    Our Qwiic Soil Moisture Sensor utilizes the I2C protocol with the existing signals and the ATtiny85 MCU as the I2C gateway, which does all the nitty gritty stuff for you. The default I2C address is 0x28, which you can change by cutting the jumpers on the front of the board. The qwiic connector should be self-evident, and this board also has pins broken out for SPI programming.

    Qwiic Soil Moisture sensor with parts labelled

    Programming Pins

    For those of you who are interested in the Qwiic system but aren't quite set up yet, there are pins broken out such that you can use I2C or SPI protocols. See the image below for pin functionality.

    Programming pins of the Qwiic Sensor

    Theory of Operation

    The two probes are acting as a variable resistor – more water in the soil means better conductivity and results in a lower resistance and a higher SIG out. Your analog readings will vary depending on what voltage you use for Vcc as well as the resolution of your ADC pins.

    Powering the Soil Moisture Sensor

    If you're using Qwiic to power your board, then you're good to go. Otherwise, we recommend powering the Soil Moisture Sensor with between 3.3V - 5V. Please note that the analog value returned will vary depending on what voltage is provided for the sensor.

    One commonly known issue with soil moisture sensors is their short lifespan when exposed to a moist environment. To combat this, we've had the PCB coated in Gold Finishing (Electroless Nickel Immersion Gold).

    Another way to extend the lifespan of your sensor is to only power it when you take a reading. Using a digital pin set to HIGH on an Arduino, for example, is an easy way to accomplish this. If you wish to power the sensor with more than a digital pin on your microcontroller can provide, you could always use a transistor.

    Assembly

    If you bought the Soil Moisture Sensor that already has the 3-pin screw terminal attached, you may skip this section. Likewise, if you are using the Qwiic connector!

    There are a few different options for connecting the sensor to your circuit. You can solder on a 3-pin JST Jumper Wire Assembly if you need to easily switch sensors on your project. This pairs nicely with our JST to Breadboard Jumper connector.

    3-pin JST Jumper Wire Assembly

    Another option is to solder on a 3-pin 3.5mm Screw Pin Terminal for a slightly more robust connection.

    3-pin 3.5mm Screw Pin Terminal

    Of course, you can always solder some hookup wire straight to the sensor.

    If you've opted for the Qwiic version of this board, assembly is a breeze.

    Qwiic cable plugged into the soil moisture sensor qwiic port

    Weatherproofing

    If you intend to use this sensor outdoors, we recommend adding a little protection to the PCB to extend its lifespan. You could always use good ol' fashioned hot glue. However, hot glue does not hold up well in the sun and is only recommended for projects that will not be exposed to high temperatures. For projects that need to be able to withstand all the elements, you could use a conformal coating to cover the SMD parts on the PCB as well as your solder connections.

    wires soldered to sensor

    Wires have been soldered to this sensor. All the SMD parts and solder joints have then been covered in conformal coating.

    Soil Moisture Sensing Basic Example

    Note: 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.

    For this first example, we will connect the sensor to a RedBoard or other Arduino-compatible board in a minimalist fashion to show its output over the serial terminal.

    Connect your Soil Moisture Sensor to your board as shown in the diagram below.

    simple hookup

    Once the circuit is built, upload the following code to your RedBoard or Arduino.

    language:c
    /*  Soil Mositure Basic Example
        This sketch was written by SparkFun Electronics
        Joel Bartlett 
        August 31, 2015
    
        Basic skecth to print out soil moisture values to the Serial Monitor 
    
        Released under the MIT License(http://opensource.org/licenses/MIT)
    */
    
    int val = 0; //value for storing moisture value 
    int soilPin = A0;//Declare a variable for the soil moisture sensor 
    int soilPower = 7;//Variable for Soil moisture Power
    
    //Rather than powering the sensor through the 3.3V or 5V pins, 
    //we'll use a digital pin to power the sensor. This will 
    //prevent corrosion of the sensor as it sits in the soil. 
    
    void setup() 
    {
      Serial.begin(9600);   // open serial over USB
    
      pinMode(soilPower, OUTPUT);//Set D7 as an OUTPUT
      digitalWrite(soilPower, LOW);//Set to LOW so no power is flowing through the sensor
    }
    
    void loop() 
    {
    Serial.print("Soil Moisture = ");    
    //get soil moisture value from the function below and print it
    Serial.println(readSoil());
    
    //This 1 second timefrme is used so you can test the sensor and see it change in real-time.
    //For in-plant applications, you will want to take readings much less frequently.
    delay(1000);//take a reading every second
    }
    //This is a function used to get the soil moisture content
    int readSoil()
    {
    
        digitalWrite(soilPower, HIGH);//turn D7 "On"
        delay(10);//wait 10 milliseconds 
        val = analogRead(soilPin);//Read the SIG value form sensor 
        digitalWrite(soilPower, LOW);//turn D7 "Off"
        return val;//send current moisture value
    }
    

    Note that in the code, we are powering the soil moisture sensor with a digital pin on the RedBoard, not directly from 3.3V or 5V. Since this is a 5V device, the digital IO pins have a HIGH voltage of ~5V.

    Once the sketch is uploaded, open a Serial Monitor window to see the output from the RedBoard. You should see a value at or close to 0 when the sensor is not touching anything. To see it sense moisture, you can grab both probes with your hand. The moisture from your body will be enough for the sensor to detect.

    Further Examples

    The Qwiic version of this board was built in cooperation with Zio Smart Prototyping. They've got some great examples in their Qwiic Soil Sensor GitHub Repository, which we've forked here.

    The Qwiic Soil Moisture Sensor can be connected to a Qwiic Redboard as shown here:

    Qwiic Redboard and Qwiic Soil Moisture sensor connected by Qwiic cable

    Click the image for a larger view

    Additional Projects

    To connect your plant monitor to the Internet of Things, check out this experiment from our SparkFun Inventor's Kit for Photon. In it, we show how to connect the soil moisture sensor to an Internet connected device such as the Photon or the SparkFun Photon RedBoard.

    You can also learn how to use the soil moisture sensor with the Blynk app in the Blynk Experiemnt Guide. Get plant watering notifications right on your phone or other mobile device!

    Check out this great Instructables project from Circuito.io that uses the SparkFun Soil Moisture Sensor:

    Calibration

    System Calibration

    To get any sort of useful data out of your Soil Moisture Sensor, it is advised that you calibrate it to whatever soil you plan to monitor. Different types of soil can affect the sensor, and you may get different readings from one composition tot he next. Before you start storing moisture data or triggering events based on that value, you should see what values you are actually getting from your sensor. Using the sketch above, note what values your sensor outputs when the sensor is completely dry vs when the sensor is completely submerged in a shallow cup of water. Depending on what microcontoller you're using, the operating voltage of that microcontoller, and the resolution of its analog-to-digital converter, you're results will vary.

    For example, using the same circuit above, if I detach the VCC pin from D7 and attach it directly to the 5V supply on the RedBoard, you'll see the close to the following values in the serial monitor when the senor is dry (~0) and when it is completely saturated with moisture (~880).

    5V calibration output

    But, if I take the VCC pin and connect it to the 3.3V supply on the RedBoard, the values change. As expected, they get lower since there is less resolution between 0V and 3.3V than there is between 0V and 5V.

    3.3V calibration output

    Thus, it is difficult to write an example sketch that works for all platforms. It really depends on the operating voltage and ADC resolution of the board you're using.

    Soil Calibration

    Once you have an idea what values your sensor is outputting in completely dry and completely wet situations, it's time to calibrate your sensor for the specific soil you want to monitor. Do the same test above, only this time test your soil when it is as dry as possible, then measure it when the soil is completely saturated with moisture. Getting these values and comparing them to the ones from the previous calibration will give you the best insight into what values mean for your specific plant and soil. This test may take some trial and error and patience. Be careful not to over-water (or under-water) your plants during these tests.

    Once you have a good handle on the values you can expect, you can use the map() function to adjust your code accordingly.

    Soil Moisture Sensing Project

    For this next example, we're going to make a portable soil moisture sensor that will print the current moisture value to an LCD screen. We'll use the circuit from the previous example. This time we just need to add a Serial Enabled LCD Screen and portable power.

    Hook up your circuit as pictured below:

    Fritzing example of hooking up the Soil Moisture sensor to a SparkFun RedBoard

    Along with the soil moisture sensor, we have connected the LCD screen to 5V, GND, and digital pin 2 (D2) for serial communication (also can be changed in the code).

    Feel free to put your circuit in an enclosure of some sort. A SparkFun red box makes for a great project box. For this project, we are powering the ReadBoard with a 9V battery and 9V battery holder to make it portable.

    Sparkfun Soil moisture sensor with LCD screen

    The code for this is fairly straightforward. You will need the Software Serial library to interact with the serial LCD screen. If you do not have this library you can get it from the Arduino GitHub here. If you have never uploaded a library or want a quick refresher on how to do that, check out our tutorial here. Installation should not be necessary, as this library now comes with the Arduino IDE by default.

    For more specific information about the code, you can read the comments in the code itself:

    language:c
    // SparkFun Soil Moisture Sensor and Serial LCD example 1
    // By Sarah Al-Mutlaq 2015
    // Sketch reads sensor and desplays level and whether soil is wet or dry
    
    // Use the softwareserial library to create a new "soft" serial port
    // for the display. This prevents display corruption when uploading code.
    #include <SoftwareSerial.h>
    
    // Attach the serial display's RX line to digital pin 2
    SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused)
    
    
    // Here we are setting up some water thersholds that we will 
    // use later. Note that you will need to change these to match
    // your soil type and environment. 
    
    /********************************************************
     * Change these values based on your calibration values
     *******************************************************/
    int thresholdUp = 400;
    int thresholdDown = 250;
    
    // We are setting up the pin A0 on the redboard to be our sensor
    // pin input:
    
    int soilPin = A0;
    int soilPower = 7;//Variable for Soil moisture Power
    
    void setup(){
      mySerial.begin(9600); // set up serial port for 9600 baud (speed)
      delay(500); // wait for display to boot up
    
      pinMode(soilPower, OUTPUT);//Set D7 as an OUTPUT
      digitalWrite(soilPower, LOW);//Set to LOW so no power is flowing through the sensor
    }
    
    void loop(){
      // Here we are declaring a string, which are lines of words,
      // and we want DisplayWords to be the words displayed on
      // the LCD screen, which will change based on whether the soil
      // wet or dry based on our threshold values above.
      String DisplayWords;
    
      // We need to set up a pin to get the value that the soil 
      // moisture sensor is outputting, so sensorValue will get the
      // analog value from the sensor pin A0 on the redboard that we 
      // set up earlier.
    
      int sensorValue;
      sensorValue = readSoil();
    
      // move cursor to beginning of first line on LCD:
      mySerial.write(254); 
      mySerial.write(128);
    
      // clear display:
      mySerial.write(""); 
      mySerial.write("");
    
      // move cursor to beginning of first line of the LCD screen:
      mySerial.write(254); 
      mySerial.write(128);
    
      //Write what we want to desplay on the screen:
      mySerial.write("Water Level: ");
      mySerial.print(sensorValue); //Using .print instead of .write for values
    
      // Now we are going to check if the water level is below a 
      // out thresholdDown value we set earlier, and if it is have 
      // words "Dry, Water it!" display one column over on the first 
      // row:
    
      if (sensorValue <= thresholdDown){
        // move cursor to beginning of second line on LCD:
        mySerial.write(254); 
        mySerial.write(192);
    
        DisplayWords = "Dry, Water it!";
        mySerial.print(DisplayWords);
    
      // If the value is not below our thresholdDown value we want to 
      // check if it is above our thresholdUp value, and if it is 
      // change the display words to "Wet, Leave it!":
    
    
    
      } else if (sensorValue >= thresholdUp){
        // move cursor to beginning of second line on LCD:
        mySerial.write(254); 
        mySerial.write(192);
    
        DisplayWords = "Wet, Leave it!";
        mySerial.print(DisplayWords);
    
      // Otherwise if it is inbetween the two values we want it to 
      // the display it had, so if our soil was really wet and drying 
      // the words would only change to "Dry, Water it!" when it got to the lower threshold
      // (thresholdDown), but if it was dry and getting wetter the words
      // would only change to "Wet, Leave it!" when it got to the upper 
      // threshold (thresholdUp_):
    
      } else {
        // move cursor to beginning of second line on LCD:
        mySerial.write(254); 
        mySerial.write(192);
    
        mySerial.print(DisplayWords);
      }
    
      delay(500); //wait for half a second, so it is easier to read
    }
    
    //This is a function used to get the soil moisture content
    int readSoil()
    {
        digitalWrite(soilPower, HIGH);//turn D7 "On"
        delay(10);//wait 10 milliseconds 
        int val = analogRead(soilPin);//Read the SIG value form sensor 
        digitalWrite(soilPower, LOW);//turn D7 "Off"
        return val;//send current moisture value
    }
    

    This code has different values for an upper threshold and a lower one, so you have a middle zone that could either be wet or dry depending on whether the soil is drying out (coming down from being wet) or getting wet (coming up from being dry). If you don't want this middle zone, you can set both thresholds to the same value, but I have found that having this middle area is more similar to how soil actually works; there really isn't a point at which soil goes from being wet to dry. If you are interested in soil and how it reacts to water, you should read up on it; it can be very complicated and interesting.

    You will need to adjust the code variables anyway, since this will be unique to your setup, soil type, and how wet you actually want your soil to be. Using the calibration techniques mentioned above, test out the reading and play around with the values until you find some that fit your needs.

    Resources and Going Further

    For more information, check out the links below:

    SparkFun Soil Moisture Sensor (13322):

    SparkFun Soil Moisture Sensor with Screw Terminals (13637):

    SparkFun Qwiic Soil Moisture Sensor(17731):

    Zio:

    Still want more? Check out these other great SparkFun tutorials for more soil moisture sensing fun!

    SparkFun Inventor's Kit for Photon Experiment Guide

    Dive into the world of the Internet of Things with the SparkFun Inventor's Kit for Photon.

    Photon Weather Shield Hookup Guide V11

    Create Internet-connected weather projects with the SparkFun Weather Shield for the Photon.

    ESP32 Environment Sensor Shield Hookup Guide

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

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

    SparkFun expLoRaBLE Hookup Guide

    $
    0
    0

    SparkFun expLoRaBLE Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    The SparkFun LoRa Thing Plus – expLoRaBLE is a feather form-factor development board with the NM180100 system in package (SiP), from Northern Mechatronics. The NM180100 SiP includes a Semtex SX1262 LoRa module paired with the Apollo3 MCU, which is used in the SparkFun Artemis module. This provides the board with compatibility in the Arduino IDE, through our Apollo3 Arduino core. The Semtex SX1262 is a long range, low power RF tranceiver introduces LoRaWAN capabilities to the board. Additionally, both the BLE and LoRa capabilities of the expLoRaBLE allow it to operate as a Bluetooth enabled LoRa node.

    SparkFun LoRa Thing Plus - expLoRaBLE

    SparkFun LoRa Thing Plus - expLoRaBLE

    WRL-17506
    $49.95

    Required Materials

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

    SparkFun LoRa Thing Plus - expLoRaBLE

    SparkFun LoRa Thing Plus - expLoRaBLE

    WRL-17506
    $49.95
    Wide Band 4G LTE Internal LoRa Antenna

    Wide Band 4G LTE Internal LoRa Antenna

    WRL-17841
    $1.95
    USB 3.1 Cable A to C - 3 Foot

    USB 3.1 Cable A to C - 3 Foot

    CAB-14743
    $4.95
    2

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

    Li-Po Battery

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

    Lithium Ion Battery - 400mAh

    Lithium Ion Battery - 400mAh

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

    Lithium Ion Battery - 2Ah

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

    Lithium Ion Battery - 1Ah

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

    Lithium Ion Battery - 110mAh

    PRT-13853
    $4.95
    2

    Jumper Modification

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

    Solder Lead Free - 100-gram Spool

    Solder Lead Free - 100-gram Spool

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

    Chip Quik No-Clean Flux Pen - 10mL

    TOL-14579
    $7.95
    3
    Weller WLC100 Soldering Station

    Weller WLC100 Soldering Station

    TOL-14228
    $44.95
    1
    Hobby Knife

    Hobby Knife

    TOL-09200
    $2.95
    2

    Qwiic Example

    If you would like to follow along with the examples below to interact with the physical world, you will also need the following items:

    Qwiic Cable - 100mm

    Qwiic Cable - 100mm

    PRT-14427
    $1.50
    SparkFun Qwiic 12 Bit ADC - 4 Channel (ADS1015)

    SparkFun Qwiic 12 Bit ADC - 4 Channel (ADS1015)

    DEV-15334
    $10.50
    Magnetic Screwdriver Set (20 Piece)

    Magnetic Screwdriver Set (20 Piece)

    TOL-15003
    $6.95
    1

    Headers & Accessories

    Headers are great for development purposes, letting users swap parts with just a set of jumper wires. If you would like to add headers to your board, check out some of the options for the Thing Plus or Feather form factor boards:

    Break Away Headers - Straight

    Break Away Headers - Straight

    PRT-00116
    $1.50
    20
    SparkFun Beginner Tool Kit

    SparkFun Beginner Tool Kit

    TOL-14681
    $57.95
    Photon Header - 12 Pin Female

    Photon Header - 12 Pin Female

    PRT-14321
    $0.50
    Feather Stackable Header Kit

    Feather Stackable Header Kit

    PRT-15187
    $1.50
    Header - 8-pin Female (PTH, 0.1")

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

    PRT-11895
    $0.50

    Below is a sample selection of our other headers and soldering tools in our catalog. For a full selection of our available Headers or Soldering Tools, click on the associated link.

    Break Away Headers - Straight

    Break Away Headers - Straight

    PRT-00116
    $1.50
    20
    Arduino Stackable Header Kit - R3

    Arduino Stackable Header Kit - R3

    PRT-11417
    $1.50
    12
    Female Headers

    Female Headers

    PRT-00115
    $1.50
    7
    Raspberry Pi GPIO Tall Header - 2x20

    Raspberry Pi GPIO Tall Header - 2x20

    PRT-14017
    $1.95
    Soldering Iron - 60W (Adjustable Temperature)

    Soldering Iron - 60W (Adjustable Temperature)

    TOL-14456
    $14.95
    11
    Insulated Silicone Soldering Mat

    Insulated Silicone Soldering Mat

    TOL-14672
    $9.95
    7
    Weller WE1010 Soldering Station

    Weller WE1010 Soldering Station

    TOL-14734
    $129.00
    4
    Solder Lead Free - 100-gram Spool

    Solder Lead Free - 100-gram Spool

    TOL-09325
    $7.95
    7

    JTAG Functionality

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

    J-Link EDU Base Programmer

    J-Link EDU Base Programmer

    PGM-15346
    $60.00
    1
    J-Link EDU Mini Programmer

    J-Link EDU Mini Programmer

    PGM-15345
    $18.00
    1
    J-Link BASE Compact Programmer

    J-Link BASE Compact Programmer

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

    Header - 2x5 Pin (Male, 1.27mm)

    PRT-15362
    $1.50

    JTAG Functionality

    Users interested in modifying or updating the firmware on the Apollo3 will need an Arm® Programmer and need to solder on a JTAG header. We recommend these programmers from our catalog:
    J-Link EDU Base Programmer

    J-Link EDU Base Programmer

    PGM-15346
    $60.00
    1
    J-Link EDU Mini Programmer

    J-Link EDU Mini Programmer

    PGM-15345
    $18.00
    1
    J-Link BASE Compact Programmer

    J-Link BASE Compact Programmer

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

    Header - 2x5 Pin (Male, 1.27mm)

    PRT-15362
    $1.50

    Antennas

    Below, is a selection of a few LoRA antenna options from the antenna product category.

    Interface Cable RP-SMA to U.FL

    Interface Cable RP-SMA to U.FL

    WRL-00662
    $4.95
    1
    Pycom LoRa and Sigfox Antenna Kit - 915MHz

    Pycom LoRa and Sigfox Antenna Kit - 915MHz

    WRL-14676
    $11.95
    915MHz LoRa Antenna RP-SMA - 1/4 Wave 2dBi

    915MHz LoRa Antenna RP-SMA - 1/4 Wave 2dBi

    WRL-14875
    $8.95
    915MHz LoRa Antenna RP-SMA - 1/2 Wave 2dBi

    915MHz LoRa Antenna RP-SMA - 1/2 Wave 2dBi

    WRL-14876
    $7.95
    Wide Band 4G LTE Internal LoRa Antenna

    Wide Band 4G LTE Internal LoRa Antenna

    WRL-17841
    $1.95
    LoRa Fiberglass Antenna Type N - 5.8dBi (860-930MHz)

    LoRa Fiberglass Antenna Type N - 5.8dBi (860-930MHz)

    WRL-15597
    $49.95
    Interface Cable N to RP-SMA Cable - 1m

    Interface Cable N to RP-SMA Cable - 1m

    CAB-14911
    $7.95
    (*A diplexer is used to combine the BLE and LoRa signals to a single U.FL connection. Only the Wide Band 4G LTE Internal FPC Antenna is recommended for use as a combination LoRa and BLE antenna.)

    LoRa Gateways

    Below, is a selection of a few LoRA gateway options from the LoRa product category.

    LoRa Raspberry Pi 4 Gateway with Enclosure

    LoRa Raspberry Pi 4 Gateway with Enclosure

    WRL-16447
    $199.95
    1
    LoRa Raspberry Pi Gateway with Enclosure

    LoRa Raspberry Pi Gateway with Enclosure

    WRL-15336
    $199.95
    1
    Nebra Indoor HNT Hotspot Miner (915MHz)

    Nebra Indoor HNT Hotspot Miner (915MHz)

    WRL-17843
    $349.95
    Nebra Outdoor HNT Hotspot Miner (915MHz)

    Nebra Outdoor HNT Hotspot Miner (915MHz)

    WRL-17844
    $488.95
    SparkFun LoRa Gateway - 1-Channel (ESP32)

    SparkFun LoRa Gateway - 1-Channel (ESP32)

    WRL-15006
    $34.95
    3
    Interface Cable RP-SMA to U.FL

    Interface Cable RP-SMA to U.FL

    WRL-00662
    $4.95
    1
    915MHz LoRa Antenna RP-SMA - 1/4 Wave 2dBi

    915MHz LoRa Antenna RP-SMA - 1/4 Wave 2dBi

    WRL-14875
    $8.95

    Suggested Reading

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

    Serial Communication

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

    I2C

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

    Bluetooth Basics

    An overview of the Bluetooth wireless technology.

    Logic Levels

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

    Serial Peripheral Interface (SPI)

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

    ARM Programming

    How to program SAMD21 or SAMD51 boards (or other ARM processors).

    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.

    Three Quick Tips About Using U.FL

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

    LoRaWAN with ProRF and The Things Network

    Learn how to make a LoRaWAN node for your next long range IoT project and connect it to the internet with The Things Network!

    Artemis Development with Arduino

    Get our powerful Artemis based boards (Artemis Nano, BlackBoard Artemis, and BlackBoard Artemis ATP) blinking in less than 5 minutes using the SparkFun Artemis Arduino Core!

    Pulse Width Modulation

    An introduction to the concept of Pulse Width Modulation.

    Analog vs. Digital

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

    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.

    Artemis Development with the Arduino IDE

    This is an in-depth guide on developing in the Arduino IDE for the Artemis module and any Artemis microcontroller development board. Inside, users will find setup instructions and simple examples from blinking an LED and taking ADC measurements; to more complex features like BLE and I2C.

    Installing Arduino IDE

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

    Qwiic Connect System

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

    Hardware Overview

    Board Dimensions

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

    Board Dimensions
    Board dimensions (PDF) for the SparkFun expLoRaBLE, in inches. (Click to enlarge)

    USB-C Connector

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

    USB-C Connector
    USB-C connector on the SparkFun expLoRaBLE. (Click to enlarge)

    CH340E Serial-to-UART

    The CH340E allows the NM180100 to communicate with a computer/host device through its USB-C connection. This allows the board to show up as a device on the serial (or COM) port of the computer. Users will need to install the latest CH340 driver for the computer to recognize the board.

    How to Install CH340 Drivers

    August 6, 2019

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

    Power

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

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

    power
    SparkFun expLoRaBLE power connections. (Click to enlarge)

    Charging Circuit

    The charging circuit utilizes the MCP73831 linear charge management controller and is powered directly from the USB-C connector or USB. The controller is configured for a 500mA charge rate 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.

    NM180100 SiP

    The NM180100 SiP from Northern Mechatronics is the brains of the SparkFun expLoRaBLE. The system in package (SiP) includes an Apollo3 MCU connected to a Semtech SX1262 radio transceiver. The connection between the two ICs is laid out in the table below.

    NM180100 SiP
    NM180100 SiP on the SparkFun expLoRaBLE. (Click to enlarge)
    Apollo3SX1262Description
    PinNamePinName
    H6GPIO 3619NSSSPI Slave Select
    J6GPIO 3817MOSISPI Slave Input
    J5GPIO 4316MISOSPI Slave Output
    H5GPIO 4218SCKSPI Clock Input
    J8GPIO 3914BusyRadio Busy Indicator
    J9GPIO 4013DIO1Multipurpose Digital I/o
    H9GPIO 4706DIO3Multipurpose Digital I/o
    J7GPIO 4415NRESETRadio Reset Signal (Active Low)

    A breakdown of the NM180100 functionality is shown in the block diagram below and the functionality of each embedded chip is laid out in the following subsections. It should be noted, that the Bluetooth and LoRa antenna connections on the SparkFun expLoRaBLE share the same u.FL connector with the use of a diplexer. For more details on the NM180100 SiP, check out the datasheet.

    NM180100 Func. Block Diagram

    Note: While most users will utilize the USB connection for serial programming, the Apollo3 MCU in the NM180100 SiP can also be programmed through its JTAG or SWD pins. This might is useful for individuals developing and testing firmware that would be flashed directly onto the NM180100 SiP, such as in production for commercial applications. For more details on programming, please check out our ARM Programming tutorial

    ARM Programming

    May 23, 2019

    How to program SAMD21 or SAMD51 boards (or other ARM processors).
    SparkFun expLoRaBLE's JATG pins
    The JTAG pins on the SparkFun expLoRaBLE. (Click to enlarge)

    Apollo3 MCU

    For details on the Apollo3, users should refer to the Designing with the SparkFun Artemis hookup guide. Additionally, users can reference the following resources for more technical information:

    SX1262 RF Transceiver

    Note: In the US, LoRaWAN operates in the 915MHz frequency band (i.e. 902 to 928 MHz).

    The Semtech SX1262 module is a long range, low power, half-duplex transceiver with global LoRa® frequency coverage, capable of operating as a Long range (LoRa) wide area network (LoRaWAN) or frequency-shift keying (FSK) modem. The module was designed for long battery life with just 4.2 mA of active receive current consumption and it can transmit up to +22 dBm with the use of its highly efficient, integrated power amplifiers. The SX1262 is optimal for devices that are designed to comply with the physical layer requirements of the LoRaWAN specification released by the LoRa Alliance™. For more details on the SX1262, check out the datasheet.

    SX1262 Block Diagram
    Functional block diagram for the SX1262. (Click to enlarge)
    CharacteristicDescription
    Current
    Consumption
    4.2 to 10.1 mA (RX)
    32 to 118 mA (TX)
    Frequency Range150 to 960 MHz
    Modulation FSK, GFSK, MSK,
    GMSK and LoRa
    Link Budget170 dB (max)
    Bit Rate
    (programmable)
    FSK: .6 to 300 kb/s
    LoRa: .018 to 62.5 kb/s
    RF Sensitivity-104 to -148 dBm
    RF Output Power+14 to +22 dBm

    u.FL Antenna Connector

    Note: Make sure to utilize an antenna that is appropriate for your RF and/or BLE application.

    The Apollo3 BLE and SX1262 RF antenna connections share a single U.FL antenna connector with the use of a diplexer.

    U.FL connector
    Antenna connection on the SparkFun expLoRaBLE. (Click to enlarge)

    Breakout Pin Connections

    The pins from the NM180100 SiP are broken out into a feather form factor layout.

    breakout pins
    SparkFun expLoRaBLE breakout pins. (Click to enlarge)

    Power Pins

    The power pins aren't really I/O (Input/Output) connections for the microcontroller; however, they are pertinent to the board.

    Power pins
    SparkFun expLoRaBLE power pins. (Click to enlarge)

    The power I/O mostly consists of voltage supply pins. These pins are traditionally used as power sources for other pieces of hardware (like LEDs, potentiometers, and other circuits).

    • 3.3V - A regulated 3.3V voltage source.
      • Regulated from the USB 5V power and/or battery connection.
      • Used to power the NM180100 SiP and Qwiic I2C bus.
    • USB - The voltage from the USB-C connector, usually 5V.
    • VBAT - The voltage from the JST battery connector; meant for single cell LiPo batteries.
    • GND - The common ground or the 0V reference for the voltage supplies.
    Note: The EN pin is used to contol the 3.3V voltage regulator output (i.e. the boards power) from the battery or USB connection to the rest of the board.

    I/O Pins

    ⚡ Note: All the GPIO on the SparkFun LoRa Thing Plus – expLoRaBLE are 3.3V pins.

    There are 21 I/O pins broken out on this board, which can be used as digital inputs to or outputs from the NM180100 SiP.

    digital i/o
    I/O breakout pins and headers. (Click to enlarge)

    All of the SparkFun expLoRaBLE pins are broken out with .1" pitch spacing for headers. It is best practice to define the pinMode()(link) in the setup of each sketch (programs written in the Arduino IDE) for the pins used.

    Input

    When configured properly, an input pin will be looking for a HIGH or LOW state. Input pins are High Impedance and takes very little current to move the input pin from one state to another.

    Output

    When configured as an output the pin will be at a HIGH or LOW voltage. Output pins are Low Impedance: This means that they can provide a relatively substantial amount of current to other circuits.

    ⚡ Note: It should be noted that there are electrical limitations to the amount of current that the NM180100 SiP can sink or source. For more details, check out the Absolute Maximum Ratings section of the Electrical Characteristics on page 774 of the Apollo3 datasheet.

    Additional Functions

    There are several pins that have special functionality in addition to general digital I/O. These pins and their additional functions are listed in the tabs below. For more technical specifications on the I/O pins, you can refer to the Apollo 3 datasheet.

    Analog Input Pins

    Note: Be aware that the ADC input range is from 0 - 2V. Although connecting a sensor with an output to 3.3V is safe for the NM180100 SiP, it will saturate the ADC at 2V.

    The NM180100 SiP offers a 14-bit ADC input for eight of the SparkFun expLoRaBLE's I/O pins. This functionality is accessed in the Arduino IDE using the analogRead(pin) function.

    Note: By default, in the Arduino IDE, analogRead() returns a 10-bit value. To change the resolution of the value returned by the analogRead() function, use the analogReadResolution(bits) function.

    Annotated image of analog inputs
    Analog input pins on the SparkFun expLoRaBLE. (Click to enlarge)

    Note: To learn more about analog vs. digital signals, check out this great tutorial.


    Analog vs. Digital

    July 18, 2013

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

    Pulse Width Modulation (PWM) Output Pins

    The NM180100 SiP provides 16-bit PWM output for all of the SparkFun expLoRaBLE's twenty-one digital I/O pins. Additionally, the SCL line of the primary, Qwiic I2C bus and GPIO 10, which is connected to the status LED are also PWM capable outputs. This functionality is accessed in the Arduino IDE using the analogWrite(pin, value) function or the Servo library.

    Note: By default, in the Arduino IDE, analogWrite() accepts an 8-bit value. To change the resolution of the PWM signal for the analogWrite() function, use the analogWriteResolution(bits) function.

    (*The PWM output is the result of the NM180100 SiP's signal generator clock functionality and is not a true analog signal.)

    Annotated image of PWM pins
    PWM pins on the SparkFun expLoRaBLE. (Click to enlarge)

    Note: To learn more about pulse width modulation (PWM), check out this great tutorial.


    Pulse Width Modulation

    February 27, 2013

    An introduction to the concept of Pulse Width Modulation.

    Serial Communication Pins

    The SparkFun expLoRaBLE has two UART modules that can function independently of each other. By default, the dedicated UART port to the USB connection (Serial) can be accessed through the Arduino IDE using the serial communication module. D0 (RX) and D1 (TX) of the breakout I/O pins are connected to the secondary UART module.

    Annotated image of serial communication pins
    The available serial communication connections on the SparkFun expLoRaBLE.

    Note: To learn more about serial communication, check out this great tutorial.


    Serial Communication

    December 18, 2012

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

    SPI Communication

    The default SPI bus on the SparkFun expLoRaBLE is accessible through the Arduino IDE using the SPI module. By default, in the Arduino IDE, the SPI module is configured to utilize pins 25, 27, and 28.

    ConnectionPin
    SCK13
    SDI or CIPO12
    SDO or COPI11
    CSANY
    Note: To comply with the latest OSHW design practices, on the SparkFun expLoRaBLE 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.

    Annotated image of SPI pins
    The SPI pins on the SparkFun expLoRaBLE. (Click to enlarge)

    Note: To learn more about the serial peripheral interface (SPI) protocol, check out this great tutorial.


    Serial Peripheral Interface (SPI)

    January 14, 2013

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

    I2C Communication Pins

    The SparkFun expLoRaBLE has 2 I2C modules. The Qwiic connector is connected to the default I2C bus that is accessed through the Arduino IDE using the Wire module.

    Annotated image of I2C pins
    The available I2C bus connections for the the SparkFun expLoRaBLE. (Click to enlarge)

    Note: To learn more about the inter-integrated circuit (I2C) protocol, check out this great tutorial.


    I2C

    July 8, 2013

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

    Buttons

    There are two buttons on SparkFun expLoRaBLE; a reset and GPIO button.

    Reset Button

    The reset (RST) button allows users to reset the program running on the NM180100 SiP without unplugging the board.

    Reset Button
    Reset button on the SparkFun expLoRaBLE. (Click to enlarge)

    User Button

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

    pinMode(D10, INPUT_PULLUP);
    

    The user (10 ) button allows users to short GPIO 10 to ground (GND).

    GPIO 10 Button
    GPIO 10 button on the SparkFun expLoRaBLE. (Click to enlarge)

    Indicator LEDs

    There are five indication LEDs on the SparkFun expLoRaBLE:

    • Status/Pin 18? (Blue)
    • Power (Red)
    • Battery Charging (Yellow)
    • RX (Yellow) and TX (Green)

    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
    SparkFun expLoRaBLE Thing Plus 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 (*dimmed), when the charge management controller is in standby (after the battery charging has been completed), or when the charge management controller is shutdown. The LED will be on when the charge management controller is in the process of charging the battery. For more information, please refer to the MCP73831 datasheet.

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

    STAT LED

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

    Status LED
    The status (18) LED indicator on the SparkFun expLoRaBLE Thing Plus. (Click to enlarge)

    RX and TX LEDs

    The yellow, RX and green, TX LEDs are used to indicate serial communication and programming between the CH340E serial-to-UART and NM180100 SiP.

    RX and TX LEDs
    The RX and TX LED indicators on the SparkFun expLoRaBLE Thing Plus. (Click to enlarge)

    Jumpers

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

    • ISO - This jumper can be used to isolate the 3.3V connection from the voltage regulator.
    • LED - This jumper can be used to remove 3.3V power to the PWR LED and reduce power consumption on the board.
    • RTS - This jumper can be used to disconnect the CH340E from the RESET pin of the Apollo3; effectively, disabling the ability of the CH340E to reset the MCU through software.

    Primary I2C Bus

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

    Connection VDDGNDSCLSDA
    Pad Number
    (NM180100 SiP)
    3.3VGNDD15D14
    Qwiic Connector

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

    qwiic connector
    Qwiic connector on the SparkFun expLoRaBLE. (Click to enlarge)

    What is Qwiic?

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

    Features of the Qwiic System

    Keep your soldering iron at bay.

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

    Qwiic Cable and Board

    Qwiic cables connected to Spectral Sensor Breakout

    Minimize your mistakes.

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

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

    JST Connector

    1mm pitch, 4-pin JST connector

    Expand with ease.

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

    Software Overview

    CH340 Driver

    Users will need to install the latest CH340 driver on their computer, in order for it to properly recognize the board.

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

    Software Dependencies

    1. The ArduinoBLE Arduino library
    2. The RadioLib Arduino library

      Note: Currently, the RadioLib Arduino library, doesn't support the SparkFun expLoRaBLE Thing Plus. There is a pull-request to integrate support for the expLoRaBLE into the library. In the meantime, users will need to manually install the library with this .zip file.

    • Provides support for peer-to-peer RF communication
      Note: Peer-to-peer refers to direct RF communication using FSK modulation and not a mesh network LoRa integration.
  • Our port of the basicmac code(*requires manual .zip file installation)

    Note: Currently, there isn't an Arduino library that provides a LoRa implementation, supporting the SX1262. However, we were able to modify and port the basicmac code as an Arduino library for the SparkFun expLoRaBLE. Users will need to manually install the library with this .zip file.

    The library includes modifications for the SPI pins use by the NM180100 to connect the Apollo3 MCU to the SX1262 module. Additionally, it also contains modifications to pre-configure the library to use the SX1262, the US LoRa frequency band, and defaults to a SF7 (spreading factor).


    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.

    The Things Network

    Users will need an account on The Things Network for the example that demonstrates the LoRaWAN capabilities of the expLoRaBLE. Please, use the information in either of the following tutorials to create an account on register a node on The Things Network.

    LoRaWAN with ProRF and The Things Network

    July 3, 2018

    Learn how to make a LoRaWAN node for your next long range IoT project and connect it to the internet with The Things Network!

    SparkFun SAMD21 Pro RF Hookup Guide

    October 4, 2018

    Using the super blazing, nay blinding, fast SAMD21 whipping clock cycles at 48MHz and the RFM96 module to connect to the Things Network (and other Radio woodles).
  • Learn about Working with Bytes
  • Hardware Assembly

    USB Programming

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

    SparkFun expLoRaBLE connected to a computer
    The SparkFun expLoRaBLE attached to a computer. (Click to enlarge)

    Antenna

    In order to utilize the LoRa and RF capabilities of the SX1262, users will need to attach an antenna. Check out the tutorial below for tips on using U.FL connectors.

    Attaching a whip antenna to the SparkFun expLoRaBLE
    Attaching a patch antenna to the SparkFun expLoRaBLE
    The SparkFun expLoRaBLE with a whip or patch antenna attached. (Click to enlarge)

    Three Quick Tips About Using U.FL

    December 28, 2018

    Quick tips regarding how to connect, protect, and disconnect U.FL connectors.
    Note: Users should be aware that the transmission signal from the Wide Band 4G LTE Internal FPC antenna emmits orthogonally to the top surface (i.e. towards the camera in the image above). Additionally, from our experience the antenna runs better in the wire down orientation as well.

    Battery

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

    Battery connected to the SparkFun expLoRaBLE
    The SparkFun expLoRaBLE with a battery connected. (Click to enlarge)
    Solar Panel Charger - 10W

    Solar Panel Charger - 10W

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

    USB 3.1 Cable A to C - 3 Foot

    CAB-14743
    $4.95
    2

    Qwiic Devices

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

    Qwiic devices connected to SparkFun expLoRaBLE
    The Qwiic XA110 GPS breakout board and Micro OLED board connected to the SparkFun expLoRaBLE.

    LoRaWAN Example

    LEGAL IMPLICATIONS!!!

    Regional Configuration: The (ported)basicmac library includes configurations required for the SPI pins use by the NM180100 to connect the Apollo3 MCU to the SX1262 module. Additionally, it also contains modifications to pre-configure the library to use the SX1262, the US LoRa frequency band, and defaults to a spreading factor of 7 (SF7).

    In order to change the regional configuration (for outside the US), users will need to go into the library files to make the necessary modifications to the target configuration file (target-conf.h). The configuration file can be found with the following file path BasicMAC>src>hal>target-config.h; on Windos 10, the file path is C:\Users\"username"\Documents\Arduino\libraries\BasicMAC\src\hal\target-config.h.

    Modification lines for regioins
    Lines 36-43 in the target-conf.h file used to configure the regional settings. (Click to enlarge)

    On lines 36-43, users will find the available regional options. To make the required modifications, users simply need to comment in/out their configuration choice and save the file, before uploading their code. (*It is recommended that users also close and re-open the Arduino IDE before uploading their code, to ensure the modifications are in place.)

    Register a Device on The Things Network

    In order to utilize this example, users will need access to a gateway that is connected to The Things Network. Additionally, users should have their own account on The Things Network and have registered a device for their node. A device must be registered, in order to receive the Network Session Key, App Session Key, and Device Address required for the SparkFun expLoRaBLE to operate as a node and have its data passed to The Things Network servers. For those who are unfamiliar with LoRaWAN and The Things Network, please refer to the information provided below.

    Registering a Device on The Things Network:

    Users will need an account on The Things Network for this example. Please, use the information in either of the following tutorials to create an account and register a device on The Things Network.

    LoRaWAN with ProRF and The Things Network

    July 3, 2018

    Learn how to make a LoRaWAN node for your next long range IoT project and connect it to the internet with The Things Network!

    SparkFun SAMD21 Pro RF Hookup Guide

    October 4, 2018

    Using the super blazing, nay blinding, fast SAMD21 whipping clock cycles at 48MHz and the RFM96 module to connect to the Things Network (and other Radio woodles).
    Credentials:

    Once a device has been registered (*the device activation method should be configure to ABP), the Network Session Key, App Session Key, and Device Address are displayed on the Device Overview page. In order for the expLoRaBLE to have its data passed to The Things Network, the Network Session Key, App Session Key, and Device Address must be hard coded on the device. By default, the Network Session Key and App Session Key fields are obscured for security reasons. Click the icon to show the code and click the <> button to show the codes in a C-style format. Below, is a diagram explaining which field on the Device Overview page corresponds to the variables in the provided example code.

    Screenshot of the Device Address, Network Session Key, and App Session Key fields from the Device Overview page
    A screen shot from the Device Overview page with labels. (Click to enlarge)

    Additional Resources

    For more information, feel free to utilize the documentation from The Things Network to:

    1. Create or Register an Account
    2. Add an Application through the Console
    3. Register a Device in the Application
    4. Once registered, in the device settings:
  • Learn about Working with Bytes
  • LoRa Example Code

    Once users have a device registered on The Things Network, the example code will need to be downloaded and a few modifications are required before uploading.

    Credentials

    Lines 36-47 of the example code, need to be modified to hard code the credentials required for the payload from the node to be passed to The Things Network:

    language:c
    // LoRaWAN NwkSKey, network session key
    // This is the default Semtech key, which is used by the early prototype TTN
    // network.
    static const PROGMEM u1_t NWKSKEY[16] = { 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x## };
    
    // LoRaWAN AppSKey, application session key
    // This is the default Semtech key, which is used by the early prototype TTN
    // network.
    static const u1_t PROGMEM APPSKEY[16] = { 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x## };
    
    // LoRaWAN end-device address (DevAddr)
    static const u4_t DEVADDR =  0x######## ; // <-- Change this address for every node! For example, our device address is 26022DEN. We will need to replace "DEVICE_ADDRESS_HERE" as 0x26022DEB.
    

    Transmission Interval

    Lines 62-64 of the example code, are used to set the transmission intervals between payloads:

    language:c
    // Schedule TX every this many milliseconds (might become longer due to duty
    // cycle limitations).
    const unsigned TX_INTERVAL = 20000;
    

    Payload Data

    Lines 329-336 of the example code, is where the contents of the payload can be modified. The contents of the transmission on can be viewed on The Things Network through the Application Data page, once the node begins broadcasting. To access the Application Data page, click on the Data tab from the Device Overview page on The Things Network console.

    language:c
    void send_packet() {
      // Prepare upstream data transmission at the next possible time.
      uint8_t mydata[] = "<Enter Text>";
      LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0);
      Serial.println(F("Packet queued"));
    
      last_packet = millis();
    }
    
    Note: The data is limited to 13 bytes in size. The data can take 3 different formats: text (as shown above), integers (8-bit unsigned), or an array. Any data sent as an array, must be in the following format: { 0x01, 0x02, 0x03,... up to ... 0x13}.

    Before You Upload the Code

    STOP!!!

    Regional Configuration: Before uploading the code, be sure to make any necessary regional configuration changes, as mentioned at the beginning of this section, to avoid breaking any laws.

    Note: For those utilizing our LoRa Gateway - 1-Channel (ESP32), the code on lines 288-300 will need to be uncommented. The modification forces the device/node to only use channel 8; instead of randomly picking a channel to broadcast on. This is important as the single channel gateeway only receives transmissions on channel 8 and if the device were broadcasting on channels randomly, only a portion of the transmissions would reach The Things Network.

    // disable channels 0-7
    for (int i = 0; i <= 7 ; i++)
    {
    LMIC_disableChannel(i);
    }
    
    // note, leave channel 8 enabled
    
    // disable all other higher channels
    for (int i = 9; i <= 63 ; i++)
    {
    LMIC_disableChannel(i);
    }
    

    Code in Operation

    Once the example code has been modified and uploaded to the SparkFun expLoRaBLE, users can monitor the serial terminal (or SerialMonitor on the Arduino IDE) for successful transmissions. Additionally, users can use The Things Network to decode the data packets to verify the data transmission.

    Serial Output from Example Code
    Example of serial output from successful transmissions. (Click to enlarge)

    Mapping with Node

    For those looking to test out the range of their setup configuration, The Things Network has an application called TTN Mapper. To get started follow the Mapping Gateway Coverage using a Things Node. There is also an option to map using a either an Android phone or iPhone. For more information on the app, please cheack out the documentation on The Things Network.

    To generate the images below, the Android guide was followed. The steps were relatively simple:

    1. Download the App
    2. Link a Device by:
      1. Logging-in to The Things Network
      2. Select an Application
      3. Select Device
    3. Power on Device
    4. Walk Around

    The TTN Mapper app uses the phone's positioning and ties it to the data transmission from the linked device. Therefore, users will need to enable their phone's data and location for the application to work properly.

    Patch AntennaWhip Antenna

    Example mapping of the signal coverage, using a spreading factor of 7 (SF7), for two different antennas.
    Note: To maximize the range of the device, the spreading factor should be changed to SF12. However, this modification will reduce the bitrate; and therefore, lowers the data rate; and therefore, minimizes the packet size that can be transmitted.

    You can even publish your data online, to get a radar-like coverage map for a gateway:

    Gateway Coverage - Radar
    A radar, coverage map for a gateway. (Click to enlarge)

    There were some vehicles parked to the northwest and northwest-by-north of where the gateway was positioned; as well as a tree and post to the immediate west and west-by-north. The image illustrates how the signal strength to the west drops off significantly, due to the proximity of the trees and poles. Additionally, how the signal strength in the northwest gradually falls from interference by the vehicles. The signal coverage to the south of the gateway was spotty since it was around the corner of the building.

    Peer-to-Peer Example

    In this example, the RadioLib library utilizes the frequency shift keying (FSK) capabilities of the SX1262 transceiver. For this example, users will need two expLoRaBLEs; one to transmit data and the other to receive that data. For more information on this library, check out the GitHub repository Wiki.

    Once the example codes has been uploaded to their respective boards, users should see the data transmissions in the Serial Monitor:

    Serial Monitor- Transmitter Output
    A screen shot of the Serial Monitor, showing that data is being transmitted. (Click to enlarge)

    Serial Monitor- Receiver Output
    A screen shot of the Serial Monitor, showing that data was received. (Click to enlarge)
    Note: The Arduino IDE only lets users connect to one COM (or serial) port at a time. Just verify that the board with the transmit code is sending data; then, monitor the COM port of the board with the receiver code for incoming data. If all is working, Hello World! transmissions will begin to appear.

    Resources and Going Further

    For more on the Artemis Development Kit, check out the links below:


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

    SparkFun Tutorials

    Installing an Arduino Library

    How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

    What is an Arduino?

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

    Installing Arduino IDE

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

    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.

    Arduino Tutorials

    Arduino Board Comparison Guides

    Choosing an Arduino for Your Project

    Examining the diverse world of Arduino boards and understanding the differences between them before choosing one for a project.

    Standard Arduino Comparison Guide

    Arduino Comparison Guide Uno or Pro Mini? Bluetooth or wireless? When it comes to Arduinos, there are a lot of choices. We've compiled every Arduino development…

    RedBoard vs. Uno

    In this tutorial we discuss the differences and similarities between the RedBoard and the Arduino Uno (SMD and PTH). The development platforms
    Beginner

    Click the buttons above for tutorials relating to the board functionality based on topic difficulty.

    Beginner

    Serial Communication

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

    Analog to Digital Conversion

    The world is analog. Use analog to digital conversion to help digital devices interpret the world.

    Logic Levels

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

    Analog vs. Digital

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

    Data Types in Arduino

    Learn about the common data types and what they signify in the Arduino programming environment.

    How to Work with Jumper Pads and PCB Traces

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

    Artemis Development with Arduino

    Get our powerful Artemis based boards (Artemis Nano, BlackBoard Artemis, and BlackBoard Artemis ATP) blinking in less than 5 minutes using the SparkFun Artemis Arduino Core!

    Intermediate

    Serial Peripheral Interface (SPI)

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

    I2C

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

    Processor Interrupts with Arduino

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

    Advanced

    Integrated Circuits

    An introduction to integrated circuits (ICs). Electronics' ubiquitous black chips. Includes a focus on the variety of IC packages.

    Bluetooth Basics

    An overview of the Bluetooth wireless technology.

    Reading and Writing Serial EEPROMs

    EEPROM is a great way to add extra memory to your microcontroller project. Wait 'til you see how easy it is to use!

    ARM Programming

    How to program SAMD21 or SAMD51 boards (or other ARM processors).

    Software Development Guides

    Using SparkFun Edge Board with Ambiq Apollo3 SDK

    We will demonstrate how to get started with your SparkFun Edge Board by setting up the toolchain on your computer, examining an example program, and using the serial uploader tool to flash the chip.

    Artemis Development with Arduino

    Get our powerful Artemis based boards (Artemis Nano, BlackBoard Artemis, and BlackBoard Artemis ATP) blinking in less than 5 minutes using the SparkFun Artemis Arduino Core!

    Artemis Development with the Arduino IDE

    This is an in-depth guide on developing in the Arduino IDE for the Artemis module and any Artemis microcontroller development board. Inside, users will find setup instructions and simple examples from blinking an LED and taking ADC measurements; to more complex features like BLE and I2C.

    Example Projects

    Programming the SparkFun Edge with Arduino

    Running low-power machine learning examples on the SparkFun Edge can now be done using the familiar Arduino IDE. In this follow-up to the initial Edge tutorial, we'll look at how to get three examples up and running without the need to learn an entirely new SDK.

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

    Qwiic SHIM Kit Hookup Guide for Raspberry Pi

    Next: Qwiic SHIM Kit for Raspberry Pi Hookup Guide
    Previous: SparkFun expLoRaBLE Hookup Guide
    $
    0
    0

    Qwiic SHIM Kit Hookup Guide for Raspberry Pi a learn.sparkfun.com tutorial

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

    Introduction

    The Qwiic SHIM Kit for Raspberry Pi gets you started with some of the basics surrounding I2C and Python on your Raspberry Pi. This tutorial will go over connecting Qwiic-enabled devices, installing their Python packages, and running the example code.

    SparkFun Qwiic SHIM Kit for Raspberry Pi

    SparkFun Qwiic SHIM Kit for Raspberry Pi

    KIT-16987
    $29.95

    Required Materials

    To follow along with this tutorial, you will also need a few pieces of hardware. Single board computers with the Raspberry Pi 40-pin GPIO standard header will work. We'll be using a Raspberry Pi throughout this tutorial. If you have not worked with a Raspberry Pi, we recommend pairing the Qwiic SHIM Kit with a Raspberry Pi 4 kit. At a minimum, you'll need a basic kit. However, if you need keyboard and mouse combination, we recommend getting the desktop kit.

    SparkFun Raspberry Pi 4 Basic Kit - 4GB

    SparkFun Raspberry Pi 4 Basic Kit - 4GB

    KIT-16384
    $89.95
    6
    SparkFun Raspberry Pi 4 Desktop Kit - 4GB

    SparkFun Raspberry Pi 4 Desktop Kit - 4GB

    KIT-16386
    $159.95

    Optional Materials

    You have several options when it comes to working with the Raspberry Pi. Most commonly, the Pi is used as a standalone computer, which requires a monitor. The following parts can be used with the Pi 4 if you opt for a small display. To save on costs, the Pi can also be used as a headless computer (without a monitor, keyboard, and mouse). This setup has a slightly more difficult learning curve, as you will need to use the command-line interface (CLI) from another computer.

    SmartiPi Touch 2

    SmartiPi Touch 2

    PRT-16302
    $27.95
    1
    Raspberry Pi LCD - 7" Touchscreen

    Raspberry Pi LCD - 7" Touchscreen

    LCD-13733
    $60.00
    49

    Suggested Reading

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

    Qwiic Connect System
    Qwiic Connect System

    We also recommend taking a look at some of our other tutorials and familiarizing yourself with some of these topics and parts. We will end up working with the Raspberry Pi and Python programming language.

    Raspberry Pi 4 Kit Hookup Guide

    March 14, 2020

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

    Python Programming Tutorial: Getting Started with the Raspberry Pi

    June 27, 2018

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

    I2C

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

    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.

    SparkFun 9DoF IMU (ICM-20948) Breakout Hookup Guide

    How to use the SparkFun 9DoF ICM-20948 breakout board for your motion sensing projects. This breakout is ideal for wearable sensors and IoT applications.

    Qwiic SHIM for Raspberry Pi Hookup Guide

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

    Hardware Assembly

    The hardware that is included in this kit is a 16x2 SerLCD with RGB backlight, 9DoF IMU (ICM-20948), Qwiic SHIM, and Qwiic cables. The Qwiic connector color may vary. This should not affect the overall functionality of the boards.

    Qwiic SHIM Kit

    Connecting Qwiic devices to the Raspberry Pi makes it even easier than ever with the Qwiic SHIM. Slide the Qwiic SHIM into the Raspberry Pi's header so that the square PTH pad is aligned with pin 1.

    Pi 4 with SHIM

    At this point, connect the Qwiic cable between the boards. Insert the shorter Qwiic cable between the Qwiic SHIM and 9DoF's Qwiic connectors. Then insert the longer Qwiic cable between the 9DoF and Qwiic SHIM. The length of the cable between the boards does not really matter so you could insert the cables any way that you would like as well.

    Qwiic Cable between Qwiic Shim and SerLCD 16x2

    Then connect all the necessary peripherals to your Raspberry Pi. In this case, we connected a keyboard, mouse, HDMI monitor, and a power supply.

    Power and Monitor Cable Connected Full Setup

    Configure Your Pi

    We are going to assume that you already have a Raspberry Pi up and running with Raspbian. We'll also assume that it is connected to the Internet. If not, check out our starter kits and tutorials on setting up a Raspberry Pi.

    Raspberry Pi 4 Kit Hookup Guide

    March 14, 2020

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

    Make sure to update the image so that we have the latest distribution. Enter the following commands in the command line individually to update your image.

    language:bash
    sudo apt-get update
    sudo apt-get dist-upgrade
    
    Note: sudo stands for "Super User Do", it is a way to give you superuser powers from the command line. Be careful whenever using sudo.

    User Configuration Settings

    Once you are set up, I highly recommend changing your password. At this point, we are going be dealing with the Internet of things and don't want unsavory characters sneaking into your system using the default login: (username: pi, password: raspberry).

    The raspi-config tool is a quick way to change your password as well as setup the network, language, keyboard, etc. Type the following command using the command line and then go through the menus to update your information.

    language:bash
    sudo raspi-config
    

    You'll want to enable the I2C pins using the tool to read the sensors on the I2C bus.

    Enabling I2C on a Pi

    Raspi-config for I2C

    You will need to restart your Pi before the settings can take effect. After exiting raspi-config, let's reboot your Pi with the following command.

    language:bash
    sudo reboot
    

    Python

    Notice: This tutorial was written with the following software versions.

    • Raspbian Pi OS Full (32-bit) version 10, Kernel version 5.4 (Released 12/2/2020)
    • Python version 3.7.3
    • pip 20.3.3 for Python 3.7

    Other versions may affect how some of the steps in this guide are performed.

    Indentation

    In many programming languages, we indent things to make things easier to read. In Python, those indents are part of the code. Instead of putting brackets around your loop or if() statements, you just indent that entire chunk with a leading whitespace. In other words, you have to make sure your indents are correct. I also recommend not using your keyboard's TAB button to indent as various programs will read it differently (and usually incorrectly).

    Commenting

    Another thing to keep in mind is comments. In Python, the symbol "#" is used to denote that the line is a comment. Unlike many other languages there is no official multi-line comment available. So you'll just have to get use to typing # for each line when writing large comments.

    Python Versions and Installing PIP

    There are also 2 commonly used Python versions. Even after Python 3 came out many people continued to use 2.7 for many years. Part of the reason is that Python 3 improved on some things and in the process made it not backwards compatible. As of January 1st, 2020, Python 2 is no longer supported. For our example we will be using Python 3.7. To see what version of Python your Pi is using, open a command line and type each of the following commands individually to check.

    language:bash
    python --version
    python -m pip --version
    

    If you are not using Python 3, then we'll need to open the */.bashrc file and add an alias.

    First, you will need to update the python installation package by running the following command to install pip for Python 3. Execute the following commands.

    language:bash
    sudo apt-get install python3-pip
    

    Type the following command to open the file.

    language:bash
    nano ~/.bashrc
    

    Then add the following lines at the end. That should tell the computer whenever you want to run python to look for the file located at /usr/bin/python3.

    language:bash
    alias python='/usr/bin/python3'
    alias pip=pip3
    

    Alias Python 3 and pip3

    To exit nano type CTRL + X and then hit Y when it asks you if you want to save and then ENTER. You can now either reboot or type the following to force the Pi to run the *.bashrc file again.

    language:bash
    source ~/.bashrc
    

    Once adjusted, type the following command to ensure that pip is up to date.

    language:bash
    python -m pip install --upgrade pip
    

    Python Library

    We will also need to install the Qwiic Python libraries. This will automatically download a folder containing all the Qwiic_Py files and dependencies to your Raspberry Pi. Run the following command to automatically install the modules for the Qwiic sensors and SerLCD. To ensure that you are installing to the correct path for Python 3, make sure that you use pip3.

    language:bash
    sudo pip3 install sparkfun_qwiic
    

    Example: ICM-20948 Readings

    To start, there are basic examples written in Python for the ICM-20948 and SerLCD. We'll go over one for each to see if the Qwiic-enabled devices are working as expected.

    Reading the Data with the ICM-20948

    In your terminal window, type the following to download the basic example code from the GitHub repository. Otherwise, you can manually download the example code.

    language:bash
    git clone https://github.com/sparkfun/Qwiic_9DoF_IMU_ICM20948_Py
    

    Then navigate to examples folder by entering the following command.

    language:bash
    cd Qwiic_9DoF_IMU_ICM20948_Py/examples
    

    Using the ls command will list the examples in the folder. As of the writing from this tutorial, there's only one so we will enter the following command to run the example.

    language:bash
    python ex1_qwiic_ICM20948.py
    

    You should see an output similar to image below. Depending on how the sensor is oriented, the values might be different. Moving the sensor around will change the raw values in the terminal window. The window will probably be too small and wrap around to the next row. To slow the output down, stop the code by typing CTRL + C and adjust the value for the delay after the print() function where it says time.sleep(0.03) to a larger number. Once the code has been adjusted, try running the code again.

    9DoF Readings Through Terminal

    You could also navigate to the example folder, open the example in Thonny, and hit the Run button. The readings will show up in the shell.

    Thonny IDE 9DoF ICM20948 Readings

    Example: SerLCD - Hello World!

    SerLCD: Hello World!

    In your terminal window, type the following to download the basic example code from the GitHub repository.

    language:bash
    git clone https://github.com/sparkfun/Qwiic_SerLCD_Py
    

    Then navigate to the examples folder by entering the following command.

    language:bash
    cd Qwiic_SerLCD_Py/examples
    

    Using the ls command will list the examples in the folder. There are few examples in the folder but we're interested in only viewing the "Hello World!" example. Enter the following command to run the example.

    language:bash
    python ex1_qwiic_serlcd_hello_world.py
    

    You should see the familiar phrase "Hello World!" displayed in the terminal window with a counter increasing.

    Output Terminal Window

    If you are using Thonny, you should see the same output in the Shell.

    Output Thonny

    You should see the same message on the SerLCD with a counter increasing on the next row as well.

    RGB Character Serial LCD Displaying Hello World with Counter

    Sweet! There are several other examples available in the Qwiic_SerLCD_Py library. Try running the other examples listed in the examples folder to test by using the python command followed by the name of the python file.

    Example: Combined SerLCD and ICM-20948

    Combined Example

    This code combines a few of the examples together. The orientation of the 9DoF will control the RGB backlight. For simplicity, we will only display the name of the color. Try scaling the readings down before printing the accelerometer readings on the screen.

    In your terminal window, type the following to download the combined example code from the GitHub repository.

    language:bash
    git clone https://github.com/sparkfun/Qwiic_SHIM_Kit
    

    Then navigate to the examples folder by entering the following command.

    language:bash
    cd Qwiic_SHIM_Kit/examples
    

    Enter the following command to run the combined example.

    language:bash
    python combined1_RGB_SerLCD_ICM20948.py
    

    You can also copy the example below.

    language:python
    #!/usr/bin/env python3
    #-----------------------------------------------------------------------------
    # combined1_RGB_SerLCD_ICM20948.py
    #
    # Combined example to control the RGB LED on the SerLCD
    # based on the accelerometer readings on the ICM20948.
    #------------------------------------------------------------------------
    #
    # Written by  SparkFun Electronics, March 2020
    # 
    # This python library supports the SparkFun Electroncis qwiic 
    # qwiic sensor/board ecosystem on a Raspberry Pi (and compatible) single
    # board computers. 
    #
    # More information on qwiic is at https://www.sparkfun.com/qwiic
    #
    # Do you like this library? Help support SparkFun. Buy a board!
    #
    #==================================================================================
    # Copyright (c) 2019 SparkFun Electronics
    #
    # Permission is hereby granted, free of charge, to any person obtaining a copy 
    # of this software and associated documentation files (the "Software"), to deal 
    # in the Software without restriction, including without limitation the rights 
    # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    # copies of the Software, and to permit persons to whom the Software is 
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in all 
    # copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    # SOFTWARE.
    #==================================================================================
    
    from __future__ import print_function
    import qwiic_serlcd
    import qwiic_icm20948
    import time
    import sys
    
    #create global variable to keep track of color when debugging
    ledColor = 1
    
    def runExample():
    
        print("\nSparkFun SerLCD and 9DoF ICM-20948 Sensor Example\n")
        myLCD = qwiic_serlcd.QwiicSerlcd()
        IMU = qwiic_icm20948.QwiicIcm20948()
    
        if myLCD.connected == False:
            print("The Qwiic SerLCD device isn't connected to the system. Please check your connection", \
                file=sys.stderr)
            return
    
        if IMU.connected == False:
            print("The Qwiic ICM20948 device isn't connected to the system. Please check your connection", \
                  file=sys.stderr)
            return
    
    
        myLCD.setBacklight(255, 255, 255) # Set backlight to bright white
        myLCD.setContrast(5)  # Set contrast. Lower to 0 for higher contrast.
        myLCD.clearScreen()   # Clear Screen - this moves the cursor to the home position as well
        myLCD.print("white")  # Write to color name to SerLCD
    
        time.sleep(0.5) # give a sec for system messages to complete
    
        IMU.begin()
    
        while True:
            #declare ledColor a global variable inside here to access it 
            global ledColor
    
            if IMU.dataReady():
                IMU.getAgmt() # read all axis and temp from sensor, note this also updates all instance variables
    
                #the following are the threshold values for each axis is pointing right-side up
    
                # anything above IMU.azRaw > 16000 is red
                # ledColor = 1
                aZPos = 16000
    
                # anything below IMU.azRaw < -16000 is blue
                # ledColor = 2
                aZNeg = -16000
    
                # anything above IMU.ayRaw > 16100 is green
                # ledColor = 3
                ayPos = 16100
    
                # anything below IMU.ayRaw < -16000 is green
                # ledColor = 4
                ayNeg = -16000
    
                # anything above IMU.axRaw > 16000 is magenta
                # ledColor = 5
                axPos = 16000
    
                # anything below IMU.axRaw < -16400 is cyan
                # ledColor = 6
                axNeg = -16400
    
                #adjust color of the LED based on the accelerometer's reading
                if IMU.azRaw > aZPos:
                    # Set LED red
                    myLCD.setBacklight(255, 0, 0) # Set backlight to bright white
                    ledColor = 1
                    myLCD.clearScreen()
                    myLCD.print("red")
    
                elif IMU.azRaw < aZNeg:
                    # Set LED blue
                    myLCD.setBacklight(0, 0, 255) # Set backlight to bright white
                    ledColor = 2
                    myLCD.clearScreen()
                    myLCD.print("blue")
    
                elif IMU.ayRaw > ayPos:
                    # Set LED yellow
                    myLCD.setBacklight(255, 255, 0) # Set backlight to bright white
                    ledColor = 3
                    myLCD.clearScreen()
                    myLCD.print("yellow")
    
                elif IMU.ayRaw < ayNeg:
                    # Set LED green
                    myLCD.setBacklight(0, 255, 0) # Set backlight to bright white
                    ledColor = 4
                    myLCD.clearScreen()
                    myLCD.print("green")
    
                elif IMU.axRaw > axPos:
                    # Set LED magenta
                    myLCD.setBacklight(255, 0, 255) # Set backlight to bright white
                    ledColor = 5
                    myLCD.clearScreen()
                    myLCD.print("magenta")
    
                elif IMU.axRaw < axNeg:
                    # Set LED cyan
                    myLCD.setBacklight(0, 255, 255) # Set backlight to bright white
                    ledColor = 6
                    myLCD.clearScreen()
                    myLCD.print("cyan")
    
                if ledColor == 1:
                    print("ledColor = red" ,'\n', '\n')
                elif ledColor == 2:
                    print("ledColor = blue" ,'\n', '\n')
                elif ledColor == 3:
                    print("ledColor = yellow" ,'\n', '\n')
                elif ledColor == 4:
                    print("ledColor = green" ,'\n', '\n')
                elif ledColor == 5:
                    print("ledColor = magenta" ,'\n', '\n')
                elif ledColor == 6:
                    print("ledColor = cyan" ,'\n', '\n')
    
                aX = IMU.axRaw
                aY = IMU.ayRaw
                aZ = IMU.azRaw
                gX = IMU.gxRaw
                gY = IMU.gyRaw
                gZ = IMU.gzRaw
                mX = IMU.mxRaw
                mY = IMU.myRaw
                mZ = IMU.mzRaw
    
                # Remove the `#` for the following lines to 
                # display accelerometer readings on SerLCD
    
                #myLCD.setCursor(8,0)
                #myLCD.print("aX")
                #myLCD.print(str(aX))
    
                #myLCD.setCursor(0,1)
                #myLCD.print("aY")
                #myLCD.print(str(aY))
    
                #myLCD.setCursor(8,1)
                #myLCD.print("aZ")
                #myLCD.print(str(aZ))
    
                print(\
                 ' aX:', '{: 4.1f}'.format(aX)\
                , ' \t, aY:', '{: 4.1f}'.format(aY)\
                , '\t, aZ:', '{: 4.1f}'.format(aZ)\
                , '\n gX:', '{: 4.1f}'.format(gX)\
                , '\t, gY:', '{: 4.1f}'.format(gY)\
                , '\t, gZ:', '{: 4.1f}'.format(gZ)\
                , '\n mX:', '{: 4.1f}'.format(mX)\
                , '\t, mY:', '{: 4.1f}'.format(mY)\
                , '\t, mZ:', '{: 4.1f}'.format(mZ)\
                , '\n'\
                )
    
                time.sleep(1) # small delay so that the screen doesn't flicker
            else:
                print("Waiting for data")
                time.sleep(0.5)
    
    
    
    
    
    if __name__ == '__main__':
        try:
            runExample()
        except (KeyboardInterrupt, SystemExit) as exErr:
            print("\nEnding Combined Example")
            sys.exit(0)
    

    The terminal will begin displaying the current color and sensor readings.

    Terminal Output of Combined Example

    If you are using Thonny, you will see the same output in the Shell.

    Thonny Output of Combined Example

    If you check out the SerLCD with RGB backlight, the screen will display the color name and color backlight based on the accelerometer readings. The color will change depending on what axis is pointing up. Your setup may look slightly different depending on how you connected the Qwiic cables so be sure to reference the silkscreen for the accelerometer.

    RGB Character Serial LCD Display Controlled by the ICM-20948's accelerometer readings

    Resources and Going Further

    For more information, check out the resources below:

    • GitHub
    • Qwiic SHIM Kit for Pi Demo Code
    Python Logo

    Looking for more inspiration? Check out these other Raspberry Pi projects and Python tutorials.:

    Graph Sensor Data with Python and Matplotlib

    Use matplotlib to create a real-time plot of temperature data collected from a TMP102 sensor connected to a Raspberry Pi.

    Python GUI Guide: Introduction to Tkinter

    Tkinter is the standard graphical user interface package that comes with Python. This tutorial will show you how to create basic windowed applications as well as complete full-screen dashboard examples complete with live graph updates from matplotlib.

    How to Run a Raspberry Pi Program on Startup

    In this tutorial, we look at various methods for running a script or program automatically whenever your Raspberry Pi (or other Linux computer) boots up.

    Qwiic Kit for Raspberry Pi Hookup Guide

    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!

    Qwiic Distance Sensor (VL53L1X) Hookup Guide

    The Qwiic VL53L1X time of flight sensor is capable of several modes, as well as having a range of 4M. Let's hook it up and find out just how far away that thing over there is.

    Computer Vision and Projection Mapping in Python

    Use computer vision to detect faces and project images on top of them.

    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.

    Qwiic Atmospheric Sensor (BME280) Hookup Guide

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

    Or check out some of these blog posts for ideas:


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

    Qwiic SHIM Kit for Raspberry Pi Hookup Guide

    Next: MicroMod Asset Tracker Carrier Board Hookup Guide
    Previous: Qwiic SHIM Kit Hookup Guide for Raspberry Pi
    $
    0
    0

    Qwiic SHIM Kit for Raspberry Pi Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    The Qwiic SHIM Kit for Raspberry Pi gets you started with some of the basics surrounding I2C and Python on your Raspberry Pi. This tutorial will go over connecting Qwiic-enabled devices, installing their Python packages, and running the example code.

    SparkFun Qwiic SHIM Kit for Raspberry Pi

    SparkFun Qwiic SHIM Kit for Raspberry Pi

    KIT-16987
    $29.95

    Required Materials

    To follow along with this tutorial, you will also need a few pieces of hardware. Single board computers with the Raspberry Pi 40-pin GPIO standard header will work. We'll be using a Raspberry Pi throughout this tutorial. If you have not worked with a Raspberry Pi, we recommend pairing the Qwiic SHIM Kit with a Raspberry Pi 4 kit. At a minimum, you'll need a basic kit. However, if you need keyboard and mouse combination, we recommend getting the desktop kit.

    SparkFun Raspberry Pi 4 Basic Kit - 4GB

    SparkFun Raspberry Pi 4 Basic Kit - 4GB

    KIT-16384
    $89.95
    6
    SparkFun Raspberry Pi 4 Desktop Kit - 4GB

    SparkFun Raspberry Pi 4 Desktop Kit - 4GB

    KIT-16386
    $159.95

    Optional Materials

    You have several options when it comes to working with the Raspberry Pi. Most commonly, the Pi is used as a standalone computer, which requires a monitor. The following parts can be used with the Pi 4 if you opt for a small display. To save on costs, the Pi can also be used as a headless computer (without a monitor, keyboard, and mouse). This setup has a slightly more difficult learning curve, as you will need to use the command-line interface (CLI) from another computer.

    SmartiPi Touch 2

    SmartiPi Touch 2

    PRT-16302
    $27.95
    1
    Raspberry Pi LCD - 7" Touchscreen

    Raspberry Pi LCD - 7" Touchscreen

    LCD-13733
    $60.00
    49

    Suggested Reading

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

    Qwiic Connect System
    Qwiic Connect System

    We also recommend taking a look at some of our other tutorials and familiarizing yourself with some of these topics and parts. We will end up working with the Raspberry Pi and Python programming language.

    Raspberry Pi 4 Kit Hookup Guide

    March 14, 2020

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

    Python Programming Tutorial: Getting Started with the Raspberry Pi

    June 27, 2018

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

    I2C

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

    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.

    SparkFun 9DoF IMU (ICM-20948) Breakout Hookup Guide

    How to use the SparkFun 9DoF ICM-20948 breakout board for your motion sensing projects. This breakout is ideal for wearable sensors and IoT applications.

    Qwiic SHIM for Raspberry Pi Hookup Guide

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

    Hardware Assembly

    The hardware that is included in this kit is a 16x2 SerLCD with RGB backlight, 9DoF IMU (ICM-20948), Qwiic SHIM, and Qwiic cables. The Qwiic connector color may vary. This should not affect the overall functionality of the boards.

    Qwiic SHIM Kit

    Connecting Qwiic devices to the Raspberry Pi makes it even easier than ever with the Qwiic SHIM. Slide the Qwiic SHIM into the Raspberry Pi's header so that the square PTH pad is aligned with pin 1.

    Pi 4 with SHIM

    At this point, connect the Qwiic cable between the boards. Insert the shorter Qwiic cable between the Qwiic SHIM and 9DoF's Qwiic connectors. Then insert the longer Qwiic cable between the 9DoF and Qwiic SHIM. The length of the cable between the boards does not really matter so you could insert the cables any way that you would like as well.

    Qwiic Cable between Qwiic Shim and SerLCD 16x2

    Then connect all the necessary peripherals to your Raspberry Pi. In this case, we connected a keyboard, mouse, HDMI monitor, and a power supply.

    Power and Monitor Cable Connected Full Setup

    Configure Your Pi

    We are going to assume that you already have a Raspberry Pi up and running with Raspbian. We'll also assume that it is connected to the Internet. If not, check out our starter kits and tutorials on setting up a Raspberry Pi.

    Raspberry Pi 4 Kit Hookup Guide

    March 14, 2020

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

    Make sure to update the image so that we have the latest distribution. Enter the following commands in the command line individually to update your image.

    language:bash
    sudo apt-get update
    sudo apt-get dist-upgrade
    
    Note: sudo stands for "Super User Do", it is a way to give you superuser powers from the command line. Be careful whenever using sudo.

    User Configuration Settings

    Once you are set up, I highly recommend changing your password. At this point, we are going be dealing with the Internet of things and don't want unsavory characters sneaking into your system using the default login: (username: pi, password: raspberry).

    The raspi-config tool is a quick way to change your password as well as setup the network, language, keyboard, etc. Type the following command using the command line and then go through the menus to update your information.

    language:bash
    sudo raspi-config
    

    You'll want to enable the I2C pins using the tool to read the sensors on the I2C bus.

    Enabling I2C on a Pi

    Raspi-config for I2C

    You will need to restart your Pi before the settings can take effect. After exiting raspi-config, let's reboot your Pi with the following command.

    language:bash
    sudo reboot
    

    Python

    Notice: This tutorial was written with the following software versions.

    • Raspbian Pi OS Full (32-bit) version 10, Kernel version 5.4 (Released 12/2/2020)
    • Python version 3.7.3
    • pip 20.3.3 for Python 3.7

    Other versions may affect how some of the steps in this guide are performed.

    Indentation

    In many programming languages, we indent things to make things easier to read. In Python, those indents are part of the code. Instead of putting brackets around your loop or if() statements, you just indent that entire chunk with a leading whitespace. In other words, you have to make sure your indents are correct. I also recommend not using your keyboard's TAB button to indent as various programs will read it differently (and usually incorrectly).

    Commenting

    Another thing to keep in mind is comments. In Python, the symbol "#" is used to denote that the line is a comment. Unlike many other languages there is no official multi-line comment available. So you'll just have to get use to typing # for each line when writing large comments.

    Python Versions and Installing PIP

    There are also 2 commonly used Python versions. Even after Python 3 came out many people continued to use 2.7 for many years. Part of the reason is that Python 3 improved on some things and in the process made it not backwards compatible. As of January 1st, 2020, Python 2 is no longer supported. For our example we will be using Python 3.7. To see what version of Python your Pi is using, open a command line and type each of the following commands individually to check.

    language:bash
    python --version
    python -m pip --version
    

    If you are not using Python 3, then we'll need to open the */.bashrc file and add an alias.

    First, you will need to update the python installation package by running the following command to install pip for Python 3. Execute the following commands.

    language:bash
    sudo apt-get install python3-pip
    

    Type the following command to open the file.

    language:bash
    nano ~/.bashrc
    

    Then add the following lines at the end. That should tell the computer whenever you want to run python to look for the file located at /usr/bin/python3.

    language:bash
    alias python='/usr/bin/python3'
    alias pip=pip3
    

    Alias Python 3 and pip3

    To exit nano type CTRL + X and then hit Y when it asks you if you want to save and then ENTER. You can now either reboot or type the following to force the Pi to run the *.bashrc file again.

    language:bash
    source ~/.bashrc
    

    Once adjusted, type the following command to ensure that pip is up to date.

    language:bash
    python -m pip install --upgrade pip
    

    Python Library

    We will also need to install the Qwiic Python libraries. This will automatically download a folder containing all the Qwiic_Py files and dependencies to your Raspberry Pi. Run the following command to automatically install the modules for the Qwiic sensors and SerLCD. To ensure that you are installing to the correct path for Python 3, make sure that you use pip3.

    language:bash
    sudo pip3 install sparkfun_qwiic
    

    Example: ICM-20948 Readings

    To start, there are basic examples written in Python for the ICM-20948 and SerLCD. We'll go over one for each to see if the Qwiic-enabled devices are working as expected.

    Reading the Data with the ICM-20948

    In your terminal window, type the following to download the basic example code from the GitHub repository. Otherwise, you can manually download the example code.

    language:bash
    git clone https://github.com/sparkfun/Qwiic_9DoF_IMU_ICM20948_Py
    

    Then navigate to examples folder by entering the following command.

    language:bash
    cd Qwiic_9DoF_IMU_ICM20948_Py/examples
    

    Using the ls command will list the examples in the folder. As of the writing from this tutorial, there's only one so we will enter the following command to run the example.

    language:bash
    python ex1_qwiic_ICM20948.py
    

    You should see an output similar to image below. Depending on how the sensor is oriented, the values might be different. Moving the sensor around will change the raw values in the terminal window. The window will probably be too small and wrap around to the next row. To slow the output down, stop the code by typing CTRL + C and adjust the value for the delay after the print() function where it says time.sleep(0.03) to a larger number. Once the code has been adjusted, try running the code again.

    9DoF Readings Through Terminal

    You could also navigate to the example folder, open the example in Thonny, and hit the Run button. The readings will show up in the shell.

    Thonny IDE 9DoF ICM20948 Readings

    Example: SerLCD - Hello World!

    SerLCD: Hello World!

    In your terminal window, type the following to download the basic example code from the GitHub repository.

    language:bash
    git clone https://github.com/sparkfun/Qwiic_SerLCD_Py
    

    Then navigate to the examples folder by entering the following command.

    language:bash
    cd Qwiic_SerLCD_Py/examples
    

    Using the ls command will list the examples in the folder. There are few examples in the folder but we're interested in only viewing the "Hello World!" example. Enter the following command to run the example.

    language:bash
    python ex1_qwiic_serlcd_hello_world.py
    

    You should see the familiar phrase "Hello World!" displayed in the terminal window with a counter increasing.

    Output Terminal Window

    If you are using Thonny, you should see the same output in the Shell.

    Output Thonny

    You should see the same message on the SerLCD with a counter increasing on the next row as well.

    RGB Character Serial LCD Displaying Hello World with Counter

    Sweet! There are several other examples available in the Qwiic_SerLCD_Py library. Try running the other examples listed in the examples folder to test by using the python command followed by the name of the python file.

    Example: Combined SerLCD and ICM-20948

    Combined Example

    This code combines a few of the examples together. The orientation of the 9DoF will control the RGB backlight. For simplicity, we will only display the name of the color. Try scaling the readings down before printing the accelerometer readings on the screen.

    In your terminal window, type the following to download the combined example code from the GitHub repository.

    language:bash
    git clone https://github.com/sparkfun/Qwiic_SHIM_Kit
    

    Then navigate to the examples folder by entering the following command.

    language:bash
    cd Qwiic_SHIM_Kit/examples
    

    Enter the following command to run the combined example.

    language:bash
    python combined1_RGB_SerLCD_ICM20948.py
    

    You can also copy the example below.

    language:python
    #!/usr/bin/env python3
    #-----------------------------------------------------------------------------
    # combined1_RGB_SerLCD_ICM20948.py
    #
    # Combined example to control the RGB LED on the SerLCD
    # based on the accelerometer readings on the ICM20948.
    #------------------------------------------------------------------------
    #
    # Written by  SparkFun Electronics, March 2020
    # 
    # This python library supports the SparkFun Electroncis qwiic 
    # qwiic sensor/board ecosystem on a Raspberry Pi (and compatible) single
    # board computers. 
    #
    # More information on qwiic is at https://www.sparkfun.com/qwiic
    #
    # Do you like this library? Help support SparkFun. Buy a board!
    #
    #==================================================================================
    # Copyright (c) 2019 SparkFun Electronics
    #
    # Permission is hereby granted, free of charge, to any person obtaining a copy 
    # of this software and associated documentation files (the "Software"), to deal 
    # in the Software without restriction, including without limitation the rights 
    # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
    # copies of the Software, and to permit persons to whom the Software is 
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in all 
    # copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    # SOFTWARE.
    #==================================================================================
    
    from __future__ import print_function
    import qwiic_serlcd
    import qwiic_icm20948
    import time
    import sys
    
    #create global variable to keep track of color when debugging
    ledColor = 1
    
    def runExample():
    
        print("\nSparkFun SerLCD and 9DoF ICM-20948 Sensor Example\n")
        myLCD = qwiic_serlcd.QwiicSerlcd()
        IMU = qwiic_icm20948.QwiicIcm20948()
    
        if myLCD.connected == False:
            print("The Qwiic SerLCD device isn't connected to the system. Please check your connection", \
                file=sys.stderr)
            return
    
        if IMU.connected == False:
            print("The Qwiic ICM20948 device isn't connected to the system. Please check your connection", \
                  file=sys.stderr)
            return
    
    
        myLCD.setBacklight(255, 255, 255) # Set backlight to bright white
        myLCD.setContrast(5)  # Set contrast. Lower to 0 for higher contrast.
        myLCD.clearScreen()   # Clear Screen - this moves the cursor to the home position as well
        myLCD.print("white")  # Write to color name to SerLCD
    
        time.sleep(0.5) # give a sec for system messages to complete
    
        IMU.begin()
    
        while True:
            #declare ledColor a global variable inside here to access it 
            global ledColor
    
            if IMU.dataReady():
                IMU.getAgmt() # read all axis and temp from sensor, note this also updates all instance variables
    
                #the following are the threshold values for each axis is pointing right-side up
    
                # anything above IMU.azRaw > 16000 is red
                # ledColor = 1
                aZPos = 16000
    
                # anything below IMU.azRaw < -16000 is blue
                # ledColor = 2
                aZNeg = -16000
    
                # anything above IMU.ayRaw > 16100 is green
                # ledColor = 3
                ayPos = 16100
    
                # anything below IMU.ayRaw < -16000 is green
                # ledColor = 4
                ayNeg = -16000
    
                # anything above IMU.axRaw > 16000 is magenta
                # ledColor = 5
                axPos = 16000
    
                # anything below IMU.axRaw < -16400 is cyan
                # ledColor = 6
                axNeg = -16400
    
                #adjust color of the LED based on the accelerometer's reading
                if IMU.azRaw > aZPos:
                    # Set LED red
                    myLCD.setBacklight(255, 0, 0) # Set backlight to bright white
                    ledColor = 1
                    myLCD.clearScreen()
                    myLCD.print("red")
    
                elif IMU.azRaw < aZNeg:
                    # Set LED blue
                    myLCD.setBacklight(0, 0, 255) # Set backlight to bright white
                    ledColor = 2
                    myLCD.clearScreen()
                    myLCD.print("blue")
    
                elif IMU.ayRaw > ayPos:
                    # Set LED yellow
                    myLCD.setBacklight(255, 255, 0) # Set backlight to bright white
                    ledColor = 3
                    myLCD.clearScreen()
                    myLCD.print("yellow")
    
                elif IMU.ayRaw < ayNeg:
                    # Set LED green
                    myLCD.setBacklight(0, 255, 0) # Set backlight to bright white
                    ledColor = 4
                    myLCD.clearScreen()
                    myLCD.print("green")
    
                elif IMU.axRaw > axPos:
                    # Set LED magenta
                    myLCD.setBacklight(255, 0, 255) # Set backlight to bright white
                    ledColor = 5
                    myLCD.clearScreen()
                    myLCD.print("magenta")
    
                elif IMU.axRaw < axNeg:
                    # Set LED cyan
                    myLCD.setBacklight(0, 255, 255) # Set backlight to bright white
                    ledColor = 6
                    myLCD.clearScreen()
                    myLCD.print("cyan")
    
                if ledColor == 1:
                    print("ledColor = red" ,'\n', '\n')
                elif ledColor == 2:
                    print("ledColor = blue" ,'\n', '\n')
                elif ledColor == 3:
                    print("ledColor = yellow" ,'\n', '\n')
                elif ledColor == 4:
                    print("ledColor = green" ,'\n', '\n')
                elif ledColor == 5:
                    print("ledColor = magenta" ,'\n', '\n')
                elif ledColor == 6:
                    print("ledColor = cyan" ,'\n', '\n')
    
                aX = IMU.axRaw
                aY = IMU.ayRaw
                aZ = IMU.azRaw
                gX = IMU.gxRaw
                gY = IMU.gyRaw
                gZ = IMU.gzRaw
                mX = IMU.mxRaw
                mY = IMU.myRaw
                mZ = IMU.mzRaw
    
                # Remove the `#` for the following lines to 
                # display accelerometer readings on SerLCD
    
                #myLCD.setCursor(8,0)
                #myLCD.print("aX")
                #myLCD.print(str(aX))
    
                #myLCD.setCursor(0,1)
                #myLCD.print("aY")
                #myLCD.print(str(aY))
    
                #myLCD.setCursor(8,1)
                #myLCD.print("aZ")
                #myLCD.print(str(aZ))
    
                print(\
                 ' aX:', '{: 4.1f}'.format(aX)\
                , ' \t, aY:', '{: 4.1f}'.format(aY)\
                , '\t, aZ:', '{: 4.1f}'.format(aZ)\
                , '\n gX:', '{: 4.1f}'.format(gX)\
                , '\t, gY:', '{: 4.1f}'.format(gY)\
                , '\t, gZ:', '{: 4.1f}'.format(gZ)\
                , '\n mX:', '{: 4.1f}'.format(mX)\
                , '\t, mY:', '{: 4.1f}'.format(mY)\
                , '\t, mZ:', '{: 4.1f}'.format(mZ)\
                , '\n'\
                )
    
                time.sleep(1) # small delay so that the screen doesn't flicker
            else:
                print("Waiting for data")
                time.sleep(0.5)
    
    
    
    
    
    if __name__ == '__main__':
        try:
            runExample()
        except (KeyboardInterrupt, SystemExit) as exErr:
            print("\nEnding Combined Example")
            sys.exit(0)
    

    The terminal will begin displaying the current color and sensor readings.

    Terminal Output of Combined Example

    If you are using Thonny, you will see the same output in the Shell.

    Thonny Output of Combined Example

    If you check out the SerLCD with RGB backlight, the screen will display the color name and color backlight based on the accelerometer readings. The color will change depending on what axis is pointing up. Your setup may look slightly different depending on how you connected the Qwiic cables so be sure to reference the silkscreen for the accelerometer.

    RGB Character Serial LCD Display Controlled by the ICM-20948's accelerometer readings

    Resources and Going Further

    For more information, check out the resources below:

    Python Logo

    Looking for more inspiration? Check out these other Raspberry Pi projects and Python tutorials.:

    Graph Sensor Data with Python and Matplotlib

    Use matplotlib to create a real-time plot of temperature data collected from a TMP102 sensor connected to a Raspberry Pi.

    Python GUI Guide: Introduction to Tkinter

    Tkinter is the standard graphical user interface package that comes with Python. This tutorial will show you how to create basic windowed applications as well as complete full-screen dashboard examples complete with live graph updates from matplotlib.

    How to Run a Raspberry Pi Program on Startup

    In this tutorial, we look at various methods for running a script or program automatically whenever your Raspberry Pi (or other Linux computer) boots up.

    Qwiic Kit for Raspberry Pi Hookup Guide

    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!

    Raspberry Pi Twitter Monitor

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

    Bark Back Interactive Pet Monitor

    Monitor and interact with pets through this dog bark detector project based on the Raspberry Pi!

    Qwiic Distance Sensor (VL53L1X) Hookup Guide

    The Qwiic VL53L1X time of flight sensor is capable of several modes, as well as having a range of 4M. Let's hook it up and find out just how far away that thing over there is.

    Qwiic MUX Hookup Guide

    Have a bunch of sensors with the same I2C address? Put them on the Qwiic MUX (TCA9548A) to get them all talking on the same bus!

    Or check out some of these blog posts for ideas:


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

    MicroMod Asset Tracker Carrier Board Hookup Guide

    Next: MicroMod Update Tool Hookup Guide
    Previous: Qwiic SHIM Kit for Raspberry Pi Hookup Guide
    $
    0
    0

    MicroMod Asset Tracker Carrier Board Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    The MicroMod Asset Tracker Carrier Board provides you with a toolkit to monitor and track the location of your assets. Do you want to know where your assets are at all times? Or maybe you just want an update if an asset is moved? If so, this is the product for you!

    SparkFun MicroMod Asset Tracker Carrier Board

    SparkFun MicroMod Asset Tracker Carrier Board

    DEV-17272
    $149.95

    Built around the u-blox SARA-R510M8S module, the MicroMod Asset Tracker Carrier Board offers Secure Cloud LTE-M and NB-IoT data communication for multi-regional use and has an integrated u-blox M8 GNSS receiver for accurate positioning information.

    Please check that your service provider offers LTE-M / NB-IoT coverage for your area before purchasing.

    The Asset Tracker will work with any of our MicroMod Processor Boards, but because the asset tracker offers so many features and can be configured in different ways, some processor boards may be a better choice for your application than others. Please see “Choosing a Processor Board” below for more details.

    The SARA-R5 supports many different forms of data communication from full TCP/IP sockets and packet switched data, through HTTP Get/Put/Post, FTP (the SARA has a built-in file system), Ping, to good old SMS text messaging!

    The Asset Tracker has an integrated ICM-20948 Inertial Measurement Unit for 9-Degree Of Freedom orientation and movement detection. Want to send a message if your asset is moved? The asset tracker can do that! It also has a built-in digital microphone and so can send an alert as soon as a noise is detected too. Want to add a light sensor? The Qwiic connector will let you do that.

    Want to use the Asset Tracker to log data during a journey or shipping? It has a built-in micro-SD card socket for data logging. Power options include both USB-C and LiPo battery (with built-in charging and battery fuel gauge), but you can provide power via a breakout pin too.

    We’ve provided a full set of examples to get you up and running quickly and our SARA-R5 Arduino Library does all of the heavy lifting for you.

    Required Materials

    In addition to the MicroMod Asset Tracker Carrier Board, you’ll need a processor board to get started. Depending on which features of the SARA-R5 you want to use, some of our processor boards may be a better choice for your application. Please see “Choosing a Processor Board” below for more details.

    SparkFun MicroMod ESP32 Processor

    SparkFun MicroMod ESP32 Processor

    WRL-16781
    $14.95
    SparkFun MicroMod nRF52840 Processor

    SparkFun MicroMod nRF52840 Processor

    WRL-16984
    $14.95
    SparkFun MicroMod SAMD51 Processor

    SparkFun MicroMod SAMD51 Processor

    DEV-16791
    $14.95
    SparkFun MicroMod Artemis Processor

    SparkFun MicroMod Artemis Processor

    DEV-16401
    $14.95

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

    SparkFun Qwiic Cable Kit

    SparkFun Qwiic Cable Kit

    KIT-15081
    $7.95
    10
    Flexible Qwiic Cable - 100mm

    Flexible Qwiic Cable - 100mm

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

    USB 3.1 Cable A to C - 3 Foot

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

    Reversible USB A to C Cable - 2m

    CAB-15424
    $7.95

    You can power the Asset Tracker via USB-C but for portable applications you'll need a single-cell LiPo battery too. Here are some examples:

    Lithium Ion Battery - 2Ah

    Lithium Ion Battery - 2Ah

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

    Lithium Ion Battery - 1Ah

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

    Lithium Ion Battery - 6Ah

    PRT-13856
    $29.95
    6

    The Asset Tracker requires a Nano SIM for LTE-M / NB-IoT connectivity. Your service provider will be able to supply this.

    You'll also need LTE and GNSS antennas. There are many to choose from, but here are some recommendations:

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

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

    GPS-15192
    $64.95
    1
    698MHz-2.7GHz LTE Hinged External Antenna, with SMA Male Connector

    698MHz-2.7GHz LTE Hinged External Antenna, with SMA Male Connector

    CEL-16432
    $6.95
    Note: The SMA connections are standard polarity: the connector on the Asset Tracker is female, the antenna connection needs to be standard male. Antennas with reverse-polarity connectors are not suitable for the Asset Tracker.

    Optional Extras

    Want to be able to communicate directly with the SARA-R5 over USB-C, without needing a Processor Board? Or, want to upgrade the SARA firmware? The Asset Tracker Update Tool lets you do just that:

    SparkFun MicroMod Update Tool

    SparkFun MicroMod Update Tool

    DEV-17725
    $4.95

    Recommended Tools

    You will need a screw driver to tighten the screw between the processor board and carrier board.

    SparkFun Mini Screwdriver

    SparkFun Mini Screwdriver

    TOL-09146
    $0.95
    3

    Suggested Reading

    If you are not 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

    Finally, if you aren't familiar with the following concepts you may want to check out a few of these tutorials before continuing.

    Serial Communication

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

    Installing an Arduino Library

    How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

    Logic Levels

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

    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 MicroMod Asset Tracker has a lot going on so buckle up. In this section we'll cover the various components and hardware included on the Asset Tracker.

    Common Components

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

    • M.2 MicroMod Connector - This special keyed M.2 connector lets you install your MicroMod Processor of choice on your Asset Tracker Carrier Board.
    • USB-C Connector - Connect to your computer to program your Processor and also can provide power to your MicroMod system.
    • 3.3V Regulator - Provides a regulated 3.3V and sources up to 1A.
    • Qwiic Connector - The standard Qwiic connector so you can add other Qwiic devices to your MicroMod system.
    • Boot/Reset Buttons - Push buttons to enter Boot Mode on Processor boards and to Reset your MicroMod circuit.
    • microSD Slot - Insert a microSD card for reading and writing data.
    • RTC Battery - We've included a 3V Lithium Rechargeable Battery as a backup power source for the Processor Board Real Time Clock (if present).

    Annotated photo of common components.

    u-blox SARA-R510M8S

    The heart of the Asset Tracker is the SARA-R510M8S LTE-M / NB-IoT module from u-blox. This module does so much, it is difficult to know where to begin!

    Photo highlighting SARA-R5 module, SMA connectors, SIM slot and SARA On button.

    Designed to last an IoT lifetime, this module is 5G-ready with the u-blox UBX-R5 chipset. It has built-in end-to-end security with hardware-based root of trust inside a discrete secure element. It provides a full security suite with foundation, design and end-to-end security, as well as access control. The built-in u‑blox M8 GNSS receiver provides accurate and reliable positioning, always and everywhere. It is optimized for ultra-low power consumption and critical firmware updates can be delivered and services enabled via uFOTA (Firmware Over The Air). There. We told you it did a lot!

    The SARA-R5 supports many different forms of data communication from full TCP/IP sockets and packet switched data, through HTTP Get/Put/Post, FTP (the SARA has a built-in file system), Ping, to good old SMS text messaging! The built-in GNSS receiver provides NMEA format data and our library looks after the parsing for you.

    The connection between the SARA-R5 and the MicroMod Processor Board is serial (3.3V UART) but again, with this module being so clever, it can communicate over two serial interfaces at the same time. Want your LTE data on one interface and your GNSS data on a separate interface? It can do that too!

    Note: Only some of our MicroMod Processors fuly support dual serial interfaces. If this is an important feature for you please see the "Choosing a Processor Board" section below for more details.

    LTE and GNSS connections are via separate, robust SMA connectors. Switchable 3.3V power for an active antenna is available on the GNSS connector. The Asset Tracker includes a socket for a Nano SIM.

    If you need to, you can manually turn the SARA off by pushing and holding the SARA On button. The SARA will disconnect from the network before going into low power sleep. Press the button briefly to turn the SARA back on again.

    ICM-20948 IMU

    The Asset Tracker carries the same ICM-20948 9-Degree Of Freedom Inertial Measurement Unit as OpenLog Artemis. It can provide fast accelerometer, gyro and magnetometer data and can be configured for “Wake On Motion” too. We have a WOM example ready to go. It has a built-in temperature sensor too.

    Photo highlighting the ICM-20948 IMU.

    Digital Microphone

    Thieves are wily these days. When attempting to steal your asset, one of the first things they will do is cover or break the antenna (if they can see it). The built-in SPH0641 digital microphone can be used to send an alert as soon as the Asset Tracker hears the thieves coming!

    Photo highlighting the digital microphone.

    Battery Charging and Monitoring Circuit

    Since many applications for the Asset Tracker involve a battery-powered circuit, the board includes both the MCP73831 LiPo battery charger and the MAX17048 battery fuel gauge. The MCP7381 Single-cell charge management IC can deliver a charge current up to 500mA. The MAX17048 is a low-power I2C fuel gauge to monitor your battery's remaining charge.

    Photo highlighting the LiPo connector, charger and fuel gauge.

    Plated Through-Hole (PTH) Connections

    GPIO PTHs

    We've broken out dedicated PTHs for digital, analog, pulse width modulation (PWM), I2C and SPI along the sides of the Asset Tracker Carrier Board. You may also notice that we've included a ground rail next to the digital, analog and PWM pins.

    Photo highlighting the GPIO PTH header.

    Power PTHs

    We've also provided PTHs for monitoring and accessing the following power circuits:

    • VIN - The power rail fed by USB-C and/or the LiPo battery.
    • 3.3V - The regulated 3.3V rail which feeds most of the components on the board. You can measure the 3.3V current draw using the MEAS pins (see below).
    • VCCIO - This is the 1.8V rail generated by the SARA-R5. We use it to power the 1.8V to 3.3V level shifters for the UART and I2C connections.
    • 1.8V - This is the 1.8V rail which powers the IMU. You can disable it by pulling the MicroMod G4 digital pin LOW.
    • RST - Pull this low to reset the MicroMod Processor and the SARA-R5.

    Photo highlighting the power PTH header.

    SARA-R5 PTHs

    The following SARA-R5 I/O connections are also broken out to PTH headers:

    • NI - This is the SARA's Network Indicator signal. It will be low (0V) when the network is available, and high (3.3V) when the network is not available.
    • TP - This is the Timing Pulse (1PPS) signal and is connected to SARA GPIO6/TP. It will pulse low and high when the SARA is receiving a GNSS signal and the timing pulse has been enabled. Please see Example11 for more details.
    • SARA USB D-/D+/DET - These PTHs provide access to the SARA's diagnostic USB port. This connection is only used to access the SARA's trace log. You cannot (currently) upgrade the SARA via this interface. Please consult the SARA R5 Integration Manual for more details.
    • SARA I2C - These 3.3V (level-shifted) PTHs can be used to access the SARA's I2C bus. Some models of the SARA-R5 use I2C to communicate with an external GNSS module. As the SARA-R510M8S has GNSS built-in, it is unclear what you might want to use them for. But, we've been diligent and have broken them out anyway!

    Photo highlighting the SARA-R5 PTH pins.

    SWD Programming Pins

    An unpopulated JTAG footprint is available for more advanced users who need breakpoint level debugging. Note that this is not populated so you will need a compatible header and compatible JTAG programmer to connect.

    Photo highlighting the JTAG footprint.

    Solder Jumpers

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

    On the rear of the board, you will find a large number of jumpers which you can use to connect and disconnect several of the connections between the SARA and the MicroMod Processor:

    Photo highlighting the solder jumpers on the Asset Tracker

    Having trouble seeing the detail in the photo? Click on it for a larger view.

    The tables below outline all of the jumpers on the Asset Tracker along with brief descriptions of their functionality.

    Jumper Name/LabelDescriptionDefault StateNotes
    G0 / SD CSTies the µSD Chip Enable to G0CLOSED
    G1 / SD PWRToggles 3.3V to control power the µSD card.CLOSEDOpen to isolate G1. µSD will default to always on.
    G2 / LTE_PWRConnects G2 to the SARA-R5 ON signal via a level-shifting circuit.CLOSEDAllows G2 to function in the exact same way as the SARA On button. Cut the jumper to isolate G2 if required.
    G3 / IMU PWRWhen closed, G3 can be used to control power for the IMU via software. By default, IMU power is always on.OPENOn the ESP32 Processor G3 is linked directly to the processor's TX1 pin. Leave the G3 jumper OPEN if you are using the ESP32 Processor or else serial communication with the SARA will not work.
    G4 / RIWhen closed, connects G4 to the SARA-R5's Ring Indicator pin.OPENOn the ESP32 Processor, G4 is shared with the processor's RX1 pin. Similarly, G4 is shared with SPI CIPO on the RP2040 Processor. Leave this jumper OPEN if using either Processor to avoid serial communication errors with the SARA.
    G5 / SARA INTWhen closed, connects G5 with either the SARA-R5's Interrupt I/O pin or the SARA's GPIO3 I/O pin depending on the state of the EXT INT / GPIO3 dual jumper (covered below).OPENOn the RP2040 Processor, G5 is shared with SPI Chip Select line. Closing the jumper will interfere with the SPI bus on the RP2040 Processor.
    G6 / SARA ONWhen closed, this jumper allows G6 to monitor if the SARA power is on.OPENThis signal is different to the SARA On push-button. On the RP2040 Processor, G6 is shared with the SPI Clock line. Closing this jumper will interfere with the SPI bus on the RP2040 Processor.
    G7 / DSRWhen closed, connects G7 to the SARA's DSR signal.OPENOn the RP2040 Processor, G7 is shared with the SPI COPI line. Leave this jumper open to avoid interfering with the SPI bus on this processor.
    PDM DATConnects the data signal from on-board microphone to AUD_LRCLK (MicroMod Pad 52).CLOSEDOn the RP2040 Processor, AUD_LRCLK is shared with CTS1. Open this jumper to use the CTS connection on the SARA.
    PDM CLKConnects the clock signal from the on-board microphone to AUD_BCLK (MicroMod Pad 50).CLOSEDOn the RP2040 Processor, AUD_BCLK is shared with RTS1. Open this jumper to use the RTS connection on the SARA.
    I2CA dual jumper that ties SDA & SCL on the primary I2C/Qwiic bus to 3.3V via a pair of 2.2k&ohm; resistors.CLOSEDOpen both jumpers to disconnect the pull-ups.
    SARA I2CA dual jumper that ties the SARA's SDA and SCL lines to 3.3V via a pair of 2.2k&ohm;CLOSEDOpen both jumpers to disable the pull-ups.
    CIPOTies SPI CIPO/SDI to 3.3V via a 2.2k&ohm; resistor.CLOSEDOpen to disconnect the pull-up. Opening this jumper may be advantageous for very low power applications where Processors like the Artemis have internal pull-ups which can be used instead.
    EXT INT / GPIO3A dual jumper used to select which signal is connected to MicroMod G5. SEE NOTEBy default, this jumper is set so if the G5 / SARA INT jumper is closed, G5 is connected to the SARA EXT INT I/O pin. Switch this jumper to the opposite side to connect G5 to the SARA GPIO3 pin.
    DSRA dual jumper used to control the direction of DSR from input to output .SEE NOTEBy default, this jumper sets DSR as an input. Switching it sets DSR as an output so users can use dual-UART communication modes on the SARA.
    MEASAllows users to measure the current draw from the 3.3V power rail.CLOSEDOpen this jumper and complete the circuit using a digital multimeter to measure current draw on the 3.3V power rail.
    VIN/3Completes the VIN/3 voltage divider circuit.CLOSEDOpen the jumper to disable the VIN/3 voltage divider circuit. Disabling this can be useful in very low power applications to reduce total current draw.
    3V3 (LED)Connects the anode of the 3.3V LED to 3.3V via a 1k&ohm; resistor.CLOSEDOpen the jumper to disable the 3.3V LED to reduce total current draw of the MicroMod circuit.
    VIN (LED)Connects the anode of the VIN LED to VIN (5V if powered by USB, 3.7V nominal if powered by LiPo battery) via a 4.7k&ohm; resistor.CLOSEDOpen the jumper to disable the VIN LED to reduce the total current draw of the MicroMod circuit.
    ICM_INTConnects the ICM IMU Interrupt pin to the primary I2C Interrupt pin (I2C_INT) on the MicroMod connector.CLOSEDOpen the jumper to isolate the MicroMod I2C_INT pin from the ICM-20948. On the RP2040 Processor, I2C_INT is shared with TX2. You may need to open this jumper to use the DTR handshake signal.
    Jumper Name/LabelDescriptionDefault StateNotes
    V USBConnects VUSB_DET on the SARA's diganostic (trace log) USB port to V_USB (5VOPEN Important! You must not have a Processor installed to use the diagnostic USB port.
    USB D+Connects USB_D+ on the SARA's diagnostic (trace log) USB port to USB_D+ on the USB-C connector.OPEN Important! You must not have a Processor installed to use the diagnostic USB port.
    USB_D-Connects USB_D- on the SARA's diagnostic (trace log) USB port to USB_D- on the USB-C connector.OPEN Important! You must not have a Processor installed to use the diagnostic USB port.
    VEWhen closed, allows the Processor to disable the main 3.3V regulator via the 3.3V_EN pin.OPENRecommended only for very low power applications. The Processor can draw power from the RTC battery while the voltage regulator is disabled.
    BYPBypasses the 6V/2A fuse and nets VIN and V_USB together.OPENThe "penny-in-the-fuse" jumper. Close only if you know what you are doing!

    MicroMod Pinout

    Wondering what the pins are that are broken out on the MicroMod Asset Tracker Carrier Board? The tables below outline the Asset Tracker pinout as well as the general MicroMod pinout. Remember to compare the pins against your Processor Board to determine which pins are available.

    Note: You may not recognize the COPI/CIPO labels for SPI pins. SparkFun is working to move away from using MISO/MOSI to describe signals between the controller and the peripheral. Check out this page for more on our reasoning behind this change.
    AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
    M.2 Connector Pin#MicroMod Pin NameAsset Tracker ConnectionDescription
    1GNDGNDGround plane.
    23.3V3.3VRegulated 3.3V via USB-C.
    3USB_D+PassthroughUSB D+ connection for Processor Board.
    43.3V_EN3.3V EnableVoltage regulator enable input.
    5USB_D-PassthroughUSB D- connection for Processor Board.
    6RESETRESET ButtonConnected to RESET Button. Reset is active LOW
    9USB_VINVINInput voltage from USB.
    10D0SPI PTH CS/D0 PTHSPI Chip Select for SPI PTH Header. D0 also broken out for I/O PTHs
    11BOOTBOOT ButtonConnected to BOOT Button. Boot is active LOW.
    12I2C_SDAI2C_SDAI2C data for Fuel Gauge & Qwiic connector
    13UART_RTS1SARA RTS_IUART Request to Send for SARA
    14I2C_SCLI2C_SCLI2C clock for Fuel Gauge & Qwiic connector
    15UART_CTS1SARA CTS_OUART Clear to Send for SARA
    16I2C_INT#IMU INTIMU Interrupt pin
    17UART_TX1SARA RXD_OSARA UART Data Output
    18D1D1General digital I/O PTH
    19UART_RX1SARA TXD_ISARA UART Data Input
    20UART_RX2SARA DCD_O/RXD2_OSARA UART Data Carrier Detect / AUX UART Data Output
    21SWDCKSWDCKSerial Wire Debug Clock
    22UART_TX2SARA DTR_I/TXD2_ISARA UART Data Terminal Ready / AUX UART Data Input
    23SWDIOSWDIOSerial Wire Debug I/O
    32PWM0PWM0PWM0 PTH
    34A0A0A0 PTH (Input Only)
    34A1A1A1 PTH (Input Only)
    40G0/BUS0SD CSGeneral purpose pin configured for Chip Select on µSD.
    42G1/BUS1microSD_PWRGeneral purpose pin configured for µSD Power Enable
    44G2/BUS2LTE_PWR_ONGeneral purpose pin configured for turning SARA on/off
    46G3/BUS3ICM_PWRGeneral purpose pin configured for controlling IMU power
    48G4/BUS4SARA RI_O/CTS2_OSARA UART Ring Indicator / AUX UART Clear to Send
    49BATT_VIN/3VIN/3Divided input voltage for monitoring power supply.
    50AUD_BCLKI2S_SCK/PDM_CLKMicrophone PDM clock signal
    51I2C_SDA1SARA I2C SDASARA I2C data signal
    52AUD_LRCLKI2S_WS/PDM_DATMicrophone PDM data signal
    53I2C_SCL1SARA I2C SCLSARA I2C clock signal
    55SPI_CS#ICM_CSChip select for IMU level shifting IC
    57SPI_SCKSPI_SCKSPI Clock
    59SPI_COPISPI_SDOSPI controller out/peripheral in
    61SPI_CIPOSPI_SDOSPI controller in/peripheral out
    69G7/BUS7SARA DSR_O/RTS2_ISARA UART Data Set Ready / AUX UART Request to Send
    71G6/BUS6SARA_ONGeneral purpose pin conifgured to monitor power for SARA
    72RTC_3VRTC_3V3V output for backup battery charging.
    73G5/BUS5SARA_INTGeneral purpose pin configured for SARA Interrupt I/O pin
    743.3V3.3V3.3V output from voltage regulator
    FunctionBottom
    Pin
       Top   
    Pin
    Function
    (Not Connected)75GND
    3.3V7473G5 / BUS5
    RTC_3V_BATT7271G6 / BUS6
    SPI_CS1#SDIO_DATA3 (I/O)7069G7 / BUS7
    SDIO_DATA2 (I/O)6867G8
    SDIO_DATA1 (I/O)6665G9ADC_D- CAM_HSYNC
    SPI_CIPO1SDIO_DATA0 (I/O)6463G10ADC_D+CAM_VSYNC
    SPI COPI1SDIO_CMD (I/O)6261SPI_CIPO (I)
    SPI SCK1SDIO_SCK (O)6059SPI_COPI (O)LED_DAT
    AUD_MCLK (O)5857SPI_SCK (O)LED_CLK
    CAM_MCLKPCM_OUTI2S_OUTAUD_OUT5655SPI_CS#
    CAM_PCLKPCM_INI2S_INAUD_IN5453I2C_SCL1 (I/O)
    PDM_DATAPCM_SYNCI2S_WSAUD_LRCLK5251I2C_SDA1 (I/O)
    PDM_CLKPCM_CLKI2S_SCKAUD_BCLK5049BATT_VIN / 3 (I - ADC) (0 to 3.3V)
    G4 / BUS44847PWM1
    G3 / BUS34645GND
    G2 / BUS24443CAN_TX
    G1 / BUS14241CAN_RX
    G0 / BUS04039GND
    A13837USBHOST_D-
    GND3635USBHOST_D+
    A03433GND
    PWM03231Module Key
    Module Key3029Module Key
    Module Key2827Module Key
    Module Key2625Module Key
    Module Key2423SWDIO
    UART_TX2 (O)2221SWDCK
    UART_RX2 (I)2019UART_RX1 (I)
    CAM_TRIGD11817UART_TX1 (0)
    I2C_INT#1615UART_CTS1 (I)
    I2C_SCL (I/0)1413UART_RTS1 (O)
    I2C_SDA (I/0)1211BOOT (I - Open Drain)
    D0109USB_VIN
    SWOG1187GND
    RESET# (I - Open Drain)65USB_D-
    3.3V_EN43USB_D+
    3.3V21GND
    Signal GroupSignalI/ODescriptionVoltage
    Power3.3VI3.3V Source3.3V
    GNDReturn current path0V
    USB_VINIUSB VIN compliant to USB 2.0 specification. Connect to pins on processor board that require 5V for USB functionality4.8-5.2V
    RTC_3V_BATTI3V provided by external coin cell or mini battery. Max draw=100μA. Connect to pins maintaining an RTC during power loss. Can be left NC.3V
    3.3V_ENOControls the carrier board's main voltage regulator. Voltage above 1V will enable 3.3V power path.3.3V
    BATT_VIN/3ICarrier board raw voltage over 3. 1/3 resistor divider is implemented on carrier board. Amplify the analog signal as needed for full 0-3.3V range3.3V
    ResetResetIInput to processor. Open drain with pullup on processor board. Pulling low resets processor.3.3V
    BootIInput to processor. Open drain with pullup on processor board. Pulling low puts processor into special boot mode. Can be left NC.3.3V
    USBUSB_D±I/OUSB Data ±. Differential serial data interface compliant to USB 2.0 specification. If UART is required for programming, USB± must be routed to a USB-to-serial conversion IC on the processor board.
    USB HostUSBHOST_D±I/OFor processors that support USB Host Mode. USB Data±. Differential serial data interface compliant to USB 2.0 specification. Can be left NC.
    CANCAN_RXICAN Bus receive data.3.3V
    CAN_TXO CAN Bus transmit data.3.3V
    UARTUART_RX1IUART receive data.3.3V
    UART_TX1OUART transmit data.3.3V
    UART_RTS1OUART request to send.3.3V
    UART_CTS1IUART clear to send.3.3V
    UART_RX2I2nd UART receive data.3.3V
    UART_TX2O2nd UART transmit data.3.3V
    I2CI2C_SCLI/OI2C clock. Open drain with pullup on carrier board.3.3V
    I2C_SDAI/OI2C data. Open drain with pullup on carrier board3.3V
    I2C_INT#IInterrupt notification from carrier board to processor. Open drain with pullup on carrier board. Active LOW3.3V
    I2C_SCL1I/O2nd I2C clock. Open drain with pullup on carrier board.3.3V
    I2C_SDA1I/O2nd I2C data. Open drain with pullup on carrier board.3.3V
    SPISPI_COPIOSPI Controller Output/Peripheral Input.3.3V
    SPI_CIPOISPI Controller Input/Peripheral Output.3.3V
    SPI_SCKOSPI Clock.3.3V
    SPI_CS#OSPI Chip Select. Active LOW. Can be routed to GPIO if hardware CS is unused.3.3V
    SPI/SDIOSPI_SCK1/SDIO_CLKO2nd SPI Clock. Secondary use is SDIO Clock.3.3V
    SPI_COPI1/SDIO_CMDI/O2nd SPI Controller Output/Peripheral Input. Secondary use is SDIO command interface.3.3V
    SPI_CIPO1/SDIO_DATA0I/O2nd SPI Peripheral Input/Controller Output. Secondary use is SDIO data exchange bit 0.3.3V
    SDIO_DATA1I/OSDIO data exchange bit 1.3.3V
    SDIO_DATA2I/OSDIO data exchange bit 2.3.3V
    SPI_CS1/SDIO_DATA3I/O2nd SPI Chip Select. Secondary use is SDIO data exchange bit 3.3.3V
    AudioAUD_MCLKOAudio master clock.3.3V
    AUD_OUT/PCM_OUT/I2S_OUT/CAM_MCLKOAudio data output. PCM synchronous data output. I2S serial data out. Camera master clock.3.3V
    AUD_IN/PCM_IN/I2S_IN/CAM_PCLKIAudio data input. PCM syncrhonous data input. I2S serial data in. Camera periphperal clock.3.3V
    AUD_LRCLK/PCM_SYNC/I2S_WS/PDM_DATAI/OAudio left/right clock. PCM syncrhonous data SYNC. I2S word select. PDM data.3.3V
    AUD_BCLK/PCM_CLK/I2S_CLK/PDM_CLKOAudio bit clock. PCM clock. I2S continuous serial clock. PDM clock.3.3V
    SWDSWDIOI/OSerial Wire Debug I/O. Connect if processor board supports SWD. Can be left NC.3.3V
    SWDCKISerial Wire Debug clock. Connect if processor board supports SWD. Can be left NC.3.3V
    ADCA0IAnalog to digital converter 0. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
    A1IAnalog to digital converter 1. Amplify the analog signal as needed to enable full 0-3.3V range.3.3V
    PWMPWM0OPulse width modulated output 0.3.3V
    PWM1OPulse width modulated output 1.3.3V
    DigitalD0I/O General digital input/output pin.3.3V
    D1/CAM_TRIGI/OGeneral digital input/output pin. Camera trigger.3.3V
    General/BusG0/BUS0I/OGeneral purpose pins. Any unused processor pins should be assigned to Gx with ADC + PWM capable pins given priority (0, 1, 2, etc.) positions. The intent is to guarantee PWM, ADC and Digital Pin functionality on respective ADC/PWM/Digital pins. Gx pins do not guarantee ADC/PWM function. Alternative use is pins can support a fast read/write 8-bit or 4-bit wide bus.3.3V
    G1/BUS1I/O3.3V
    G2/BUS2I/O3.3V
    G3/BUS3I/O3.3V
    G4/BUS4I/O3.3V
    G5/BUS5I/O3.3V
    G6/BUS6I/O3.3V
    G7/BUS7I/O3.3V
    G8I/OGeneral purpose pin3.3V
    G9/ADC_D-/CAM_HSYNCI/ODifferential ADC input if available. Camera horizontal sync.3.3V
    G10/ADC_D+/CAM_VSYNCI/ODifferential ADC input if available. Camera vertical sync.3.3V
    G11/SWOI/OGeneral purpose pin. Serial Wire Output3.3V

    Board Dimensions

    The Asset Tracker Carrier Board measures 3.0 inches by 3.0 inches (76.2mm x 76.2mm) and has four mounting holes that fit a 4-40 screw.

    Asset Tracker Board Dimensions

    Having trouble seeing the details in the image? Click on it for a larger view!

    Choosing a Processor Board

    As you can see from the Jumpers section above, there are some things to consider when choosing a MicroMod Processor Board to go with your Asset Tracker.

    The MicroMod M.2 connector pinout is very comprehensive and some of the processor chips on our MicroMod Processor Boards just don't have enough I/O pins to let us allocate one to every M.2 pin. So, on those boards we share the pins. For example, on the ESP32 Processor Board, you will see that the UART TX1 pin is shared with the G3 I/O pin and the AUD_OUT pin. We do that so that you can use that pin for TX1 or G3 or AUD_OUT. And for most users and most Carrier Boards, that's perfectly fine. However, since the SARA-R5 has so many pins that we need to connect to, the sharing of TX1 and G3 causes a small problem. We need TX1 to communicate with the SARA, and G3 would normally be used to enable power for the ICM-20948 IMU. We get round that by including a normally-open split pad jumper on G3 and making the IMU power circuit default to on. Simple!

    So, you can use any SparkFun MicroMod Processor in the Asset Tracker, but if you need complete access to all of the pins then here are the restrictions:

    ESP32 Processor

    TX1 is shared with G3. This means you cannot close the G3 split pad to enable control of the IMU Power. The IMU power will need to be always on.

    RX1 is shared with G4. This means you cannot close the G4 split pad to access the SARA Ring Indicator / Clear To Send 2 pin.

    AUD_LRCLK is shared with G1. G1 controls the micro-SD power and AUD_LRCLK is connected to the digital microphone. If you want to use the microphone, you will need to open the G1 split pad jumper. The micro-SD power will default to on.

    AUD_BCLK is shared with G2. G2 can be used to turn the SARA-R5 on/off and AUD_BCLK is connected to the digital microphone. If you want to use the microphone, you will need to open the G2 jumper. You won’t then be able to have the processor turn the SARA on and off. The SARA always powers on automatically when power is connected, so no worries there, and the SARA On button is there if you need it.

    Artemis Processor

    The Artemis Processor does not support the M.2 TX2 and RX2 pins. This means you cannot use the Artemis to talk to the SARA using any of the dual-UART variants (called variants 2, 3 and 4 in the SARA-R5 System Integration Manual). This means you cannot, for example, use UART 1 for your LTE traffic and UART 2 for your GNSS data. That's all. You can do everything over a single UART anyway.

    nRF5280 Processor

    The nRF52840 Processor Board supports all of the pins used by the Asset Tracker. There are no restrictions for this Processor Board.

    SAMD51 Processor

    The SAMD51 Processor Board does not support RTS1 and CTS1 and so you will not be able to perform hardware handshaking when using the UART. Serial buffers are so large these days that you probably won’t even notice this restriction, but it is something to be aware of.

    RP2040 Processor

    AUD_LRCLK is shared with CTS1. This means that if you want to use hardware handshaking for the UART communication, you won’t be able to use the digital microphone.

    Likewise AUD_BCLK is shared with RTS1, again preventing you from using the microphone and hardware handshaking at the same time.

    I2C_INT is shared with TX2. This means that you cannot use the ICM-20948 IMU interrupt and SARA DTR / TXD2 simultaneously. You can open the ICM_INT split pad to isolate the IMU interrupt signal.

    G4, G5, G6 and G7 are shared with the SPI connections SPI_SCK, SPI_COPI, SPI_CIPO and SPI_CS. This should not be an issue for you, but it does mean you cannot close the G4-G7 jumpers to enable access to: SARA_RI, SARA_INT, SARA is On, and SARA_DSR.

    Hardware Assembly

    Now that we are familiar with the hardware on the Asset Tracker Carrier Board, it's time to assemble it with your chosen MicroMod Processor and get it connected to your computer.

    Inserting Your Processor

    With the M.2 MicroMod connector, connecting your processor board is a breeze. Simply match up the key on your processor's beveled edge connector to the key on the M.2 connector. At a 45° angle, insert the processor board to the M.2 connector. The processor board will stick up at an angle as seen here:

    Photo showing the Processor inserted into M.2 connector at 45 degree angle.

    Once the board is in the socket, gently press the Processor down, grab the set screw and tighten it with a Phillip's head screwdriver:

    Photo showing the Processor being secured with a screwdriver.

    With the Processor secure, your assembled MicroMod Asset Tracker system should look similar to the image below!

    Photo showing a properly secured Processor Board.
    Note There is technically no way to insert the Processor backwards since the key prevents from mating with the M.2 connector. As an extra safeguard to prevent inserting a Processor improperly or with a poor connection, the mounting screw will not match up if the Processor is not plugged in entirely.

    Connecting Everything Up

    Now is a good time to insert the Nano SIM from your service provider. Make sure the orientation matches the symbol on the PCB; the edge with the trimmed corner is inserted first.

    The LTE and GNSS connections simply screw on to the appropriate SMA connectors. Make sure you check the labeling on the board and connect them the right way round. (LTE is on the Left.)

    With your processor inserted and secured it's time to connect your MicroMod Asset Tracker Carrier Board to your computer using the USB-C connector. Depending on which processor you choose and which drivers you already have installed, you may need to install drivers for your board. Refer to your Processor's Hookup Guide for detailed instructions on how to install them.

    Software Setup

    Note: The software examples assume you are using the latest version of the Arduino IDE on your computer. If this is your first time using Arduino, please review our tutorial on Installing the Arduino IDE. If you have not previously installed an Arduino library, please read through our Arduino Library Installation Guide
    Note: Make sure that for whichever MicroMod Processor you choose, you have the correct board definitions installed.
    The Asset Tracker examples will run on any SparkFun MicroMod Processor Board (PB) but each PB has a slightly different sequence to follow when uploading and running code. For example, some require a press of the Boot button and others do not. Head over to our MicroMod Processor Boards landing page, find your Processor, and read through its tutorial for help installing your board definition and how to upload the code.

    We have prepared a complete set of examples showing you how to use all of the features on the Asset Tracker. However, the examples need access to several Arduino Libraries before they will run correctly and so you need to install those too.

    Installing the MicroMod Asset Tracker Carrier Board Examples

    The Asset Tracker examples live on GitHub in the Asset Tracker repository and you will find them in the Examples folder. You can download the complete repository from GitHub as a single .ZIP file by clicking the button below:

    Unzip the .ZIP file and copy all 22 examples to a suitable folder on your computer. We recommend putting them in your Arduino folder.

    You will see that each example comprises three files. E.g for Example1:

    • AssetTracker_Example1_Blink.ino is the actual example code
    • AssetTrackerPins.h contains the pin definitions to allow each Processor to work correctly with the Asset Tracker
    • AssetTrackerPins.ino ontains useful ‘housekeeping’ functions that do things like turn on the SD or IMU power. They are in a separate file to make them easier to update when we add new processor boards and to avoid cluttering up the main example code.

    When it is time to open and try Example1 select the AssetTracker_Example1_Blink.ino file first. The other two will open automatically as they are in the same folder.

    SparkFun u-blox SARA-R5 Arduino Library

    The SparkFun u-blox SARA-R5 Arduino Library lives on GitHub too and you can either install it using the Arduino Library Manager, or you can install it manually.

    If you want to install the library using the Arduino Library Manager, then search for ‘SparkFun u-blox SARA-R5’.

    Alternatively, you can download a .ZIP of the library by clicking the button below:

    Additional Libraries

    Once you have the u-blox SARA-R5 library installed, most (but not all) of the examples will work correctly. To allow the full set to run, you also need to install the following libraries:

    You can install them using the Arduino Library manager by searching for their respective names. Alternatively, you can download the .ZIP for each of them by clicking the buttons below:

    Arduino Examples

    Once you have the MicroMod Asset Tracker Carrier Board examples and all of the required libraries installed, it is finally time to run your first example!

    Example 1: Blink

    Baby steps… Example1 checks that you can communicate with the MicroMod Processor Board, compile and upload code successfully.

    Navigate to the location the Asset Tracker Examples repository downloaded to and open the Examples folder. In that folder you'll find all the examples. Navigate to Example1 and open the file called AssetTracker_Example1_Blink.ino in the Arduino IDE or copy the code below into a blank sketch, select your Board and Port and click "Upload".

    language:c
    #include "AssetTrackerPins.h" // Include the Asset Tracker pin and port definitions
    
    #define SERIAL_PORT Serial // This is the console serial port - change this if required
    
    #include <SparkFun_u-blox_SARA-R5_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_SARA-R5_Arduino_Library
    
    // Create a SARA_R5 object to use throughout the sketch. Pass it the power pin number.
    SARA_R5 assetTracker(SARA_PWR);
    
    void setup()
    {
      initializeAssetTrackerPins(); // Initialize the pins and ports (defined in AssetTrackerPins.ino)
    }
    
    void loop()
    {
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); // Flash the STAT LED at 0.5Hz (Read-Invert-Write)
      delay(1000);
    }
    

    All Example1 does is blink the STAT LED on the Processor Board. That's all it does. Yes, really. But it proves that you have the correct Processor Board selected and that code compilation and upload works. The good stuff comes in the following examples.

    Example 2: IMU

    Example2 demonstrates how to get readings from the ICM-20948 Inertial Measurement Unit on the Asset Tracker. Open AssetTracker_Example2_IMU.ino and upload to the Processor Board. Now open the Serial Monitor or a terminal emulator and connect to the Processor Board at 115200 Baud. If all is well, you should see the following:

    Screenshot showing Arduino Serial Monitor open

    Click Send or hit Enter and you should then see the following, followed by lots of lovely IMU data scrolling up the screen:

    Screenshot of Arduino Serial Monitor printing IMU data.

    The things to look out for are a 980 milli-g Acceleration in Z - if your board is horizontal. That's gravity. You will also see a reading of the Earth's magnetic field on one or more of the Magnetometer (Compass) axes, but the value will depend on your local Angle Of Magnetic Declination and Inclination. (Strange but true: the strongest magnetic field points downward into the ground in many places.)

    Example 3: µSD Card

    Example3 uses Bill Greiman's SdFat library to print a directory of all the files on your microSD card.

    The usual restrictions apply: we recommend disconnecting the power to your Asset Tracker before removing or inserting the µSD card. Removing the card while powered can cause data corruption.

    Example 4: MAX17048 Fuel Gauge

    Example4 demonstrates how to use the MAX17048 Fuel Gauge to read the battery charge status.

    Example 5: Qwiic

    Example5 demonstrates how to use the Qwiic bus to talk to an external sensor attached to the Qwiic connector. The example assumes that you have a Qwiic Power Switch attached, but you can adapt the code to use whichever Qwiic board you have available. The Qwiic I2C bus is called Wire on the Asset Tracker.

    Example 6: I/O Pins

    Example6 demonstrates how to configure the D0, D1, A0, A1, PWM0 and PWM1 Input / Output pins.

    Example 7: GNSS Antenna Power

    Example7 is where we communicate with the SARA-R5 for the first time. The power for the active GNSS antenna is controlled by the SARA GPIO2 pin. When the SARA is on and GPIO2 is high, the 3.3V antenna power is enabled. We need to instruct the SARA to enable GPIO2 and set it high via the UART interface.

    The example code calls enableGNSSAntennaPower(); and disableGNSSAntennaPower(); which do the heavy lifting for you. Those functions are defined in AssetTrackerPins.in and in turn call the SARA-R5 library:

    language:c
    assetTracker.setGpioMode(assetTracker.GPIO2, assetTracker.GPIO_OUTPUT, 1); // Enable
    

    and

    language:c
    assetTracker.setGpioMode(assetTracker.GPIO2, assetTracker.GPIO_OUTPUT, 0); // Disable
    

    There is no indicator LED to tell you if the antenna power is on. You can, if you wish, use a digital multimeter to probe carefully on the center pin of the GNSS SMA connector. You will see voltage toggling between 3.3V and 0V.

    Important! When probing the GNSS SMA connector be very careful to avoid static discharge. A grounding strap is recommended to prevent damaging the antenna and board from static discharge.

    This example demonstrates that serial communication is taking place between the Processor Board and the SARA-R5.

    Example 8: External SPI

    Example8 shows how to use the SPI Breakout Plated-Through Holes (PTHs) on the left edge of the board. The example assumes you have a SparkFun Micro OLED Display connected, but you can adapt the code to talk to whichever SPI board you have available. The SPI port is called SPI on the Asset Tracker.

    Example 9: VIN

    Example9 demonstrates how to read the VIN bus voltage using the resistor divider on the Asset Tracker. The function readVIN() in AssetTrackerPins.ino automatically converts the Analog To Digital Converter result into voltage correctly for the different Processor Boards.

    Example 10: IMU Wake-On-Motion

    Example10 demonstrates how the ICM-20948 IMU can be configured to detect motion or an impact. This example could be a key part of your final asset-tracking code.

    Example 11: GNSS GPRMC

    Example11 demonstrates how to read the Asset Tracker’s location using the u-blox M8 GNSS receiver built into the SARA-R5. The GNSS generates an NMEA GPRMC data stream and our SARA-R5 library does the heavy lifting for you, extracting the latitude and longitude etc. as numbers.

    Example 12: Identification

    Example12 is the first example which communicates with the LTE part of SARA-R5. The example reads data from the SARA including its ID, firmware version, serial number, IMEI and subscriber number. The subscriber number - if present - comes from the SIM. This example demonstrates that the SIM is inserted correctly.

    Example 13: Network Information

    Example13 is the first example which checks that the SARA is receiving an LTE signal. The code prints the received signal strength, registration status and data “context ID”. The SARA reads your operator details from the SIM and uses those when registering on the network.

    It is important that you run examples 13, 14 and 17 in order as each plays a role in making sure the SARA's data connection is configured correctly.

    Example 14: Register Operator

    Example14 shows if you are already connected to a network and gives you the opportunity to register on a different network (if one is available and if your SIM supports this). You can use this example to list all of the LTE operators the SARA can detect, but you will only be able to connect to networks supported by your SIM.

    Example 15: Receive SMS

    For many applications, good old Short Message Service text messaging is a good solution. Example15 demonstrates how to read and print any existing text messages in the SARA's memory. The code will then wait for a new message to arrive and will print it when it does.

    Incoming messages are automatically marked as read once they have been printed by the code. You can force the code to print all the messages in memory by commenting the line which says:

    language:c
    if (unread == "REC UNREAD") // Only print new (previously-unread) messages.
    

    Screenshot showing serial printout of SMS messages and message data

    Example 16: Send SMS

    Example16 demonstrates how to send an SMS message to another phone or Asset Tracker. The code will ask for the destination number, followed by the message. If you are using the Arduino IDE Serial Monitor, you can type these into the text box at the top of the window and then click Send or press Enter. If you are using a terminal emulator, type the number and then press Enter (or add a newline / line feed character (“\n” or 0x0A)) to end the message.

    Example 17: Packet Switched Data

    Example17 is an important example as it configures the “Context Identifier” for your mobile data connection. The SARA will read details of the data context from the network and SIM and you can confirm which one you want to use. The first context may be blank; select one that shows a sensible name and IP address for your service provider. In the screenshots below, we select option 1:

    Screenshot showing serial monitor printout for Example 17

    Screenshot showing serial monitor printout after entering "1" for Example 17

    The code provides a warning that “deactivate profile failed”. We see this because the SARA needs to disconnect from a profile before it can connect to a new one, and in this case this failed because there was no profile active. Don’t worry about this warning, it is just there for information. The example shows that our connection was successful by displaying the Internet Protocol (IP) address the SARA has been allocated by the service operator.

    Example 18: Ping

    Example18 tests the SARA's data connection by performing one of the oldest and shortest data transfers going… A ping!

    The code will ask for the name of the server you want to ping. www.google.com is a good choice, but www.sparkfun.com works too! If the ping is successful, you will see the time it took for the ping to do a round trip in milliseconds.

    Screenshot showing serial printout from successful ping.
    Having trouble seeing the detail in this image? Click on it for a larger view.

    If the ping is not successful, one option to find out why is to uncomment the line which says:

    language:c
    assetTracker.enableDebugging(SERIAL_PORT); // Uncomment this line to enable helpful debug messages
    

    This enables a bunch of helpful debug messages that print in the Serial Monitor or your terminal emulator window. After uncommenting the above line, upload the code again.

    Look for any messages that include +UUPINGER:. That will give you the cause of the PING ERror. The SARA-R5 AT Command Reference contains the full list of Ping error codes in Appendix A.10.

    For example, error 8 means that the SARA “Cannot resolve host” which is usually a sign that a Domain Name Server (DNS) is not available. Error 17 indicates “Packet Switched Data connection not established”. If you see errors like this, please make sure you ran examples 13, 14, 17 and 18 in order. Each builds on the previous example.

    Example 19: ThingSpeak

    Example19 demonstrates how to send data to ThingSpeak using HTTP POST or GET.

    Prior to using this example you need to complete the following steps:

    • Create a ThingSpeak User Account here
    • Create a new Channel by selecting Channels -->My Channels -->New Channel
    • Note the Write API Key and copy/paste it into myWriteAPIKey in the example code.

    The example code reads the temperature from the Asset Tracker IMU and POSTs it to ThingSpeak. It will be added to your ThingSpeak channel as "Field 1".

    Note: The IMU temperature is always a few degrees warmer than ambient as it is inside a nice warm chip busy running accelerometer, gyro and compass sensors!

    If you open your serial monitor at 115200 baud the code prints out over serial the data sent to ThingSpeak:

    Screenshot showing serial monitor printout while temperature data is posted to ThingSpeak.

    Check your ThingSpeak channel and you should see data posted to it similar to the screenshot below:

    Screenshot of ThingSpeak application showing temperature data posts.

    Examples 20-22: Production Tests

    Examples 20 - 22 are the ones we use using Asset Tracker production tests to check if the SARA’s I/O pins are connected correctly. We’ve included them as you might find them useful if you want to control the pins on the SARA. The examples use the SARA’s +UTEST mode to control the pins. Please consult the SARA-R5 AT Command Reference for further details.

    Troubleshooting

    In this section we'll go over a few troubleshooting tips for common snags and questions using the MicroMod Asset Tracker Carrier Board.

    LTE Network Availability

    The SARA-R5 supports LTE-M and NB-IoT data communication for multi-regional use. Please check the LTE signal availability for your area before purchasing a SARA-R5 product and selecting an LTE service provider / operator.

    Data Connectivity

    When working through the data connectivity examples, it is important that you run examples 13, 14 and 17 in order, before moving on to example 18 or 19. Each example builds on the last and together they configure the SARA’s data connection correctly.

    TP (1PPS) Pin and LED

    At the time of writing, we are shipping the SARA-R5 on the Asset Tracker with firmware version 02.06 on it. 02.06 contains a feature (which is just a polite name for a bug!) which means the 1 Pulse-Per-Second from the GNSS does work, but the pulse is only ~3 microseconds wide and cannot be adjusted. Handy huh? u-blox are aware of this - in fact we told them about it - and a fix is coming but they haven’t added it yet. We will keep an eye out for it and update this section once the fix is released.

    Just to complicate matters, 3 microseconds is too short for the buffer FET and LED connected to the timing pulse to respond. So, we regret that you cannot currently use the TP PTH. We will share the fix with you as soon as we have it. The SARA firmware is easy to update using the Asset Tracker Firmware Update Tool.

    General Troubleshooting Help

    Resources and Going Further

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

    MicroMod Asset Tracker Carrier Documentation:

    u-blox SARA-R5 LTE-M / NB-IoT module Documentation:

    MicroMod Documentation:

    Users looking to update the firmware on their Asset Tracker Carrier Board using the MicroMod Update Tool should read through our MicroMod Update Tool Hookup Guide:

    New!

    MicroMod Update Tool Hookup Guide

    February 25, 2021

    Follow this guide to learn how to use the MicroMod Update Tool to interact directly with the UART on the MicroMod Asset Tracker's SARA-R5. Using this board you can talk directly to the module using u-blox's m-center software as well as update the firmware using EasyFlash.

    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 Artemis Processor Board Hookup Guide

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

    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 Machine Learning Carrier Board Hookup Guide

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

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


    MicroMod Update Tool Hookup Guide

    Next: Qwiic Carrier Board Hookup Guide
    Previous: MicroMod Asset Tracker Carrier Board Hookup Guide
    $
    0
    0

    MicroMod Update Tool Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    Introducing the SparkFun MicroMod Update Tool! This simple little board allows you to interact directly with the SARA-R5 LTE-M / NB-IoT module on the MicroMod Asset Tracker Carrier Board via the module's UART.

    SparkFun MicroMod Update Tool

    SparkFun MicroMod Update Tool

    DEV-17725
    $4.95

    The MicroMod Asset Tracker Carrier Board provides you with a toolkit to monitor and track the location of your assets. Do you want to know where your assets are at all times? Or maybe you just want an update if an asset is moved? If so, this is the product for you!

    Built around the u-blox SARA-R510M8S module, the asset tracker offers Secure Cloud LTE-M and NB-IoT data communication for multi-regional use and has an integrated u-blox M8 GNSS receiver for accurate positioning information. The SARA-R5 supports many different forms of data communication from full TCP/IP sockets and packet switched data, through HTTP Get/Put/Post, FTP (the SARA has a built-in file system), Ping, to good old SMS text messaging!

    The Update Tool is not a full MicroMod Processor Board, it is much simpler than that. It has a CH340C USB-Serial converter on it which gives you full access to all eight pins of the SARA-R5's UART interface via the Asset Tracker’s USB-C connector. Think of it as a bridge from USB to serial.

    Why is this a good idea? Well, for a start - as the name suggests - it is an ideal way to upgrade the SARA-R5’s firmware should you need to. The Update Tool also makes it simple to communicate directly with the SARA using u-blox’s sophisticated m-center cellular evaluation software. If you’re familiar with u-center, u-blox’s GNSS evaluation software, you’ll know how excellent their software is. m-center is every bit as good.

    The Update Tool features eight pairs of Plated Through Hole connections for the UART signals. You can use these to connect directly to the SARA UART using 3.3V signals if you want to. The split pads on the rear of the Tool can be opened to isolate the CH340C completely; the pins nearest the M.2 will link straight to the SARA UART.

    Required Materials

    In order to follow along with this tutorial, you'll want to have the following items.

    The Asset Tracker Firmware Update Tool, as the name suggests, is designed to work with the MicroMod Asset Tracker Carrier Board:

    SparkFun MicroMod Asset Tracker Carrier Board

    SparkFun MicroMod Asset Tracker Carrier Board

    DEV-17272
    $149.95

    You'll also need a USB-C cable to connect the Carrier to your computer. Below are some options for USB cables:

    USB 2.0 Cable A to C - 3 Foot

    USB 2.0 Cable A to C - 3 Foot

    CAB-15092
    $3.95
    USB 3.1 Cable A to C - 3 Foot

    USB 3.1 Cable A to C - 3 Foot

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

    Reversible USB A to C Cable - 0.8m

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

    Reversible USB A to C Cable - 2m

    CAB-15424
    $7.95

    Optional Extras

    If you want to manipulate the UART connections on the Update Tool we recommend soldering a set of headers to your board. Below are a few options:

    Break Away Headers - Straight

    Break Away Headers - Straight

    PRT-00116
    $1.50
    20
    Header - 2x8 (Male, 0.1")

    Header - 2x8 (Male, 0.1")

    PRT-13156
    $0.95

    Suggested Reading

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

    MicroMod Logo
    MicroMod Ecosystem

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

    Serial Communication

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

    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.

    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

    In this section we'll go over the hardware and components on the MicroMod Update Tool.

    M.2 Connector

    All of our MicroMod Processor boards come equipped with the M.2 MicroMod Connector, which leverages the M.2 standard and the Update Tool is no different. Just remember this is for use only with the MicroMod Asset Tracker Carrier Board.


    M.2 Connector from the FrontM.2 Connector from the Back

    CH340 USB-Serial Converter

    The heart of the Asset Tracker Firmware Update Tool is the CH340C USB-Serial converter which we use on many of our RedBoards and other breakouts. It converts 8-wire UART serial to USB.

    Photo highlighting the CH340 IC

    PTH Connections and Jumpers

    The Update Tool includes a set of eight jumpers to allow users to connect the SARA-R5 UART pins to a 3.3V devlopment board. The jumpers can be opened to disconnect the pins from the CH340C to be re-routed to your development board.

    Photo highlighting the PTH Jumpers

    Take care to only connect the pins to a 3.3V RedBoard or Arduino Board or properly shift the logic level down to 3.3V. Connecting them to a 5V board may damage the Asset Tracker.

    Read on to the Using the PTH Connections for more information.

    MicroMod Update Tool Pin Functionality

    Since the MicroMod Update Tool serves a specific purpose to communicate directly with the SARA-R5 on the MicroMod Asset Tracker Carrier Board, the pinout is much simpler than other MicroMod Processors. The tables below outline the pin functionality for the Update Tool along with the general MicroMod pinout. If you prefer to refer to the schematic it can be viewed here.

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

    Board Dimensions

    The board measures 22mm x 22mm, with 15mm to the top notch and 12mm to the E key. For more information regarding the processor board physical standards, head on over to the Getting Started with MicroMod tutorial and check out the Hardware Overview section.

    MicroMod Update Tool Board Dimensions

    Hardware Assembly

    Inserting your Update Tool

    With the M.2 MicroMod connector, connecting your Update Tool to the Asset Tracker is a breeze. Simply match up the key on your Processor's beveled edge connector to the key on the M.2 connector. At a 45° angle, insert the processor board to the M.2 connector. The Update Tool will stick up at an angle as seen here:

    Update Tool inserted into M.2 connector.

    Once the update tool is in the socket, gently press the board down, grab the set screw and tighten it with a Phillip's head screwdriver:

    Securing the Update Tool

    Once the Update Tool is secure, your assembled MicroMod Asset Tracker system should look similar to the image below!

    Secured Update Tool on the Asste Tracker Carrier

    Connecting Everything Up

    Now is a good time to insert the Nano SIM from your service provider into the Asset Tracker. Make sure the orientation matches the symbol on the PCB; the edge with the trimmed corner is inserted first.

    The LTE and GNSS connections simply screw on to the appropriate SMA connectors. Make sure you check the labelling and connect them the right way round. LTE is on the Left.

    With your Update Tool inserted and secured it's time to connect your MicroMod Asset Tracker Carrier Board to your computer using the USB-C connector. Depending on which drivers you already have installed, you may need to install drivers for the CH340. Please refer to our CH340 tutorial for further instructions.

    Software Setup

    Note: This guide assumes you already have the CH340 drivers installed. If needed, please refer to our How to Install CH340 Drivers tutorial.

    Installing u-blox m-center

    You can find the webpage for u-blox's m-center software here. Sadly m-center is only available for Windows and we don’t know of an equivalent for Linux. This link will download version 2.03.0 of m-center (but please do check the u-blox website for more recent versions):

    Unzip the file and run the m-center .EXE to install the software.

    Using u-blox m-center

    Like u-center, m-center is very easy and intuitive to use. Let's go over the features of the software.

    Home

    Begin by clicking Set port and selecting the port for the CH340 Update Tool:

    Selecting the port for the Update Tool

    Having trouble seeing the detail in this screenshot? Click on it for a closer look.

    Click Connect, followed by Initialization to connect to the SARA-R5. The IMEI and firmware version should appear:

    m-center screenshot showing port and firmware version

    The carrier operator name and signal strength will appear in the top right corner of the window. We are told by u-blox that it is normal for the signal strength to appear quite low; LTE communication works with relatively low signal levels.

    We believe the Trace Port option can be used to connect to the SARA-R5's USB diagnostic port via the SARA USB D+/D-/DET pins on the Asset Tracker Carrier Board, but we have not tried that yet.

    Click Set current time to set the SARA's internal clock from the LTE network.

    Network

    Click the Network icon, next to the Home icon in the top left of the window, to see the network operator settings.

    Click Refresh Info, Get List and Refresh to update the network information and Packet Switched Data Profiles.

    Network information in m-center

    You can choose to deregister from the current operator and connect to a new one if your SIM supports it.

    You can also activate and deactivate the Packet Switched Data profile from this page. You will not able to send and receive data until you have activated a profile.

    Phonebook

    As the name suggests, the phonebook icon opens the SARA’s phonebook. You can add and delete numbers here.

    m-center Phonebook menu

    SMS

    The SMS (envelope) icon will allow you to send text messages and read or reply to any received messages.

    m-center SMS menu

    File System

    The File System icon provides access to the SARA’s internal file system. You can add, retrieve and delete files from here. If you have run the Asset Tracker ThingSpeak (HTTP POST) example, the results of the most recent POST are stored in post_response.txt.

    Did you know that the SARA-R5 supports FTP transfer too? Of course it does...

    m-center File System menu

    Positioning

    The Positioning icon provides access to positioning information derived from either the LTE network, or the SARA-R510M8S’s built-in M8 GNSS receiver.

    m-center Positioning menu

    Firmware Over the Air (FOTA) and eCall Simulator

    Advanced users can make use of the SARA’s Firmware download Over The Air and eCall Simulation functions:

    m-center eCall Simulator

    AT Terminal

    One of the most important features offered by m-center is the AT Terminal. Clicking the button below the signal strength indicator opens a Pandora’s Box full of AT Command goodies!

    m-center AT Terminal
    Having trouble seeing the detail in this image? Click on it for a larger view.

    You can either type the AT commands manually into the text box, or select a template message from the drop-down menus, and then click Send or hit Enter to send the message. The replies from the SARA are shown in the Terminal window. You can log everything to file too if you wish. Scripts? Yes, you can run those too! This is a very powerful tool.

    To manually Ping a server (such as www.sparkfun.com) the truncated set of commands is:

    • AT+UPSD=0,100,1
      • This instructs the SARA to map the Context ID 1 profile into Profile ID 0.
    • AT+UPSD=0,0,2
      • This instructs the SARA to use the “IPv4v6 with IPv4 preferred” protocol for Profile ID 0 (this needs to match the operator’s protocol).
    • AT+UPSDA=0,3
      • This instructs the SARA to activate Profile ID 0.
    • AT+UPING="www.sparkfun.com"
      • This instructs the SARA to ping the SparkFun server

    Upgrading the SARA Firmware with u-blox EasyFlash

    Just about the only thing that m-center doesn’t allow you to do is to upgrade the SARA-R5’s firmware. To do that you need to download and install u-blox’s EasyFlash update tool.

    u-blox EasyFlash main menu.

    The link below will download EasyFlash version 12.08 but do check the SARA-R5 resources page for the latest version as of this writing:

    Again, EasyFlash only appears to be available for Windows. We are not aware of a version for Linux. Unzip the .ZIP file and run the EasyFlash .MSI installer to install the software. u-blox will make the firmware updates available through the SARA-R5 resources page.

    Note: SparkFun is not able to give users the latest firmware file. It must come from u-blox.

    You need to manually download the .DOF update binary file and place it in the same folder as the EasyFlash executable. (That bit is important!). After the .DOF file is downloaded follow these steps:

    • Run the EasyFlash executable.
    • Select SARA-R5 as the Product.
    • Select the COM port your Firmware Update Tool (CH340) is connected to.
    • Select 921600 as the Baud Rate.
      • Do not select 3000000 Baud as the CH340 cannot support it.
    • Turn the SARA-R5 off by pushing and holding the SARA On button on the Asset Tracker for five seconds.
      • Check that the white On LED on the Asset Tracker goes out.
    • Click the Start button on EasyFlash.
    • Press the SARA On button briefly when instructed to turn the SARA back on again.
    • The update process takes around three minutes to complete.
    • Turn the SARA off again when instructed to complete the update.
    EasyFlash updating SARA-R5 FirmwareEasyFlash firmware update completed.
    Firmware update in progressFirmware update completed

    You can confirm that the update was successful by opening m-center and connecting to the SARA-R5. The firmware version is shown on the Home page:

    m-center Home menu showing updated firmware version.

    Having trouble seeing the detail in this screenshot? Click on it for a larger view.

    Using the PTH Connections

    Want to connect the SARA UART pins to your favourite 3.3V RedBoard or Arduino Board? The Firmware Update Tool lets you do that too!

    Photo highlighting solder jumpers and PTH pins.

    If you flip the Update Tool over, you will see eight jumpers linking each pair of Plated Through Holes. You can cut the jumpers to disconnect the PTHs from the CH340C. You can then connect the holes closest to the M.2 connector to your 3.3V board.

    Insert 1x8 or 2x8 0.1”-pitch header pins through the front of the Firmware Update Tool and solder them on the back. 2x8 header pins are a good idea as it means you can use header jumper links to reconnect the CH340C again if you want to.

    Important Notes:
    • Take care when selecting which header pins to solder onto the Update Tool. The pins must not protrude from the back of the board by more than 1.25mm or they will collide with the IMU and other components on the Asset Tracker circuit board. Trim the pins if necessary before soldering.
    • Take care to only connect the pins to a 3.3V RedBoard or Arduino Board or properly shift the logic level down to 3.3V. Connecting them to a 5V board may damage the Asset Tracker.

    Troubleshooting

    Below we have outlined a few troubleshooting tips for the MicroMod Update Tool and MicroMod Asset Tracker Carrier Board.

    LTE Network Availability

    The SARA-R5 supports LTE-M and NB-IoT data communication for multi-regional use. Please check the LTE signal availability for your area before purchasing a SARA-R5 product and selecting an LTE service provider / operator.

    TP (1PPS) Pin and LED

    At the time of writing, we are shipping the SARA-R5 on the Asset Tracker with firmware version 02.06 on it. 02.06 contains a feature (which is just a polite name for a bug!) which means the 1 Pulse-Per-Second from the GNSS does work, but the pulse is only ~3 microseconds wide and cannot be adjusted. Handy huh? u-blox are aware of this - in fact we told them about it - and a fix is coming but they haven’t added it yet. We will keep an eye out for this fix and update this page when it is available.

    Just to complicate matters, 3 microseconds is too short for the buffer FET and LED connected to the timing pulse to respond. So, we regret that you cannot currently use the TP PTH. We will share the fix with you as soon as we have it. The SARA firmware is easy to update using the Asset Tracker Firmware Update Tool.

    General Troubleshooting

    Resources and Going Further

    Want more information on the MicroMod Update Tool? Check out these links!

    u-blox Documentation and Software:

    MicroMod Documentation:

    If you have not already, be sure to check out our Hookup Guide for the Asset Tracker Carrier Board:

    New!

    MicroMod Asset Tracker Carrier Board Hookup Guide

    February 25, 2021

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

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

    Qwiic Carrier Board Hookup Guide

    Next: Configuring the PATH System Variable
    Previous: MicroMod Update Tool Hookup Guide
    $
    0
    0

    Qwiic Carrier Board Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    The MicroMod Qwiic Carrier Board can be used to rapidly prototype with other Qwiic devices; it is available in either a single or double mounting configuration. Just like other MicroMod Carrier Boards, users are free to develop with MicroMod Processor Board of their choice.

    SparkFun MicroMod Qwiic Carrier Board - Single

    SparkFun MicroMod Qwiic Carrier Board - Single

    DEV-17723
    $9.95
    SparkFun MicroMod Qwiic Carrier Board - Double

    SparkFun MicroMod Qwiic Carrier Board - Double

    DEV-17724
    $11.95

    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:

    SparkFun MicroMod Artemis Processor

    SparkFun MicroMod Artemis Processor

    DEV-16401
    $14.95
    SparkFun MicroMod SAMD51 Processor

    SparkFun MicroMod SAMD51 Processor

    DEV-16791
    $14.95
    SparkFun MicroMod nRF52840 Processor

    SparkFun MicroMod nRF52840 Processor

    WRL-16984
    $14.95
    SparkFun MicroMod RP2040 Processor

    SparkFun MicroMod RP2040 Processor

    DEV-17720
    $11.95

    Required Hardware

    A Phillips screw driver is necessary to attach the processor board to the carrier board. Additionally, 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
    $4.95
    2
    SparkFun Mini Screwdriver

    SparkFun Mini Screwdriver

    TOL-09146
    $0.95
    3

    Optional Hardware

    To connect Qwiic breakout boards for your MicroMod project, Qwiic cables are required. Users can also attach the Qwiic devices with 4-40 screws or stacked them with standoffs.

    SparkFun Qwiic Cable Kit

    SparkFun Qwiic Cable Kit

    KIT-15081
    $7.95
    10
    Flexible Qwiic Cable - 100mm

    Flexible Qwiic Cable - 100mm

    PRT-17259
    $1.50
    Screw - Phillips Head (1/4", 4-40, 10 pack)

    Screw - Phillips Head (1/4", 4-40, 10 pack)

    PRT-10453
    $1.50
    Standoff - Metal Hex (4-40; 3/8"; 10 pack)

    Standoff - Metal Hex (4-40; 3/8"; 10 pack)

    PRT-10463
    $3.95

    A single-cell Lithium-ion battery can be connected to the Qwiic carrier board for portability.

    Lithium Ion Battery - 400mAh

    Lithium Ion Battery - 400mAh

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

    Lithium Ion Battery - 2Ah

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

    Lithium Ion Battery - 1Ah

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

    Lithium Ion Battery - 110mAh

    PRT-13853
    $4.95
    2

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

    Solder Lead Free - 100-gram Spool

    Solder Lead Free - 100-gram Spool

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

    Chip Quik No-Clean Flux Pen - 10mL

    TOL-14579
    $7.95
    3
    Weller WLC100 Soldering Station

    Weller WLC100 Soldering Station

    TOL-14228
    $44.95
    1
    Hobby Knife

    Hobby Knife

    TOL-09200
    $2.95
    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.

    MicroMod Logo

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

    I2C

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

    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!

    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.

    Hardware Overview

    This section will cover the various hardware components and solder jumpers on the MicroMod Qwiic carrier board. It will also review the connections of the M.2 connector and how it interfaces with a MicroMod processor.

    Board Dimensions

    The Qwiic carrier board dimensions are:

    • Single: 3.15" x 1.40" (80.00mm x 35.56mm)
    • Double: 4.10" x 1.40" (109.22mm x 35.56mm)

    MicroMod Qwiic carrier board dimensions - single

    MicroMod Qwiic carrier board dimensions - double
    Dimensions of the MicroMod Qwiic carrier board. (Click to enlarge)

    The boards also include mounting holes and inserts for a standard 4-40 screw. The inserts are arranged to mount, attach, and/or stack compatible (1" x 1") Qwiic boards.

    Photo highlighting inserts layout - single
    Photo highlighting inserts layout - double

    Mounting areas on the MicroMod Qwiic carrier board to attach Qwiic devices. (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 Qwiic 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 Qwiic 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 Qwiic carrier board
    Common MicroMod components featured on the MicroMod Qwiic 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 MicroMod Qwiic carrier board. (Click to enlarge)

    Status LEDs

    The carrier board has two status LEDs:

    • PWR - 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 MicroMod Qwiic 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 a total of seven adjustable solder jumpers on the MicroMod Qwiic carrier board labeled I2C, MEAS, BYP, VE, UV, 5V and 3V3. 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 MicroMod Qwiic 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 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
    M.2 Connector Pin# MicroMod Pin Name Board Connection Description
    1GNDGNDGround plane.
    23.3V3.3VRegulated 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 ButtonConnected to RESET Button. Reset is active LOW
    9USB_VIN--Input voltage from USB.
    10D0D0Digital I/O pin
    11BOOTBOOT ButtonConnected to BOOT Button. Boot is active LOW.
    12I2C_SDAQwiic Connector - SDAI2C data signal for Qwiic devices.
    14I2C_SCLQwiic Connector - SCLI2C clock signal for Qwiic devices.
    16I2C_INTINTI2C interrupt pin
    18D1D1Digital I/O pin
    55SPI_CSCSChip Select.
    57SPI_SCKSCKSPI Clock signal.
    59SPI_COPICOPISPI Controller Out/Peripheral In signal.
    61SPI_CIPOCIPOSPI Controller In/Peripheral Out signal.

    Breakout Pins

    The Qwiic 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 MicroMod Qwiic carrier board. (Click to enlarge)

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

    Processor Board

    To get started with the Qwiic carrier board, users will need a compatible processor board. Insert the MicroMod processor board into the M.2 socket 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 on the MicroMod Qwiic carrier board. (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 Qwiic carrier board
    A processor board attached to the MicroMod Qwiic carrier board. (Click to enlarge)

    Qwiic Devices

    Screw inserts are available in either a single or double configuration to attach/mount 1" x 1" Qwiic devices to the Qwiic carrier board. The inserts are compatible with 4-40 screws; additionally, 4-40 3/8" standoffs can also be used to stack boards vertically.

    To electronically connect the Qwiic devices to the carrier board, users will need Qwiic cables. For more information, check out our Qwiic ecosystem page.

    Attaching Qwiic devices to single carrier board
    Attaching Qwiic devices to double carrier board

    Mounting and connecting Qwiic devices to the MicroMod Qwiic carrier board. (Click to enlarge)

    Programming

    To program the processor board utilized on the Qwiic carrier board; connect the carrier board to a computer with a USB-C cable. Depending on the processor board, user 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.

    USB connection
    USB connection to the MicroMod Qwiic carrier board for programming the attached processor board. (Click to enlarge)

    Example

    Below is a simple demonstration of using the MicroMod Qwiic carrier board to create a bubble level, using an accelerometer and OLED display. Users will also need other parts and accessories; all parts besides the Qwiic carrier board are listed below:

    SparkFun Qwiic Cable Kit

    SparkFun Qwiic Cable Kit

    KIT-15081
    $7.95
    10
    SparkFun Micro OLED Breakout (Qwiic)

    SparkFun Micro OLED Breakout (Qwiic)

    LCD-14532
    $16.95
    6
    SparkFun MicroMod ESP32 Processor

    SparkFun MicroMod ESP32 Processor

    WRL-16781
    $14.95
    USB 3.1 Cable A to C - 3 Foot

    USB 3.1 Cable A to C - 3 Foot

    CAB-14743
    $4.95
    2
    SparkFun Mini Screwdriver

    SparkFun Mini Screwdriver

    TOL-09146
    $0.95
    3
    Screw - Phillips Head (1/4", 4-40, 10 pack)

    Screw - Phillips Head (1/4", 4-40, 10 pack)

    PRT-10453
    $1.50
    Triple Axis Accelerometer Breakout - LIS2DH12 (Qwiic)

    Triple Axis Accelerometer Breakout - LIS2DH12 (Qwiic)

    SPX-15760
    $6.95
    Standoff - Metal Hex (4-40; 3/8"; 10 pack)

    Standoff - Metal Hex (4-40; 3/8"; 10 pack)

    PRT-10463
    $3.95

    Note: We have chosen the MicroMod ESP32 for the processor board for this demonstration; however, users are free to utilize the processor board of their choice.

    Please note, that the sample code below is intended to program processor boards that are compatible with the Arduino IDE. Therefore, processor boards like the RP2040 are going to need extra effort to adapt the code (technical assistance for which, is not available).

    Assembly

    The assemble process is relatively straight forward. The primary thing that users need to pay attention to is the orientation of the OLED display relative to the axes of the accelerometer. The x-axis should point to the right of the OLED display and the y-axis should point to the top of the display (see images below).

    Accelerometer attached to single carrier board
    OLED display stacked above the acceleromter on the carrier board

    Mounting and connecting the Qwiic devices to the MicroMod Qwiic carrier board. (Click to enlarge)

    Some users may find it the movement of the bubble in the example code to be more intuitive if the OLED display is stacked above the accelerometer.

    assembled demo
    Don't forget to daisy-chain the boards together with Qwiic cables. (Click to enlarge)

    Example Code

    Users can download the example code here or by clicking the button below. Besides the RP2040 processor board, users only need to select the proper port and board from the board manager in the Arduino IDE before uploading the code.

    The following sections break down the example code execution for users who might want to modify the code. Please note, as defined in our terms of service, that we do not provide technical assistance for any code modifications.

    Dependencies

    Below are the dependencies for the code including the libraries, pin definitions, and variable instantiations. The example code requires both the Micro OLED and LIS2DH12 Arduino libraries to be installed in the Arduino IDE.

    Tip: While in the Arduino IDE, users can click the links in the code (i.e. //Click here to get the library: http://librarymanager/All#SparkFun_LIS2DH12) to pull up the required library in the library manager.

    link pulling up the library manager
    Clicking the link to pull up the required library in the Arduino IDE. (Click to enlarge)

    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.
    Libraries and Pin Definitions

    This section of the code contains the required libraries and pin definitions for the code.

    language:c
    #include <Wire.h>
    
    // Accelerometer
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #include "SparkFun_LIS2DH12.h" //Click here to get the library: http://librarymanager/All#SparkFun_LIS2DH12
    SPARKFUN_LIS2DH12 accel;
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    // External Display
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #include <SFE_MicroOLED.h> //Click here to get the library: http://librarymanager/All#SparkFun_Micro_OLED
    //#include "icons.h"
    
    #define PIN_RESET 7
    #define DC_JUMPER 1
    MicroOLED oled(PIN_RESET, DC_JUMPER);
    //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    Variables

    This section of the code instantiates most of the variables used in the code.

    language:c
    // Set target and dot size
    int radiusLarge = 10; // Target area 2
    int radiusSmall = 4;  // Target area 1
    int radiusBubble = 2; // Bubble size
    
    // Set initial roll and pitch measurement
    double averagedRoll = 0.0;
    double averagedPitch = 0.0;
    

    Setup Loop

    This section of the code runs the setup loop, which initializes the serial output, I2C connection, the OLED display operation, and the accelerometer operation and configuration.

    language:c
    void setup()
    {
      // Initialize Output for Print Statements
      Serial.begin(115200);
      Serial.println("SparkFun Accel Example");
    
      // Initialize I2C Connection
      Wire.begin();
      //Wire.setClock(400000);
    
      beginDisplay(); //Check if an external Qwiic OLED is attached and display splash screen
    
      // Check for accelerometer
      if (accel.begin() == false)
      {
        Serial.println("Accelerometer not detected. Check address jumper and wiring. Freezing...");
        while (1)
          ;
      }
    
      // Set sample/data rate for accelerometer
      // The larger the avgAmount the faster we should read the sensor
      //accel.setDataRate(LIS2DH12_ODR_100Hz); //6 measurements a second
      accel.setDataRate(LIS2DH12_ODR_400Hz); //25 measurements a second
    }
    
    Setup Functions

    These functions are executed in the setup loop, to initialize the OLED display I2C connection and display the splash screen.

    language:c
    // Ping an I2C address and see if it responds
    bool isConnected(uint8_t deviceAddress)
    {
      Wire.beginTransmission(deviceAddress);
      if (Wire.endTransmission() == 0)
        return true;
      return false;
    }
    
    
    void beginDisplay()
    {
      // Connect to address display is on by pinging addresses
      // 0x3D is default on Qwiic board
      if (isConnected(0x3D) == true || isConnected(0x3C) == true)
      {
        //Init and display splash
        oled.begin();     // Initialize the OLED
        oled.display();   // Display splash screen
        delay(1200);
        oled.clear(PAGE); // Clear the display's internal memory
    
        oled.setCursor(15, 7); //x, y
        oled.setFontType(0); //Set font to smallest
        oled.print(F("Bubble"));
        oled.setCursor(19, 20); //x, y
        oled.print(F("Level"));
    
        oled.display();
        delay(1200);
      }
    }
    

    Main loop

    This section of the code runs the main loop. The code retrieves roll and pitch calculation, clears the display buffer, displays the bubble and target circles or areas. If the position of the bubble is within the target are, the roll and pitch angles are displayed as X and Y coordinates on the screen.

    language:c
    void loop()
    {
      getAngles(); // Calculate roll and pitch angles based on the acceleromter readings
      oled.clear(PAGE); // Clear the display's internal memory
    
      // Set dot position
      double bubbleX = LCDWIDTH / 2 - averagedPitch; // Bubble location on x-axis
      double bubbleY = LCDHEIGHT / 2 - averagedRoll; // Bubble location on y-axis
    
      // Limit bubble position to edge of screen
      if (bubbleX < radiusBubble) { bubbleX = radiusBubble; }
      else if (bubbleX > LCDWIDTH - radiusBubble) { bubbleX = LCDWIDTH - radiusBubble - 1; }
      if (bubbleY < radiusBubble) { bubbleY = radiusBubble; }
      else if (bubbleY > LCDHEIGHT - radiusBubble) { bubbleY = LCDHEIGHT - radiusBubble - 1; }
    
      // Draw circle relative to dot
      oled.circle(LCDWIDTH / 2, LCDHEIGHT / 2, radiusLarge);
      oled.circle(LCDWIDTH / 2, LCDHEIGHT / 2, radiusSmall);
      oled.circleFill(bubbleX, bubbleY, radiusBubble);
    
      // Display angle/position once bubble is inside larger target area
      if ( sqrt(averagedPitch * averagedPitch + averagedRoll * averagedRoll) < (radiusLarge - radiusBubble))
      {
        oled.setFontType(0); //Set font to smallest
    
        oled.setCursor(LCDWIDTH/2 - 21, 0); //x, y
        oled.print("X:");
        oled.print(-averagedPitch);
        oled.setCursor(LCDWIDTH/2 - 21, LCDHEIGHT - 8); //x, y
        oled.print("Y:");
        oled.print(averagedRoll);
    
    
    //    oled.setCursor(LCDWIDTH/2 - 11, 0); //x, y
    //    oled.print(averagedRoll);
    //    if (-averagedPitch < 0) { oled.setCursor(LCDWIDTH - 29, LCDHEIGHT/2 - 3); }
    //    else { oled.setCursor(LCDWIDTH - 23, LCDHEIGHT/2 - 3); }
    //    oled.print(-averagedPitch);
      }
    
      oled.display();
    }
    
    getAngles() Function

    This function is executed in the main loop. The code retrieves accelerometer readings, translates the readings into roll and pitch angles, and calculates an average based on a sample set size (avgAmount = 16).

    language:c
    void getAngles()
    {
      averagedRoll = 0.0;
      averagedPitch = 0.0;
      const int avgAmount = 16;
    
      // Average readings after 'avgAmount' samples
      for (int reading = 0 ; reading < avgAmount ; reading++)
      {
        while (accel.available() == false) delay(1); // Wait for accelerometer connection
    
        // Retrieve data from accelerometer
        float accelX = accel.getX();
        float accelY = accel.getY();
        float accelZ = accel.getZ();
    
        // Optional modification: https://www.nxp.com/docs/en/application-note/AN3461.pdf
        //int signZ = constrain(accelZ, -1, 1);
        //double roll = atan2(accelY , signZ * sqrt( accelZ * accelZ + .001 *  abs(accelX) ) ) * 57.3;
    
        // Calculate roll and pitch angles
        double roll = atan2(accelY , accelZ) * 57.3;
        double pitch = atan2((-accelX) , sqrt(accelY * accelY + accelZ * accelZ)) * 57.3;
        if (constrain(accelZ, -1, 1) == -1) { roll = atan2(accelY, -accelZ) * 57.3; } // Invert if upside down
    
        averagedRoll += roll;
        averagedPitch += pitch;
    
        // Debug Print Statements
        //Serial.print(roll, 6);
        //Serial.print(", ");
        //Serial.print(pitch, 6);
        //Serial.print(", ");
        //
        //Serial.print(accelX);
        //Serial.print(", ");
        //Serial.print(accelY);
        //Serial.print(", ");
        //Serial.print(accelZ);
        //Serial.println("");
      }
    
      averagedRoll /= (float)avgAmount;
      averagedPitch /= (float)avgAmount;
    
      // Debug Print Statements
      //Serial.print(averagedRoll, 6);
      //Serial.print(", ");
      //Serial.print(averagedPitch, 6);
      //Serial.println(", ");
    
    }
    

    Demo Operation

    Below is a demonstration of the example code in action. Enjoy!

    Troubleshooting

    Resources and Going Further

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

    MicroMod Documentation:

    Looking for some inspiration? Check out theses other MicroMod tutorials:

    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 ESP32 Processor Board Hookup Guide

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

    SparkFun MicroMod Input and Display Carrier Board Hookup Guide

    A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board

    MicroMod nRF52840 Processor Hookup Guide

    Get started with the MicroMod nRF52840 Processor following this guide.

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

    Configuring the PATH System Variable

    Next: SparkFun PIR Breakout Hookup Guide
    Previous: Qwiic Carrier Board Hookup Guide
    $
    0
    0

    Configuring the PATH System Variable a learn.sparkfun.com tutorial

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

    Introduction

    A path is the name of a file's directory, which specifies a unique location in a file system. Whereas, the PATH system variable ($PATH), specifies a set of directories where executable programs are located. This allows software applications to access commonly executed programs.

    There are different methods for modifying the ($)PATH variable on various operating systems. The directions below are based on the most common methods for each operating system. For more information, just use your favorite search engine with the keywords: path system variable along with <the name of the OS you are working on>.

    Windows 10

    In Windows 10, the PATH system variable is configured through the System Properties window. There are various methods for users to access the System Properties window; for example, users can search view advanced system settings from the taskbar ⊞ Start menu.

    searching for system properties window
    Searching view adva from the taskbar⊞ Startmenu, to access the the System Properties window. (Click to enlarge)

    Once the System Properties window has been pulled up, select the Environment Variables... button from the Advanced tab.

    opening the environment variables window
    Opening the Environment Variables window. (Click to enlarge)

    Within the Environment Variables window, select the Path variable from the User variables for <username> section. Then, select the Edit... button to configure the PATH system variable.

    Note: The User variables are specific for a user account on the computer; while, the System variables will be available for all accounts on the computer.

    opening the path system variable window
    Opening the PATH system variable window. (Click to enlarge)

    From the PATHEdit environment variable window, select the Browse... button. Once the pop-up dialog box appears, navigate to the folder containing the executable file to be included in the PATH system variable.

    Note: Make sure not to select and overwrite a previously configured file path. Users can click on the black space area to make sure that a previously configured file path isn't highlighted and therefore, won't get overwritten.

    adding a directory to the path system variable
    Adding a directory to the PATH system variable. (Click to enlarge)

    Mac OSX and Linux Based Systems

    On Mac OSX and linux based systems, users can display the paths for the $PATH system variable by entering echo $PATH into the terminal.

    Note: The commands below use the GNU nano text editor. Feel free to use another text editor of your choice (such as vi for Vim).

    To modify the variable:

    1. Open up Terminal and run the following command to edit the paths file: sudo nano <file path location>
      • There are several locations where users might be able to modify the $PATH system variable:
        • /etc/paths (Mac OSX - Mountain Lion)
        • /usr/bin
        • /usr/local/bin
        • /usr/local/sbin
        • /usr/sbin
        • ~/.bash_profile
        • ~/.bashrc
        • ~/.profile
    2. Enter the super user (administrative) password, if prompted.
    3. Enter the modifications for the path you wish to add.
      • The entry field is usually near the bottom of the file.
    4. Hit Ctrl+X to quit.
    5. At the input prompt, send Y and hit Enter or Return to save the modified buffer.

    PATH variable
    Displaying paths of $PATH variable and accessing the ~/.profile file for modifications. (Click to enlarge)

    That’s it! To verify the changes, in a terminal window, type: echo $PATH

    Note: Another common method is to use the export command in the terminal.

    Example: export PATH=$PATH:<file path to be added>

    Resources and Going Further

    Looking for some additional programming related tutorials? Check out the guides below:

    Alternative Arduino Interfaces

    We admit the Arduino IDE isn't for everyone. Here are some other options for programming your Arduino boards, including web interfaces and graphical programming languages.

    Digital Sandbox Arduino Companion

    Let's take the same examples from the ArduBlock-based Digital Sandbox guide, and implement them using Arduino code.

    Simon Says Experiments

    So you've built up a Simon Says kit? What next? This tutorial will get you up and running with Arduino software, guide you through a few example sketches, and send you on your way to create your own. Careful, this stuff is highly addictive. :)

    How to Run a Raspberry Pi Program on Startup

    In this tutorial, we look at various methods for running a script or program automatically whenever your Raspberry Pi (or other Linux computer) boots up.

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

    SparkFun PIR Breakout Hookup Guide

    Next: Qwiic PIR Hookup Guide
    Previous: Configuring the PATH System Variable
    $
    0
    0

    SparkFun PIR Breakout Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    Looking to add some motion detection to a project you are working on? The SparkFun PIR Breakout - 170uA (EKMC4607112K) and SparkFun PIR Breakout - 1uA (EKMB1107112) might be just the thing! These breakouts use two versions of the EKM-series PIR sensors from Panasonic® to offer low profile motion-sensing options for both battery powered and continuously powered applications.

    SparkFun PIR Breakout - 170uA (EKMC4607112K)

    SparkFun PIR Breakout - 170uA (EKMC4607112K)

    SEN-17372
    $19.95
    SparkFun PIR Breakout - 1uA (EKMB1107112)

    SparkFun PIR Breakout - 1uA (EKMB1107112)

    SEN-17373
    $29.95

    Passive Infrared (PIR) sensors do not return specific distance data like distance sensors. Instead, PIR sensors measure IR light coming from objects to detect motion in their field of view making them perfect for motion-sensing applications such as turning devices like lights, cameras, motors, etc. on automatically. The PIR sensors on these breakouts output a digital signal whenever a moving object is detected in the sensing area. That signal can be monitored by a microcontroller to trigger action on a connected device like those mentioned above. If you would prefer to use these PIR sensors on an I2C bus, check out our Qwiic breakouts of the 170uA PIR and 1uA PIR.

    Required Materials

    In order to follow along with this tutorial you'll need a few items along with your PIR Breakout. First, you'll need a microcontroller or Single-Board Computer (SBC) like a Raspberry Pi or Jetson Nano to monitor the PIR's signal:

    NVIDIA Jetson Nano Developer Kit (V3)

    NVIDIA Jetson Nano Developer Kit (V3)

    DEV-16271
    $99.00
    10
    SparkFun RedBoard Qwiic

    SparkFun RedBoard Qwiic

    DEV-15123
    $19.95
    8
    Raspberry Pi 4 Model B (2 GB)

    Raspberry Pi 4 Model B (2 GB)

    DEV-15446
    $35.00
    4
    SparkFun RedBoard Artemis

    SparkFun RedBoard Artemis

    DEV-15444
    $19.95
    8

    You also may need some wire and headers to connect your breakout to your microcontroller. Depending on your intended connections, you may want to use one or more of the following connection and wire options:

    Break Away Headers - Straight

    Break Away Headers - Straight

    PRT-00116
    $1.50
    20
    Female Headers

    Female Headers

    PRT-00115
    $1.50
    7
    Jumper Wires Premium 6" M/F Pack of 10

    Jumper Wires Premium 6" M/F Pack of 10

    PRT-09140
    $3.95
    1
    Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)

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

    PRT-11026
    $2.25
    20

    Lastly, for easier testing of the range and detection area of your PIR Breakout installation, you may want to have an LED or sound output like a buzzer to act as an indicator for when the sensor detects motion.

    Recommended Tools

    We recommend soldering to the PTH header on the PIR Breakouts for the best connection. If you do not have soldering tools and accessories, take a look at the following options:

    Soldering Iron - 60W (Adjustable Temperature)

    Soldering Iron - 60W (Adjustable Temperature)

    TOL-14456
    $14.95
    11
    Solder Lead Free - 100-gram Spool

    Solder Lead Free - 100-gram Spool

    TOL-09325
    $8.95
    7
    Solder Lead Free - 15-gram Tube

    Solder Lead Free - 15-gram Tube

    TOL-09163
    $3.50
    2
    Weller WLC100 Soldering Station

    Weller WLC100 Soldering Station

    TOL-14228
    $44.95
    2

    Suggested Reading

    PIR sensors are pretty straight-forward and a great entry point for novices with embedded electronics and sensors but if you aren't familiar with the concepts covered in the tutorials linked below, you may want to take a look through them before getting started with the SparkFun PIR Breakout:

    How to Solder: Through-Hole Soldering

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

    What is an Arduino?

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

    Logic Levels

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

    Raspberry Pi 4 Kit Hookup Guide

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

    Hardware Overview

    In this section we'll cover the characteristics and features of the PIR sensors on these breakouts.

    Panasonic EKM-Series PIR Sensors

    The EKMC4607112K and EKMB1107112 from Panasonic are low-profile PIR sensors ideal for things like motion-activated lights, cameras or other electronics. Applications include automatic lighting for energy conservation, motion-activated security or trail cameras or maybe something fun like a homemade convenience store chime (complete with a 100th customer celebration!). The EKMC4607112K works best in a continuous power installation and has slightly better sensing performance than the EKMB1107112 which is best suited for battery and low-power installations.

    SparkFun PIR Breakout - 1uA Front.SparkFun PIR Breakout - 1uA Back.
    SparkFun PIR Breakout - 1µA Front.SparkFun PIR Breakout - 1µA Back.

    On each breakout we've broken the sensor's three pins (3V3/VDD, Ground and OUT) to a standard 0.1"-spaced PTH header for users to solder to. Take note that the sensors share the same PCB design and the version (1µA or 170µA) is marked by the solder pads "North" of the PIR.

    The two PIR sensors have very similar electrical and sensing characteristics with a few specific differences users will want to take note of prior to deciding which sensor is best for their situation. The tables below outline the Electrical and Detection Performance Characteristics to give users a basic overview. For a more detailed look at these two sensors, take a look at their respective specification sheets: EKMC4607112K& EKMB1107112 along with the Panasonic PIR Sensors - Product Brief (EKM-Series sensors are covered on page 8).

    Electrical Characteristics
    EKMC4607112KEKMB1107112
    CharacteristicUnitsMinTyp.MaxMinTyp.Max
    Operating VoltageVDC3.0-6.02.3-4.0
    Current Consumption
    (Sensor Only)
    µA-170300-1[1]3
    Output CurrentµA--100--100
    Output VoltageVDCVDD-0.5--VDD-0.5--
    Circuit Stability Time
    (when voltage is applied)
    secs--30-25210

    As we mentioned above, the sensing performances of the PIR Sensors are very similar with a few notable differences you'll want to be aware of to decide which one works best for your application. Also take note that PIR sensor performance can vary depending on the environment it is sensing.

    Both the EKMC & EKMB have detection areas of 90° Horizontal and Vertical (±45°) and have 32 detection zones. The table below outlines their detection performance in relation to the background temperature:

    Detection Performance Characteristics
    EKMC4607112KEKMB1107112Notes
    Temperature DifferenceValueTemperature DifferenceValueTarget Conditions
    Detection Range8°C (14.4°F)up to 7m4°C (7.2°F)up to 7m1. Movement speed: 1 m/s
    2. Target concept is human body (Object size:Around700×250mm)
    4°C (7.2°F)up to 5m2°C (3.6°F)up to 5m
    Note: Current consumption for the EKMB1107112 varies depending on the operating mode. Refer to section 4-4 of the Spec Sheet for specific values.

    Board Dimensions

    The SparkFun PIR Breakout measures 0.50" x 0.85" (12.7mm x 21.59mm) and has one mounting hole that fits a 4-40 screw.

    PIR Breakout Board Dimensions

    Hardware Assembly

    Assembling the PIR Breakout circuit is pretty straight-forward since the board only has three pins. Recommended setup requires some soldering so if you are not familiar with through-hole soldering or want a refresher, we suggest reading through this tutorial:

    How to Solder: Through-Hole Soldering

    September 19, 2013

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

    The demo circuit we'll assemble for the PIR Breakout uses a standard breadboard, M/M Jumper Wires and a SparkFun RedBoard Qwiic along with the SparkFun PIR and a set of breakaway male headers - right angle.

    For permanent installations, we recommend soldering wire directly to the PIR Breakout to create a strong and stable connection to the sensor. For some tips on preparing and soldering wire, take a look at this tutorial:

    Working with Wire

    February 8, 2013

    How to strip, crimp, and work with wire.

    To start off, we break off three pins from the set of breakaway male headers and solder them to the PTH header on the PIR Breakout to have the sensor stand perpendicular to the breadboard for easy testing.

    Headers soldered to PIR Breakout

    Next, we plug the sensor into the breadboard (users connecting directly to their microcontroller can ignore this step) taking care to orient it properly so the pins are not sharing the same rail. After the PIR is in place, select three jumper wires and connect the PIR's pins to the matching pins on the microcontroller. 3.3V to 3.3V, GND to Ground/GND and OUT to a digital I/O pin.

    Note: If you choose to not use a dedicated 3.3V pin for your PIR (e.g an alternate voltage or a digital pin) make sure the voltage it supplies falls within the operating voltage for the sensor:
    • EKMC4607112K: 3.0 to 6.0V
    • EKMB1107112: 2.3 to 4.0V

    The OUT signal from the SparkFun PIR can also be used as an external interrupt to trigger an interrupt event on a microcontroller. Users who wish to use the PIR as an external interrupt should note which digital I/O pins on their microcontroller are interrupt-capable and connect the PIR's OUT to one of those pins. For this example, we'll connect the OUT pin to a digital pin that is also interrupt capable: D2.

    Assembled PIR Breakout circuit with a RedBoard Qwiic

    If you are using a Raspberry Pi or other SBC/development-board that uses Python as its primary programming language, follow the above assembly steps for the PIR and connect it to your Pi/SBC's GPIO header taking care to make the proper pin connections. Raspberry Pi users looking for a quick GPIO reference can find one here or you can use the pinout command from the GPIO Zero Python Library in the console to display the pinout there.

    Arduino Examples

    Now that our SparkFun PIR Breakout circuit is assembled it's time to upload some code to our microcontroller to interact with the sensor. We'll cover three examples in this section to demonstrate how to read the signal, stabilize it and use it as an external interrupt to trigger events on a microcontroller.

    Example 1 - Simple Read with Debounce

    This quick and dirty example monitors the PIR output signal on D2 and uses the built-in LED on the SparkFun RedBoard as a visual indicator whenever the PIR detects an object in it's field of view.

    Copy the code below into a blank Arudino sketch, open the Tools menu to select your board (in our case, Arduino Uno) and correct Port and click the "Upload" button:

    language:c
    #define PIR_PIN 2   // PIR output on D2
    #define LED_PIN  13  // LED to illuminate on motion
    #define DEBOUNCE_TIME 750
    
    
    void setup() 
    {
      Serial.begin(115200); 
      // Set the PIR Output signal as an input for the microcontroller:
      pinMode(PIR_PIN, INPUT);
    
      // Configure the LED pin as an output
      pinMode(LED_PIN, OUTPUT);
      digitalWrite(LED_PIN, LOW); // Turn the LED off
    
      // Wait for 30 seconds for the PIR to stabilize after power on:
      Serial.println("Waiting 30 Seconds while PIR warms up");
      for (uint8_t seconds = 0; seconds < 30; seconds++)
      {
        Serial.println(seconds);
        delay(1000);
      }
      Serial.println("PIR Warmed up.");
    }
    
    void loop() 
    {
      // The PIR's output is active high
      int motionStatus = digitalRead(PIR_PIN);
    
      // If motion is detected, turn the onboard LED on and print an object was detected:
      if (motionStatus == HIGH) 
      {
        Serial.println("Object Detected!");
        digitalWrite(LED_PIN, HIGH);
        delay(DEBOUNCE_TIME);
      }
      else // Otherwise turn the LED off and print All Clear:
      {
        Serial.println("All clear!");
        digitalWrite(LED_PIN, LOW);
        delay(DEBOUNCE_TIME);
      }
    }
    

    After uploading, open the serial monitor and set your baud to 115200 to see the serial data. The code will print out over serial any time the PIR detects motion in it' field of view and the D13 LED should illuminate.

    Example 2 - Interrupt

    The Interrupt Example shows how to set up the output signal from the PIR as an external interrupt to trigger an event on your microcontroller. This is particularly helpful for applications where you do not want to constantly poll the digital pin the PIR's output is connected to so you can run other loops in the background.

    As we mentioned in the Hardware Assembly, this example assumes a SparkFun RedBoard/Arduino Uno is used and uses D2 as the interrupt pin. If you are using a different microcontroller, adjust the PIR_PIN definition to an interrupt-capable pin.

    Copy the code below into a blank Arudino sketch, open the Tools menu to select your board (in our case, Arduino Uno) and correct Port and click the "Upload" button:

    language:c
    #define PIR_PIN 2 //Connect the output of the PIR to this pin
    #define DEBOUNCE_TIME 750
    
    bool pirStatus = false;
    bool lastPirStatus = pirStatus;
    
    void interruptRoutine() {
      pirStatus = digitalRead(PIR_PIN);
    }
    
    void setup() {
      Serial.begin(115200);
      pinMode(PIR_PIN, INPUT);
      attachInterrupt(digitalPinToInterrupt(PIR_PIN), interruptRoutine, CHANGE);
    
        // Wait for 30 seconds for the PIR to st abilize after power on:
      Serial.println("Waiting 30 Seconds while PIR warms up");
      for (uint8_t seconds = 0; seconds < 30; seconds++)
      {
        Serial.println(seconds);
        delay(1000);
      }
      Serial.println("PIR Warmed up. Starting readings");
    }
    
    void loop() {
      if (pirStatus != lastPirStatus) {
        if (pirStatus)
        {
          Serial.println("Object Detected");
        }
        else
        {
          Serial.println("Object Removed");
        }
        lastPirStatus = pirStatus;
      }
      delay(DEBOUNCE_TIME);
    }
    

    From here, you can modify the code so the interrupt event triggers whatever behavior you would like. If you find the interrupt is firing too often, modify the code to trigger only on detected events or by modifying the interrupt type to be either RISING or FALLING.

    Python Example

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

    If you've assembled your SparkFun PIR Breakout circuit with a Raspberry Pi or other Python-based development board, we've written a quick example to demonstrate how to read the PIR's output.

    Example Dependencies

    In order to interface with your Pi's GPIO ports your user must be a member of the gpio group. The pi user is a member by default. Users with sudo privileges can add users manually using the following command:

    language:bash
    sudo usermod -a -G gpio <username>
    

    Simple Read

    This example demonstrates reading the SIG output from the PIR sensor using digital reads. Copy the code below into your preferred Python interpreter or into a blank text file and save it. If you are using an interpreter like Thonny, you can run it from there. Otherwise, open the terminal and run it by entering the following command: python3 FILENAME.py

    language:python
    import time
    import RPi.GPIO as GPIO
    import sys
    
    #Pin Definition
    pir_pin = 4
    
    #Set up pins and set PIR signal as an input
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(pir_pin, GPIO.IN)
    
    def run_example():
    
        #Wait 30 seconds for the PIR to stabilize
    
        print ("Waiting 30 seconds for PIR to stabilize")
        for i in range(0, 30):
            print(i)
            time.sleep(1)
    
        print ("Device Stable. Starting readings...")
    
        #Start monitoring the PIR output. If an object is detected, print "Object Detected" otherwise print "All Clear"
    
        while True:
            if GPIO.input(pir_pin):
                print("Object Detected")
            else:
                print("All clear")
            time.sleep(1)
    
    if __name__ == '__main__':
        try:
            run_example()
        except (KeyboardInterrupt, SystemExit) as exErr:
            print("\nEnding Example")
            sys.exit(0)
    

    Troubleshooting

    Hopefully by following the steps in this guide you've got your SparkFun PIR Breakout up and running monitoring motion and reporting data to your preferred microcontroller or single-board computer. In case you run into any issues we've outlined a few tips and tricks for testing the PIR here.

    Hardware Check

    Most common problems with the PIR Breakout revolve around the hardware connections. If your PIR Breakout is not powering on or your microcontroller/SBC cannot detect the output signal from the sensor, double-check your solder joints and your wiring to the microcontroller/SBC. The Hardware Checks section of our Troubleshooting Tips guide can help you diagnose any connection problems.

    Detection Area/Field of View

    The effective detection area of both the EKMC4607112K and EKMB1107112 is dependent on a variety of factors. The specifications for measurement range are based on a target concept (area of ~700×250mm) of a human body moving across two detection zones at a speed of 1m/s. The PIR senses objects best when moving across two detection zones on the horizontal (X) or vertical (Y) axes. The PIR may struggle to detect objects moving away or toward the PIR (along the Z axis) unless they also move along the other two axes.

    Also note that background IR radiation can influence the PIR's ability to detect an object. The PIR can detect objects with a larger temperature difference from the background at a larger range. Refer back to the Hardware Overview section for specific ranges and temperature differences.

    Take these detection limitations into consideration when selecting the mounting position of your PIR Breakout. Section 4-7 of the sensors' spec sheets (EKMC4607112K and EKMB1107112) show diagrams for optimal placement and object motion for sensing.

    General Troubleshooting

    If you need technical assistance and more information on this or another SparkFun product that is not working as you expected, we recommend heading on over to the SparkFun Technical Assistance page for some initial troubleshooting:

    If you don't find what you need there, the SparkFun Forums are a great place to find and ask for help. If this is your first visit, you'll need to create a Forum Account to search product forums and post questions.

    Resources and Going Further

    That's all for this Hookup Guide! For more information about the SparkFun PIR Breakout take a look at the following links:

    Looking for more information on PIR sensors or for some inspiration on how to use your PIR Breakout in a motion-sensing project? These tutorials can help:


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

    Qwiic PIR Hookup Guide

    Next: Qwiic Ultrasonic Distance Sensor (HC-SR04) Hookup Guide
    Previous: SparkFun PIR Breakout Hookup Guide
    $
    0
    0

    Qwiic PIR Hookup Guide a learn.sparkfun.com tutorial

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

    Introduction

    Passive Infrared (PIR) sensors are great for detecting motion in a specific area around the sensor. The SparkFun Qwiic PIR - 170uA (EKMC4607112K) and SparkFun Qwiic PIR - 1uA (EKMB1107112) use two versions of the EKM-series PIR sensors from Panasonic® to offer low profile motion-sensing options over I2C for both battery powered and continuously powered applications.

    SparkFun Qwiic PIR - 170uA (EKMC4607112K)

    SparkFun Qwiic PIR - 170uA (EKMC4607112K)

    SEN-17374
    $20.95
    SparkFun Qwiic PIR - 1uA (EKMB1107112)

    SparkFun Qwiic PIR - 1uA (EKMB1107112)

    SEN-17375
    $30.95

    PIR sensors do not return specific distance data like distance sensors. Instead, the sensors measure IR light coming from objects in their detection area making them perfect for applications such as controlling power to devices like lights, cameras, screens, etc. automatically when motion is detected.

    The Qwiic versions of these PIR breakouts feature an ATTiny84 with firmware that handles monitoring the sensor's output signal, debouncing that signal along with a configurable interrupt and translates it all to the I2C interface; making it easy to add a PIR to an existing Qwiic/I2C project.

    If you would prefer to directly monitor the sensors' digital outputs, check out our standard breakouts of the 170uA PIR and 1uA PIR.

    In this guide we'll cover the hardware present on the Qwiic PIRs, how to connect them to your circuit and we'll finish things up covering both the Arduino Library and Python Package we have written for these sensors along with the examples included in both code packages.

    Required Materials

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

    SparkFun Thing Plus - ESP32 WROOM

    SparkFun Thing Plus - ESP32 WROOM

    WRL-15663
    $20.95
    5
    SparkFun RedBoard Qwiic

    SparkFun RedBoard Qwiic

    DEV-15123
    $19.95
    8
    SparkFun RedBoard Artemis

    SparkFun RedBoard Artemis

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

    SparkFun Qwiic Micro - SAMD21 Development Board

    DEV-15423
    $20.95
    4

    We also have a Python package available for the Qwiic PIRs so you can use a single-board computer (SBC) like a Raspberry Pi or Jetson Nano as your controller as well.

    NVIDIA Jetson Nano Developer Kit (V3)

    NVIDIA Jetson Nano Developer Kit (V3)

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

    SparkFun DLI Kit for Jetson Nano

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

    Raspberry Pi 4 Model B (2 GB)

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

    SparkFun Raspberry Pi 4 Desktop Kit - 4GB

    KIT-16386
    $159.95

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

    SparkFun Qwiic Shield for Arduino

    SparkFun Qwiic Shield for Arduino

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

    SparkFun Qwiic pHAT v2.0 for Raspberry Pi

    DEV-15945
    $5.95
    2
    SparkFun Qwiic Shield for Thing Plus

    SparkFun Qwiic Shield for Thing Plus

    DEV-16790
    $4.25
    SparkFun Qwiic Shield for Arduino Nano

    SparkFun Qwiic Shield for Arduino Nano

    DEV-16789
    $4.25

    Finally, you'll need at least one Qwiic cable to connect your Qwiic PIR to your microcontroller:

    Qwiic Cable - 100mm

    Qwiic Cable - 100mm

    PRT-14427
    $1.50
    Flexible Qwiic Cable - 500mm

    Flexible Qwiic Cable - 500mm

    PRT-17257
    $1.95
    Qwiic Cable - 200mm

    Qwiic Cable - 200mm

    PRT-14428
    $1.50
    Flexible Qwiic Cable - 50mm

    Flexible Qwiic Cable - 50mm

    PRT-17260
    $0.95

    Suggested Reading

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

    Qwiic Connect System

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

    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.

    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 4 Kit Hookup Guide

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

    Hardware Overview

    In this section we'll cover the characteristics and features of the PIR sensors and other hardware included on the Qwiic PIR boards.

    Panasonic EKM-Series PIR Sensors

    The EKMC4607112K and EKMB1107112 from Panasonic are low-profile PIR sensors ideal for things like motion-activated lights, cameras or other electronics. Applications include automatic lighting for energy conservation, motion-activated security or trail cameras or maybe something fun like a homemade convenience store chime. The EKMC4607112K works best in a continuous power installation and has slightly better sensing performance than the EKMB1107112 which is best suited for battery and low-power installations.

    Photo of the Qwiic PIR with the Panasonic EKM PIR Sensor Highlighted.
    The version (1µA or 170µA) is marked by one of two solder pads "East" of the PIR sensor.

    Input voltage (normally 3.3V) for the Qwiic PIR is provided either via the Qwiic connectors or through the 3.3V pin on the PTH header. The Output (OUT) pin is connected to a digital pin on the ATTiny84. Take note that both versions of the Qwiic PIR share the same PCB design and the version (1µA or 170µA) are marked by the solder pads "East" of the PIR sensor.

    The two PIR sensors have very similar electrical and sensing characteristics with a few specific differences users will want to take note of prior to deciding which sensor best suits their needs. The tables below outline the Electrical and Detection Performance Characteristics to give users a basic overview. For a more detailed look at these two sensors, take a look at their respective specification sheets (EKMC4607112K& EKMB1107112) along with the Panasonic PIR Sensors - Product Brief (EKM-Series sensors are covered on page 8).

    Electrical Characteristics
    EKMC4607112KEKMB1107112
    CharacteristicUnitsMinTyp.MaxMinTyp.Max
    Operating VoltageVDC3.0-6.02.3-4.0
    Current Consumption
    (Sensor Only)
    µA-170300-1[1]3
    Output CurrentµA--100--100
    Output VoltageVDCVDD-0.5--VDD-0.5--
    Circuit Stability Time
    (when voltage is applied)
    secs--30-25210

    As mentioned above, the sensing performances of the PIR Sensors are very similar with a few notable differences. Also take note that PIR sensor performance can vary depending on the environment it is monitoring.

    Detection Performance Characteristics
    EKMC4607112KEKMB1107112Notes
    Temperature DifferenceValueTemperature DifferenceValueTarget Conditions
    Detection Range8°C (14.4°F)up to 7m4°C (7.2°F)up to 7m1. Movement speed: 1 m/s
    2. Target concept is human body (Object size:Around700×250mm)
    4°C (7.2°F)up to 5m2°C (3.6°F)up to 5m
    Note: Current consumption for the EKMB1107112 varies depending on the operating mode. Refer to section 4-4 of the EKMB Spec Sheet for specific values.

    ATTiny84 IC

    The ATTiny84 on this board comes pre-programmed with firmware to act as an intermediary between the PIR sensor and the microcontroller via Qwiic/I2C. The firmware handles monitoring the raw sensor output to detect objects entering or leaving the sensing area, automatically debouncing the output, triggering an interrupt whenever motion is detected and even storing a queue of sensing events you can pull from and clear.

    Qwiic PIR with the ATTiny84 IC Highlighted.

    The default I2C address for the Qwiic PIR is 0x12 but can be switched to 0x13 by adjusting the ADR jumper. Alternatively, users can alter the address to a custom value using functions from the libraries or direct writes to the address register. Software setting of the I2C address is covered in more detail in the Arduino and Python library sections.

    Finally, a 2x3 header broken out on the back of the board allows for programming the ATTiny84. This is primarily used for programming during manufacturing but can be used re-program the IC with custom firmware. You can download and modify the firmware from the Hardware GitHub Repository.

    Need help re-programming your Qwiic PIR? Take a look through these tutorials for instructions and tips:

    Qwiic/I2C Interface and Interrupt Pin

    The easiest way to use the Qwiic PIR is with the Qwiic connect system. Connect it to your microcontroller or SBC with a Qwiic Cable to start communicating with it via I2C. For users who prefer a soldered connection, the I2C pins for the Qwiic PIR are broken out to a standard 0.1"-spaced PTH header.

    Highlighting the Qwiic connectors on the front of the Qwiic PIRHighlighting the Qwiic PIR's PTH Header for I2C and Interrupt pin.

    Having trouble viewing the detail in these photos? Click on them for a larger view.

    We've also included a dedicated Interrupt pin users can connect to an interrupt-capable pin on their microcontroller to trigger interrupt events based on the activity detected by the Qwiic PIR. Read on to the Arduino and Python sections for more information on how to configure and use this pin.

    Solder Jumpers

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

    There are four solder jumpers on the Qwiic PIR boards labeled PWR, I2C, INT and ADR. Let's briefly cover each jumper's functionality and default state.

    Highlighting the Power LED Jumper on the Qwiic PIRHighlighting the I2C, Interrupt and Address Jumpers on the back of the Qwiic PIR

    Power Jumper

    The Power (PWR) Jumper controls the power LED on the board and is closed by default. It ties the anode of the Power LED to 3.3V via a 1K&ohm; resistor. Open the jumper and disable the LED by severing the trace between the two pads. Disabling the Power LED helps to reduce the total current draw of the Qwiic PIR.

    I2C Jumper

    The I2C Jumper pulls the ATTiny84's SDA and SCL lines to 3.3V via a pair of 2.2k&ohm; resistors. The default state is closed. Open the jumper by severing the trace connecting the three pads to disable the pull-up resistors.

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

    Interrupt Jumper

    The Interrupt (INT) Jumper pulls the ATTiny84's Interrupt pin to 3.3V via a 10k&ohm; resistor. The default state of the Interrupt jumper is closed. The Interrupt Pin on the ATTiny84 is configured as an active LOW interrupt and must be pulled to logic HIGH (3.3V) to function properly. Disable the Interrupt pin by opening the jumper.

    Address Jumper

    The Address (ADR) Jumper sets the I2C address of the ATTiny84. The jumper is closed by default. Open the jumper by severing the trace between the two pads to change the I2C address from its default value (0x12) to 0x13.

    Board Dimensions

    The Qwiic PIR matches the standard 1" x 1" (24.5mm x 24.5mm) form-factor for most Qwiic breakouts and has two mounting holes that fit a 4-40 screw.

    Qwiic PIR Board Dimensions

    Hardware Assembly

    With the Qwiic system, assembling your SparkFun Qwiic PIR incredibly easy. We'll cover the basics of hardware assembly here along with a couple of tips for using the Interrupt pin.

    Connecting Qwiic Cables

    Assuming you are using a Qwiic-enabled development board like the RedBoard Qwiic shown below or you have a Qwiic shield or Qwiic adapter attached to your development board or Raspberry Pi/SBC, all you need to do to connect the Qwiic PIR to your circuit is to plug one end of your Qwiic cable into the Qwiic PIR and the other end into the Qwiic connector on your development board/shield.

    Qwiic PIR connected to RedBoard Qwiic

    Alternatively, you can use one of our adapter cables (male and female) to convert the Qwiic system to a standard jumper wire assembly. If you use one of these adapter cables, make sure you match the signals correctly:

    • Black = GND
    • Red = 3.3V
    • Blue = SDA
    • Yellow = SCL

    If you prefer to not use the Qwiic connectors you can solder wire or header pins to the PTH header to make your connections.

    Connecting Everything Up

    If you do not plan to use the Interrupt pin on the Qwiic PIR go ahead and connect your development board to your computer via USB or if you are using a Raspberry Pi or other SBC, power it up.

    If you want to use the Interrupt pin, a bit more assembly is required. In order to use the Interrupt pin we need to either solder to it or, for quick prototyping, you can connect it to your development board/SBC using IC hooks like these that terminate in a standard male jumper wire connection.

    After you have made your connection to the Qwiic PIR's Interrupt Pin, run that wire to a digital pin available for external interrupts. If you are not sure which pins are interrupt-capable, refer to your board's documentation for clarification. Since we're using the RedBoard Qwiic we can set up D2 or D3 as an interrupt pin. In the circuit below and the Interrupt Example in the Arduino library, the Interrupt pin is connected to D2:

    The completed Qwiic PIR circuit with Interrupt Pin connected.

    Now that the Qwiic PIR circuit is fully assembled, connect the RedBoard to your PC via USB (or if using a Raspberry Pi or other SBC, power it on) and we can move on to uploading code and monitoring motion.

    Qwiic PIR Arduino Library

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

    We've written an Arduino library to make it easy to get started and interact with the Qwiic PIR. Before we jump into the examples for reading data from the sensor, we need to install the library and we'll take a closer look at the available functions in the library. The Arduino Library Manager is the easiest way to install the library. Open the Library Manager, search for "SparkFun Qwiic PIR Arduino Library" and click the "Install" button to download the latest version. If you prefer manually installing the library from the GitHub repository, you can download it here:

    Library Functions

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

    Class

    In the global scope, construct your sensor object (such as mySensor or myPIR) without arguments.

    • QwiicPIR mySensor;

    Device Setup & Settings

    • bool begin(uint8_t address = DEFAULT_ADDRESS, TwoWire &wirePort = Wire); - Initializes the Qwiic PIR on the I2C bus. Users can specify an alternate address if it has been changed as well as choose which I2C port used to communicate with the PIR.
    • bool isConnected(); - Returns true if the PIR will acknowledge over I2C and false otherwise.
    • uint8_t deviceID(); - Returns the 8-bit device ID.
    • bool checkDeviceID(); - Returns true if the device ID matches the Qwiic PIR ID.
    • uint8_t getDeviceType(); - Returns 1 if a Qwiic PIR is attached to the bus and 0 if no device is attached.
    • uint16_t getFirmwareVersion(); - Returns the Qwiic PIR firmware version as a 16-bit integer. Major Revision Number = leftmost (high) byte. Minor Revision Number = rightmost (low) byte.
    • bool setI2Caddress(uint8_t address); - Configures the attached Qwiic PIR to initialize to the bus using the specified address.
    • uint8_t getI2Caddress(); - Returns the I2C address of the attached Qwiic PIR.

    PIR Status and Debounce Configuration

    These functions are the primary ways to read whether or not an object is detected in the sensing area as well as how to customize the debounce time from the PIR to reduce noise and false detections and how to manipulate the detection queues.

    • bool rawPIRReading(); - Returns 1 when PIR is outputting a signal, 0 when not. This is the raw output from the PIR with no debouncing.
    • bool objectDetected(); - Returns 1 if a debounced object detection event occurs in the sensing area. The debounce time objectDetected(); waits for is set by the setDebounceTime(uint16_t time);.
    • bool ojbectRemoved(); - Returns 1 if a debounced object removal event occurs in the sensing area. The debounce time objectRemoved(); waits for is set by the setDebounceTime(uint16_t time);.
    • uint16_t getDebounceTime(); - Returns the debounce time set for the PIR reading to settle (in milliseconds).
    • uint8_t setDebounceTime(uint16_t time); Sets the time the Qwiic PIR waits for the raw reading from the sensor to settle. The default value for debounce time is 750ms.

    Interrupt Status and Configuration

    • uint8_t enableInterrupt(); - When called, the interrupt pin is configured to trigger on all PIR events (detection & removal).
    • uint8_t disableInterrupt(); - When called, the interrupt pin is no longer configured to trigger on PIR events.
    • bool available(); - Returns the eventAvailable bit.
    • uint8_t clearEventBits(); - Sets objectDetected, objectRemoved and eventAvailable bits to zero.
    • uint8_t resetInterruptConfig(); - Resets any configured interrupt functions to defaults (OFF).

    Queue Manipulation

    • bool isDetectedQueueFull(); - Returns true if queue of object detections timestamps is full and false if not. This queue stores ten timestamp values.
    • bool isDetectedQueueEmpty(); - Returns true if the queue of object detections timestamps is empty and false otherwise.
    • unsigned long timeSinceLastDetect(); - Returns the time (in milliseconds) since the objectDetected(); function last returned 1.
    • unsigned long timeSinceFirstDetect(); - Returns the time (in milliseconds) for the oldest value stored in the Detected Queue.
    • unsigned long popDetectedQueue(); - Returns the oldest value stored in the Detected Queue and removes it.
    • bool isRemovedQueueFull(); - Returns true if the object removals queue is full and false if not. This queue stores ten timestamp values.
    • bool isRemovedQueueEmpty(); - Returns true if the object removals queue is empty and false otherwise.
    • unsigned long timeSinceLastRemove(); - Returns the time (in milliseconds) since the objectRemoved(); function last returned 1.
    • unsigned long timeSinceFirstRemove(); - Returns the time (in milliseconds) for the oldest value stored in the Removed Queue.
    • unsigned long popRemovedQueue(); - Returns the oldest value stored in the Removed Queue and removes it.

    Arduino Examples

    The SparkFun Qwiic PIR Arduino Library includes five examples to help users get started with the board and library. In this section we'll go over a few of the examples and highlight how they work.

    Example 1 - Print Raw PIR Status

    The first example demonstrates how to set up the Qwiic PIR on your I2C bus and then retrieve raw data readings from the Qwiic PIR using the rawPIRReading(); function. Open the first example by navigating to File > Examples > SparkFun Qwiic PIR Arduino Library > Example1_PrintRawPIRStatus. Next, open the Tools menu and select your board (in our case, Arduino Uno) and the correct Port your board enumerated on. Upload the code and open your serial monitor with the baud set to 115200.

    The example first sets up the Qwiic PIR object and debounce time (in milliseconds):

    language:c
    QwiicPIR pir;
    
    #define DEBOUNCE_TIME 750
    

    Next it initializes the sensor and then waits 30 seconds for the PIR to warm up and stabilize.

    language:c
    if (pir.begin() == false) {
        Serial.println("Device did not acknowledge! Freezing.");
        while (1);
      }
    
      Serial.println("PIR acknowledged. Waiting 30 Seconds while PIR warms up");
      for (uint8_t seconds = 0; seconds < 30; seconds++)
      {
        Serial.println(seconds);
        delay(1000);
      }
    

    The code will freeze if the Qwiic PIR does not acknowledge on the I2C bus at the default address. A bad connection or a different I2C address are the most common causes of this failure.

    Once the PIR warms up the main loop checks whether rawPIRReading(); returns TRUE or FALSE and waits to update again for the value set for DEBOUNCE_TIME. The code prints out objects detected or removed via serial. Take note when using the rawPIRReading(); any debouncing of the signal must be done manually.

    Example 2 - Print PIR Status

    The second example is very similar to the first but uses the objectDetected(); and objectRemoved(); functions instead of rawPIRReading();. The primary difference between these functions is where debouncing the PIR signal happens. Instead of manually debouncing the PIR signal each time it occurs, the objectDetected(); and objectRemoved(); functions refer to the value stored for setDebounceTime(uint16_t time); and will automatically debounce the signal for that time. The default value for setDebounceTime(); is 750ms.

    Open the example, upload it and open a serial terminal set to 115200 baud. After initializing the sensor and waiting for 30 seconds for the PIR to warm up, the code will start polling the PIR for events and prints what they are over serial:

    language:c
    if (pir.available()) {
        if (pir.objectDetected()) {
            Serial.println("Object Detected");
        }    
        if (pir.objectRemoved()) {
            Serial.println("Object Removed");
        }
        pir.clearEventBits();
    }
    

    Example 3 - Queue Usage

    The third example included with the library shows how to read and manipulate the Object Detected and Object Removed queues. After uploading the example, open a serial terminal with the baud set again to 115200. After initializing the Qwiic PIR, the main loop checks if either the Detected or Removed queues have values stored for either time (in seconds) since first detect/remove or time since last detect/remove and prints them over serial. If no values are present in either queue, the code prints out which queue is empty:

    language:c
    if(pir.isDetectedQueueEmpty() == false) {
        Serial.print(pir.timeSinceLastDetect()/1000.0);
        Serial.print("s since PIR detect   ");
        Serial.print(pir.timeSinceFirstDetect()/1000.0);
        Serial.print("s since PIR detect   ");
    }
    
    if(pir.isDetectedQueueEmpty() == true) {
        Serial.print("PIR Detected Queue is empty! ");
    } 
    
    if(pir.isRemovedQueueEmpty() == false) { 
        Serial.print(pir.timeSinceLastRemove()/1000.0);
        Serial.print("s since PIR remove   ");
        Serial.print(pir.timeSinceFirstRemove()/1000.0);
        Serial.print("s since PIR remove   ");
    }
    if(pir.isRemovedQueueEmpty() == true) {
        Serial.print("  PIR Removed Queue is empty!");
    }
    

    Along with printing values from each queue, this example also shows how to manipulate and pop values from any queue:

    language:c
    if(Serial.available()) {
    
        uint8_t data = Serial.read();
        if(data == 'd' || data == 'D') { 
            pir.popDetectedQueue();
            Serial.println("Popped DetectedQueue!");
        }
    
        if(data == 'r' || data == 'R') { 
            pir.popRemovedQueue();
            Serial.println("Popped RemovedQueue!");
        }
    }
    delay(20);
    

    With a serial terminal open, send the letter "D" (capitalized or not) to pop a value off the Detected Queue. Similarly, send the letter "R" to pop a value off the Removed Queue.

    Example 4 - External Interrupt

    Example 4 - ExtInterrupt demonstrates how to use the Interrupt pin on the Qwiic PIR.

    Along with setting up the Qwiic PIR in the global class, the code defines the interrupt pin and creates an interrupt flag:

    language:c
    int interruptPin = 2;
    
    bool interruptEntered = false;
    

    Adjust the value for your interrupt pin as needed. This example assumes a SparkFun RedBoard/Arduino Uno is used and sets D2 as the interrupt pin. In the setup, the code initializes the Interrupt pin as an input and attaches it as a falling-edge interrupt to a custom function called pirHandler:

    language:c
    pinMode(interruptPin, INPUT);
    attachInterrupt(digitalPinToInterrupt(interruptPin), pirHandler, FALLING);
    

    After initializing the Qwiic PIR on the bus and waiting for 30 seconds for the PIR to warm up, the code calls the enableInterrupt(); and clearEventBits(); functions to tell the Qwiic PIR to trigger the pin on object events and clears any event bits to toggle the Interrupt pin HIGH:

    pir.enableInterrupt();
    pir.clearEventBits();
    

    The main loop checks for motion events and if any are detected it will fire the interrupt pin:

    language:c
    void loop() {
      if (interruptEntered)
      {
        if (pir.objectDetected()) {
          Serial.println("Object Detected");
        }
        pir.clearEventBits();
        interruptEntered = false;
        delay(10);
      }
    }
    
    void pirHandler()
    {
      interruptEntered = true;
    }
    

    From here, you can modify this example or insert it into more complex code to trigger whatever interrupt event you would like using the Qwiic PIR.

    Qwiic PIR Python Package

    Note: This tutorial assumes you are using the latest version of Python 3. If this is your first time using Python or I2C hardware on a Raspberry Pi these tutorials will help you get started:

    We've written a Python package for the Qwiic PIR for users who prefer to use something like a Raspberry Pi with their sensor. The package can be installed with the all inclusive SparkFun Qwiic Python package or independently.

    We recommend installing the entire SparkFun Qwiic Package as it also installs the required I2C driver.

    Note: Don't forget to double check that the hardware I2C connection is enabled on your Raspberry Pi or other single board computer. Make sure to reboot your Pi after enabling the I2C bus for changes to take effect.

    SparkFun Qwiic Package

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

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

    language:bash
    sudo pip3 install sparkfun-qwiic
    

    For the current user:

    language:bash
    pip3 install sparkfun-qwiic
    

    Independent Qwiic PIR Py Package Installation

    If you prefer to only install the Qwiic PIR package, you can download the sparkfun-qwiic-pir Python package hosted by PyPi via pip3 following the instructions below. Alternatively, if you prefer to manually download and build the libraries you can grab them from the Qwiic PIR Py GitHub Repository or by clicking the button below:

    PyPi Installation

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

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

    language:bash
    sudo pip3 install sparkfun-qwiic-PIR
    

    For the current user:

    language:bash
    pip3 install sparkfun-qwiic-PIR
    

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

    Qwiic PIR Python Package Operation

    Let's take a quick look at the functions available in the Python package. For more details on how the package works, take a look at the source code and package documentation hosted on ReadTheDocs.

    Dependencies

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

    language:python
    import time
    import sys
    

    Default Variables

    language:python
    # Define the device name and I2C addresses. These are set in the class definition
    # as class variables, making them available without having to create a class instance.
    # This allows higher level logic to rapidly create an index of qwiic devices at runtime.
    
    # This is the name of the device
    _DEFAULT_NAME = "Qwiic PIR"
    
    # Some devices have  multiple available addresses - this is a list of these addresses.
    # NOTE: The first address in this list is considered the default I2C address for the 
    # device.
    _AVAILABLE_I2C_ADDRESS = [0x12]
    
    Note: This package differs from other SparkFun packages as the register values are declared in the object class.
    language:python
    # Constructor
    device_name = _DEFAULT_NAME
    available_addresses = _AVAILABLE_I2C_ADDRESS
    
    # Device ID for all Qwiic PIRs
    DEV_ID = 0x72
    
    # Registers
    ID = 0x00
    FIRMWARE_MINOR = 0x01
    FIRMWARE_MAJOR = 0x02
    EVENT_STATUS = 0x03
    INTERRUPT_CONFIG = 0x04
    EVENT_DEBOUNCE_TIME = 0x05
    DETECTED_QUEUE_STATUS = 0x07
    DETECTED_QUEUE_FRONT = 0x08
    DETECTED_QUEUE_BACK = 0x0C
    REMOVED_QUEUE_STATUS = 0x10
    REMOVED_QUEUE_FRONT = 0x11
    REMOVED_QUEUE_BACK = 0x15
    I2C_ADDRESS = 0x19
    
    # Status Flags
    eventAvailable = 0
    objectRemove = 0
    objectDetect = 0
    rawObjectDetected = 0
    
    # Interrupt Configuration Flags
    interruptEnable = 0
    
    # Queue Status Flags
    popRequest = 0
    isEmpty = 0
    isFull = 0
    

    Class

    QwiicPIR() or QwiicPIR(address)

    This Python package operates as a class object, allowing new instances of that type to be made. An __init__() constructor is used that creates a connection to an I2C device over the I2C bus using the default or specified I2C address.

    Note: If the Qwiic PIR's address has been altered from the default (0x12), create the Qwiic PIR object with the new address. For example, if the address jumper is opened create the Qwiic PIR object using this format: QwiicPIR(0x13).
    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 (0x12) stored under _AVAILABLE_I2C_ADDRESS variable.
    Input: i2c_driver
    Loads the specified I2C driver; by default the Qwiic I2C driver is used: qwiic_i2c.getI2CDriver(). Users should use the default I2C driver and leave this field blank.

    Functions

    A function is an attribute of the class, which defines a method for instances of that class. In simple terms, they are objects for the operations (or methods) of the class. For a complete list of all the available functions, head over to the API Reference page of ReadtheDocs for the Qwiic PIR Py Python Package.

    Upgrading the Package

    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-pir 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-pir
    

    For the current user:

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

    Python Examples

    The SparkFun Qwiic PIR Python Library includes four examples to help users get started with the board and library. In this section we'll go over the examples and highlight how they work.

    To use the examples, open them from the Python library's location or copy the code into your preferred Python interpreter.

    Example 1 - Simple Example (Raw PIR Readings)

    The first example shows how to set up the Qwiic PIR on the I2C bus and retrieve raw data from the PIR's output signal. Because we are reading raw PIR output the code manually sets up a debounce time (in milliseconds) to wait for the PIR output signal to stabilize. Adjust the debounce time by changing this value:

    language:python
    debounce_time = .20
    

    The main example loop sets up the PIR object, attempts to initialize it on the I2C bus and, if successful, waits 30 seconds for the PIR to stabilize:

    language:python
    def run_example():
    
    
            print("\nSparkFun Qwiic PIR Example1\n")
            my_PIR = qwiic_pir.QwiicPIR()
    
            if my_PIR.begin() == False:
                    print("The Qwiic PIR isn't connected to the system. Please check your connection", \ file=sys.stderr)
    
                    return
            print ("Waiting 30 seconds for PIR to stabilize")
            for i in range(0,30):
                    print(i)
                    time.sleep(1)
    
            print("Device Stable")
    

    Once the PIR has initialized and stabilized, the code begins to take readings and print out whether an object was detected or removed, pausing for the value set for debounce_time after each reading:

    language:python
    while True:
            if my_PIR.raw_reading() is True:
                    print("Object Detected")
            else:
                    print("Object Removed")
            time.sleep(debounce_time)
    

    Example 2 - Debounced Readings

    The second example demonstrates how to read the debounced output signals from the Qwiic PIR using the object_detected() and object_removed() functions. Just like with the Arduino library, the Qwiic PIR Python Library includes functions for both raw PIR readings as well as automatically debounced readings.

    Using the object_detected()/removed() functions allows you to set a debounce time with the set_debounce_time() function and the PIR will always wait for that amount of time before taking another reading. The default value for set_debounce_time() is 750ms.

    The code initializes the Qwiic PIR on the bus and waits for 30 seconds for the PIR to stabilize prior to taking readings for object detections:

    language:python
    while True:
            if my_PIR.available() is True:
                    if my_PIR.object_detected():
                            print("Object Detected")
                    if my_PIR.object_removed():
                            print("Object Removed")
                    my_PIR.clear_event_bits()
            time.sleep(1)
    

    Example 3 - Queue Usage

    The third example shows how to read values stored for the Object Detected and Object Removed queues. After initializing the sensor and waiting for it to stabilize the code then prints out values stored in Detected Queue & Removed Queue for both time (in seconds) since the last (most recent) object detection or removal event as well as the time since the oldest stored object detection or removal event. If either queue is empty, the code prints out which queue is empty.

    language:python
    while True:
            if my_PIR.is_detected_queue_empty() is False:
                    last_detect = my_PIR.time_since_last_detect() / 1000.0
                    first_detect =  my_PIR.time_since_first_detect() / 1000.0
                    print(last_detect)
                    print("s since last PIR detect   ")
                    print(first_detect)
                    print("s since first PIR detect   ")
            else:
                    print("Detected queue is empty")
    
            if my_PIR.is_removed_queue_empty() is False:
                    last_remove = my_PIR.time_since_last_remove() / 1000.0
                    first_remove =  my_PIR.time_since_first_remove() / 1000.0
                    print(last_remove)
                    print("s since last PIR detect   ")
                    print(first_remove)
                    print("s since first PIR detect   ")
            else:
                    print("Removed queue is empty")
    

    Example 4 - Pop Queue

    Example 4 demonstrates how to pop values from both the object_detected() and object_removed() queues by sending the appropriate characters over serial.

    Just like the other examples, the Qwiic PIR is initialized on the I2C bus and the code waits for 30 seconds for the PIR to stabilize it's readings. After waiting, the code prints out to enter either "d" or "r" to pop values from either the detected (d) or removed (r) queues:

    language:python
    while True:
        print("\mType 'd' to pop from the detected queue.")
        val = raw_input("Type 'r' to pop from the removed queue: ")
        # If the character is 'd' or 'D', then pop a value off the detected queue
        if val == 'd' or val == 'D':
            print("\nPopped detected queue! The first timestamp in detected queue was: ")
            print(str(my_PIR.pop_detected_queue() / 1000.0))
    
        # If the character is 'r' or 'R', then pop a value off the removed queue
        if val == 'r' or val == 'R':
            print("\nPopped removed queue! The first timestamp in removed queue was: ")
            print(str(my_PIR.pop_removed_queue90 / 1000.0))
    
        time.sleep(debounce_time)
    

    If the correct value is entered the code prints out over serial the respective queue has been popped and prints out the timestamp for the removed value in seconds.

    Troubleshooting

    Assembling and testing the Qwiic PIR is fairly straight-forward but in case you run into any issues we've outlined a few tips and tricks for testing the PIR here.

    Detection Area/Field of View

    The effective detection area of both the EKMC4607112K and EKMB1107112 is dependent on a variety of factors. The specifications for measurement range are based on a target concept (area of ~700×250mm) of a human body moving across two detection zones at a speed of 1m/s. The PIR senses objects best when moving across two detection zones on the horizontal (X) or vertical (Y) axes. The PIR may struggle to detect objects moving away or toward the PIR (along the Z axis) unless they also move along the other two axes.

    Also note that background IR radiation can influence the PIR's ability to detect an object. The PIR can detect objects with a larger temperature difference from the background at a larger range. Refer back to the Hardware Overview section for range specifications at different temperature differences.

    Take these detection factors into consideration when selecting the mounting position of your Qwiic PIR. Section 4-7 of the sensors' spec sheets (EKMC4607112K and EKMB1107112) show diagrams for optimal sensor placement and object motion for sensing performance.

    Qwiic PIR Not Recognized on I2C Bus

    The examples included in both the Arduino and Python libraries will freeze if the Qwiic PIR does not acknowledge on the I2C bus. The most common cause of this is a poor or incomplete connection either using the Qwiic connectors or PTH header. Check your Qwiic cables for a secure connection to the Qwiic connectors or for damage. If using the PTH header, double check your solder joints and wires to make sure they are complete and secure.

    Another common cause for this error is if the Qwiic PIR is set to an alternate address. The examples assume the PIR uses the default I2C address (0x12) and will freeze if the code is not adjusted to reflect a change in address. For example, if the ADR jumper is set to switch the address to 0x13, the begin(); function in the Arduino Library can be adjusted as follows:

    language:c
    pir.begin(0x13);
    

    Similarly, the Qwiic PIR object can be created in the Python package at an alternate address using the following code:

    language:python
    QwiicPIR(0x13)
    

    Finally, Raspberry Pi users encountering this error should check to make sure the I2C bus is enabled. Refer to this section of our Raspberry Pi SPI & I2C tutorial for detailed instructions on enabling the bus.

    General Troubleshooting

    If you need technical assistance and more information on this or another SparkFun product that is not working as you expected, we recommend heading on over to the SparkFun Technical Assistance page for some initial troubleshooting:

    If you don't find what you need there, the SparkFun Forums are a great place to find and ask for help. If this is your first visit, you'll need to create a Forum Account to search product forums and post questions.

    Resources and Going Further

    For more information about the SparkFun Qwiic PIR boards, take a look at theses resources:

    Looking for some project inspiration to use your Qwiic PIR in? Check out these resources:

    Vernier Photogate

    Vernier Photogate Timer -- using the Serial Enabled LCD Kit.

    Photon Remote Water Level Sensor

    Learn how to build a remote water level sensor for a water storage tank and how to automate a pump based off the readings!

    Are You Okay? Widget

    Use an Electric Imp and accelerometer to create an "Are You OK" widget. A cozy piece of technology your friend or loved one can nudge to let you know they're OK from half-a-world away.

    Boss Alarm

    Build a Boss Alarm that alerts you of anyone walking into your office and automatically changes your computer screen.

    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>