LoRa E32 device for Arduino, esp32 or esp8266: configuration – Part 3

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Now we are going to learn the configuration of our E32 UART LoRa device based on popular SX1276/SX1278 Wireless Modules.

sx1278 sx1276 wireless lora uart module serial 3000m arduino 433 rf

You can find It here

As I already specified I created a dedicated library for this device, because configuration and transmission mode are not so simple to manage.

Library

You can find my library here.

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 your /libraries/ folder.

You may need to create the libraries subfolder if its your first library.

Restart the IDE.

Programming connection schemas

For the basic usage we had used this configuration for Arduino, but in this configuration you are working only in “Normal mode”, and we are going to manage only the needed pin dynamic (RX, TX) to simplify the process.

Normal configuration
LoRa E32-TTL-100 Arduino breadboard
M0GND (Set normal mode)
M1GND (Set normal mode)
RXPIN D2 (PullUP 4,7KΩ & Voltage divider)
TXPIN D3 (PullUP 4,7KΩ)
AUXNot connected
VCC3.3v
GNDGND

and this configuration for Wemos D1 mini:

LoRa E32-TTL-100 Wemos D1 breadboard
M0GND (Set normal mode)
M1GND (Set normal mode)
RXPIN D2 (PullUP 4,7KΩ)
TXPIN D3 (PullUP 4,7KΩ)
AUXNot connected
VCC3.3v
GNDGND
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 set HIGH or LOW the pins as needed without problem.

LoRa E32 TTL 100 Wemos D1 Programming/Sleep mode
M0VCC (Set programming/sleep mode)
M1VCC (Set programming/sleep mode)
RXPIN D2 (PullUP 4,7KΩ)
TXPIN D3 (PullUP 4,7KΩ)
AUXNot connected
VCC3.3v
GNDGND
LoRa E32 TTL 100 Arduino Programming/Sleep mode
M0 3.3v (Set programming/sleep mode)
M1 3.3v (Set programming/sleep mode)
RXPIN D2 (PullUP 4,7KΩ & Voltage divider)
TXPIN D3 (PullUP 4,7KΩ)
AUXNot connected
VCC3.3v
GNDGND

In this mode you can manage the configuration of the device

Basic configuration option

ADDHHigh address byte of module (the default 00H)00H-FFH
ADDLLow address byte of module (the default 00H)00H-FFH
SPEDInformation about data rate parity bit and Air data rate
CHANCommunication channel(410M + CHAN*1M), default 17H (433MHz), valid only for 433MHz device00H-1FH
OPTIONType of transmission, pull-up settings, wake-up time, FEC, Transmission power

You can find configuration options on Library article.

Get configuration

Arduino example sketch

/*
* LoRa E32-TTL-100
* Get configuration.
* https://www.mischianti.org
*
* E32-TTL-100----- Arduino UNO
* M0         ----- 3.3v
* M1         ----- 3.3v
* RX         ----- PIN 2 (PullUP & Voltage divider)
* TX         ----- PIN 3 (PullUP)
* AUX        ----- Not connected
* VCC        ----- 3.3v/5v
* GND        ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(2, 3); // RX, TX
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);
}
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("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 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 the 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 device, 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 that. The parameter change the Transmission power constant as described upper in the configuration schema.

At 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 select only one of that. The parameter change the reference frequences only for display porpuse,

Set configuration

Naturally when you have a configuration you want change It for your pourpuse, my idea is that you can get the configuration from 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 an Arduino sketch:

/*
* LoRa E32-TTL-100
* Get configuration.
* https://www.mischianti.org
*
* E32-TTL-100----- Arduino UNO
* M0         ----- 3.3v
* M1         ----- 3.3v
* RX         ----- PIN 2 (PullUP & Voltage divider)
* TX         ----- PIN 3 (PullUP)
* AUX        ----- Not connected
* VCC        ----- 3.3v/5v
* GND        ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(2, 3); // RX, TX
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);
}
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 the result on 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
----------------------------------------

With the library is quite simple, but in the next chapter we are going to test various device options.

Thanks

  1. LoRa E32 device for Arduino, esp32 or esp8266: settings and basic usage
  2. LoRa E32 device for Arduino, esp32 or esp8266: library
  3. LoRa E32 device for Arduino, esp32 or esp8266: configuration
  4. LoRa E32 device for Arduino, esp32 or esp8266: fixed transmission
  5. LoRa E32 device for Arduino, esp32 or esp8266: power saving and sending structured data
  •  
  •  
  •  
  •  
  •  
  •  

You may also like...

1 Response

  1. 10 November 2019

    […] LoRa E32 device for Arduino, esp32 or esp8266: configuration […]

Leave a Reply

Your email address will not be published. Required fields are marked *