Now we will learn the configuration of our E32 UART LoRa device based on popular SX1276/SX1278 Wireless Modules.
You can find here AliExpress (433MHz 5Km) - AliExpress (433MHz 8Km) - AliExpress (433MHz 16Km) - AliExpress (868MHz 915MHz 5.5Km) - AliExpress (868MHz 915MHz 8Km)
As I already specified, I created a dedicated library for this device because configuration and transmission mode are not so simple to manage.
If you have trouble with the freeze device, 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 Arduino IDE library manager.
To download.
Click the DOWNLOADS button in the top right corner, rename the uncompressed folder LoRa_E32.
Check that the LoRa_E32 folder contains LoRa_E32.cpp and LoRa_E32.h.
Place the LoRa_E32 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 basic usage, we had used this configuration for Arduino. Still, you are working only in “Normal mode” in this configuration, and we will manage only the needed pin dynamic (RX, TX) to simplify the process.
Normal 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 |
VCC | 3.3v |
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 |
VCC | 3.3v |
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 |
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 | PIN 1 (PullUP 4,7KΩ) |
VCC | 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 |
VCC | 3.3v |
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 |
VCC | 3.3v |
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 |
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 | PIN 1 (PullUP 4,7KΩ) |
VCC | 5V |
GND | GND |
In this mode, you can manage the configuration of the device
Basic configuration option
ADDH | High address byte of the module (the default 00H) | 00H-FFH |
ADDL | Low address byte of the module (the default 00H) | 00H-FFH |
SPED | Information about data rate parity bit and Air data rate | |
CHAN | Communication channel(410M + CHAN*1M), default 17H (433MHz), valid only for 433MHz device | 00H-1FH |
OPTION | Type of transmission, pull-up settings, wake-up time, FEC, Transmission power |
You can find configuration options in the Library article.
Get configuration
Arduino example sketch
/*
* LoRa E32-TTL-100
* Get configuration.
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO
* M0 ----- 3.3v
* M1 ----- 3.3v
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(2, 3); // e32 TX e32 RX
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
void setup() {
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e32ttl100.begin();
ResponseStructContainer c;
c = e32ttl100.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 = e32ttl100.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 BIN: ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX);
Serial.println(F(" "));
Serial.print(F("AddH BIN: ")); Serial.println(configuration.ADDH, BIN);
Serial.print(F("AddL BIN: ")); Serial.println(configuration.ADDL, BIN);
Serial.print(F("Chan BIN: ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription());
Serial.println(F(" "));
Serial.print(F("SpeedParityBit BIN : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription());
Serial.print(F("SpeedUARTDataRate BIN : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRate());
Serial.print(F("SpeedAirDataRate BIN : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate());
Serial.print(F("OptionTrans BIN : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription());
Serial.print(F("OptionPullup BIN : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription());
Serial.print(F("OptionWakeup BIN : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription());
Serial.print(F("OptionFEC BIN : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription());
Serial.print(F("OptionPower BIN : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
Serial.println("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, 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
Begin
Success
1
----------------------------------------
HEAD BIN: 11000000 192 C0
AddH BIN: 0
AddL BIN: 0
Chan BIN: 23 -> 433MHz
SpeedParityBit BIN : 0 -> 8N1 (Default)
SpeedUARTDataRate BIN : 11 -> 9600bps (default)
SpeedAirDataRate BIN : 10 -> 2.4kbps (default)
OptionTrans BIN : 0 -> Transparent transmission (default)
OptionPullup BIN : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
OptionWakeup BIN : 0 -> 250ms (default)
OptionFEC BIN : 1 -> Turn on Forward Error Correction Switch (Default)
OptionPower BIN : 0 -> 20dBm (Default)
----------------------------------------
Success
1
----------------------------------------
HEAD BIN: 11000011 195 C3
Model no.: 32
Version : 44
Features : 14
----------------------------------------
If you change pins 2, 3 with D2, D3 you can do the same operation with your Wemos D1 or other esp8266/esp32.
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 E32_TTL_100
#define E32_TTL_500
#define E32_TTL_1W
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 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 It for your purpose, I think you can get the configuration from a device, modify what you want and set It.
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 sketch:
/*
* LoRa E32-TTL-100
* Get configuration.
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO
* M0 ----- 3.3v
* M1 ----- 3.3v
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(2, 3); // e32 TX e32 RX
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
void setup() {
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e32ttl100.begin();
ResponseStructContainer c;
c = e32ttl100.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);
configuration.ADDL = 0x0;
configuration.ADDH = 0x1;
configuration.CHAN = 0x19;
configuration.OPTION.fec = FEC_0_OFF;
configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.transmissionPower = POWER_17;
configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;
configuration.SPED.airDataRate = AIR_DATA_RATE_011_48;
configuration.SPED.uartBaudRate = UART_BPS_115200;
configuration.SPED.uartParity = MODE_00_8N1;
// Set configuration changed and set to not hold the configuration
ResponseStatus rs = e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
Serial.println(rs.getResponseDescription());
Serial.println(rs.code);
printParameters(configuration);
c.close();
}
void loop() {
}
void printParameters(struct Configuration configuration) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD : ")); Serial.print(configuration.HEAD, BIN);Serial.print(" ");Serial.print(configuration.HEAD, DEC);Serial.print(" ");Serial.println(configuration.HEAD, HEX);
Serial.println(F(" "));
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, BIN);
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, BIN);
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.getUARTBaudRate());
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRate());
Serial.print(F("OptionTrans : ")); Serial.print(configuration.OPTION.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFixedTransmissionDescription());
Serial.print(F("OptionPullup : ")); Serial.print(configuration.OPTION.ioDriveMode, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getIODroveModeDescription());
Serial.print(F("OptionWakeup : ")); Serial.print(configuration.OPTION.wirelessWakeupTime, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription());
Serial.print(F("OptionFEC : ")); Serial.print(configuration.OPTION.fec, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getFECDescription());
Serial.print(F("OptionPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
Serial.println("----------------------------------------");
}
Here is the result on the console
Begin
Success
1
----------------------------------------
HEAD : 11000000 192 C0
AddH : 1
AddL : 0
Chan : 23 -> 433MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 11 -> 9600bps (default)
SpeedAirDataRate : 10 -> 2.4kbps (default)
OptionTrans : 0 -> Transparent transmission (default)
OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
OptionWakeup : 0 -> 250ms (default)
OptionFEC : 1 -> Turn on Forward Error Correction Switch (Default)
OptionPower : 0 -> 20dBm (Default)
----------------------------------------
Success
1
----------------------------------------
HEAD : 11000000 192 C0
AddH : 1
AddL : 0
Chan : 25 -> 435MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 111 -> 115200bps
SpeedAirDataRate : 11 -> 4.8kbps
OptionTrans : 0 -> Transparent transmission (default)
OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups
OptionWakeup : 100 -> 1250ms
OptionFEC : 0 -> Turn off Forward Error Correction Switch
OptionPower : 1 -> 17dBm
----------------------------------------
The library is quite simple, but in the next chapter, we will test various device options.
Thanks
- LoRa E32 device for Arduino, esp32 or esp8266: settings and basic usage
- LoRa E32 device for Arduino, esp32 or esp8266: library
- LoRa E32 device for Arduino, esp32 or esp8266: configuration
- LoRa E32 device for Arduino, esp32 or esp8266: fixed transmission
- LoRa E32 device for Arduino, esp32 or esp8266: power saving and sending structured data
- LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and Arduino shield
- LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and WeMos D1 shield
- EByte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) and new ESP32 shield
- Ebyte LoRa E32 with STM32: WOR (wake on radio) and new STM32 shield
- Mischianti Arduino LoRa shield (Open source)
- Mischianti WeMos LoRa shield (Open source)
- Mischianti ESP32 DOIT DEV KIT v1 shield (Open source)
- STM32F1 Blue-Pill EByte LoRa E32, E22, and E220 Shield
- STM32F4 Black-Pill EByte LoRa E32, E22, and E220 Shield