LoRa or Long Range wireless data telemetry is a technology pioneered by Semtech that operates at a lower frequency than NRF24L01 (433 MHz, 868 MHz, or 916 MHz against 2.4 GHz for the NRF24L01) but at thrice the distance (from 5000m to 11000m).
Now we try to examine better how to configure the Ebyte E220 UART LoRa device based on LLCC68 Wireless Modules.
Here some devices: E220-400T22D 433MHz 5Km - E220-400T30D 433MHz 10Km - E220-900T22D 868MHz 915MHz 5Km - E220-900T30D 868MHz 915MHz 10Km
I created this library to manage EBYTE E220 especially to simplify the configuration process because can be very tedious.
If you have device freezing problems, you must put a pull-up 4.7k resistor or better connect to the device AUX pin.
Library
You can find my library here, and It’s available on the Arduino IDE library manager.
To download.
Click the DOWNLOADS button in the top right corner, and rename the uncompressed folder LoRa_E220.
Check that the LoRa_E220 folder contains LoRa_E220.cpp and LoRa_E220.h.
Place the LoRa_E220 library folder in your /libraries/ folder.
You may need to create the libraries subfolder if it’s your first library.
Restart the IDE.
Connection schemas for programming
For the primary usage, we had used a specified configuration for Arduino. Still, you are working only in “Normal mode” in that configuration. Now we will manage only the needed pins dynamic (RX, TX) to simplify the programming process and the others statically.
Pin No. | Pin item | Pin direction | Pin application |
---|---|---|---|
1 | M0 | Input(weak pull-up) | Work with M1 & decide on the four operating modes. Floating is not allowed; it can be ground. |
2 | M1 | Input(weak pull-up) | Work with M0 & decide on the four operating modes. Floating is not allowed; it can be ground. |
3 | RXD | Input | TTL UART inputs connect to external (MCU, PC) TXD output pin. It can be configured as open-drain or pull-up input. |
4 | TXD | Output | TTL UART outputs connect to external RXD (MCU, PC) input pin. Can be configured as open-drain or push-pull output |
5 | AUX | Output | To indicate the module’s working status & wake up the external MCU. During the procedure of self-check initialization, the pin outputs a low level. It can be configured as open-drain or push-pull output (floating is allowed). |
6 | VCC | Power supply 3V~5.5V DC | |
7 | GND | Ground |
As you can see, you can set various modes via M0 and M1 pins.
Mode | M1 | M0 | Explanation |
---|---|---|---|
Normal | 0 | 0 | UART and wireless channels are open, and transparent transmission is on |
WOR Transmitter | 0 | 1 | WOR Transmitter |
WOR Receiver | 1 | 0 | WOR Receiver (Supports wake up over air) |
Deep sleep mode | 1 | 1 | The module goes to sleep (automatically wake up when configuring parameters) |
Standard configuration (transparent)
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
TX | PIN 2 (PullUP 4,7KΩ) |
RX | PIN 3 (PullUP 4,7KΩ & Voltage divider) |
AUX | Not connected (PullUP 4,7KΩ) |
VCC | 5v |
GND | GND |
and this configuration for Wemos D1 mini:
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
TX | PIN D2 (PullUP 4,7KΩ) |
RX | PIN D3 (PullUP 4,7KΩ) |
AUX | Not connected (PullUP 4,7KΩ) |
VCC | 3.3v/5v |
GND | GND |
ESP-32:
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
RX | TX2 (PullUP 4,7KΩ) |
TX | RX2 (PullUP 4,7KΩ) |
AUX | Not connected (PullUP 4,7KΩ) |
VCC | 3.3v/5v |
GND | GND |
Arduino MKR WiFi 1010:
M0 | GND (Set normal mode) |
M1 | GND (Set normal mode) |
TX | PIN 14 Tx (PullUP 4,7KΩ) |
RX | PIN 13 Rx (PullUP 4,7KΩ) |
AUX | Not connected (PullUP 4,7KΩ) or better connected to Pin 1 |
VCC | 3.3v/5V |
GND | GND |
Wiring for programming/sleep mode
To configure It, you must set M0 and M1 to high (remember to use 3.3v).
But If you connect all pins, the library sets HIGH or LOW the pins as needed without a problem.
M0 | VCC (Set programming/sleep mode) |
M1 | VCC (Set programming/sleep mode) |
TX | PIN D2 (PullUP 4,7KΩ) |
RX | PIN D3 (PullUP 4,7KΩ) |
AUX | Not connected (PullUP 4,7KΩ) |
VCC | 5v |
GND | GND |
M0 | 3.3v (Set programming/sleep mode) |
M1 | 3.3v (Set programming/sleep mode) |
TX | PIN 2 (PullUP 4,7KΩ) |
TX | PIN 3 (PullUP 4,7KΩ & Voltage divider) |
AUX | Not connected (PullUP 4,7KΩ) |
VCC | 3.3v/5v |
GND | GND |
M0 | 3.3v (Set programming/sleep mode) |
M1 | 3.3v (Set programming/sleep mode) |
RX | TX2 (PullUP 4,7KΩ) |
TX | RX2 (PullUP 4,7KΩ) |
AUX | Not connected (PullUP 4,7KΩ) or to D18 |
VCC | 3.3v/5v |
GND | GND |
M0 | 3.3v (Set programming/sleep mode) |
M1 | 3.3v (Set programming/sleep mode) |
TX | PIN 14 Tx (PullUP 4,7KΩ) |
RX | PIN 13 Rx (PullUP 4,7KΩ) |
AUX | Not connected (PullUP 4,7KΩ) |
VCC | 3.3v/5V |
GND | GND |
In this mode, you can manage the configuration of the device
Basic configuration option
Name | Description | Address |
---|---|---|
ADDH | High address byte of the module (the default 00H) | 00H |
ADDL | Low address byte of the module (the default 00H) | 01H |
SPED | Information about data rate parity bit and Air data rate | 02H |
OPTION | Type of transmission, pull-up settings, wake-up time, FEC, Transmission power | 03H |
CHAN | Communication channel(410M + CHAN*1M), default 17H (433MHz), valid only for 433MHz device | 04H |
TRANSMISSION_MODE | All transmission parameters | 05H |
CRTYPT_H | User encryption | 06H |
CRTYPT_L | User encryption | 07H |
You can find configuration options in the Library article.
Get configuration
Arduino MKR WiFi 1010 example sketch fully connected (remove M0 and M1 if you want).
/*
* LoRa E220 LLCC68
* Get configuration.
* https://mischianti.org
*
* E220 ----- Arduino MKR
* M0 ----- 2 (or 3.3v)
* M1 ----- 3 (or 3.3v)
* RX ----- 14 (PullUP)
* TX ----- 13 (PullUP)
* AUX ----- 1 (PullUP)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "EByte_LoRa_E220_library.h"
// ---------- esp8266 pins --------------
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
// -------------------------------------
// ---------- Arduino pins --------------
// LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
// -------------------------------------
// ------------- Arduino MKR WiFi 1010 -------------
LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
// -------------------------------------------------
// ---------- esp32 pins --------------
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
void setup() {
Serial.begin(9600);
while(!Serial){};
delay(500);
Serial.println();
// Startup all pins and UART
e220ttl.begin();
ResponseStructContainer c;
c = e220ttl.getConfiguration();
// It's important get configuration pointer before all other operation
Configuration configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());
Serial.println(c.status.code);
printParameters(configuration);
ResponseStructContainer cMi;
cMi = e220ttl.getModuleInformation();
// It's important get information pointer before all other operation
ModuleInformation mi = *(ModuleInformation*)cMi.data;
Serial.println(cMi.status.getResponseDescription());
Serial.println(cMi.status.code);
printModuleInformation(mi);
c.close();
}
void loop() {
}
void printParameters(struct Configuration configuration) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD : ")); Serial.print(configuration.COMMAND, HEX);Serial.print(" ");Serial.print(configuration.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(configuration.LENGHT, HEX);
Serial.println(F(" "));
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, HEX);
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, HEX);
Serial.println(F(" "));
Serial.print(F("Chan : ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription());
Serial.println(F(" "));
Serial.print(F("SpeedParityBit : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription());
Serial.print(F("SpeedUARTDatte : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRateDescription());
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRateDescription());
Serial.println(F(" "));
Serial.print(F("OptionSubPacketSett: ")); Serial.print(configuration.OPTION.subPacketSetting, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getSubPacketSetting());
Serial.print(F("OptionTranPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
Serial.print(F("OptionRSSIAmbientNo: ")); Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
Serial.println(F(" "));
Serial.print(F("TransModeWORPeriod : ")); Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
Serial.print(F("TransModeEnableLBT : ")); Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
Serial.print(F("TransModeEnableRSSI: ")); Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
Serial.print(F("TransModeFixedTrans: ")); Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
Serial.println("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD: ")); Serial.print(moduleInformation.COMMAND, HEX);Serial.print(" ");Serial.print(moduleInformation.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(moduleInformation.LENGHT, DEC);
Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
Here is the result of the sketch
Success
1
----------------------------------------
HEAD : C1 0 8
AddH : 0
AddL : 3
Chan : 23 -> 433MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 11 -> 9600bps (default)
SpeedAirDataRate : 10 -> 2.4kbps (default)
OptionSubPacketSett: 0 -> 200bytes (default)
OptionTranPower : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
TransModeWORPeriod : 11 -> 2000ms (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 1 -> Enabled
TransModeFixedTrans: 0 -> Transparent transmission (default)
----------------------------------------
Success
1
----------------------------------------
HEAD: C1 8 3
Model no.: 20
Version : A
Features : 16
----------------------------------------
As you can see, I add a lot of constructors for every device, and if you change the first configuration, you can switch the device with the same code.
To get the correct information, I add some #define to change the device type (same #define
manage more other devices, I create only one for type for simplicity).
#define E220_22
#define E220_30
You can select only one of them. The parameter changes the Transmission power constant as described in the configuration schema.
In the same manner, you can select one on reference frequences
#define FREQUENCY_433
#define FREQUENCY_170
#define FREQUENCY_470
#define FREQUENCY_868
#define FREQUENCY_915
You can choose only one of them. The parameter changes the reference frequencies only for display purposes,
Set configuration
Naturally, when you have a configuration you want to change for your purpose, I think you can get the configuration from a device, modify what you want and set It.
But in the example sketch, I add a set of configuration comments. You can uncomment the config you want. In the other examples in the library, there is a reference to the relative configuration to apply.
Ricorda che il parametro saveType è fondamentale per mantenere le opzioni al riavvio del dispositivo, WRITE_CFG_PWR_DWN_LOSE naturalmente perderai le impostazioni con WRITE_CFG_PWR_DWN_SAVE non perderai le impostazioni.
Here is an Arduino MKR WiFi 1010 sketch fully connected (remove M0 and M1 If you want):
/*
* LoRa E220
* set configuration.
* https://mischianti.org
*
* E220 ----- Arduino MKR
* M0 ----- 2 (or 3.3v)
* M1 ----- 3 (or 3.3v)
* RX ----- 14 (PullUP)
* TX ----- 13 (PullUP)
* AUX ----- 1 (PullUP)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E220.h"
// ---------- esp8266 pins --------------
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
// -------------------------------------
// ------------- Arduino MKR WiFi 1010 -------------
LoRa_E220 e220ttl(&Serial1, 1, 2, 3); // RX AUX M0 M1
// -------------------------------------------------
// ------------- Arduino Nano 33 IoT -------------
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
// -------------------------------------------------
// ---------- esp32 pins --------------
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
void setup() {
Serial.begin(9600);
while(!Serial){};
delay(500);
Serial.println();
// Startup all pins and UART
e220ttl.begin();
ResponseStructContainer c;
c = e220ttl.getConfiguration();
// It's important get configuration pointer before all other operation
Configuration configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());
Serial.println(c.status.code);
printParameters(configuration);
// ----------------------- DEFAULT TRANSPARENT -----------------------
configuration.ADDL = 0x03;
configuration.ADDH = 0x00;
configuration.CHAN = 23;
configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.subPacketSetting = SPS_200_00;
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower = POWER_22;
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// ----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
// configuration.ADDL = 0x03;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// ----------------------- FIXED SENDER -----------------------
// configuration.ADDL = 0x02;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
//
// ----------------------- FIXED RECEIVER -----------------------
// configuration.ADDL = 0x03;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// ----------------------- FIXED SENDER RSSI -----------------------
// configuration.ADDL = 0x02;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
//
// ----------------------- FIXED RECEIVER RSSI -----------------------
// configuration.ADDL = 0x03;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// ----------------------- WOR SENDER -----------------------
// configuration.ADDL = 0x02;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
//
// ----------------------- WOR RECEIVER -----------------------
// configuration.ADDL = 0x03;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_500_000;
// ----------------------- BROADCAST MESSAGE 1 -----------------------
// configuration.ADDL = 0x04;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// ----------------------- BROADCAST MESSAGE 2 -----------------------
// configuration.ADDL = 0x05;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// ----------------------- BROADCAST MESSAGE 3 -----------------------
// configuration.ADDL = 0x06;
// configuration.ADDH = 0x00;
//
// configuration.CHAN = 23;
//
// configuration.SPED.uartBaudRate = UART_BPS_9600;
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
// configuration.SPED.uartParity = MODE_00_8N1;
//
// configuration.OPTION.subPacketSetting = SPS_200_00;
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
// configuration.OPTION.transmissionPower = POWER_22;
//
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
// Set configuration changed and set to not hold the configuration
ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Serial.println(rs.getResponseDescription());
Serial.println(rs.code);
c = e220ttl.getConfiguration();
// It's important get configuration pointer before all other operation
configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());
Serial.println(c.status.code);
printParameters(configuration);
c.close();
}
void loop() {
}
void printParameters(struct Configuration configuration) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD : ")); Serial.print(configuration.COMMAND, HEX);Serial.print(" ");Serial.print(configuration.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(configuration.LENGHT, HEX);
Serial.println(F(" "));
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, HEX);
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, HEX);
Serial.println(F(" "));
Serial.print(F("Chan : ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription());
Serial.println(F(" "));
Serial.print(F("SpeedParityBit : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription());
Serial.print(F("SpeedUARTDatte : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRateDescription());
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRateDescription());
Serial.println(F(" "));
Serial.print(F("OptionSubPacketSett: ")); Serial.print(configuration.OPTION.subPacketSetting, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getSubPacketSetting());
Serial.print(F("OptionTranPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
Serial.print(F("OptionRSSIAmbientNo: ")); Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
Serial.println(F(" "));
Serial.print(F("TransModeWORPeriod : ")); Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
Serial.print(F("TransModeEnableLBT : ")); Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
Serial.print(F("TransModeEnableRSSI: ")); Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
Serial.print(F("TransModeFixedTrans: ")); Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
Serial.println("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD: ")); Serial.print(moduleInformation.COMMAND, HEX);Serial.print(" ");Serial.print(moduleInformation.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(moduleInformation.LENGHT, DEC);
Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
Here is the result on the console
Success
1
----------------------------------------
HEAD : C1 0 8
AddH : 0
AddL : 3
Chan : 23 -> 433MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 11 -> 9600bps (default)
SpeedAirDataRate : 10 -> 2.4kbps (default)
OptionSubPacketSett: 0 -> 200bytes (default)
OptionTranPower : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
TransModeWORPeriod : 11 -> 2000ms (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 1 -> Enabled
TransModeFixedTrans: 0 -> Transparent transmission (default)
----------------------------------------
Success
1
Success
1
----------------------------------------
HEAD : C1 0 8
AddH : 0
AddL : 3
Chan : 23 -> 433MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 11 -> 9600bps (default)
SpeedAirDataRate : 10 -> 2.4kbps (default)
OptionSubPacketSett: 0 -> 200bytes (default)
OptionTranPower : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
TransModeWORPeriod : 11 -> 2000ms (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 0 -> Disabled (default)
TransModeFixedTrans: 0 -> Transparent transmission (default)
----------------------------------------
The library is quite simple, but we will test various device options in the next chapter.
Thanks
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: settings and basic usage
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: library
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: configuration
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: fixed transmission, broadcast, monitor, and RSSI
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: power-saving and sending structured data
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: WOR microcontroller and Arduino shield
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: WOR microcontroller and WeMos D1 shield
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: WOR microcontroller and esp32 dev v1 shield
- Mischianti Arduino LoRa shield (Open source)
- Mischianti WeMos LoRa shield (Open source)
- Mischianti ESP32 DOIT DEV KIT v1 shield (Open source)