Ebyte LoRa E32 device for Arduino, esp32 or esp8266: fixed transmission – 4
We will now understand the various transmission types of our E32 UART LoRa device based on popular SX1276/SX1278 Wireless Modules.
You can find module here AliExpress (433MHz 5Km) - AliExpress (433MHz 8Km) - AliExpress (433MHz 16Km) - AliExpress (868MHz 915MHz 5.5Km) - AliExpress (868MHz 915MHz 8Km)
In the first part, we’ve used a transparent transmission, so we send to all and receive from all that have the same address e channel.
But It isn’t a standard scenario, and we usually want to send to a specified point and receive a response.
If you have trouble with the device’s freeze, you must put a pull-up 4.7k resistor or better connect to the device AUX pin.
Normal mode
For normal transmission, you must set M0 and M1 to LOW, and It’s better if you connect the AUX pin to have a better synchronization, but not needed. You can check the connection of the AUX pin in the library complete example connection, and you only must add the pin number to the constructor.
So you must only instantiate the constructor
// Arduino constructor
LoRa_E32 e32ttl100(2, 3); // e32 TX e32 RX
// LoRa_E32 e32ttl100(2, 3, 5); // e32 TX e32 RX, AUX If you want use AUX pin
// Wemos D1 constructor
LoRa_E32 e32ttl100(D2, D3); // e32 TX e32 RX
// LoRa_E32 e32ttl100(D2, D3, D5); // e32 TX e32 RX, AUX If you want use AUX pin
Transparent transmission
Arduino sketch:
/*
* LoRa E32-TTL-100
* Write on serial to transfer a message to other device
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO
* M0 ----- GND
* M1 ----- GND
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(2, 3); // e32 TX e32 RX
void setup() {
Serial.begin(9600);
delay(500);
Serial.println("Hi, I'm going to send message!");
// Startup all pins and UART
e32ttl100.begin();
// Send message
ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
// Check If there is some problem of successfully send
Serial.println(rs.getResponseDescription());
}
void loop() {
// If something available
if (e32ttl100.available()>1) {
// read the String message
ResponseContainer rc = e32ttl100.receiveMessage();
// Is something goes wrong print error
if (rc.status.code!=1){
rc.status.getResponseDescription();
}else{
// Print the data received
Serial.println(rc.data);
}
}
if (Serial.available()) {
String input = Serial.readString();
e32ttl100.sendMessage(input);
}
}
Here is the Wemos D1 (esp8266) sketch:
/*
* LoRa E32-TTL-100
* Start device or reset to send a message
* https://mischianti.org
*
* E32-TTL-100----- Wemos D1 mini
* M0 ----- GND
* M1 ----- GND
* TX ----- PIN D2 (PullUP)
* RX ----- PIN D3 (PullUP)
* AUX ----- Not connected
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
LoRa_E32 e32ttl100(D2, D3); // e32 TX e32 RX
void setup() {
Serial.begin(9600);
delay(500);
Serial.println("Hi, I'm going to send message!");
// Startup all pins and UART
e32ttl100.begin();
// Send message
ResponseStatus rs = e32ttl100.sendMessage("Hello, world?");
// Check If there is some problem of successfully send
Serial.println(rs.getResponseDescription());
}
void loop() {
// If something available
if (e32ttl100.available()>1) {
// read the String message
ResponseContainer rc = e32ttl100.receiveMessage();
// Is something goes wrong print error
if (rc.status.code!=1){
rc.status.getResponseDescription();
}else{
// Print the data received
Serial.println(rc.data);
}
}
if (Serial.available()) {
String input = Serial.readString();
e32ttl100.sendMessage(input);
}
}
If you have already changed the configuration, you must restore the base parameter:
// If you have ever change configuration you must restore It
ResponseStructContainer c;
c = e32ttl100.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());
configuration.CHAN = 0x17;
configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Fixed transmission
For fixed transmission, you must set M0 and M1 to LOW, and as for transparent transmission, It’s better to connect the AUX pin to have a better synchronization.
Fixed transmission: point to point
To use this type of transmission, we must set a parameter on configuration and set a specified address for every device.
So first, we must set M0 and M1 pin to HIGH to enter on program/sleep mode and set correct address and fixed transmission flag.
If we want to replicate the condition of the sender in the upper image, we must do this configuration.
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0;
configuration.ADDH = 1;
configuration.CHAN = 2;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Then for the receiver device, we must set this configuration.
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0;
configuration.ADDH = 3;
configuration.CHAN = 4;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Now we just sent a message to the specified device.
ResponseStatus rs = e32ttl.sendFixedMessage(0, 3, 4, "Message to 00 03 04 device");
Serial.println(rs.getResponseDescription());
The receiver is more transparent because the device manages the address and channel.
void loop()
{
if (e32ttl.available() > 1){
ResponseContainer rs = e32ttl.receiveMessage();
// First of all get the data
String message = rs.data;
Serial.println(rs.status.getResponseDescription());
Serial.println(message);
}
}
If you want to add another receiving device to complete a test, create one with this configuration.
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0;
configuration.ADDH = 5;
configuration.CHAN = 4;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
So, you can check that no data has arrived.
Send sketch (If you don’t attach all pins first, you must put on program mode then restore normal mode):
/*
* LoRa E32-TTL-100
* Send fixed transmission message to a specified point.
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO or esp8266
* M0 ----- 3.3v (To config) GND (To send) 7 (To dinamically manage)
* M1 ----- 3.3v (To config) GND (To send) 6 (To dinamically manage)
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected (5 if you connect)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6);
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6); // Config without connect AUX and M0 M1
#include <SoftwareSerial.h>
SoftwareSerial mySerial(D2, D3); // e32 TX e32 RX
LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3);// e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(2, 3, 5, 7, 6);
//LoRa_E32 e32ttl(2, 3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3); // e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, 5, 7, 6);
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
delay(100);
e32ttl.begin();
// After set configuration comment set M0 and M1 to low
// and reboot if you directly set HIGH M0 and M1 to program
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0x01;
configuration.ADDH = 0x00;
configuration.CHAN = 0x04;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
// ---------------------------
}
// The loop function is called in an endless loop
void loop()
{
delay(2000);
Serial.println("Send message to 00 03 04");
ResponseStatus rs = e32ttl.sendFixedMessage(0, 3, 0x04, "Message to 00 03 04 device");
Serial.println(rs.getResponseDescription());
}
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("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
Receiver code (If you don’t attach all pins first, you must put on program mode than reset in normal mode) :
/*
* LoRa E32-TTL-100
* Receive fixed transmission message as a specified point.
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO or esp8266
* M0 ----- 3.3v (To config) GND (To send) 7 (To dinamically manage)
* M1 ----- 3.3v (To config) GND (To send) 6 (To dinamically manage)
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected (5 if you connect)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6);
//LoRa_E32 e32ttl(D2, D3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(2, 3, 5, 7, 6);
LoRa_E32 e32ttl(2, 3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3);// e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, 5, 7, 6);
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
delay(100);
e32ttl.begin();
// e32ttl.resetModule();
// After set configuration comment set M0 and M1 to low
// and reboot if you directly set HIGH M0 and M1 to program
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0x03;
configuration.ADDH = 0x00;
configuration.CHAN = 0x04;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
// ---------------------------
Serial.println();
Serial.println("Start listening!");
}
// The loop function is called in an endless loop
void loop()
{
if (e32ttl.available() > 1){
ResponseContainer rs = e32ttl.receiveMessage();
// First of all get the data
String message = rs.data;
Serial.println(rs.status.getResponseDescription());
Serial.println(message);
}
}
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, DEC);
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, DEC);
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("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
If you change the address or channel to the receiver sketch, you don’t receive messages anymore.
Fixed transmisison: broadcast
We can test the broadcast communication with the exact configuration of the address and channel.
With my library, you can use two types of transmission methods.
ResponseStatus rs = e32ttl.sendBroadcastFixedMessage(4, "Send message to channel 4");
Serial.println(rs.getResponseDescription());
Or
ResponseStatus rs = e32ttl.sendFixedMessage(BROADCAST_ADDRESS, BROADCAST_ADDRESS, 4, "Send message to channel 4");
Serial.println(rs.getResponseDescription());
The receiver, as described, has the same code because the device manages the preamble with Address and Channel.
Here is the sender sketch (If you don’t attach all pins first, you must put on program mode then reset in normal mode) :
/*
* LoRa E32-TTL-100
* Send fixed broadcast transmission message to a specified channel.
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO or esp8266
* M0 ----- 3.3v (To config) GND (To send) 7 (To dinamically manage)
* M1 ----- 3.3v (To config) GND (To send) 6 (To dinamically manage)
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected (5 if you connect)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6);
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6); // Config without connect AUX and M0 M1
#include <SoftwareSerial.h>
SoftwareSerial mySerial(D2, D3);// e32 TX e32 RX
LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(2, 3, 5, 7, 6);
//LoRa_E32 e32ttl(2, 3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3);// e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, 5, 7, 6);
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
delay(100);
e32ttl.begin();
// After set configuration comment set M0 and M1 to low
// and reboot if you directly set HIGH M0 and M1 to program
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = 0x01;
configuration.ADDH = 0x00;
configuration.CHAN = 0x04;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
// ---------------------------
}
// The loop function is called in an endless loop
void loop()
{
delay(2000);
Serial.println("Broadcast message to channel 04");
ResponseStatus rs = e32ttl.sendBroadcastFixedMessage(0x04, "Broadcast message to channel 04");
Serial.println(rs.getResponseDescription());
}
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("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
Fixed transmission: monitoring
As you have already seen on the first schema, you can hear all messages in the specified channel, and you must configure your address like so.
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = BROADCAST_ADDRESS;
configuration.ADDH = BROADCAST_ADDRESS;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
And the received message become (If you don’t attach all pins first, you must put on program mode than reset in normal mode) :
/*
* LoRa E32-TTL-100
* Receive fixed transmission message on channel.
* https://mischianti.org
*
* E32-TTL-100----- Arduino UNO or esp8266
* M0 ----- 3.3v (To config) GND (To send) 7 (To dinamically manage)
* M1 ----- 3.3v (To config) GND (To send) 6 (To dinamically manage)
* TX ----- PIN 2 (PullUP)
* RX ----- PIN 3 (PullUP & Voltage divider)
* AUX ----- Not connected (5 if you connect)
* VCC ----- 3.3v/5v
* GND ----- GND
*
*/
#include "Arduino.h"
#include "LoRa_E32.h"
// ---------- esp8266 pins --------------
//LoRa_E32 e32ttl(D2, D3, D5, D7, D6);
//LoRa_E32 e32ttl(D2, D3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(D2, D3); // e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, D5, D7, D6);
// -------------------------------------
// ---------- Arduino pins --------------
//LoRa_E32 e32ttl(2, 3, 5, 7, 6);
LoRa_E32 e32ttl(2, 3); // Config without connect AUX and M0 M1
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(2, 3); // e32 TX e32 RX
//LoRa_E32 e32ttl(&mySerial, 5, 7, 6);
// -------------------------------------
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
delay(100);
e32ttl.begin();
// e32ttl.resetModule();
// After set configuration comment set M0 and M1 to low
// and reboot if you directly set HIGH M0 and M1 to program
ResponseStructContainer c;
c = e32ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDL = BROADCAST_ADDRESS;
configuration.ADDH = BROADCAST_ADDRESS;
configuration.CHAN = 0x04;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
printParameters(configuration);
// ---------------------------
Serial.println();
Serial.println("Start listening!");
}
// The loop function is called in an endless loop
void loop()
{
if (e32ttl.available() > 1){
ResponseContainer rs = e32ttl.receiveMessage();
// First of all get the data
String message = rs.data;
Serial.println(rs.status.getResponseDescription());
Serial.println(message);
}
}
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, DEC);
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, DEC);
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("----------------------------------------");
}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println("----------------------------------------");
Serial.print(F("HEAD BIN: ")); Serial.print(moduleInformation.HEAD, BIN);Serial.print(" ");Serial.print(moduleInformation.HEAD, DEC);Serial.print(" ");Serial.println(moduleInformation.HEAD, HEX);
Serial.print(F("Freq.: ")); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
Serial.println("----------------------------------------");
}
Thanks
- LoRa E32 device for Arduino, esp32 or esp8266: settings and basic usage
- LoRa E32 device for Arduino, esp32 or esp8266: library
- LoRa E32 device for Arduino, esp32 or esp8266: configuration
- LoRa E32 device for Arduino, esp32 or esp8266: fixed transmission
- LoRa E32 device for Arduino, esp32 or esp8266: power saving and sending structured data
- LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and Arduino shield
- LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and WeMos D1 shield
- EByte LoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) and new ESP32 shield
- Ebyte LoRa E32 with STM32: WOR (wake on radio) and new STM32 shield
- Mischianti Arduino LoRa shield (Open source)
- Mischianti WeMos LoRa shield (Open source)
- Mischianti ESP32 DOIT DEV KIT v1 shield (Open source)
- STM32F1 Blue-Pill EByte LoRa E32, E22, and E220 Shield
- STM32F4 Black-Pill EByte LoRa E32, E22, and E220 Shield
Thank you for your tutorial.
I have set up two LoRa modules using ES32 and ESP8266 and am having a problem with the receive module (and maybe the send module).
On the receive module I am getting the following:
HEAD : 0 0 0
AddH : 0
AddL : 3
Chan : 4 -> 414MHz
SpeedParityBit : 0 -> 8N1 (Default)
SpeedUARTDatte : 0 -> 1200bps
SpeedAirDataRate : 0 -> 0.3kbps
OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
OptionPullup : 0 -> TXD, RXD, AUX are open-collectors
OptionWakeup : 0 -> 250ms (default)
OptionFEC : 0 -> Turn off Forward Error Correction Switch
OptionPower : 0 -> 20dBm (Default)
—————————————-
I have checked the value of e32ttl.available() and found it to be 0 so the loop is never completed as it should be.
Any help would be appreciated.
John B.
P.S. there is a minor glitch on your Github Example of setConfiguration — the header in that file says Get
Hi John,
when this strange parameter are retrieved probably there is a connection problem, try to check the connection.
If you continue to have this problem uncomment the
// #define LoRa_E32_DEBUG
and send me (on forum topic) the result.
Bye Renzo
Hello Renzo, thank you for all the content!
I am having a little bit of trouble with the fixed transmission send/receive example script. I wired up two LoRa’s in two separate Arduino Uno’s and I’m trying to run the send code in one, and the receive code in another. Eventhough I do receive some type of message on the serial monitor and there is a Success message, the message itself is all giberish. It is as if the decodification method isn’t right…
Hi Gabriel,
it’s strange.
First check the wiring and the power supply.
Then try to set the configuration like the examples in the articles.
Bye Renzo
Hi Renzo,
You did a great job! I have a problem. I’m working with E32433T20DT and T.
I tried to restore the default configuration. It doesn’t work.
I used your arduinoSetConfiguration program but each time i retart the module, the old config comes up.
Could you help me ?
Thanks a lot
Hi J-F,
check the parameter of set configuration.
In the default example you can find WRITE_CFG_PWR_DWN_LOSE, you need to set WRITE_CFG_PWR_DWN_SAVE.
Bye Renzo
Hello! I would like to ask if Ebyte E32 can communicate with Lilygo TTGO Lora 32? Would this library help me? Thank you in advance.
Hi Edge,
no It can’t because EByte wrap the communication and add noise check and encryption.
Some people decrypt the message but the use of fixed message isn’t possible, only transparent.
Bye Renzo
Hello, i would like to ask a question. I have 2 LoRa’s and 2 arduino’s, wired up them and have comm between them but my question is i want to see the variable change in my serial monitor but all i can see is the first value that came to the buffer. Even if i remove the sender arduino i kept seeing the first value. I tried to use ur cleanUARTBuffer function or resetModule funciton but i think these are not in the header file idk.
Hi Burga,
It isn’t easy to figure it out. Please open a topic forum and paste your code.
Bye Renzo