LoRaSerial Hookup Guide a learn.sparkfun.com tutorial

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

Contents

Introduction

The LoRaSerial radios are simply to use radio modems that transmit over long distances (LoRa is a commonly used portmanteau of Long and Range). LoRaSerial is unique in that it makes LoRa and all the finicky radio configuration bits transparent to the user. Pull the radios out of the box, power them up, and you’ll be transmitting serial back and forth effortlessly.

SparkFun LoRaSerial Kit - 915MHz

WRL-19311
Retired

We have successfully received data over 9.2 miles or 15 km line-of-sight. Your mileage will vary depending on the amount of metal, concrete, and other materials you are trying to transmit through. In general, the larger the antenna the better the range. We include ½ wave dipole antennas that have demonstrated impressive range but may be too large for your application. Any 915MHz antenna with RP-SMA termination will work.

LoRaSerial supports both Point-to-Point as well as Broadcast configurations. P2P is common and uses a transmit then wait-for-acknowledgment packet delivery system. Whereas Broadcast simply broadcasts packets without waiting for or expecting an acknowledgement. A Broadcast setup is very useful in systems where you have one ‘base’ transmitting information to multiple receivers or ‘rovers’ (common with GNSS RTK deployments).

LoRaSerial uses Frequency Hopping Spread Spectrum technology or FHSS for short. This allows any given transmission to be split up between frequencies. As you feed new serial data to the radio both transmitter and receiver will start to hop from one frequency to the next. This prevents transmissions from sitting on one frequency for too long (something called dwell time) and allows these radios to operate legally within the 915/868/433MHz* ISM band.

In the United States 433MHz operation requires a HAM radio license. 433MHz is an open band in most other countries.

LoRaSerial supports AES encryption by default as well as unique network IDs. This means that two radios will share a key and transmit any information using 128-bit AES GCM encryption. This is very strong encryption. Further, each radio is ‘paired’ (when in Point-to-Point mode) with another radio. Any packets received with the incorrect ID are ignored. This feature combined with FHSS

LoRa Serial uses a unique and very easy to use train feature. Each radio has a default Network ID and AES key programmed into it. Changing these keys is as easy as pressing a button! If the train button is pressed for more than 2 seconds the RSSI LEDs will begin to blink. Releasing the train button will put the unit into a ‘cylon’ mode. This indicates that the radio has chosen a new ‘random’ Network ID and AES key, as well as turned its radio down to the lowest power. Next, press and hold the train key on the second radio. Once the RSSI LEDs begin to blink, release the button. The second radio will ping the first radio. The units will then exchange new IDs and keys and immediately hop to the next frequency in the table.

Note that training uses the ‘lowest power’ radio setting. We turn the radios down to prevent any eavesdropper from obtaining the new AES keys. While these ‘new’ keys are themselves encrypted, they are encrypted using the default AES key so one could theoretically back out the new AES keys if they are within ~30ft of the devices when they are being trained. If you’re paranoid, train them with the antennas off inside a Faraday cage.

If two radios need to be paired but cannot be proximally near one another there are AT commands to support the changing of the Network ID and the AES key. If a radio is physically unreachable, a radio can be configured and even trained remotely.

The 915MHz band is used in many countries. By default, the radios will use 902 to 928MHz as allowed per the FCC in the USA. Understanding that some countries (looking at you Australia) have a narrower ISM band, the upper and lower frequencies used by the radio can be modified via AT command. Additionally, we plan to offer 868MHz (Europe) and 433MHz (longer range) based radios shortly.

Note: LoRaSerial radios currently use half-duplex serial. This means only one radio can transmit at a time. LoRaSerial was designed for applications that are predominantly one sided, meaning the base station or the remote device periodically transmits some data, and the base station receives it. This configuration is perfect for a remote weather station to transmit data or a chicken coop that needs to receive periodic commands from the house.

Hardware Overview

The LoRaSerial is a SAMD21 based assembly with a SX1276 LoRa radio with innovative firmware to make things as simple as possible.

SAMD21 based serial radio

SAMD21 based serial radio

LoRa module

1 watt module containing the SX1276 and a power amplifier

The LoRaSerial uses a 1W LoRa radio based on the SX1276 radio along with a SAMD21 utilizing the UF2 bootloader. Any serial received by the radio will be queued up, encrypted, and sent out. Any received packets are checked for CRC, Network ID, decrypted, then printed.

Note: By default there is a 50ms timeout in which the radio will wait for additional characters to be received until a partial frame is sent.

USB C

USB C connector for power and serial

USB C connector for power and serial

The USB C connector provides power and serial communication to the unit. LoRaSerial will automatically show up on a computer or SBC (single board computer) as a serial COM port at a default of 57600bps. Currently only 8-N-1 serial communication is supported but we are open to additional features as user’s needs arise.

6-Pin JST

6-pin locking JST connector for power and  serial

6-pin locking JST connector for power and serial

LoRaSerial features a ‘locking’ type 6-pin JST connector. The connector on LoRaSerial is X and mates with a connector JST-GHR-06V. Each LoRaSerial radio comes with a JST to breadboard friendly pins. If you need additional cables they are available here (Note: the wire color may be different between cables).

The pinout is as follows:

PWR (3.3-5V) - LoRaSerial requires 3.3 to 5V to operate. We recommend 5V for maximum transmission range but we’ve found operating off of a LiPo at 3.7 to 4.2V works great.

RX (Receive) - Connect this pin to the TX pin of your system. This pin is 3.3-5V tolerant and has an internal pull-up.

TX (Transmit - Connect this pin to the RX pin of your system. This pin uses 3.3V logic.

CTS (Clear To Send - (Optional) Connect this pin to a GPIO of your system. This pin is 3.3-5V tolerant and has an internal pull-up. When this pin is high the radio will continue to send data. If the host system pulls this pin low, the radio will stop sending data.

RTS (Ready To Send) - (Optional) Connect this pin to a GPIO of your system. This pin uses 3.3V logic. If the radio’s buffer (size currently is 4096 bytes) becomes full the system will drive RTS low indicating that it should not be passed more data. If more serial data is received, the buffer will be overwritten, oldest data first.

GND (Ground) - Connect this pin to the ground of your system.

RSSI LEDs

4 LEDs indicating signal strength

4 LEDs indicating signal strength

There are four LEDs indicating in real-time the received signal strength or RSSI. These LEDs are meant to indicate a qualitative level of receive strength. Don’t worry if you’ve got three LEDs rather than four. LoRa technology is capable of transmitting a long range in harsh RF conditions. As long as you’ve got one LED, you will be able to send and receive data.

RPSMA Connector

Reverse polarized SMA antenna connector

Reverse polarized SMA antenna connector

Attach a 915MHz RPSMA antenna to this port. Not sure which is SMA and which is RPSMA? Checkout this RF Connector Guide. The LoRaSerial is also compatible with large, LoRa type antennas. We recommend a good thick RG58 RPSMA extension from the radio to your antenna to minimize loss. Remember, we are transmitting at 1W so keep your cables and connectors to a minimum.

Qwiic Connector

Qwiic connector for I2C communication

Qwiic connector for I2C communication

The Qwiic connector and I2C accessibility is not yet implemented.

Train Button

Button to enter train mode

Button to enter train mode

LoRa Serial uses a unique and very easy to use train feature. Each radio has a default Network ID and AES key programmed into it. Changing these keys is as easy as pressing a button!

Using a ball point pen or other small pointed device, press and hold the Train button for 2 seconds, until you see the RSSI LEDs begin to blink. You can release the button. If the LEDs begin to cylon (bounce back and forth) the device has entered training ‘wait’ mode where it waits for another device to ping it.

On the second radio, press and hold the Train button for 2 seconds, until you see the RSSI LEDs begin to blink. Release the button. The RSSI LEDs on both units will blink in unison indicating that the units are now trained to each other.

For security reasons the radios are both set to the lowest transmission power to minimize any eavesdropper from monitoring the transaction. While the ‘new’ keys are themselves encrypted, they are encrypted using the default AES key so one could theoretically back out the new AES keys if they are within ~30ft of the devices when the radios are being trained. If you’re paranoid, train the radios with the antennas off, within a few inches of each other. If total security is a concern, or if the radios cannot be physically brought near one another, the AES keys and/or the network IDs can be set via software commands.

Internal Reset Button

SAMD21 reset button

SAMD21 reset button

The firmware on the LoRaSerial can be upgraded from a computer without ever having to open the unit. In the rare case that the SAMD21 needs to be forced into bootloader mode the reset button should be quickly double tapped. The unit will then enter bootloader mode and wait for new firmware or for a reset event (button is pressed or power is cycled).

GPIO

GPIOs on SAMD21

GPIOs on SAMD21

Two GPIOs capable of ADC are broken out for potential future use.

UFL Connector

Zero ohm jumper resistor and U.FL connector

Zero ohm jumper resistor and U.FL connector

For advanced users, the 915/868MHz modules feature a U.FL connector. This can be helpful if you need to embed the radio in an enclosure and need an external bulkhead RP-SMA connector. To use the U.FL connection, desolder the 0402 0Ω jumper and move it to the U.FL's RF path.

AT Commands

LoRaSerial radios are very flexible. By default the radio is looking for serial communication at 57600bps. Open the terminal of your choice and enter +++ and wait for an OK. The radio is now ready for an AT command.

Below is a brief list of commands:

AT Command Command Description
+++ Enter command mode
AT Reports OK
ATI Show board variant, firmware
ATI0 Show all user settable parameters
ATI1 Show board variant
ATI2 Show firmware version
ATI3 Display latest RSSI
ATI4 Generate random byte based on RSSI
ATI5 Show max possible bytes per second
ATI6 Show AES Key Values
ATI7 Show FHSS Channel
RTI? Show equivalent remote setting
ATO Exit command mode
ATZ Reboot the radio
AT&W Write current parameters to EEPROM
AT&F Reset all parameters to factory defaults
AT&T=RSSI Show RX packet RSSI, SNR, and FreqError
ATT Enter Training Mode
ATF Enter Training Mode with Defaults
ATSn? Display a parameter
ATSn=X Set a parameter
RTSn? Display remote parameter
RTSn=X Set remote parameter

Table of AT Commands

For a PDF of the AT commands, click here.

The main user settable parameters are listed below and available here in PDF format. A parameter is set using the ATSx command. For example sending ‘ATS21=1’ will enable debug printing. This setting can be stored in NVM (non-volatile memory) by sending the ‘AT&W’ command.

Remote configuration is supported. If two radios are linked, all AT commands can be sent to the remote radio using the RT equivalent (ie, RTZ will reboot the remote radio). Be careful as it is very possible to break the link. For example, setting the remote AES key should be done first before setting the local AES key.

Table of common parameters

Table of common parameters

The table of common parameters is available here in PDF format.

Hop Table Generation

The LoRaSerial uses a novel technique for generating the frequencies it uses for transmission. In order to prevent other radios and other LoRaSerial products from transmitting over each other a unique hop table must be generated. To achieve this, a unit’s settings needed for a working link are combined into a 16 bit number that is used as a random seed. A table, based on the min/max frequencies and the number of channels, is then randomly sorted using the random seed. This guarantees that two radios, even with slightly different settings, have very different hop patterns.

AirSpeed Table

The following table shows the relationship between the AirSpeed setting and the resulting LoRa specific bandwidth, spread factor, and coding rates. In general, it is recommended that users use AirSpeed and to not use custom bandwidths, spread factors, or coding rates as this may lead to out-of-compliance setups.

How AirSpeed relates to LoRa settings

How AirSpeed relates to LoRa settings

The bandwidth, spread, and coding rates were chosen to get close to an ‘equivalent’ commonly used baud rate. However this is not absolute. An airspeed of 4800 bits per second is default but as can be seen in the table, the actual max bytes per second is approximately 510 best case scenario.

Resources and Going Further

We hope you enjoy using the LoRaSerial as much as we have!

Here are the pertinent technical documents for the LoRaSerial:

Check out these additional tutorials for your perusal:

Setting up a Rover Base RTK System

Getting GNSS RTCM correction data from a base to a rover is easy with a serial telemetry radio! We'll show you how to get your high precision RTK GNSS system setup and running.

How to Build a DIY GNSS Reference Station

Learn how to affix a GNSS antenna, use PPP to get its ECEF coordinates and then broadcast your own RTCM data over the internet and cellular using NTRIP to increase rover reception to 10km!

SparkFun RTK Surveyor Hookup Guide

Learn how to use the enclosed RTK Surveyor product to achieve millimeter level geospatial coordinates.

SparkFun RTK Express Hookup Guide

Learn how to use the enclosed RTK Express product to achieve millimeter level geospatial coordinates.

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