制造商零件编号 18573
MICROMOD LORA FUNCTION BOARD
SparkFun Electronics
License: See Original Project LoRa Wireless Arduino MicroMod
Courtesy of SparkFun
Guide by Nate, santaimpersonator
Introduction
Frequency Operation
This LoRa module can only be used in the 915MHz LoRaWAN frequency band (i.e., 902 to 928 MHz). It is not compatible with other frequency bands; double check the frequency band used in your region. Check out these resources from The Things Network for an unofficial summary of regional radio regulations and list of the regional frequency plans.
The 1W LoRa MicroMod Function Board adds LoRa capabilities to your MicroMod project. It is intended to be used in conjunction with a MicroMod processor board and a MicroMod main board, which provides the electrical interface between a processor board and the function board(s).
Match up the board's M.2 edge connector to the slot of the M.2 connector and secure the function board with the screws provided with the main board.
Utilizing the 915M30S LoRa module from EBYTE, which is a 1W (30dBm) transceiver based around the SX1276 from Semtech. There is a robust edge mount RP-SMA connector for large LoRa (915MHz) antennas; with modification, a U.FL connector is also available. We've successfully tested a 12 miles line-of-sight transmission with this module (user results may vary).
With the MicroMod standardization, users no longer need to cross-reference schematics with datasheets, while fumbling around with jumper wires. Simply, match up the function board's M.2 edge connector to the slot of the M.2 connector on the main board and secure the function board with screws. All connections are hardwired to compatible pins of the processor board and the pin connections are standardized for the processor boards.
Required Materials
To get started, users will need a few of the items listed below. (You may already have a some of these items; read through the guide and modify your cart accordingly.)
MicroMod Processor Board
A processor board is required for the MicroMod system to operate. Users can choose a processor board, based upon their needs, to attach to the MicroMod M.2 connector of the main board. Below, are few options:
MicroMod Main Board
A main board provides the electrical connections between the function and processor boards to operate. Users can choose a main board based upon their needs. Below, are few options:
Required Hardware
A Phillips screwdriver is necessary to attach the processor board and function board(s) to the main board. Additionally, a USB-C cable is needed to connect the main board to a computer. The LoRa function board also requires a LoRa antenna for the transceiver to operate.
Below, is a selection of our 915MHz frequency band RP-SMA antennas.
Pycom LoRa and Sigfox Antenna Kit - 915MHz
Optional Hardware
A LoRa gateway provides internet connection for LoRaWAN network. Below are a few options from our LoRa product category.
Nebra Indoor HNT Hotspot Miner (915MHz)
Nebra Outdoor HNT Hotspot Miner (915MHz)
Users can also use other LoRa boards for peer-to-peer communication. Below are a few options from our LoRa product category.
Interface Cable RP-SMA to U.FL - 100mm
To modify the jumpers, users will need soldering equipment and/or a knife.
Chip Quik No-Clean Flux Pen - 10mL
Weller WLC100 Soldering Station
Suggested Reading
The MicroMod ecosystem is a unique way to allow users to customize their project to their needs. Click on the banner below for more information.
For users who aren't familiar with the following concepts, we also recommend reading the following tutorials before continuing.
Serial Communication: Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!
Serial Peripheral Interface (SPI): SPI is commonly used to connect microcontrollers to peripherals such as sensors, shift registers, and SD cards.
Pulse Width Modulation: An introduction to the concept of Pulse Width Modulation.
Logic Levels: Learn the difference between 3.3V and 5V devices and logic levels.
I2C: An introduction to I2C, one of the main embedded communications protocols in use today.
Analog vs. Digital: This tutorial covers the concept of analog and digital signals, as they relate to electronics.
Processor Interrupts with Arduino: What is an interrupt? In a nutshell, there is a method by which a processor can execute its normal program while continuously monitoring for some kind of event, or interrupt. There are two types of interrupts: hardware and software interrupts. For the purposes of this tutorial, we will focus on hardware interrupts.
SparkFun expLoRaBLE Hookup Guide: Check out our latest LoRaWAN development board with Bluetooth capabilities! With this guide, we'll get you passing data to The Things Network in no time.
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 Main Board Hookup Guide: The MicroMod Main Board - Single and Double are specialized carrier boards that allow you to interface a Processor Board with a Function Board(s). The modular system allows you to add an additional feature(s) to a Processor Board with the help of a Function Board(s). In this tutorial, we will focus on the basic functionality of the Main Board - Single and Main Board - Double.
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
Board Dimensions
The overall board dimensions are roughly 65 x 35 mm with an approximate 6 mm protrusion of the RP-SMA antenna connector.
The dimensions for the LoRa MicroMod Function Board.
M.2 Edge Connector and Screw Slots
Like other function and processor boards, there is a polarized M.2 edge connector, which provides a standardized electrical connection. The attachment points for the screws prevent users from connecting a processor board into a function board slot and vice-versa.
The Micromod M.2 edge connector and screw slots on the LoRa Function Board.
Power
There is a power status LED to help make sure that your LoRa function board is getting (5V) power. Power is provided through the (MicroMod) M.2 edge connector. The LoRa module is meant to run on 5V with 3.3V logic levels. A jumper is available on the back of the board to remove power to the LED for low-power applications (see the Jumpers section below).
Power LED on the LoRa MicroMod Function Board.
E19-915M30S LoRa Module
Note: The range verification was performed in a clear and open area (direct line-of-sight) with a 5dBi antenna gain, height of 2.5m, and data rate 0.3 kbps. Users' results may vary.
The Chengdu Ebyte E19-915M30S RF transceiver module is a 1W 915MHz LoRa module, based on the SX1276 from Semtech. It is FCC, CE, and RoHS certified and has been tested up to a range of 10km by the manufacturer. Please refer to the datasheet for more details.
Global license free ISM 915MHz band
1W maximum transmission power
Software multi-level adjustable
256Byte FIFO data buffer
SX1276
The E19-915M30S transceiver is based on the SX1276 chip from Semtech. Please refer to the datasheet for more details.
The E19-915M30S RF transceiver module on the LoRa MicroMod Function Board.
Pin Connections
Below is a table of the pin connections available on the E19-915M30S RF transceiver module. However, not all the pins listed are utilized by the LoRa function board (see the Function Board Pinout Table section below).
MicroMod Edge Connector
The MicroMod M.2 edge connector provides a standardized interface for the pin connection of a function board.
The Micromod M.2 edge connector on the LoRa Function Board.
Function Board Pinout Table
The tables below outline the pin on the M2. edge connector and their functions.
MicroMod Function Board Pinout Table
MicroMod General Pinout Table
MicroMod General Pin Descriptions
EEPROM
There is an I2C serial EEPROM on the LoRa function board. It has been reserved for future use, but users have access to it. A jumper is available on the back of the board to write protect the EEPROM (see the Jumpers section below).
EEPROM on the LoRa MicroMod Function Board.
RP-SMA Antenna Connector
Warning: Users should attach the antenna before powering their LoRa function board. Transmitting without an antenna connected may potentially damage the transceiver module.
The LoRa function board features a sturdy RP-SMA antenna connector for users to attach an antenna of their choice. While this antenna connector is fairly robust, users should not expect to leverage a lot of weight off of it.
The edge-type antenna connector allows for the threads to protrude just beyond the edge of the board. Along with the dimensions of the LoRa function board, this feature is designed so that the connection also extends past the edge of the main board that the function board interfaces with; and is therefore, well suited to be used with an enclosure.
RP-SMA antenna connector on the LoRa MicroMod Function Board.
Note: Users who wish to use the u.FL connector can modify the position of this 0Ω resistor. Due to the size and position of the resistor, we only recommended for highly experience soldering experts attempt this modification. More novice users could potentially damage their LoRa function board if they attempt this modification.
Antenna select jumper on the E19-915M30S RF transceiver module.
Jumpers
There are three jumpers available on the LoRa function board.
LED Power
For more low power projects, the PWR jumper can be cut to remove power from the red power LED.
LED power jumper on the LoRa MicroMod Function Board.
Current Measurement
For users who would like to measure the current going to LoRa function board, the MEAS jumper can be cut and used for measurements. This jumper is only connected to the 5V power, which is used by only the E19-915M30S RF transceiver module and power LED.
Current measurement jumper on the LoRa MicroMod Function Board.
EEPROM Write Protection
To permanently write protect the EEPROM on the LoRa function board, users can bridge the WP jumper.
EEPROM WP jumper on the LoRa MicroMod Function Board.
Software Overview
Getting Started with MicroMod
For those unfamiliar with the MicroMod ecosystem, be sure to review the Getting Started with MicroMod guide. Also, make sure that the correct board definitions are installed in the Arduino IDE, for the associated processor board.
Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
Programming
Note: Make sure that the correct board definitions are installed in the Arduino IDE, for the connected processor board. Depending on the processor board, users may need to install drivers (if they have not done so already). For help installing board definitions, use the MicroMod processor boards landing page and review the associated hookup guide for that hardware.
Installing Board Definitions in the Arduino IDE
How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.
Arduino Library
Note: The example for this tutorial assumes users have the latest version of the Arduino IDE installed. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide:
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.
SparkFun External EEPROM Arduino Library
We've written a library to easily get setup and read/write data on the EEPROM. You can install this library through the Arduino Library Manager. Search for SparkFun External EEPROM Arduino Library and you should be able to install the latest version. If you prefer manually downloading the libraries from the GitHub repository, you can grab them here:
Download the SparkFun External EEPROM Arduino Library
For more details on this Arduino library and its use, please refer to the Serial EEPROM hookup guide:
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!
RadioLib Arduino Library
The RadioLib library provides support for peer-to-peer RF communication with the 1W LoRa MicroMod Function Board. Users can install this library through the Arduino Library Manager. Search for RadioLib and you should be able to install the latest version. If you prefer manually downloading the libraries from the GitHub repository, you can grab them here:
Download the RadioLib Arduino Library
Note: Peer-to-peer refers to direct RF communication using a specific modulation protocol (similar to a 2-way walkie talkie); and is not to be confused with a mesh network or LoRaWAN network integration.
For more details on this Arduino library, check out the Arduino reference page, the API reference page, and GitHub repository. Additional specifics of the library that users may be interested in can be found in the links below:
LoRaWAN Library
The MCCI LoRaWAN LMIC Library library provides support for an end node/device (i.e., 1W LoRa MicroMod Function Board) integration into a LoRaWAN network and communication with a LoRaWAN server. Users can install this library through the Arduino Library Manager. Search for MCCI LoRaWAN LMIC and you should be able to install the latest version. If you prefer manually downloading the libraries from the GitHub repository, you can grab them here:
Download the MCCI LoRaWAN LMIC Arduino Library
Notes:
Initially we were inclined to utilize the Arduino-LMIC library. However, we followed the repository's recommendation and chose to utilize the MCCI LoRaWAN LMIC Library instead.
Support for this library has only been confirmed with The Things Stack - Community Edition's (i.e., V3 or previously TTN) and Helium's servers.
To utilize this library, users are expected to be able to modify various files for regional configuration and compatibility with specific processor boards.
We assume that users are familiar with the device registration process for each LoRaWAN server. For more information, please refer to the LoRaWAN server's documentation:
Usage Cost: 1 Data Credit (1 DC = 0.001¢ in USD) per packet (up to 24 bytes)
After a device is first added/registered to an account, it takes approx. 20 min for it to get added to the blockchain. Until then, hotspots will not recognize the device and relay its data packets.
The Things Stack Device Registration:
The information below also assumes that users have migrated to and are currently using The Things Stack Community Edition (or V3).
When manually registering a device on The Things Stack, users will need to set the LoRaWAN version to MAC V1.0.3 (per the library specifications).
Devices registered with the V3 console will only work with gateways on the V3 console. (i.e., Data transmissions from a device registered on the V3 console will not be passed to the server, if its transmissions are only received by a gateway on registered to the V2 console.)
Warning: The Helium network is a pay-to-use 3rd party service, which does involve the use of cryptocurrency. Please, use at your own discretion.
We have no control over its service.
We are not liable for any customer's choice to utilize the network.
The cryptocurrency market valuation can be volitile.
There may be legal and financial implications for digital wallets.
etc.
To be able to utilize this library with the 1W LoRa function board and various MicroMod processor boards, users will need to make the following modifications to the library's files:
Regional Configuration
In the lmic_project_config.h file make sure that #define CFG_us915 1 and #define CFG_sx1276_radio 1 are uncommented.
// project-specific definitions
//#define CFG_eu868 1
#define CFG_us915 1
//#define CFG_au915 1
//#define CFG_as923 1
// #define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP /* for as923-JP; also define CFG_as923 */
//#define CFG_kr920 1
//#define CFG_in866 1
#define CFG_sx1276_radio 1
//#define LMIC_USE_INTERRUPTS
Processor Board Compatibility
nRF52840 Processor Board
In the hal.cpp file, users will need to modify lines 368-370 (based on the default code) to provide compatibility with the nRF52840 processor board to the library:
#if !defined(ARDUINO_ARDUINO_NANO33BLE)
void hal_sleep () {
// Not implemented
}
#endif // !defined(ARDUINO_ARDUINO_NANO33BLE)
Artemis Processor Board
Note: Currently, the Apollo3 Arduino core does not support the use of the noInterrupts() and Interrupts() functions. There is already an issue filed with the GitHub repository. Once this issue has been resolved, the modifications below will no longer be necessary.
In the hal.cpp file, users will need to modify lines 339-347 (based on the default code) to provide compatibility with the Artemis processor board to the library:
void hal_disableIRQs () {
#if !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
noInterrupts();
#endif // !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
irqlevel++;
}
void hal_enableIRQs () {
if(--irqlevel == 0) {
#if !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
interrupts();
#endif // !defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB)
ES32 Processor Board
In reference to issue #714 for the library, users will need to add the following lines to the end of lmic_project_config.h file, which is the same file used for the regional configuration.
#if defined(ARDUINO_ESP32_MICROMOD)
#define hal_init LMICHAL_init // ESP32: https://github.com/mcci-catena/arduino-lmic/issues/714
#endif // defined(ARDUINO_ESP32_MICROMOD)
Hardware Assembly
For those unfamiliar with the MicroMod ecosystem, be sure to review the Getting Started with MicroMod guide.
Dive into the world of MicroMod - a compact interface to connect a microcontroller to various peripherals via the M.2 Connector!
Processor Board and Main Board
To get started users will need a compatible processor and main board. Insert the MicroMod processor board into the M.2 socket for the processor board at an angle, with its edge connector aligned to the matching slots.
Note: The dimensions of the processor board's edge connector prevent 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:
Inserting a processor board into the M.2 socket.
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) screwdriver. Below, is an example of an assembled MicroMod system:
A processor board attached to the MicroMod Qwiic Carrier Board.
Function Board and Main Board
Warning: The LoRa module is susceptible to electrostatic discharge. Therefore, it is recommended that users a static discharge strap, like the one included in the iFixit Pro Tech Toolkit.
Static discharge strap in the upper righthand corner.
Users should also address any humidity and temperature concerns, when utilizing the LoRa function board.
Note: The dimensions of the function board's edge connector prevent it from mating with the slots of the M.2 socket in reverse. As an extra safeguard, the screw inserts are spaced to only match the screw key of MicroMod function board.
Similarly to the processor board, insert the MicroMod function board into the M.2 socket for the function board at an angle, with its edge connector aligned to the matching slots.
When inserted properly, the function board will rest at an angle:
Inserting a function board into the M.2 socket.
To secure the function board, gently hold down on the board and attach the M.2 screw with a Phillip's head (PH0 or PH1) screwdriver. Below, is an example of an assembled MicroMod system:
A function board attached to the MicroMod Main Board.
Don't forget to attach the antenna for the LoRa function board. Transmitting or powering the LoRa module without an attached antenna has the potential to permanently damage the transceiver.
Fully assembled main board with processor board and function board.
Main Board Example - Pin Connection Table
This table summarizes the pins utilized on the LoRa function board's MicroMod edge connector and their connections to the main board's processor pins; based on the slot that the LoRa function board is inserted to.
Programming
To program the processor board utilized on the Main Board; connect the board to a computer with a USB-C cable. Depending on the processor board, users may need to install drivers (if they have not done so already).
Note: Make sure that the correct board definitions are installed in the Arduino IDE, for the selected processor board. For help installing board definitions, use the MicroMod processor boards landing page and review the associated hookup guide for that hardware.
Installing Board Definitions in the Arduino IDE
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.
Peer-to-Peer Example
Note: The example codes assume that the LoRa function board is inserted into the 0 function board slot of the main board.
The example codes below, allow users to communicate between two LoRa function boards. Simply download, extract the files, and upload the code the main board with associated processor and function boards.
Download the LoRa Function Board Example Codes
Additional examples have also been provided for users who would like to use their expLoRable (LoRa Thing Plus) board to communicate with a LoRa function board.
Download the ExpLoRable Example Codes
The example codes were tested under the following parameters:
Arduino IDE version: 1.8.16
If not using the Teensy - Windows App Store version 1.8.51.0
RadioLib Library version: 4.6.0
MicroMod Processor Boards and Arduino Cores:
Once uploaded, users can open the serial monitor to view the progress of the data transmission or reception. When using the RP2040 processor board, the example code will wait until the Serial Monitor is opened to execute the code and transmit/receive data.
An example of the data transmission between an expLoRaBLE board and the LoRa MicroMod Function Board in the Serial Monitor.
Code Breakdown
In order to get the built-in example for the RadioLib library working, a few changes needed to be made. Below, is a short explanation of the modifications made to the example code that we provide (see above), to include compatibility with all the available processor boards.
CS Pin Definition
The SPI library for the Arduino IDE, by default expects the chip select pin to be defined as PIN_SPI_SS. However, this pin definition is different for the ESP32 and Artemis (Apollo3) Arduino cores. Therefore, the code below was inserted to allow the code to compile for all the various processor boards.
// Redefine CS Pin Name
// SPI_CS0: ESP32
// SS: ESP32, nRF, RP2040
// SPI_CS: Artemis
// PIN_SPI_SS: STM32, SAMD51, nRF, RP2040
#ifndef PIN_SPI_SS
// For Artemis
#ifdef SS
#define PIN_SPI_SS SPI_CS
#endif
// For ESP32
#ifdef SPI_CS0
#define PIN_SPI_SS SS
#endif
#endif
MicroMod Pin Names
Unfortunately, for the RP2040 MicroMod processor board hasn't been included in the MbedOS Arduino core; current progress is on hold (please refer to this issue in the GitHub repository). However, with the modifications below, the RP2040 Pico board definition can be used.
By using the RP2040 Pico board definition, the generic MicroMod processor board's pin names obviously can't be used. Therefore, all the pins must be declared by their GPIO pin numbers. In addition, the default pin connections for the SPI bus on the RP2040 MicroMod processor board differs from the RP2040 Pico. To accommodate for the different pin connections, a custom SPI object was created and passed into the library.
// SX1276 pin connections:
// | SLOT 0 | SLOT 1 |
//==========================
// cs | CS0 | CS1 |
// dio0 | D0 | D1 |
// dio1 | G2 | G7 |
// dio2 | G3 | G8 |
// rst | G1 | G6 |
// tx_en | PWM0 | PWM1 |
// rx_en | G0 | G5 |
#if defined(ARDUINO_RASPBERRY_PI_PICO)
// MM RP2040 Processor Board (Using RP2040 Pico board definition)
int pin_cs = 21;
int pin_dio0 = 6;
int pin_tx_enable = 13;
int pin_rx_enable = 16;
int pin_nrst = 17;
int pin_dio1 = 18;
// Redefine SPI pins
int miso = 20;
int mosi = 23;
int sck = 22;
// Custom SPI object
MbedSPI SPI_mm(miso, mosi, sck);
SX1276 radio = new Module(pin_cs, pin_dio0, pin_nrst, pin_dio1, SPI_mm);
#else
Similarly to the RP2040, the Teensy MicroMod processor board definition doesn't include the generic MicroMod processor board pin names yet (we are currently working on this update). Therefore, all the pins must be declared by their pin numbers.
#if defined(ARDUINO_TEENSY_MICROMOD)
// MM Teensy Processor Board
int pin_cs = 10;
int pin_dio0 = 4;
int pin_tx_enable = 3;
int pin_rx_enable = 40;
int pin_nrst = 41;
int pin_dio1 = 42;
#else
RP2040 Special Consideration
As mentioned above, a custom SPI object was created and passed into the library for the RP2040 MicroMod processor board. However, the library doesn't initialize the SPI bus when it is passed in. Therefore, the setup() loop includes a modification to start the SPI bus operation.
In our testing, the RP2040 MicroMod processor board had issues with the printouts on the serial port. Adding a while() statement to wait for the serial port to be accessed by the Serial Monitor, resolved the issue.
#if defined(ARDUINO_RASPBERRY_PI_PICO)
// Wait for serial monitor/port to open
while (!Serial){
; // wait for serial port
}
// Start SPI bus
SPI_mm.begin();
#endif
Enabling the STM32 Serial Port
When uploading to the provided example code (see above) to the STM32 MicroMod processor board, users will need to enable the serial port on the processor board. Otherwise, when the Serial Monitor is opened, nothing will appear. The following settings must be used in the in the Tools drop down menu:
The STM32 MicroMod processor board settings in the Tools drop-down menu to enable the microcontroller's serial port.
LoRaWAN Examples
Important Notes:
The example below assumes that the LoRa function board is inserted into the 0 function board slot of the main board.
While there are sketch examples built into the MCCI LoRaWAN LMIC Arduino library for both the Helium and The Things Network (TTN) servers, users should use the example code that we provide below (click the Download buttons). Otherwise, users will run into various issues.
The examples below, require a user account and device registration on whichever server you decide to utilize.
Click here to setup an account on Helium
Usage Cost: 1 Data Credit (1 DC = 0.001¢ in USD) per packet (up to 24 bytes)
After a device is first added/registered to an account, it takes approx. 20 min for it to get added to the blockchain. Until then, hotspots will not recognize the device and relay its data packets.
Click here to setup an account on The Things Stack
The information below also assumes that users have migrated to and are currently using The Things Stack Community Edition (or V3).
Devices registered with the V3 console will only work with gateways on the V3 console. (i.e., Data transmissions from a device registered on the V3 console will not be passed to the server, if its transmissions are only received by a gateway on registered to the V2 console.)
When manually registering a device on The Things Stack, users will need to set the LoRaWAN version to MAC V1.0.3 (per the library specifications).
Warning: The Helium network is a pay-to-use 3rd party service, which does involve the use of cryptocurrency. Please, use at your own discretion.
We have no control over its service.
We are not liable for any customer's choice to utilize the network.
The cryptocurrency market valuation can be volitile.
There may be legal and financial implications for digital wallets.
etc.
Our example codes below, allow users to communicate with a LoRaWAN server (through a connected gateway) with the LoRa function board. Simply download, extract the file, modify the sketch to include a registered device's EUIs and application key, and then upload the code the main board with associated processor and function board.
The example codes were tested under the following parameters:
Arduino IDE version: 1.8.16
If not using the Teensy - Windows App Store version 1.8.51.0
MCCI LoRaWAN LMIC Library version: 4.1.0
MicroMod Processor Boards and Arduino Cores:
Configuring the End Device Information
Once users have registered/added an end (i.e., node) device to their user account, they will need to modify the example sketch to include their device's application EUI (APPEUI), device EUI (DEVEUI), and application key (APPKEY) (provided by the server at the end of the device registration process). Simply, replace the FILLMEIN value in { FILLMEIN }, inside of the sketch at these locations:
static const u1_t PROGMEM APPEUI[8]={ FILLMEIN };
static const u1_t PROGMEM DEVEUI[8]={ FILLMEIN };
static const u1_t PROGMEM APPKEY[16] = { FILLMEIN };
in this section of the sketch:
// For normal use, we require that you edit the sketch to replace FILLMEIN
// with values assigned by the TTN console.
//# warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!"
// This EUI must be in little-endian format, so least-significant-byte
// first. When copying an EUI from ttnctl output, this means to reverse
// the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
// 0x70. For Helium issued EUIs the last bytes should be 0xF9, 0x81, 0x60.
static const u1_t PROGMEM APPEUI[8]={ FILLMEIN };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}
// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8]={ FILLMEIN };
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}
// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
static const u1_t PROGMEM APPKEY[16] = { FILLMEIN };
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}
The format of the values should be in a hex format, as shown in the example code below. Users should doublecheck they haven't mixed up their APPEUI and DEVEUI values and that they have entered those values with the least significant byte (lsb) first. These are the most likely culprits, if users aren't seeing a join/accept response or data transmissions in the LoRaWAN server's console or the serial terminal.
// This EUI must be in little-endian format, so least-significant-byte
// first. When copying an EUI from ttnctl output, this means to reverse
// the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
// 0x70. For Helium issued EUIs the last bytes should be 0xF9, 0x81, 0x60.
static const u1_t PROGMEM APPEUI[8]={ 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x## };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}
// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8]={ 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x## };
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}
// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
static const u1_t PROGMEM APPKEY[16] = { 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x##, 0x## };
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}
Once uploaded, users can open the serial monitor to view the progress of the device joining their chosen server's network and data transmissions. When using the RP2040 processor board, the example code will wait until the Serial Monitor is opened to execute the code. Users can also view the same information in the server's console, device information page.
Code Breakdown
In order to get the built-in example for the MCCI LoRaWAN LMIC library working, a few changes needed to be made. Below, is a short explanation of the modifications made to the example code that we provide (see above), to include compatibility with all the available processor boards and improve the code performance.
CS Pin Definition
The SPI library for the Arduino IDE, by default expects the chip select pin to be defined as PIN_SPI_SS. However, this pin definition is different for the ESP32 and Artemis (Apollo3) Arduino cores. Therefore, the code below was inserted to allow the code to compile for all the various processor boards.
// Redefine CS Pin Name
// SPI_CS0: ESP32
// SS: ESP32, nRF, RP2040
// SPI_CS: Artemis
// PIN_SPI_SS: STM32, SAMD51, nRF, RP2040
#ifndef PIN_SPI_SS
// For Artemis
#ifdef SS
#define PIN_SPI_SS SPI_CS
#endif // SS
// For ESP32
#ifdef SPI_CS0
#define PIN_SPI_SS SS
#endif // SPI_CS0
#endif // PIN_SPI_SS
MicroMod Pin Names
Unfortunately, for the RP2040 MicroMod processor board hasn't been included in the MbedOS Arduino core; current progress is on hold (please refer to this issue in the GitHub repository). However, with the modifications below, the RP2040 Pico board definition can be used.
By using the RP2040 Pico board definition, the generic MicroMod processor board's pin names obviously can't be used. Therefore, all the pins must be declared by their GPIO pin numbers. In addition, the default pin connections for the SPI bus on the RP2040 MicroMod processor board differs from the RP2040 Pico. To accommodate for the different pin connections, a custom SPI object was created.
// SX1276 pin connections:
// | SLOT 0 | SLOT 1 |
//==========================
// cs | CS0 | CS1 |
// dio0 | D0 | D1 |
// dio1 | G2 | G7 |
// dio2 | G3 | G8 |
// rst | G1 | G6 |
// tx_en | PWM0 | PWM1 |
// rx_en | G0 | G5 |
#if !defined(USE_STANDARD_PINMAP)
// All pin assignments use Arduino pin numbers (e.g. what you would pass
// to digitalWrite), or LMIC_UNUSED_PIN when a pin is not connected.
const lmic_pinmap lmic_pins = {
#if defined(ARDUINO_RASPBERRY_PI_PICO)
// MM RP2040 Processor Board (Using RP2040 Pico board definition)
.nss = 21, //Chip Select
.rxtx = LMIC_UNUSED_PIN,
.rst = 17,
.dio = {6, 18, LMIC_UNUSED_PIN},
Similarly to the RP2040, the Teensy MicroMod processor board definition doesn't include the generic MicroMod processor board pin names yet (we are currently working on this update). Therefore, all the pins must be declared by their pin numbers.
#elif defined(ARDUINO_TEENSY_MICROMOD)
// MM Teensy Processor Board
.nss = 10, //Chip Select
.rxtx = LMIC_UNUSED_PIN,
.rst = 41,
.dio = {4, 42, LMIC_UNUSED_PIN},
RP2040 Special Consideration
As mentioned above, a custom SPI object was created. However, the custom SPI object must be passed into code execution for the RP2040 MicroMod processor board. Therefore, the setup() loop includes a modification to do this. Additionally, during our testing, the RP2040 MicroMod processor board had issues with the printouts on the serial port. Including a while() statement to wait for the serial port to be accessed by the Serial Monitor, resolved the issue.
#if defined(ARDUINO_RASPBERRY_PI_PICO)
// Wait for serial monitor/port to open
while (!Serial)
; // wait for serial port
// Pass object back into SPI
SPI = SPI_mm;
#endif // defined(ARDUINO_RASPBERRY_PI_PICO)
Helium Network Configuration
In order to improve the performance of the example code, the modifications below were made to address a clock timing issue and limit the transmission band.
// allow much more clock error than the X/1000 default. See:
// https://github.com/mcci-catena/arduino-lorawan/issues/74#issuecomment-462171974
// https://github.com/mcci-catena/arduino-lmic/commit/42da75b56#diff-16d75524a9920f5d043fe731a27cf85aL633
// the X/1000 means an error rate of 0.1%; the above issue discusses using values up to 10%.
// so, values from 10 (10% error, the most lax) to 1000 (0.1% error, the most strict) can be used.
LMIC_setClockError(1 * MAX_CLOCK_ERROR / 40);
LMIC_setLinkCheckMode(0);
LMIC_setDrTxpow(DR_SF7,14);
#if CFG_LMIC_US_like
// This makes joins faster in the US because we don't wander all over the
// spectrum.
LMIC_selectSubBand(1);
#endif
Enabling the STM32 Serial Port
When uploading to the provided example code (see above) to the STM32 MicroMod processor board, users will need to enable the serial port on the processor board. Otherwise, when the Serial Monitor is opened, nothing will appear. The following settings must be used in the in the Tools drop down menu:
The STM32 MicroMod processor board settings in the Tools drop-down menu to enable the microcontroller's serial port.
Resources and Going Further
For more information on the SparkFun 1W LoRa Function Board, check out the links below:
Hardware Documentation:
MicroMod Documentation: