Ebyte LoRa E22 per Arduino, esp32 o esp8266: trasmissione fissa, broadcast, monitor e RSSI – 4

Spread the love

Ora capiremo i vari tipi di trasmissione del nostro dispositivo Ebyte LoRa E22 UART basato sui popolari chip RF SX1262, SX1268 di Semtech.

Ebyte LoRa E22 device for Arduino, esp32 or esp8266 fixed transmission and RSSI
Ebyte LoRa E22 device for Arduino, esp32 or esp8266 fixed transmission and RSSI

Qui una selezione dei dispositivi AliExpress (433MHz 5.5Km) - AliExpress (433MHz 10Km) - AliExpress (868MHz 915Mhz 5.5Km) - AliExpress (868MHz 915Mhz 10Km)

Nella prima parte abbiamo utilizzato una trasmissione trasparente, quindi inviavamo a tutti e ricevevano da tutti quelli con lo stesso indirizzo e canale.

LoRa E32 transmitting scenarios

Ma non è uno scenario standard e di solito vogliamo inviare a un punto specifico e ricevere una risposta.

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

Modalità normale

Per la trasmissione normale, devi impostare M0 e M1 su LOW, ed è meglio se colleghi il pin AUX per avere una sincronizzazione migliore, ma non necessaria. È possibile verificare la connessione del pin AUX nell’esempio di connessione completo della libreria e è necessario aggiungere solo il PIN al costruttore.

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Ω)
VCC5v
GNDGND

e questa configurazione per il 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

Quindi devi solo istanziare il costruttore.

// ---------- 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
// -------------------------------------

Trasmissione trasparente

Sketch generico, seleziona il costruttore corretto per ogni dispositivo:

/*
 * LoRa E22
 * send a transparent message, you must check that the transmitter and receiver have the same
 * CHANNEL ADDL and ADDH
 *
 * Renzo Mischianti <https://mischianti.org>
 * https://mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
 *
 * E22		  ----- Arduino
 * M0         ----- 7 (or GND)
 * M1         ----- 6 (or GND)
 * 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
// -------------------------------------

// ---------- 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 setup() {
  Serial.begin(9600);
  delay(500);

  // Startup all pins and UART
  e22ttl.begin();

//  If you have ever change configuration you must restore It
//	ResponseStructContainer c;
//	c = e22ttl.getConfiguration();
//	Configuration configuration = *(Configuration*) c.data;
//	Serial.println(c.status.getResponseDescription());
//	configuration.CHAN = 0x17;
//	configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
//	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);

  Serial.println("Hi, I'm going to send message!");

  // Send message
  ResponseStatus rs = e22ttl.sendMessage("Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
	ResponseContainer rc = e22ttl.receiveMessage();
	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);
	}
  }
  if (Serial.available()) {
	  String input = Serial.readString();
	  e22ttl.sendMessage(input);
  }
}

Se hai già modificato la configurazione, devi ripristinare i parametri di default:

//  If you have ever change configuration you must restore It
	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
	Configuration configuration = *(Configuration*) c.data;
	Serial.println(c.status.getResponseDescription());
	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;
	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    c.close();

Trasmissione trasparente e RSSI

Ebyte LoRa E22 device for Arduino, esp32 or esp8266 3 devices module SMD
Ebyte LoRa E22 device for Arduino, esp32, or esp8266 three devices module SMD

Nelle telecomunicazioni, un indicatore di potenza del segnale ricevuto (RSSI) misura la potenza  presente in un  segnale radio ricevuto.

L’RSSI è solitamente invisibile all’utente del dispositivo ricevente. Tuttavia, poiché la potenza del segnale può variare notevolmente e influire sulla funzionalità nelle reti wireless, i dispositivi IEEE 802.11 spesso mettono a disposizione degli utenti la misurazione.

Questo dispositivo supporta RSSI e, in alcune situazioni, è molto utile. Per utilizzarlo è necessario attivare il flag di configurazione.

//  If you have ever change configuration you must restore It
	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
	Configuration configuration = *(Configuration*) c.data;
	Serial.println(c.status.getResponseDescription());
	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;
	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    c.close();

Dopo la configurazione, possiamo passare ad utilizzare il metodo creato per gestire il valore RSSI: receiveMessageRSSI().

Per il trasmettitore tutto il processo è stato gestito dalla configurazione; solo il destinatario deve utilizzare un metodo “speciale” per recuperare il valore. Quindi lo Sketch precedente diventa così:

/*
 * LoRa E22
 * send a transparent message, you must check that the transmitter and receiver have the same
 * CHANNEL ADDL and ADDH
 *
 * Pai attention e22 support RSSI, if you want use that functionality you must enable RSSI on configuration
 * configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
 *
 * Renzo Mischianti <https://mischianti.org>
 * https://mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
 *
 */

#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 setup() {
  Serial.begin(9600);
  delay(500);

  // Startup all pins and UART
  e22ttl.begin();

  Serial.println("Hi, I'm going to send message!");

  // Send message
  ResponseStatus rs = e22ttl.sendMessage("Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
	ResponseContainer rc = e22ttl.receiveMessageRSSI();
	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);

		Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
	}
  }
  if (Serial.available()) {
	  String input = Serial.readString();
	  e22ttl.sendMessage(input);
  }
}

Trasmissione fissa

Per la trasmissione fissa, è necessario impostare M0 e M1 su LOW, ed è meglio collegare il pin AUX per avere una migliore sincronizzazione.

Trasmissione fissa: punto a punto

Per utilizzare questo tipo di trasmissione, dobbiamo impostare un parametro sulla configurazione e impostare un indirizzo specifico per ogni dispositivo.

LoRa E32 Fixed message to a specified device

Quindi, per prima cosa, dobbiamo impostare il pin M1 su HIGH e M0 su LOW per entrare in modalità programma/sleep e impostare l’indirizzo corretto e il flag di trasmissione fisso.

Se vogliamo replicare la condizione del mittente nell’immagine in alto, dobbiamo eseguire questa configurazione.

	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
	Configuration configuration = *(Configuration*) c.data;
	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;
	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    c.close();

Quindi per il dispositivo ricevitore, dobbiamo impostare questa configurazione.

	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
	Configuration configuration = *(Configuration*) c.data;
	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;
	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    c.close();

Ora dobbiamo inviare un messaggio al dispositivo specificato.

  #define DESTINATION_ADDL 2
  // Send message
  ResponseStatus rs = e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());

Il ricevitore è come per il trasparente perché il dispositivo gestisce l’indirizzo e il canale.

void loop()
{
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
	ResponseContainer rc = e22ttl.receiveMessage();
	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);
	}
  }
}

Presta attenzione a queste righe di codice:

// With FIXED SENDER configuration
// #define DESTINATION_ADDL 3

// With FIXED RECEIVER configuration
#define DESTINATION_ADDL 2

È necessario rimuovere il commento dalla corretta DESTINATION_ADDL per il mittente e il destinatario.

Sketch mittente e ricevitore:

/*
 * EBYTE LoRa E22
 * Send a string message to a fixed point ADDH ADDL CHAN 0 2 23
 *
 * Write a string on serial monitor or reset to resend default value.
 *
 * Send a fixed point message, you must check that the transmitter and receiver have different
 * CHANNEL ADDL or ADDH, check down the correct configuration
 *
 * Renzo Mischianti <https://mischianti.org>
 * https://mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
 *
 */

// With FIXED SENDER configuration
// #define DESTINATION_ADDL 3

// With FIXED RECEIVER configuration
#define DESTINATION_ADDL 2

#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 setup() {
  Serial.begin(9600);
  delay(500);

  // 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);
	c.close();


  Serial.println("Hi, I'm going to send message!");

  // Send message
  ResponseStatus rs = e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
	ResponseContainer rc = e22ttl.receiveMessage();

	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);
	}
  }
  if (Serial.available()) {
	  String input = Serial.readString();
	  e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
  }
}

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("----------------------------------------");
}

Trasmissione fissa con RSSI:

Ebyte LoRa E22 device for Arduino, esp32 or esp8266 RSSI signal strength
Ebyte LoRa E22 device for Arduino, esp32 or esp8266 RSSI signal strength

Per gestire RSSI, deve essere abilitato tramite configurazione, quindi la configurazione per il mittente diventa così:

	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
	Configuration configuration = *(Configuration*) c.data;

	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;
	
	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    c.close();

e per il ricevitore:

	ResponseStructContainer c;
	c = e22ttl.getConfiguration();
	Configuration configuration = *(Configuration*) c.data;

	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;
			
	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
    c.close();

Inoltre, in questo sketch, presta attenzione a queste righe di codice:

// With FIXED SENDER configuration
// #define DESTINATION_ADDL 3

// With FIXED RECEIVER configuration
#define DESTINATION_ADDL 2

È necessario rimuovere il commento dalla corretta DESTINATION_ADDL per il mittente e il destinatario.

Ed ecco lo sketch con RSSI:

/*
 * EBYTE LoRa E22
 * Send a string message to a fixed point ADDH ADDL CHAN 0 2 23
 *
 * Write a string on serial monitor or reset to resend default value.
 *
 * Send a fixed point message, you must check that the transmitter and receiver have different
 * CHANNEL ADDL or ADDH, check down the correct configuration
 *
 * Pai attention e22 support RSSI, if you want use that functionality you must enable RSSI on configuration
 * configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
 *
 * Renzo Mischianti <https://mischianti.org>
 * https://mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
 *
 */

// With FIXED SENDER configuration
// #define DESTINATION_ADDL 3

// With FIXED RECEIVER configuration
#define DESTINATION_ADDL 2

#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 setup() {
  Serial.begin(9600);
  delay(500);

  // 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);
	c.close();


  Serial.println("Hi, I'm going to send message!");

  // Send message
  ResponseStatus rs = e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
	ResponseContainer rc = e22ttl.receiveMessageRSSI();
	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);
		Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
	}
  }
  if (Serial.available()) {
	  String input = Serial.readString();
	  e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
  }
}

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("----------------------------------------");
}

Trasmissione fissa: broadcast

Possiamo testare la comunicazione broadcast con l’esatta configurazione dell’indirizzo e del canale.

Broadcast message to a set of channel devices

Per fare un test, puoi creare tre dispositivi con queste tre configurazioni:

Dispositivo 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;

Dispositivo 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;

Dispositivo 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;

  // Send message
  ResponseStatus rs = e22ttl.sendBroadcastFixedMessage(23, "Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());

o

  // Send message
  ResponseStatus rs = e22ttl.sendFixedMessage(BROADCAST_ADDRESS, BROADCAST_ADDRESS, 4, "Send message to channel 4");
	Serial.println(rs.getResponseDescription());

Il ricevitore, come descritto, ha lo stesso codice perché il dispositivo gestisce il preambolo con Indirizzo e Canale.

Ecco lo schizzo del mittente:

/*
 * EBYTE LoRa E22
 *
 * Send a string message to the all devices of channel 23
 *
 * Write a string on serial monitor or reset to resend default value.
 *
 * Send a fixed message, you must check that the transmitter and receiver have different
 * CHANNEL ADDL or ADDH, check the configuration down
 *
 * Pai attention e22 support RSSI, if you want use that functionality you must enable RSSI on configuration
 * configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
 *
 * and uncomment #define ENABLE_RSSI true in this sketch
 *
 * You must select 3 devices, and you must use the configuration
 * BROADCAST MESSAGE 1
 * BROADCAST MESSAGE 2
 * BROADCAST MESSAGE 3
 *
 * Renzo Mischianti <https://mischianti.org>
 * https://mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
 *
 * E22		  ----- Arduino
 * M0         ----- 7 (or GND)
 * M1         ----- 6 (or GND)
 * RX         ----- 4 (PullUP)
 * TX         ----- 5 (PullUP)
 * AUX        ----- 3  (PullUP)
 * VCC        ----- 3.3v/5v
 * GND        ----- GND
 *
 */

// If you want use RSSI uncomment //#define ENABLE_RSSI true
// and use relative configuration with RSSI enabled
//#define ENABLE_RSSI true

#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 setup() {
  Serial.begin(9600);
  delay(500);

  // Startup all pins and UART
  e22ttl.begin();

  Serial.println("Hi, I'm going to send message!");

  // Send message
  ResponseStatus rs = e22ttl.sendBroadcastFixedMessage(23, "Hello, world?");
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
#ifdef ENABLE_RSSI
	ResponseContainer rc = e22ttl.receiveMessageRSSI();
#else
	ResponseContainer rc = e22ttl.receiveMessage();
#endif
	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);
#ifdef ENABLE_RSSI
		Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
#endif
	}
  }
  if (Serial.available()) {
	  String input = Serial.readString();
	  ResponseStatus rs = e22ttl.sendBroadcastFixedMessage(23, input);
	  // Check If there is some problem of succesfully send
	  Serial.println(rs.getResponseDescription());

  }
}

Trasmissione fissa: monitoraggio

Come hai già visto nel primo schema, puoi ascoltare tutti i messaggi nel canale specificato e devi configurare il tuo indirizzo in questo modo, con un indirizzo uguale a 0xFFFF.

			configuration.ADDL = BROADCAST_ADDRESS;
			configuration.ADDH = BROADCAST_ADDRESS;
			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;

Per ricevere i messaggi:

/*
 * EBYTE LoRa E22
 *
 * Write a string on serial monitor or reset to resend default value.
 *
 * Send a fixed message, you must check that the transmitter and receiver have different
 * CHANNEL ADDL or ADDH, check the configuration down
 *
 * Pai attention e22 support RSSI, if you want use that functionality you must enable RSSI on configuration
 * configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
 *
 * and uncomment #define ENABLE_RSSI true in this sketch
 *
 * Renzo Mischianti <https://mischianti.org>
 * https://mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
 *
 * E22		  ----- Arduino
 * M0         ----- 7 (or GND)
 * M1         ----- 6 (or GND)
 * RX         ----- 4 (PullUP)
 * TX         ----- 5 (PullUP)
 * AUX        ----- 3  (PullUP)
 * VCC        ----- 3.3v/5v
 * GND        ----- GND
 *
 */

#define DESTINATION_ADDL 3

// If you want use RSSI uncomment //#define ENABLE_RSSI true
// and use relative configuration with RSSI enabled
//#define ENABLE_RSSI true

#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 setup() {
  Serial.begin(9600);
  delay(500);

  // Startup all pins and UART
  e22ttl.begin();

//  Serial.println("Hi, I'm going to send message!");
//
//  // Send message
//  ResponseStatus rs = e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world?");
//  // Check If there is some problem of succesfully send
//  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e22ttl.available()>1) {
	  // read the String message
#ifdef ENABLE_RSSI
	ResponseContainer rc = e22ttl.receiveMessageRSSI();
#else
	ResponseContainer rc = e22ttl.receiveMessage();
#endif
	// Is something goes wrong print error
	if (rc.status.code!=1){
		Serial.println(rc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rc.status.getResponseDescription());
		Serial.println(rc.data);
#ifdef ENABLE_RSSI
		Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
#endif
	}
  }
  if (Serial.available()) {
	  String input = Serial.readString();
	  e22ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
  }
}

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 *