LoRa

LoRa Nodes

With regard to the processor modules discussed on this site, the Heltec WiFi LoRa nodes, Wireless Stick and Wireless Stick Lite, and the Elecrow ESP32S modules are all ESP32-based and so very similar at a software level. There are some minor differences between these and the earlier ESP8266 processor, and there are further minor differences between all of these and the Arduino Pro Mini ATMega processor.

The Heltec CubeCell modules are based on a different, integrated core architecture [ASR605x] with an on-board [LoRa/LoRaWAN] radio.

All of these processors, however, together with the HopeRF RFM95W module or their native radio as applicable, use one variant or another of the Semtech SX12xx series LoRa transceivers (generally the SX1276 or SX1262).

I am assuming that the reader has the Arduino IDE installed with all the software and libraries required to program the modules that are used. The heltec.h library, provided at one point by Heltec, was not available when I began this project, so much of the code here uses the libraries that were used prior to that. However, with the [2022] release of the Heltec V3 modules based on the ESP32-S3 and SX1262 chips, this library, which does not support the SX1262 LoRa Node IC now used in the current versions of all Heltec modules described herein, has effectively been made obsolete and should no longer be used in any case.

Radio Configuration

Because this seems to be the most confusing part of getting different modules to communicate, I've extracted the relevant configuration paramaters for the two different libraries I am currently using—the Sandeep Mistry LoRa library used with SX127x-based radios (Hope RFM95W and earlier Heltec ESP32 modules), and the Heltec LoRa_APP or LoRaWan_APP library used for SX1262-based radios (Heltec ASR605x and ESP32-S3 modules)—and included them in a single header file (LangloLoRa.h) that can be loaded with any sketch to provide a compatibile set of configuration parameters. These are simply the settings that I use in my current application, but they should provide a starting point for anyone trying to get different modules communicating.

Note that, in some cases, the two libraries use different mechanisms to specify the same parameter. The Sandeep Mistry library, for example, identifies the signal bandwidth by its actual frequency, while the Heltec [LoRa_APP/LoRaWan_APP] library identifies it by an index. Where this situation exists, both parameters are included—if either is modified, the other should also be to maintain compatibility.

Langlo LoRa Configuration Parameters
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#define Frequency917E6// Hz
#define SignalBandwidth125E3// Hz
#define SignalBandwidthIndex0// 0: 125 kHz,
// 1: 250 kHz,
// 2: 500 kHz,
// 3: Reserved
#define SpreadingFactor7// SF7..SF12
#define CodingRate1// 1: 4/5,
// 2: 4/6,
// 3: 4/7,
// 4: 4/8
#define CodingRateDenominator5
#define PreambleLength8// Same for Tx and Rx
#define SyncWord0x12
#define OutputPower14// dBm
#define SymbolTimeout0// Symbols
#define FixedLengthPayloadfalse
#define IQInversionfalse
Sandeep Mistry LoRa Parameter Usage

Load the Sandeep Mistry LoRa library through the Arduino IDE Library Manager and include the following in the relevant sketch:

Sandeep Mistry LoRa Library Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <LoRa.h>

// Include definitions for the processor pins being used
// for the SPI/RFM95 interface (SCK,MISO,MOSI,NSS,RST,DI0)

void setup() {

// Initialise the RFM95 radio

SPI.begin(SCK,MISO,MOSI,NSS);
LoRa.setPins(NSS,RST,DI0);

Serial.println("[setup] Activate LoRa Sender");
if (!LoRa.begin(Frequency)) {
Serial.println("[setup] Starting LoRa failed!");
while (true);
}
Serial.print("[setup] LoRa Frequency: ");
Serial.println(Frequency);

LoRa.begin(Frequency);
LoRa.setSpreadingFactor(SpreadingFactor);
LoRa.setSignalBandwidth(SignalBandwidth);
LoRa.setPreambleLength(PreambleLength);
LoRa.setCodingRate4(CodingRateDenominator);
LoRa.setSyncWord(SyncWord);
LoRa.disableCrc();

Serial.println("[setup] LoRa initialisation complete");
}
Heltec LoRa Parameter Usage

The Heltec [LoRa_APP/LoRaWan_APP] library supports the Semtech SX1262 LoRa node chip, which is used in the Heltec CubeCell series and the ESP32-S3-based development boards (WiFi LoRa 32 V3 and Wireless Stick [Lite] V3). Download the Heltec hardware support libraries from GitHub and include the following in the relevant sketch:

Heltec LoRa Library Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <LoRaWan_APP.h>
// I used to use <LoRa_APP.h> but that subset of the LoRaWAN_APP library
// only seems to be available for the CubeCell boards and not the ESP32-S3

static RadioEvents_t RadioEvents;

void onTxDone(void) {
Serial.println("[onTxDone] TX done!");
// Add whatever code needs to be executed when transmission is complete
}

void onTxTimeout(void) {
Serial.println("[onTxTimeout] TX Timeout...");
// Add whatever code needs to be executed on transmission timeout
}

void setup() {

// Initialise the radio

RadioEvents.TxDone = onTxDone;
RadioEvents.TxTimeout = onTxTimeout;

Radio.Init( &RadioEvents );
Radio.SetChannel( Frequency );
Radio.SetTxConfig( MODEM_LORA, OutputPower, 0, SignalBandwidthIndex,
SpreadingFactor, CodingRate,
PreambleLength, FixedLengthPayload,
true, 0, 0, IQInversion, 3000 );

Serial.println("[setup] LoRa initialisation complete");
}

The main compatibility issue that seems to arise when attempting to interoperate between devices using these two different LoRa libraries is in the setting of the SyncWord. The SyncWord setting in the Heltec LoRa library is defined in the LoRaMac.h file as:

/*!
* Syncword for Private LoRa networks
*/
#define LORA_MAC_PRIVATE_SYNCWORD0x12

/*!
* Syncword for Public LoRa networks
*/
#define LORA_MAC_PUBLIC_SYNCWORD0x34

There does not appear to be any way to change this other than by modification of the #define statement in the LoRaMac.h file. It is therefore important to be sure to set the SyncWord [usually to 0x12] when using any other library in a communicating node.

I now note, some years after I originally wrote the above, that I have only included the transmission (TX) configuration parameters in the latter case. The receiver (RX) configuration parameters are similar and, until I get around to including them in the above, can be found in the sketches provided elsewhere on this website, in the section describing the Reliable Packet Delivery Protocol.

The reader will need to download actual sketches (see elsewhere on this site) if a deeper understanding of the context of the above code is required. As I work through refining the various software sketches, I will include more comprehensive documentation on other code elements.

07-05-2024