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

Cellular Function Board - Blues Wireless Notecarrier

$
0
0

Cellular Function Board - Blues Wireless Notecarrier a learn.sparkfun.com tutorial

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

Introduction

The SparkFun Cellular Function Board - Blues Wireless Notecarrier features the Notecard from Blues Wireless. The Notecard is unique among cellular modules as it has a built-in SIM card and includes a 10 year subscription and 500MB of data included in the price. The Notecard module also comes with integrated cellular, SIM, onboard GPS, 3-axis accelerometer with an on-chip temperature sensor. On top of that, the Notecard features outboard device firmware updates (DFU) meaning you can reprogram a connected Processor remotely through Blues' Notehub service! There are some limitations to this process so make sure to read further in this guide for more information on how to properly perform Outboard device firmware updates.

SparkFun MicroMod Cellular Function Board - Blues Wireless Notecarrier

SparkFun MicroMod Cellular Function Board - Blues Wireless Notecarrier

WRL-20409
$119.95

The MicroMod Cellular Function Board includes everything you need : a carrier board (Blues calls them Notecarriers) and the globally enabled NB-IoT & LTE-M M.2 based module (Blues calls them Notecards).

Required Materials

The following materials are necessary for following along with this guide. All Function Boards require a Main Board and Processor to connect to each other. Depending on your application, you may need a Single or Dual Main Board:

SparkFun MicroMod Main Board - Double

SparkFun MicroMod Main Board - Double

DEV-20595
$19.95
SparkFun MicroMod Main Board - Single

SparkFun MicroMod Main Board - Single

DEV-20748
$15.95

A Processor Board is needed to act as a host controller for the Function Board:

Heads Up: Outboard Device Firmware Updates only support the STM32 Processor v20 as of release. Other Processors may be supported in the future but are beyond the scope of this tutorial. We will update this guide if and when other Processors work with this feature.
SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod STM32 Processor

SparkFun MicroMod STM32 Processor

DEV-21326
$16.50

You'll also need a cellular and GNSS antenna:

GPS Embedded Antenna SMA

GPS Embedded Antenna SMA

GPS-00177
$12.95
Molex Flexible GNSS Antenna - U.FL (Adhesive)

Molex Flexible GNSS Antenna - U.FL (Adhesive)

GPS-15246
$4.50
1
LTE Hinged External Antenna - 698MHz-2.7GHz, SMA Male

LTE Hinged External Antenna - 698MHz-2.7GHz, SMA Male

CEL-16432
$7.50
PCB Antenna - U.FL (2.4GHz)

PCB Antenna - U.FL (2.4GHz)

WRL-18086
$1.50

The Notecard Module uses u.Fl connectors for both antenna connections so, depending on your choice of antennas, you may also need an adapter cable like these:

SMA to U.FL Cable - 150mm

SMA to U.FL Cable - 150mm

WRL-18568
$1.95
Interface Cable SMA to U.FL

Interface Cable SMA to U.FL

WRL-09145
$5.50
3
Interface Cable U.FL to SMA

Interface Cable U.FL to SMA

WRL-18154
$8.95

Suggested Reading

The MicroMod ecosystem is a unique way to allow users to customize their project to their needs. If you aren't familiar with the MicroMod system, click on the banner below for more information.

MicroMod Logo


You may also want to go through the tutorials below if you are not familiar with the concepts covered in them:

Serial Peripheral Interface (SPI)

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

What is an Arduino?

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

Installing Arduino IDE

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

Getting Started with MicroMod

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

Hardware Overview

Let's take a closer look at the Notecard module and other hardware present on this Function Board.

Blues Wireless Notecard - NOTE_NBGL-500

The Blues Wireless Notecard module offers a low-power cellular connection from a connected device to the cloud through either the Notehub service or alternate cellular service with a supported external SIM. The module has a built-in SIM card that includes a 10 year subscription and 500MB of data in the initial purchase price. The built-in SIM on the Notecard works in over 140 countries with varying levels of cellular coverage, for a complete list of compatible countries, refer to the Cellular Service section of the Notecard datasheet. The Cellular Function Board ships with the NOTE_NBGL-500 Notecard which operates over narrowband global networks (LTE-M, NB-IoT and GPRS).

Highlighting the Notecard

The Notecard uses the BG95-M3 cellular module with integrated GNSS from Quectel. The GNSS supports GPS, GLONASS, BeiDou, Galileo and QZSS constellations. The Notecard also has an on-board 3-axis accelerometer with an on-chip temperature sensor. For a complete overview of the Notecard, refer to the datasheet.

USB-C Connector

The USB-C connector provides a direct serial interface with the Notecard over a USB connection.

Highlighting the USB-C connector

This connection allows you to use the Notecard with Blues Wireless' browser-based CLI, Notecard Playground. This CLI is very helpful for configuring and testing the Notecard quickly over USB. Those who prefer to download and use the CLI application locally can find it here.

Nano-SIM Slot

The Function board includes a Nano-SIM slot for users who prefer to use their own nano SIM card instead of the built-in one on the Notecard module.

Highlighting nano SIM slot

Enabling the external SIM capability requires updating several settings on the Notecard. Refer to this guide from Blues Wireless for detailed instructions for configuring the Notecard to work with an external SIM card. Reminder, this Function Board uses the NOTE_NBGL-500 Notecard so it only supports narrowband LTE networks (no 3G or 4G networks).

AUX UART PTH Header

The Function Board routes the auxiliary UART pins used for Outboard DFU on the Notecard to a 0.1"-spaced PTH header along with the Auxiliary Enable pin.

Highlighting the PTH header

This interface allows for users to connect directly to the Notecard's auxiliary UART (AUX RX and AUX TX) as well as the Auxiliary Enable pin to toggle the auxiliary UART. The Function Board also routes the AUX1 to a pushbutton labeled "USRBTN" to allow for a user-configurable manual input on that pin.

LEDs

The board has three power indication LEDs labeled VIO, VIN, and AEN as well as a WS2812 RGB LED tied to the Notecard's AUX2 pin.

Highlighting LEDs
  • VIO - 3.3V I/O voltage status. LED turns on when 3.3V from the MicroMod connector is present.
  • VIN - Notecard power status. LED turns on when the Notecard is powered.
  • AEN - Auxiliary UART status. LED turns on when the AEN pin is pulled HIGH to enable the auxiliary UART on the Notecard.
  • RGB - AUX2 RGB LED. The data input for the WS2812 LED connects to AUX2 on the Notecard to allow for user-configured LED statuses. The data input also connects to F5 on the Function Board's MicroMod M.2 connector for users who prefer to manipulate the LED through a connected Processor.

The Notecard has two LEDs. The green LED reports modem activity and the red LED reports user activity.

Solder Jumpers

The Function Board has eight solder jumpers labeled: SHLD, VIO_LED, PWR_LED, AUX_EN_LED, RGB, ANT_PWR, WP, and MEAS

Highlighting solder jumpers

The table below outlines the jumpers labels, functions, default states and any notes regarding their behavior.

Jumper LabelDefault StateFunctionNotes
SHLDCLOSEDConnects USB-C Shield pin to Ground.Manipulate this jumper to adjust whether or not the USB-C cable shield pin connects to the PCB's ground plane.
VIO_LEDCLOSEDCompletes VIO status LED circuit.Open to disable the labeled LED.
PWR_LEDCLOSEDCompletes Notecard Power status LED circuit.
AUX_EN_LEDCLOSEDCompletes Auxiliary Enable status LED circuit.
RGBCLOSEDCompletes the RGB LED circuit.
ANT_PWROPENEnables power for external antenna.Close to enable power for using an active GNSS antenna.
WPOPENEEPROM write protection.Close to disable write protection for the EEPROM IC.
MEASCLOSEDMeasure Function Board current draw.Open the jumper and use a digital multimeter to measure the current draw of the Function Board. Note, opening this jumper interrupts the voltage input circuit.

MicroMod Pinout

As mentioned previously, we recommend using this Function Board with the latest versions of the MicroMod Single Main Board and Double Main Board as the revisions benefit this Function Board and the recommended STM32 Processor. Check out the MicroMod Main Board Hookup Guide v2 for details on all changes made to these Main Boards. The tables below outline the complete MicroMod Pinout and pins used by the Cellular Function Board:

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

Board Dimensions

This Function Board matches the standard Function Board footprint but as the Notecard module stacks on top of it, it's vertical profile is larger than most other Function Boards.

Board Dimensions

Hardware Assembly

If you're not familiar with assembling boards using the MicroMod connection system, head over to the MicroMod Main Board Hookup Guide for information on inserting and securing your MicroMod Processor and Function Boards to the Main Board:

MicroMod Main Board Hookup Guide

November 11, 2021

The MicroMod Main Board - Single and Double are specialized carrier boards that allow you to interface a Processor Board with a Function Board(s). The modular system allows you to add an additional feature(s) to a Processor Board with the help of a Function Board(s). In this tutorial, we will focus on the basic functionality of the Main Board - Single and Main Board - Double.

Notecard Assembly

This Function Board requires a bit more assembly than others as you'll need to attach the Notecard to your Function Board along with the antennas. The Notecard uses the same M.2 connector as the MicroMod ecosystem so just connect it as you would do with other MicroMod M.2 connections.

Antenna Connection

The antenna connections on the Notecard use u.Fl connectors. Depending on your antenna choice, you may need an adapter like this. For tips on how to properly use a u.Fl connector, this tutorial can help.

Completed Single Main Board assembly with antennas.

Completed Assembly

Our Arduino example for this Function Board demonstrates how to send environmental data from an Environmental Function Board mounted on the Double Main Board with the Cellular Function Board. The photo below shows a completed MicroMod assembly for that example:

Completed Double Main Board Assembly with Environmental Function Board and antennas.

Software Setup

Using the Cellular Function Board in the MicroMod ecosystem requires a few software setup steps before getting started.

Blues Wireless Software

Blues Wireless has several software support packages to help communicate between the Notecard and connected Processor and to communicate between the Notecard and the cloud.

Notehub

Blues Wireless' Notehub.io is a service that routes data from a Notecard to the cloud. Notehub works with a wide range of cloud options like AWS, Azure, Google Cloud. In addition, Notehub can route data to an IoT messaging platform like MQTT or a custom HTTP/HTTPS endpoint. Notehub requires an account tied to your Notecard so make sure to register if you do not have one already.

Notehub login page.

Once your account is created and verified, click the "Create Project" button in the top right of the page to start a new Project for your Notecard. This opens a pop-up on the page where you enter a Project Name, unique ID and select the billing account tied to the Project. By default, this selects the billing acount tied to your Notehub account but you can select other options in the drop-down menu. Once you have everything selected, select "Create Project".

Blues Wireless Documentation

This tutorial only does a cursory dive into using Notehub with the Function Board. For all the information you'll ever need for Notehub, Blues has written a host of tutorials covering the basics of Notehub as well as how to route data to a wide variety of platforms so be sure to check them out here:

Blues Note Arduino Library

The Blues Note Arduino Library allows users to communicate with a Notecard using the Arduino IDE over serial and I2C. To install the library using the Arduino Library Manager tool, navigate to the Tools menu and click "Manage Libraries" (you can also use the keyboard shortcut of Ctrl + Shift + I) and search for "note-arduino". Users who prefer to manually install the library can find it here on GitHub or you can click the button below to download a ZIP of the library:

Notecard CLI

Blues also offers two options for getting right to work with the Notecard with their in-browser terminal Notecard Playground(https://dev.blues.io/notecard-playground/) (Note: the in-browser terminal only runs on Chrome, Opera or Edge browsers). The CLI is also available as a traditional application for download here.

Using the CLI only requires a USB-C cable connecting the Cellular Function Board to your computer. The CLI should automatically detect the Notecard and appear as a selectable device in the drop-down menu in the CLI.

Environmental Function Board Libraries

The Arduino Example in the following section requires the SparkFun Arduino libraries for the SGP40, SHTC3 and STC3X sensors on the Environmental Function Board. Install them with the Arduino Library manager tool by opening it and searching "SparkFun SGP40", "SHTC3" and "STC3X". If you prefer to manually install them you can download them from their GitHub repositories (SGP40, SHTC3, STC3X) or click the buttons below to download a ZIP of the libraries:

Processor Arduino Board Definitions and Driver

Make sure you go through the Hookup Guide for your chosen Processor Board to install the latest Arduino board definitions and any necessary drivers:

MicroMod Artemis Processor Board Hookup Guide

October 21, 2020

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

MicroMod STM32 Processor Hookup Guide

May 13, 2021

Get started with the MicroMod Ecosystem and the STM32 Processor Board!
Heads up! While all MicroMod Processors work with this Function Board, only the STM32 Processor currently supports Outboard Device Firmware Updates from Notehub.

Pin Connection Table

The table below helps show which pins the Function Board connects to depending on the slot it is connected to on a Main Board (Note: The Single Main Board connection is Slot 0):

AUDIOUARTGPIO/BUSI2CSDIOSPI0Dedicated
Function Board
Pin Name
Main Board's
Processor Pin
Slot 0Slot 1
VCC-
3.3V-
GND-
PWR_ENSDIO_DATA2/PWR_EN0_ALTSDIO_DATA1/PWR_EN1_ALT
DFU_RSTRESET
DFU_BOOTBOOT
DFU_FC_TXRX1-DFU_TX-FC0-PLEX1RX1-DFU_TX-FC1-PLEX1
DFU_FC_RXTX1-DFU_RX-FC0-PLEX1TX1-DFU_RX-FC1-PLEX1
RXTX1-PROCESSOR-PLEX1TX2-PROCESSOR
TXRX1-PROCESSOR-PLEX1RX2-PROCESSOR
F3G0G5
F4G1G6
F5G2G7
1.Note: These UART connections connect to the multiplexer on the MicroMod Main Boards. The user should not need to interact with the multiplexer as all switching is handled by software but if you wish to learn more about the multiplexer's functionality, refer to the Hardware Overview section of the MicroMod Main Board Hookup Guide v2.

Arduino Example

In this section we'll use the MicroMod assembly built in the Hardware Assembly section to use the Notecard to send temperature, pressure, air quality and CO2 data recorded by the Environmental Function Board to notehub.io.

Arduino Code

The example configures the Notecard to receive data over I2C sent to the Processor from the Environmental Fucntion Board. The main loop retrieves data from all three sensors and every fifteen seconds creates a tells the Notecard send the data to notehub.io every fifteen seconds to be recorded as events in the Notehub Project created in the Software Setup section.

Copy the code below into a new sketch in Arduino. Select your board (the example assumes a MicroMod STM32 Processor Board is used) and port and click the Upload button:

language:c
/**
 * @file
 * @brief This example collects sensor data and posts it to NoteHub.
 * @copyright SPDX-License-Identifier: MIT
 * @author Alex Brudner, SparkFun Electronics
 * @date 2022-11-02
 * @note Based on Example01 from the MicroMod Environmental Function Board by 
 * Ho Yun "Bobby" Chan. This example code combines example codes from the 
 * SHTC3, STC31, and SGP40 libraries. Most of the steps to obtain the 
 * measurements are the same as the example code. Generic object names were 
 * renamed (e.g. mySensor => mySGP40 and mySTC3x).
 *
 *    Example 1: Basic Relative Humidity and Temperature Readings  w/ SHTC3
 *       Written by Owen Lyke
 *    Example 2: PHT (SHTC3) Compensated CO2 Readings w/ STC31
 *       Written by Paul Clark and based on earlier code by Nathan Seidle
 *    Example 1: Basic VOC Index w/ SGP40
 *       Written by Paul Clark
 *
 * Open a Serial Monitor at 115200 baud to view the readings too!
 *
 * Note: You may need to wait about ~5 minutes after starting up the code 
 * before VOC index
 * has any values.
 *
 * ========== HARDWARE CONNECTIONS ==========
 * MicroMod STM32 Processor Board => MicroMod Main Board => MicroMod 
 *  Environmental Function Board (with SHTC3, STC31, and SGP40)
 * MicroMod STM32 Processor Board => MicroMod Main Board => MicroMod 
 *  Function Board Blues Wireless Notecarrier
 *
 * Feel like supporting open source hardware?
 * Buy a board from SparkFun!
 *      MicroMod Function Board Blues Wireless Notecarrier  
 *        | https://www.sparkfun.com/products/20409
 *      MicroMod STM32 Processor                            
 *        | https://www.sparkfun.com/products/16401
 *      MicroMod Main Board - Double                        
 *        | https://www.sparkfun.com/products/18575
 *      MicroMod Environmental Function Board               
 *        | https://www.sparkfun.com/products/18632
 *
 * You can also get the sensors individually.
 *
 *      Qwiic SHTC3 | https://www.sparkfun.com/products/16467
 *      Qwiic STC31 | https://www.sparkfun.com/products/18385
 *      Qwiic SGP40 | https://www.sparkfun.com/products/17729
 */

/* Notecard Includes */
#include <Arduino.h>
#include <Wire.h>
#include <Notecard.h>

/* Sensor Includes */
#include <SparkFun_SHTC3.h>
#include <SparkFun_STC3x_Arduino_Library.h>
#include <SparkFun_SGP40_Arduino_Library.h>

#define PRODUCT_UID "com.your-company.your-name:your_product"

/* Instantiate Notecard class */
Notecard notecard;
int ncUpdateCtr = 0;

/* Instantiate sensor interface classes */
SHTC3 mySHTC3;
STC3x mySTC3x;
SGP40 mySGP40;

float rh = 0.0;           // Relative Humidity from the SHTC3
float temperature = 0.0;  // Temperature from the SHTC3
float co2 = 0.0;          // %CO2 from STC3
int32_t voc = 0;          // VOC index from SGP40

void setup() {
  /* Begin Serial communications */
  delay(2500);
  Serial.begin(115200);
  Serial.println(F("Begin - MicroMod Notecarrier Example 01: Sensor Data."));
  notecard.setDebugOutputStream(Serial);

  /* Begin I2C communications */
  Wire.begin();

  /* Initialize Notecard */
  notecard.begin();

  /* Configure Notecard */
  J *req = notecard.newRequest("hub.set");
  JAddStringToObject(req, "product", PRODUCT_UID);
  JAddStringToObject(req, "mode", "continuous");
  notecard.sendRequest(req);

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

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

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

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

  /**
   * Get an initial measurement so we can compensate for temperature and 
   * relative humidity using the readings from the SHTC3 
   */
  if (mySHTC3.update() != SHTC3_Status_Nominal) // Request a measurement
  {
    Serial.println(F("Could not read the RH and T from the SHTC3! \\
Freezing..."));
    while (1)
      ; // Do nothing more
  }

  /**
   * Configure STC31 temperature compensation based on previous measurement.
   * In case the ‘Set temperature command’ has been used prior to the above 
   * measurement command, this will set a new temperature compensation point.
   */
  temperature = mySHTC3.toDegC(); 
  Serial.print(F("Setting STC3x temperature to "));
  Serial.print(temperature, 2);
  Serial.print(F("C was "));
  if (!mySTC3x.setTemperature(temperature))
    Serial.print(F("not "));
  Serial.println(F("successful"));

  /**
   * Configure STC31 humidity compensation based on previous measurement.
   * In case the ‘Set humidity command’ has been used prior to the above 
   * measurement command, this will set a new humidity compensation point.
   */
  rh = mySHTC3.toPercent();
  Serial.print(F("Setting STC3x RH to "));
  Serial.print(rh, 2);
  Serial.print(F("% was "));
  if (!mySTC3x.setRelativeHumidity(rh))
    Serial.print(F("not "));
  Serial.println(F("successful"));

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

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

}

void loop() {

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

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

  rh = mySHTC3.toPercent();                                 // "toPercent" returns the percent humidity as a floating point number
  Serial.print(F("RelH: "));
  Serial.print(rh);
  Serial.println(F("%"));

  temperature = mySHTC3.toDegC();
  Serial.print(F("T: "));
  Serial.print(temperature);
  Serial.print(F(" deg C"));

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



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


  if (!mySTC3x.setRelativeHumidity(rh))
    Serial.print(F("Unable to set STC31 Relative Humidity with SHTC3."));

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


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

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



  //==============================
  //==========READ SGP40==========
  //==============================
  /* minimum update rate = 1Hz */
  Serial.print(F("VOC: "));
  voc = mySGP40.getVOCindex(rh, temperature);
  Serial.println(voc); 

  /* Update the notecard about every 15s.*/
  if(++ncUpdateCtr >= 14)
  {
    ncUpdateCtr = 0;
    //==============================
    //=========UPLOAD DATA==========
    //==============================
    J *req = notecard.newRequest("note.add");
    if (req != NULL) {
      JAddStringToObject(req, "file", "sensors.qo");
      JAddBoolToObject(req, "sync", true);

      J *body = JCreateObject();
      if (body != NULL) {
        JAddNumberToObject(body, "temperature", temperature);
        JAddNumberToObject(body, "humidity", rh);
        JAddNumberToObject(body, "CO2%", co2);
        JAddNumberToObject(body, "VOC", voc);
        JAddItemToObject(req, "body", body);
      }

      notecard.sendRequest(req);
    }    
  }

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

}

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

Notehub Project

First we'll return to the Notehub project created in the Software Setup section. If you haven't already, open notehub.io and open your Project. Your Notecard should appear in the devices listed.

Now open the Events tab and you should see a list of events printed out in the window assuming your Notes have synced.

This is just a basic example of transmitting data with the Notecard. From here you can route data to any of the supported cloud platforms. Head over to Blues Wireless' routing tutorials for detailed instructions on how to do that.

Outboard Device Firmware Update

Now that we're familiar with routing data through the Notecard to notehub.io, we'll demo one of the Notecard's most unique features; outboard device firmware updates (DFU). Outboard DFU's allow the Notecard to upload firmware to a connected Processor Board remotely from any location with a cellular signal. In this section we'll use notehub and Arduino to upload a new sketch to an STM32 Processor v20.

Reminder: Outboard Device Firmware Updates only work with the STM32 Processor v20 on either the SparkFun MicroMod Main Board - Single v21 or the SparkFun MicroMod Main Board - Double v22. Other Processors may be supported in the future but are beyond the scope of this tutorial. We will update this guide if and when other Processors work with this feature.

Generate the Firmware Binary

With Outboard DFU enabled, we need to generate and locate the binary file created by Arduino for the firmware to be uploaded to the STM32 Processor. Open the Arduino IDE and copy the code below into a blank sketch. Alternatively, you can find it in the examples folder of the Function Board's Hardware Github Repo.

language:c
/**
 * @file Example02_Outboard_DFU.ino
 * @brief This example performs an Outboard Device Firmware Update.
 * @copyright SPDX-License-Identifier: MIT
 * @author Alex Brudner, SparkFun Electronics
 * @date 2022-11-02
 * @note Based on the DFU example from Blues Wireless. See
 * https://github.com/blues/note-outboard-dfu
 * 
 * ========== HARDWARE CONNECTIONS ==========
 * MicroMod STM32 Processor Board => MicroMod Main Board => MicroMod 
 *  Function Board Blues Wireless Notecarrier
 *
 * Feel like supporting open source hardware?
 * Buy a board from SparkFun!
 *      MicroMod Function Board Blues Wireless Notecarrier  
 *        | https://www.sparkfun.com/products/20409
 *      MicroMod STM32 Processor                            
 *        | https://www.sparkfun.com/products/16401
 *      MicroMod Main Board - Double                        
 *        | https://www.sparkfun.com/products/18575
 */

#include <Arduino.h>
#include <Notecard.h>

#define PRODUCT_UID "com.your-company.your-name:your_product"

int ledPin = LED_BUILTIN;

Notecard notecard;

void setup()
{
    pinMode(ledPin, OUTPUT);

    /* Begin Serial communications */
    Serial.begin(115200);
    Serial.println(F("Begin - MicroMod Notecarrier Example 02: Outboard DFU"));
    notecard.setDebugOutputStream(Serial);

    /* Begin Serial communications */
    Wire.begin();
    notecard.begin();

    /* Configure Notecard */
    J *req = notecard.newRequest("hub.set");
    JAddStringToObject(req, "product", PRODUCT_UID);
    JAddStringToObject(req, "mode", "continuous");
    JAddStringToObject(req, "sn", "stm32-micromod-v20-SN0001");
    notecard.sendRequest(req);

    /* Configure DFU settings */
    req = notecard.newRequest("card.dfu");
    JAddStringToObject(req, "name", "stm32-bi"); /* bi == boot inversion */
    JAddBoolToObject(req, "on", true);
    notecard.sendRequest(req);
}

void loop()
{
    /* Fast Blink LED while waiting for DFU. */
    Serial.println("Hello, world!");
    digitalWrite(ledPin, HIGH);
    delay(100);
    digitalWrite(ledPin, LOW);
    delay(400);
}

During verification, Arduino creates a temporary folder with this binary file along with other necessary metadata. On Windows, this is commonly in a filepath similar to: Users/"Your Username"/AppData/Local/Temp. When you open the Temp folder, you may have several folders titled arduino_build_######. If you can't find it there or use another operating system, Arduino prints the file location in the output data during the compilation step with "Verbose Output" enabled.

Arduino firmware binary file location.

Open the folder containing the binary file, we'll need file location later. Alternatively, you can copy/paste it into a more easily accessible location.

Upload Binary to Notehub

Now we need to upload the binary file of the firmware to Notehub.io. Log in to your Notehub account if you have not already and navigate to the "Firmware" option below "Settings". Click the Firmware File field and navigate to the firmware binary location and click "Open". This page also includes the ability to add any notes regarding the firmware update as well as any metadata you wish to include with it. We'll skip both of those for now in this demo.

Uploading binary to Notehub.

With the firmware saved to Notehub, go back to the Devices page.

Update Device Firmware

Select your Notecard and select to the "Host Firmware" tab. Next, click the "Update" button on the far right of the screen and it should open a prompt asking you to confirm you want to update the firmware. Click "Proceed", select the firmware from the list (in our case it will only include the "Example02_Outboard_DFU" binary) and click "Apply".

Notehub apply firmware prompt.

Your Notecard should automatically start to try and update the new firmware. You can watch the status of the firmware update in the "Host Firmware" tab.

Now that you're familiar with how to perform Outboard DFU's, you can upload your own custom firmware to your Processor.

Troubleshooting

Notecard CLI Helpful Commands

The Notecard CLI has a lot of helpful commands for debugging and troubleshooting all sorts of issues with the Notecard. Below is a list of just a few commands we find particularly helpful as starting points for troubleshooting but for a complete list as well as tutorials on how to use them, head over to Blues Wireless' Developers Page.

Simply connect the Cellular Function Board - Blues Wireless Notecarrier to your computer via the USB-C connector on the Function Board and open the Notecard CLI either in a browser or on your computer to start troubleshooting your board directly:

  • '{"req": "card.version"}' - Request returns information on the Notecard version including the hardware version, device ID, name and firmware version.
  • '{"req": "card.wireless"}' - Returns cellular connection data such as RSRP/RSRQ, RSSI, modem and band type and much more. Very helpful for diagnosing cellular activity issues.
  • '{"req:""hub.sync"}' - Manually sync the Notecard with Notehub. Pair this with the following request to view the synchronization status of the Notecard with Notehub.
  • '{"req": "hub.sync.status"} - Returns helpful information about the status of communication between the Notecard and Notehub.

Notecard Firmware Version and Updating

If you run into any issues with features on notehub.io such as Outboard DFU the first thing we recommend checking is your Notecard firmware version. Verify the firmware version on the Notecard supports the features you are attempting to use and if needed, update the firmware on Notehub. You can find a step-by-step tutorial for updating Notecard firmware here.

Outboard DFU Hardware Limitations

As mentioned previously, Outboard DFU with the Cellular Function Board - Blues Wireless Notecarrier only works with specific MicroMod hardware:

This feature may work on other Processors in the future and we will update this guide when and if those Processors are added. Note, the previous versions of both MicroMod Main Boards do not support Outboard DFU with the Cellular Function Board - Blues Wireless Notecarrier.

General Troubleshooting

Resources and Going Further

That's all for this tutorial. For more information on the MicroMod Cellular Function Board - Blues Wirless Notecard, take a look at the resources below:

Cellular Function Board Resources:

Blues Wireless Resources:

MicroMod Resources:


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


Viewing all articles
Browse latest Browse all 1123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>