Ebyte LoRa E22 per Arduino, esp32 o esp8266: configurazione – 3

Spread the love

La telemetria dei dati wireless LoRa o Long Range è una tecnologia introdotta da Semtech che opera a una frequenza inferiore degli NRF24L01 (433 MHz, 868 MHz o 916 MHz contro 2,4 GHz per NRF24L01) ma copre tre volte la distanza (da 4000 ma 10000 m).

Ora proviamo ad esaminare meglio come configurare il dispositivo LoRa Ebyte E22 UART basato sui moduli wireless SX1262/SX1268.

Ebyte LoRa E22 device for Arduino, esp32 or esp8266 Configuration
Ebyte LoRa E22 device for Arduino, esp32 or esp8266 Configuration

You can find here AliExpress (433MHz 5.5Km) - AliExpress (433MHz 10Km) - AliExpress (868MHz 915Mhz 5.5Km) - AliExpress (868MHz 915Mhz 10Km)

Ho creato questa libreria per gestire gli EBYTE E22 ma soprattutto per semplificare il processo di configurazione perché può essere molto noioso.

sx1278 sx1276 wireless LoRa UART module serial 3000m Arduino 433 rf

Se hai problemi di blocco del dispotivo, devi inserire una resistenza di pull-up da 4,7k o meglio collegarti al pin AUX del dispositivo.

Libreria

Puoi trovare la mia libreria qui.

And It’s available on Arduino IDE library manager.

EByte LoRa E22 E32 Arduino library manager
EByte LoRa E22 E32 Arduino library manager

Per scaricare.

Clicca il bottone DOWNLOADS sull’angolo in alto a destra, rinomila la cartella decompressa LoRa_E22.

Controlla che la cartella LoRa_E22 contenga LoRa_E22.cpp e LoRa_E22.h.

posizione la cartella della libreria LoRa_E22 sulla tua cartella /libraries/.

Dovrai creare la sotto cartella librarues se è la tua prima libreria.

Riavvia l’IDE.

Schemi di connessione per la programmazione

Per l’utilizzo di base, abbiamo utilizzato una configurazione specifica per Arduino. Tuttavia, stai lavorando solo in “Modalità normale” in quella configurazione. Ora gestiremo solo i pin dinamici necessari (RX, TX) per semplificare il processo di programmazione e gli altri in modo statico.

ModeM1M0Explanation
Normale00UART e il canale wireless sono aperti, la trasmissione trasparente è attiva (supporta la configurazione via etere tramite comando speciale)
Modalità WOR01Può essere impostato come trasmettitore WOR e ricevitore WOR
Modalità configurazione10Gli utenti possono accedere al registro tramite la porta seriale per controllare lo stato di funzionamento del modulo
Modalità Deep sleep11Sleep mode

Configurazione normale (trasparente)

Ebyte LoRa E32 E22 E220 Arduino UNO normal mode breadboard
Ebyte LoRa E32 E22 E220 Arduino UNO normal mode breadboard
M0GND (Imposta modalità normale)
M1GND (Imposta modalità normale)
TXPIN 2 (PullUP 4,7KΩ)
RXPIN 3 (PullUP 4,7KΩ & partitore di tensione)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND

e questa configurazione per Wemos D1 mini:

Ebyte LoRa E32 E22 E220 Wemos D1 normal mode breadboard
Ebyte LoRa E32 E22 E220 Wemos D1 normal mode breadboard
M0GND (Imposta modalità normale)
M1GND (Imposta modalità normale)
TXPIN D2 (PullUP 4,7KΩ)
RXPIN D3 (PullUP 4,7KΩ)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND

ESP-32:

Ebyte LoRa E32 E22 E220 ESP32 DEV KIT V1 normal mode breadboard
Ebyte LoRa E32 E22 E220 ESP32 DEV KIT V1 normal mode breadboard
M0GND (Imposta modalità normale)
M1GND (Imposta modalità normale)
RXTX2 (PullUP 4,7KΩ)
TXRX2 (PullUP 4,7KΩ)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND

Arduino MKR WiFi 1010:

Ebyte LoRa Exx Arduino MKR WiFi 1010 normal mode connected breadboard
Ebyte LoRa Exx Arduino MKR WiFi 1010 normal mode connected breadboard
M0GND (Imposta modalità normale)
M1GND (Imposta modalità normale)
TXPIN 14 Tx (PullUP 4,7KΩ)
RXPIN 13 Rx (PullUP 4,7KΩ)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND

Cablaggio per la modalità di programmazione/sleep

Per configurarlo, è necessario impostare M0 su GND e M1 su HIGH (ricordarsi di utilizzare 3.3v).

Ma se colleghi tutti i pin, la libreria imposta in ALTO o BASSO i pin a secondo necessità senza problemi.

Ebyte LoRa E22 Wemos D1 configuration mode breadboard
Ebyte LoRa E22 Wemos D1 configuration mode breadboard
M0GND (Set programming/sleep mode)
M1VCC (Set programming/sleep mode)
TXPIN D2 (PullUP 4,7KΩ)
RXPIN D3 (PullUP 4,7KΩ)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND
Ebyte LoRa E22 Arduino UNO configuration mode breadboard
Ebyte LoRa E22 Arduino UNO configuration mode breadboard
M0GND (Set programming/sleep mode)
M13.3v (Set programming/sleep mode)
TXPIN 2 (PullUP 4,7KΩ)
TXPIN 3 (PullUP 4,7KΩ & Voltage divider)
AUXNon connesso (PullUP 4,7KΩ)
VCC5v
GNDGND
Ebyte LoRa E22 ESP32 DEV KIT V1 configuration mode breadboard
Ebyte LoRa E22 ESP32 DEV KIT V1 configuration mode breadboard
M0 GND (Set programming/sleep mode)
M1 3.3v (Set programming/sleep mode)
RXTX2 (PullUP 4,7KΩ)
TXRX2 (PullUP 4,7KΩ)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND
LoRa E22 Arduino MKR WiFi 1010 sleep config mode breadboard
LoRa E22 Arduino MKR WiFi 1010 sleep config mode breadboard
M0GND (Set programming/sleep mode)
M13.3v (Set programming/sleep mode)
TXPIN 14 Tx (PullUP 4,7KΩ)
RXPIN 13 Rx (PullUP 4,7KΩ)
AUXNon connesso (PullUP 4,7KΩ)
VCC3.3v/5v
GNDGND

In questa modalità è possibile gestire la configurazione del dispositivo

Opzione di configurazione di base

NameDescriptionAddress
ADDHIndirizzo High del modulo (impostazione predefinita 00H)00H
ADDLIndirizzo Low del modulo (impostazione predefinita 00H)01H
SPEDInformazioni sul bit di parità della velocità dei dati e sulla velocità dei dati via etere02H
OPTIONTipo di trasmissione, dimensione del pacchetto, abilitazione comandi speciali03H
CHANCanale di comunicazione(410M + CHAN*1M), default 17H (433MHz), valido solo per i dispositivi a 433Mhz controlla sotto per cambiare la frequenza04H
TRANSMISSION_MODEMolti parametri per specificare le varie modalità di trasmissione06H
CRYPTEncryption per evitare intercettazioni07H

Puoi trovare le opzioni di configurazione nell’articolo Libreria.

Ottieni configurazione

Sketch di esempio di Arduino

/*
 * EByte LoRa E22
 * Get configuration.
 * https://mischianti.org
 *
 * E22		  ----- Arduino
 * M0         ----- 7 (or GND)
 * M1         ----- 6 (or HIGH)
 * RX         ----- 4 (PullUP)
 * TX         ----- 5 (PullUP)
 * AUX        ----- 3  (PullUP)
 * VCC        ----- 3.3v/5v
 * GND        ----- GND
 *
 */
#include "Arduino.h"
#include "LoRa_E22.h"

// ---------- esp8266 pins --------------
//LoRa_E22 e22ttl(RX, TX, AUX, M0, M1);  // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E22 e22ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1
//LoRa_E22 e22ttl(D2, D3); // Config without connect AUX and M0 M1

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E22 e22ttl(&mySerial, D5, D7, D6); // AUX M0 M1
// -------------------------------------

// ---------- Arduino pins --------------
LoRa_E22 e22ttl(4, 5, 3, 7, 6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1
//LoRa_E22 e22ttl(4, 5); // Config without connect AUX and M0 M1

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E22 e22ttl(&mySerial, 3, 7, 6); // AUX M0 M1
// -------------------------------------

// ------------- Arduino MKR WiFi 1010 -------------
// LoRa_E220 e22ttl(&Serial1, 2, 4, 6); //  RX AUX M0 M1
// -------------------------------------------------

// ---------- esp32 pins --------------
//LoRa_E22 e22ttl(&Serial2, 18, 21, 19); //  RX AUX M0 M1

//LoRa_E22 e22ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); //  esp32 RX <-- e22 TX, esp32 TX --> e22 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
	e22ttl.begin();

	ResponseStructContainer c;
	c = e22ttl.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 = e22ttl.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 : "));  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.print(F("NetID : "));  Serial.println(configuration.NETID, 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("TransModeTransContr: "));  Serial.print(configuration.TRANSMISSION_MODE.WORTransceiverControl, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORTransceiverControlDescription());
	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("TransModeEnabRepeat: "));  Serial.print(configuration.TRANSMISSION_MODE.enableRepeater, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRepeaterModeEnableByteDescription());
	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("----------------------------------------");

}

Ecco il risultato dello sketch

Success
1
----------------------------------------
HEAD : C1 0 9
 
AddH : 0
AddL : 3
NetID : 0
 
Chan : 23 -> 433MHz
 
SpeedParityBit     : 0 -> 8N1 (Default)
SpeedUARTDatte     : 11 -> 9600bps (default)
SpeedAirDataRate   : 10 -> 2.4kbps (default)
 
OptionSubPacketSett: 0 -> 240bytes (default)
OptionTranPower    : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
 
TransModeWORPeriod : 0 -> 500ms
TransModeTransContr: 0 -> WOR Receiver (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 0 -> Disabled (default)
TransModeEnabRepeat: 0 -> Disabled (default)
TransModeFixedTrans: 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
----------------------------------------
Success
1
----------------------------------------
HEAD: C1 80 7
Model no.: 16
Version  : A
Features : 0
----------------------------------------

Per avere le informazioni corrette, aggiungo alcuni #define per cambiare il tipo di dispositivo (lo stesso #define gestisce più dispositivi, ne creo solo uno per tipo per semplicità).

LoRa E32 request configuration logic analyzer Arduino
LoRa E32 request configuration logic analyzer Arduino

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 E22_22
#define E22_30

Puoi selezionarne solo uno. Il parametro modifica la costante di potenza di trasmissione come descritto nello schema di configurazione.

Allo stesso modo è possibile selezionare una frequenza di riferimento

#define FREQUENCY_433
#define FREQUENCY_170
#define FREQUENCY_470
#define FREQUENCY_868
#define FREQUENCY_915

Puoi sceglierne solo uno. Il parametro modifica le frequenze di riferimento solo a scopo di visualizzazione.

Imposta configurazione

Naturalmente, quando hai una configurazione che vuoi cambiarla per il tuo scopo, penso che tu possa ottenere la configurazione da un dispositivo, modificare ciò che vuoi e impostarla.

Ma nello sketch di esempio, aggiungo un set di configurazione commentato, puoi decommentare la configurazione che vuoi, e negli altri esempi in libreria, c’è un riferimento alla relativa configurazione da applicare.

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.

Ecco uno Sketch dell’Arduino Nano 33 IoT:

/*
 * LoRa E22-TTL-100
 * Get configuration.
 * https://mischianti.org
 *
 * E22		  ----- Arduino Nano 33 IoT
 * M0         ----- 4 (or GND)
 * M1         ----- 6 (or HIGH)
 * RX         ----- TX (PullUP)
 * TX         ----- RX (PullUP)
 * AUX        ----- 2  (PullUP)
 * VCC        ----- 3.3v/5v
 * GND        ----- GND
 *
 */
#include "Arduino.h"
#include "LoRa_E22.h"

// ---------- esp8266 pins --------------
//LoRa_E22 e22ttl(RX, TX, AUX, M0, M1);  // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E22 e22ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1
//LoRa_E22 e22ttl(D2, D3); // Config without connect AUX and M0 M1

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E22 e22ttl(&mySerial, D5, D7, D6); // AUX M0 M1
// -------------------------------------

// ---------- Arduino pins --------------
// LoRa_E22 e22ttl(4, 5, 3, 7, 6); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX AUX M0 M1
//LoRa_E22 e22ttl(4, 5); // Config without connect AUX and M0 M1

//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
//LoRa_E22 e22ttl(&mySerial, 3, 7, 6); // AUX M0 M1
// -------------------------------------

// ------------- Arduino Nano 33 IoT -------------
LoRa_E22 e22ttl(&Serial1, 2, 4, 6); //  RX AUX M0 M1
// -------------------------------------------------

// ------------- Arduino MKR WiFi 1010 -------------
// LoRa_E22 e22ttl(&Serial1, 2, 4, 6); //  RX AUX M0 M1
// -------------------------------------------------

// ---------- esp32 pins --------------
//LoRa_E22 e22ttl(&Serial2, 18, 21, 19); //  RX AUX M0 M1

//LoRa_E22 e22ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); //  esp32 RX <-- e22 TX, esp32 TX --> e22 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
	e22ttl.begin();

	ResponseStructContainer c;
	c = e22ttl.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 = 0x03;
	configuration.ADDH = 0x00;
	configuration.NETID = 0x00;

	configuration.CHAN = 23;


	//	----------------------- DEFAULT TRANSPARENT -----------------------
		configuration.ADDL = 0x03;
		configuration.ADDH = 0x00;
		configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
		configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
		configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
		configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//	----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
	//	configuration.ADDL = 0x03;
	//	configuration.ADDH = 0x00;
	//	configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
	//	configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
	//	configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
	//	configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//	----------------------- FIXED SENDER -----------------------
//			configuration.ADDL = 0x02;
//			configuration.ADDH = 0x00;
//			configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
//			configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
//			configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_TRANSMITTER;
//			configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//
	//	----------------------- FIXED RECEIVER -----------------------
//			configuration.ADDL = 0x03;
//			configuration.ADDH = 0x00;
//			configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
//			configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
//			configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
//			configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//	----------------------- FIXED SENDER RSSI -----------------------
	//		configuration.ADDL = 0x02;
	//		configuration.ADDH = 0x00;
	//		configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
	//		configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
	//		configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_TRANSMITTER;
	//		configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//
	//	----------------------- FIXED RECEIVER RSSI -----------------------
	//		configuration.ADDL = 0x03;
	//		configuration.ADDH = 0x00;
	//		configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
	//		configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
	//		configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
	//		configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;

	//	----------------------- WOR SENDER -----------------------
	//		configuration.ADDL = 0x02;
	//		configuration.ADDH = 0x00;
	//		configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
	//		configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
	//		configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_TRANSMITTER;
	//		configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//
	//	----------------------- WOR RECEIVER -----------------------
//			configuration.ADDL = 0x03;
//			configuration.ADDH = 0x00;
//			configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
//			configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
//			configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
//			configuration.TRANSMISSION_MODE.WORPeriod = WOR_500_000;
	//	----------------------- BROADCAST MESSAGE 1 -----------------------
//			configuration.ADDL = 0x04;
//			configuration.ADDH = 0x00;
//			configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
//			configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
//			configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
//			configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//	----------------------- BROADCAST MESSAGE 2 -----------------------
//			configuration.ADDL = 0x05;
//			configuration.ADDH = 0x00;
//			configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
//			configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
//			configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
//			configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
	//	----------------------- BROADCAST MESSAGE 3 -----------------------
	//		configuration.ADDL = 0x06;
	//		configuration.ADDH = 0x00;
	//		configuration.NETID = 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_240_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.enableRepeater = REPEATER_DISABLED;
	//		configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
	//		configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
	//		configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;

	// Set configuration changed and set to not hold the configuration
	ResponseStatus rs = e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
	Serial.println(rs.getResponseDescription());
	Serial.println(rs.code);

	c = e22ttl.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);
}

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.print(F("NetID : "));  Serial.println(configuration.NETID, 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("TransModeTransContr: "));  Serial.print(configuration.TRANSMISSION_MODE.WORTransceiverControl, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORTransceiverControlDescription());
	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("TransModeEnabRepeat: "));  Serial.print(configuration.TRANSMISSION_MODE.enableRepeater, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRepeaterModeEnableByteDescription());
	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("----------------------------------------");

}


Ecco il risultato sulla console

Connetti alla porta seriale COM19 a 115200

Success
1
----------------------------------------
HEAD : C1 0 9
 
AddH : 0
AddL : 3
NetID : 0
 
Chan : 23 -> 433MHz
 
SpeedParityBit     : 0 -> 8N1 (Default)
SpeedUARTDatte     : 11 -> 9600bps (default)
SpeedAirDataRate   : 10 -> 2.4kbps (default)
 
OptionSubPacketSett: 0 -> 240bytes (default)
OptionTranPower    : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
 
TransModeWORPeriod : 0 -> 500ms
TransModeTransContr: 0 -> WOR Receiver (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 0 -> Disabled (default)
TransModeEnabRepeat: 0 -> Disabled (default)
TransModeFixedTrans: 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
----------------------------------------
Success
1
----------------------------------------
HEAD: C1 80 7
Model no.: 16
Version  : A
Features : 0
----------------------------------------

Connetti alla porta seriale COM19 a 115200

Success
1
----------------------------------------
HEAD : C1 0 9
 
AddH : 0
AddL : 3
NetID : 0
 
Chan : 23 -> 433MHz
 
SpeedParityBit     : 0 -> 8N1 (Default)
SpeedUARTDatte     : 11 -> 9600bps (default)
SpeedAirDataRate   : 10 -> 2.4kbps (default)
 
OptionSubPacketSett: 0 -> 240bytes (default)
OptionTranPower    : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
 
TransModeWORPeriod : 0 -> 500ms
TransModeTransContr: 0 -> WOR Receiver (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 0 -> Disabled (default)
TransModeEnabRepeat: 0 -> Disabled (default)
TransModeFixedTrans: 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
----------------------------------------
Success
1
Success
1
----------------------------------------
HEAD : C1 0 9
 
AddH : 0
AddL : 3
NetID : 0
 
Chan : 23 -> 433MHz
 
SpeedParityBit     : 0 -> 8N1 (Default)
SpeedUARTDatte     : 11 -> 9600bps (default)
SpeedAirDataRate   : 10 -> 2.4kbps (default)
 
OptionSubPacketSett: 0 -> 240bytes (default)
OptionTranPower    : 0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0 -> Disabled (default)
 
TransModeWORPeriod : 11 -> 2000ms (default)
TransModeTransContr: 0 -> WOR Receiver (default)
TransModeEnableLBT : 0 -> Disabled (default)
TransModeEnableRSSI: 0 -> Disabled (default)
TransModeEnabRepeat: 0 -> Disabled (default)
TransModeFixedTrans: 0 -> Transparent transmission (default)
----------------------------------------

La libreria è abbastanza semplice, ma nel prossimo capitolo testeremo varie opzioni del dispositivo.

Grazie

  1. Ebyte LoRa E22 per Arduino, esp32 o esp8266: specifiche ed utilizzo base
  2. Ebyte LoRa E22 per Arduino, esp32 o esp8266: libreria
  3. Ebyte LoRa E22 per Arduino, esp32 o esp8266: configurazione
  4. Ebyte LoRa E22 per Arduino, esp32 o esp8266: trasmissione fissa, broadcast, monitor e RSSI
  5. Ebyte LoRa E22 per Arduino, esp32 o esp8266: risparmio energetico ed invio di dati strutturati
  6. Ebyte LoRa E22 per Arduino, esp32 o esp8266: ripetitore e configurazione remota
  7. Ebyte LoRa E22 per Arduino, esp32 o esp8266: WOR il microcontrollore e lo shield per Arduino
  8. Ebyte LoRa E22 per Arduino, esp32 o esp8266: WOR il microcontrollore e lo shield per il WeMos D1 mini
  9. Ebyte LoRa E22 per Arduino, esp32 o esp8266: WOR il microcontrollore e lo shield per l’esp32 dev v1

Shield e PCB


Spread the love

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *