Giter Site home page Giter Site logo

xreef / ebyte_lora_e22_series_library Goto Github PK

View Code? Open in Web Editor NEW
94.0 15.0 20.0 2.64 MB

Arduino LoRa EBYTE E22 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico (rp2040 boards).. sx1262/sx1268

License: Other

C++ 79.29% C 20.71%
arduino esp8266 esp32 lora ebyte e22 stm32 10km arduino-samd-boards arduino-library

ebyte_lora_e22_series_library's Introduction

Support forum EByte e32 English
Forum supporto EByte e32 italiano

Soon a complete tutorial on my site www.mischianti.org

Changelog

  • 2023-01-28 1.0.9 Fix UART_PARITY for ESP32 C3 Forum
  • 2022-09-19 1.0.8 Fix stm32 rogerclerk library xreef/LoRa_E32_Series_Library#48
  • 2022-03-14 1.0.7 Fix frequencies
  • 2022-03-14 1.0.6 Fix support for STM32
  • 2022-03-14 1.0.5 Fix UART baud rate variable limit
  • 2022-02-23 1.0.4 Add Arduino NANO 33 BLE support and minor change
  • 2022-02-03 1.0.3 Fix file example length
  • 2022-01-24 1.0.2 Memory leak fix and adjustment
  • 2021-12-22 1.0.1 Fix on keywork and change DEBUG_PRINTLN on example with Serial And tested Arduino MKR WiFi 1010 and Arduino Nano 33 IoT

https://downloads.arduino.cc/libraries/logs/github.com/xreef/EByte_LoRa_E22_Series_Library/

An Arduino UNO shield to simplify the use

Arduino UNO shield

You can order the PCB here

Instruction and assembly video on 6 part of the guide

An WeMos D1 shield to simplify the use

Arduino UNO shield

You can order the PCB here

Instruction and assembly video on 6 part of the guide

LoRa E22 (EBYTE LoRa sx1262/sx1268) series Library for Arduino, esp8266 and esp32-

I create a library to manage EBYTE E22 series of LoRa device, very powerfull, simple and cheap device.

LoRa or Long Range wireless data telemetry is a technology pioneered by Semtech that operates at a lower frequency than NRF24L01 (433 MHz, 868 MHz or 916 MHz agains 2.4 GHz for the NRF24L01) but at thrice the distance (from 4000m to 10000m).

LoRa E22

You can find here AliExpress (433MHz 4Km) - AliExpress (433MHz 10Km)

Please refer to my article to get updated Schema

Library

You can find my library here.

To download.

Click the DOWNLOADS button in the top right corner, rename the uncompressed folder LoRa_E22.

Check that the LoRa_E22 folder contains LoRa_E22.cpp and LoRa_E22.h.

Place the LoRa_E22 library folder your /libraries/ folder.

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

Restart the IDE.

Pinout

E22

Pin No. Pin item Pin direction Pin application
1M0Input(weak pull-up)Work with M1 & decide the four operating modes.Floating is not allowed, can be ground.
2M1Input(weak pull-up)Work with M0 & decide the four operating modes.Floating is not allowed, can be ground.
3RXDInputTTL UART inputs, connects to external (MCU, PC) TXD outputpin. Can be configured as open-drain or pull-up input.
4TXDOutputTTL UART outputs, connects to external RXD (MCU, PC) inputpin. Can be configured as open-drain or push-pull output

5

AUX

Output
Per indicare lo stato di funzionamento del modulo e riattivare l’MCU esterno. Durante la procedura di inizializzazione di autocontrollo, il pin emette una bassa tensione. Può essere configurato come uscita open-drain o output push-pull (è consentito non metterlo a terra, ma se hai problemi, ad esempio ti si freeze il dispositivo è preferibile mettere una restistenza di pull-up da 4.7k o meglio collegarlo al dispositivo).
6VCC
Power supply 2.3V~5.5V DC
7GND
Ground

As you can see you can set various modes via M0 and M1 pins.

Mode M1 M0 Explanation
Normal00UART and wireless channel are open, transparent transmission is on (Supports configuration over air via special command)
WOR Mode01Can be defined as WOR transmitter and WOR receiver
Configuration mode10Users can access the register through the serial port to control the working state of the module
Deep sleep mode11Sleep mode

As you can see there are some pins that can be use in a static way, but If you connect It to the library you gain in performance and you can control all mode via software, but we are going to explain better next.

Fully connected schema

As I already say It’s not important to connect all pin to the output of microcontroller, you can put M0 and M1 pins to HIGH or LOW to get desidered configuration, and if you don’t connect AUX the library set a reasonable delay to be sure that the operation is complete.

AUX pin

When transmitting data can be used to wake up external MCU and return HIGH on data transfer finish.

LoRa E22 AUX Pin on transmission

When receiving AUX going LOW and return HIGH when buffer is empty.

LoRa e22 AUX pin on reception

It’s also used for self checking to restore normal operation (on power-on and sleep/program mode).

LoRa e22 AUX pin on self-check

esp8266 connection schema is more simple because It work at the same voltage of logical communications (3.3v).

LoRa E22 TTL 100 Wemos D1 fully connected

It’s important to add pull-up resistor (4,7Kohm) to get good stability.

E22esp8266
M0D7
M1D6
TXPIN D2 (PullUP 4,7KΩ)
RXPIN D3 (PullUP 4,7KΩ)
AUXPIN D5 (PullUP 4,7KΩ)
VCC5V (but work with less power in 3.3v)
GNDGND

Similar connection schema for esp32, but for RX and TX we use RX2 and TX2, because by default esp32 doesn’t have SoftwareSerial but have 3 Serial.

Ebyte LoRa E22 device esp32 dev kit v1 breadboard full connection

E22esp32
M0D21
M1D19
TXPIN RX2 (PullUP 4,7KΩ)
RXPIN TX3 (PullUP 4,7KΩ)
AUXPIN D18 (PullUP 4,7KΩ)
VCC5V (but work with less power in 3.3v)
GNDGND

Arduino working voltage is 5v, so we need to add a voltage divider on RX pin M0 and M1 of LoRa module to prevent damage, you can get more information here Voltage divider: calculator and application.

You can use a 2Kohm resistor to GND and 1Kohm from signal than put together on RX.

LoRa E22 TTL 100 Arduino fully connected

M07 (voltage divider)
M16 (voltage divider)
TXPIN 2 (PullUP 4,7KΩ)
RXPIN 3 (PullUP 4,7KΩ & Voltage divider)
AUXPIN 5 (PullUP 4,7KΩ)
VCC5V
GNDGND

Constructor

I made a set of quite numerous constructors, because we can have more options and situations to manage.

LoRa_E22(byte rxPin, byte txPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);

LoRa_E22(byte rxPin, byte txPin, byte auxPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);

LoRa_E22(byte rxPin, byte txPin, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);

First set of constructor are create to delegate the manage of Serial and other pins to the library.

  • txE22pin and rxE22pin is the pin to connect to UART and they are mandatory.
  • auxPin is a pin that check the operation, transmission and receiving status (we are going to explain better next), that pin It isn’t mandatory, if you don’t set It I apply a delay to permit the operation to complete itself (with latency, if you have trouble, like freeze device, you must put a pull-up 4.7k resistor or better connect to the device ).
  • m0pin and m1Pin are the pins to change operation MODE (see the table upper), I think this pins in “production” are going to connect directly HIGH or LOW, but for test they are usefully to be managed by the library.
  • bpsRate is the boudrate of SoftwareSerial normally is 9600 (the only baud rate in programmin/sleep mode)

A simple example is

#include "LoRa_E22.h"
LoRa_E22 e22ttl100(2, 3); // RX, TX
// LoRa_E22 e22ttl100(2, 3, 5, 6, 7); // RX, TX

We can use directly a SoftwareSerial with another constructor

LoRa_E22(HardwareSerial* serial, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
LoRa_E22(HardwareSerial* serial, byte auxPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
LoRa_E22(HardwareSerial* serial, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);

The example upper with this constructor can be do like so.

#include <SoftwareSerial.h>
#include "LoRa_E22.h"
SoftwareSerial mySerial(2, 3); // RX, TX
LoRa_E22 e22ttl100(mySerial);
// LoRa_E22 e22ttl100(&amp;mySerial, 5, 7, 6);

The last set of constructor is to permit to use an HardwareSerial instead of SoftwareSerial.

LoRa_E22(SoftwareSerial* serial, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
LoRa_E22(SoftwareSerial* serial, byte auxPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
LoRa_E22(SoftwareSerial* serial, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);

Begin

The begin command is used to startup Serial and pins in input and output mode.

void begin();

in execution is

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

Configuration and information method

There a set of methods for manage configuration and get information of the device.

ResponseStructContainer getConfiguration();
ResponseStatus setConfiguration(Configuration configuration, PROGRAM_COMMAND saveType = WRITE_CFG_PWR_DWN_LOSE);
ResponseStructContainer getModuleInformation();
void printParameters(struct Configuration configuration);

Response container

To simplify the manage of response I create a set of container, for me very usefully to manage errors and return generic data.

ResponseStatus

This is a status container and have 2 simple entry point, with this you can get the status code and the description of status code

Serial.println(c.getResponseDescription()); // Description of code
Serial.println(c.code); // 1 if Success

The code are

E22_SUCCESS = 1,
ERR_E22_UNKNOWN,
ERR_E22_NOT_SUPPORT,
ERR_E22_NOT_IMPLEMENT,
ERR_E22_NOT_INITIAL,
ERR_E22_INVALID_PARAM,
ERR_E22_DATA_SIZE_NOT_MATCH,
ERR_E22_BUF_TOO_SMALL,
ERR_E22_TIMEOUT,
ERR_E22_HARDWARE,
ERR_E22_HEAD_NOT_RECOGNIZED
ResponseContainer

This container is created to manage String response and have 2 entry point.

data with the string returned from message and status an instance of RepsonseStatus.

ResponseContainer rs = e22ttl.receiveMessage();
String message = rs.data;
Serial.println(rs.status.getResponseDescription());
Serial.println(message);
ResponseStructContainer

This is the more “complex” container, I use this to manage structure, It has the same entry point of ResponseContainer but data is a void pointer to manage complex structure.

ResponseStructContainer c;
c = e22ttl100.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);
c.close();

getConfiguration and setConfiguration

The first method is getConfiguration, you can use It to retrive all data stored on device.

ResponseStructContainer getConfiguration();

Here an usage example.

ResponseStructContainer c;
c = e22ttl100.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);
Serial.println(configuration.SPED.getUARTBaudRate());
c.close();

Get configuration

Structure of configuration have all data of settings, and I add a series of function to get all description of single data.

configuration.ADDL = 0x03; // First part of address
configuration.ADDH = 0x00; // Second part
configuration.NETID = 0x00; // NETID used for repeater function
 
configuration.CHAN = 23; // Communication channel
 
configuration.SPED.uartBaudRate = UART_BPS_9600; // Serial baud rate
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; // Air baud rate
configuration.SPED.uartParity = MODE_00_8N1; // Parity bit
 
configuration.OPTION.subPacketSetting = SPS_240_00; // Packet size
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED; // Need to send special command
configuration.OPTION.transmissionPower = POWER_22; // Device power
 
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED; // Enable RSSI info
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; // Transmission type
configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED; // Enable repeater mode
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED; // Check interference
configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER; // Enable WOR mode
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; // WOR timing

You have the equivalent function to get all description:

DEBUG_PRINT(F("HEAD : "));  DEBUG_PRINT(configuration.COMMAND, HEX);DEBUG_PRINT(" ");DEBUG_PRINT(configuration.STARTING_ADDRESS, HEX);DEBUG_PRINT(" ");DEBUG_PRINTLN(configuration.LENGHT, HEX);
DEBUG_PRINTLN(F(" "));
DEBUG_PRINT(F("AddH : "));  DEBUG_PRINTLN(configuration.ADDH, HEX);
DEBUG_PRINT(F("AddL : "));  DEBUG_PRINTLN(configuration.ADDL, HEX);
DEBUG_PRINT(F("NetID : "));  DEBUG_PRINTLN(configuration.NETID, HEX);
DEBUG_PRINTLN(F(" "));
DEBUG_PRINT(F("Chan : "));  DEBUG_PRINT(configuration.CHAN, DEC); DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.getChannelDescription());
DEBUG_PRINTLN(F(" "));
DEBUG_PRINT(F("SpeedParityBit     : "));  DEBUG_PRINT(configuration.SPED.uartParity, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getUARTParityDescription());
DEBUG_PRINT(F("SpeedUARTDatte     : "));  DEBUG_PRINT(configuration.SPED.uartBaudRate, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getUARTBaudRateDescription());
DEBUG_PRINT(F("SpeedAirDataRate   : "));  DEBUG_PRINT(configuration.SPED.airDataRate, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getAirDataRateDescription());
DEBUG_PRINTLN(F(" "));
DEBUG_PRINT(F("OptionSubPacketSett: "));  DEBUG_PRINT(configuration.OPTION.subPacketSetting, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getSubPacketSetting());
DEBUG_PRINT(F("OptionTranPower    : "));  DEBUG_PRINT(configuration.OPTION.transmissionPower, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getTransmissionPowerDescription());
DEBUG_PRINT(F("OptionRSSIAmbientNo: "));  DEBUG_PRINT(configuration.OPTION.RSSIAmbientNoise, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getRSSIAmbientNoiseEnable());
DEBUG_PRINTLN(F(" "));
DEBUG_PRINT(F("TransModeWORPeriod : "));  DEBUG_PRINT(configuration.TRANSMISSION_MODE.WORPeriod, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
DEBUG_PRINT(F("TransModeTransContr: "));  DEBUG_PRINT(configuration.TRANSMISSION_MODE.WORTransceiverControl, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getWORTransceiverControlDescription());
DEBUG_PRINT(F("TransModeEnableLBT : "));  DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableLBT, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
DEBUG_PRINT(F("TransModeEnableRSSI: "));  DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableRSSI, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
DEBUG_PRINT(F("TransModeEnabRepeat: "));  DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableRepeater, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getRepeaterModeEnableByteDescription());
DEBUG_PRINT(F("TransModeFixedTrans: "));  DEBUG_PRINT(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());

At same way setConfiguration want a configuration strucutre, so I think the better way to manage configuration is to retrieve the current one, apply the only change you need and set It again.

ResponseStatus setConfiguration(Configuration configuration, PROGRAM_COMMAND saveType = WRITE_CFG_PWR_DWN_LOSE);

configuration is the strucutre previsiouly show, saveType permit to you to choiche if the change become permanently of only for the current session.

ResponseStructContainer c;
c = e32ttl100.getConfiguration();
// It's important get configuration pointer before all other operation
Configuration configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());
Serial.println(c.status.code);
 
printParameters(configuration);
configuration.ADDL = 0x03; // First part of address
configuration.ADDH = 0x00; // Second part
configuration.NETID = 0x00; // NETID used for repeater function
 
configuration.CHAN = 23; // Communication channel
 
configuration.SPED.uartBaudRate = UART_BPS_9600; // Serial baud rate
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; // Air baud rate
configuration.SPED.uartParity = MODE_00_8N1; // Parity bit
 
configuration.OPTION.subPacketSetting = SPS_240_00; // Packet size
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED; // Need to send special command
configuration.OPTION.transmissionPower = POWER_22; // Device power
 
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED; // Enable RSSI info
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; // Transmission type
configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED; // Enable repeater mode
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED; // Check interference
configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER; // Enable WOR mode
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; // WOR timing
 
// Set configuration changed and set to not hold the configuration
ResponseStatus rs = e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
Serial.println(rs.getResponseDescription());
Serial.println(rs.code);
printParameters(configuration);
c.close()

The parameter all all managed as constant:

Basic configuration option

ADDHHigh address byte of module (the default 00H)00H-FFH
ADDLLow address byte of module (the default 00H)00H-FFH
SPEDInformation about data rate parity bit and Air data rate
CHANCommunication channel(410M + CHAN*1M), default 17H (433MHz), valid only for 433MHz device chek below to check the correct frequency of your device00H-1FH
OPTIONType of transmission, packet size, allow special message
TRANSMISSION_MODEA lot of parameter that specify the transmission modality

OPTION

Type of transmission, pull-up settings, wake-up time, FEC, Transmission power

SPED detail

UART Parity bit: UART mode can be different between communication parties

43UART parity bitConstant value
008N1 (default)MODE_00_8N1
018O1MODE_01_8O1
108 E1MODE_10_8E1
118N1 (equal to 00)MODE_11_8N1

UART baud rate: UART baud rate can be different between communication parties, The UART baud rate has nothing to do with wireless transmission parameters & won’t affect the wireless transmit / receive features.

765TTL UART baud rate(bps) Constant value
0001200UART_BPS_1200
0012400UART_BPS_2400
0104800UART_BPS_4800
0119600 (default)UART_BPS_9600
10019200UART_BPS_19200
10138400UART_BPS_38400
11057600UART_BPS_57600
111115200UART_BPS_115200

Air data rate: The lower the air data rate, the longer the transmitting distance, better anti- interference performance and longer transmitting time, The air data rate must keep the same for both communication parties.

210Air data rate(bps) Constant value
0000.3kAIR_DATA_RATE_000_03
0011.2kAIR_DATA_RATE_001_12
0102.4k (default)AIR_DATA_RATE_010_24
0114.8kAIR_DATA_RATE_011_48
1009.6kAIR_DATA_RATE_100_96
10119.2kAIR_DATA_RATE_101_192
11038.4kAIR_DATA_RATE_110_384
11162.5kAIR_DATA_RATE_111_625

OPTION detail

####Sub packet setting

This is the max lenght of the packet.

When the data is smaller than the sub packet length, the serial output of the receiving end is an uninterrupted continuous output. When the data is larger than the sub packet length, the receiving end serial port will output the sub packet.

76Packet size Constant value
00240bytes (default)SPS_240_00
01128bytesSPS_128_01
1064bytesSPS_064_10
1132bytesSPS_032_11

####RSSI Ambient noise enable

This command can enable/disable the management type of RSSI, It’s important to manage the remote configuration, pay attention isn’t the RSSI parameter in the message.

When enabled, the C0 C1 C2 C3 command can be sent in the transmitting mode or WOR transmitting mode to read the register. Register 0x00: Current ambient noise rssi Register 0X01: rssi when the data was received last time.

5RSSI Ambient noise enable Constant value
0EnableRSSI_AMBIENT_NOISE_ENABLED
1Disable (default)RSSI_AMBIENT_NOISE_DISABLED

####Transmission power

You can change this set of constant by apply a define like so:

#define E22_22 // default value without set 
#define E22_30

You can configure Channel frequency olso with this define:

// One of

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

TRANSMISSION_MODE Detail

####Enable RSSI

When enabled, the module receives wireless data and it will follow an RSSI strength byte after output via the serial port TXD

####Transmission type

Transmission mode: in fixed transmission mode, the first three bytes of each user’s data frame can be used as high/low address and channel. The module changes its address and channel when transmit. And it will revert to original setting after complete the process.

####Enable repeater function

####Monitor data before transmission

When enabled, wireless data will be monitored before it is transmitted, which can avoid interference to a certain extent, but may cause data delay.

####WOR

WOR transmitter: the module receiving and transmitting functions are turned on, and a wake-up code is added when transmitting data. Receiving is turned on.

WOR receiver: the module is unable to transmit data and works in WOR monitoring mode. The monitoring period is as follows (WOR cycle), which can save a lot of power.

####WOR cycle

If WOR is transmitting: after the WOR receiver receives the wireless data and outputs it through the serial port, it will wait for 1000ms before entering the WOR again. Users can input the serial port data and return it via the wireless during this period. Each serial byte will be refreshed for 1000ms. Users must transmit the first byte within 1000ms.

  • Period T = (1 + WOR) * 500ms, maximum 4000ms, minimum 500ms
  • The longer the WOR monitoring interval period, the lower the average power consumption, but the greater the data delay
  • Both the transmitter and the receiver must be the same (very important).

Send receive message

First we must introduce a simple but usefully method to check if something is in the receiving buffer

int available();

It’s simply return how many bytes you have in the current stream.

Normal transmission mode

Normal/Transparent transmission mode is used to send messages to all device with same address and channel.

LoRa E22 transmitting scenarios, lines are channels

There are a lot of method to send/receive message, we are going to explain in detail:

ResponseStatus sendMessage(const String message);
ResponseContainer receiveMessage();

First method is sendMessage and is used to send a String to a device in Normal mode.

ResponseStatus rs = e22ttl.sendMessage("Prova");
Serial.println(rs.getResponseDescription());

The other device simply do on the loop

if (e22ttl.available() > 1){
ResponseContainer rs = e22ttl.receiveMessage();
String message = rs.data;` `// First ever get the data
Serial.println(rs.status.getResponseDescription());
Serial.println(message);
}

Manage structure

If you want send a complex strucuture you can use this method

ResponseStatus sendMessage(const void *message, const uint8_t size);

ResponseStructContainer receiveMessage(const uint8_t size);

It’s used to send strucutre, for example:

struct Messaggione {

char type[5];

char message[8];

bool mitico;

};

struct Messaggione messaggione = {"TEMP", "Peple", true};

ResponseStatus rs = e22ttl.sendMessage(&amp;messaggione, sizeof(Messaggione));

Serial.println(rs.getResponseDescription());

and the other side you can receive the message so

ResponseStructContainer rsc = e22ttl.receiveMessage(sizeof(Messaggione));

struct Messaggione messaggione = *(Messaggione*) rsc.data;

Serial.println(messaggione.message);

Serial.println(messaggione.mitico);
Read partial strucure

If you want read first part of the message to manage more type of strucutre you can use this method.

ResponseContainer receiveInitialMessage(const uint8_t size);

I create It to receive a string with type or other to identify the strucuture to load.

struct Messaggione { // Partial strucutre without type

char message[8];

bool mitico;

};

char type[5]; // first part of structure

ResponseContainer rs = e22ttl.receiveInitialMessage(sizeof(type));

// Put string in a char array (not needed)

memcpy ( type, rs.data.c_str(), sizeof(type) );

Serial.println("READ TYPE: ");

Serial.println(rs.status.getResponseDescription());

Serial.println(type);

// Read the rest of structure

ResponseStructContainer rsc = e22ttl.receiveMessage(sizeof(Messaggione));

struct Messaggione messaggione = *(Messaggione*) rsc.data;

Fixed mode instead of normal mode

At same manner I create a set of method to use with fixed transmission

Fixed transmission

You need to change only the sending method, because the destination device don’t receive the preamble with Address and Channel.

So for String message you have

ResponseStatus sendFixedMessage(byte ADDL, byte ADDH, byte CHAN, const String message);

ResponseStatus sendBroadcastFixedMessage(byte CHAN, const String message);

and for structure you have

ResponseStatus sendFixedMessage(byte ADDL, byte ADDH, byte CHAN, const void *message, const uint8_t size);

ResponseStatus sendBroadcastFixedMessage(byte CHAN, const void *message, const uint8_t size );

Here a simple example

ResponseStatus rs = e22ttl.sendFixedMessage(0, 0, 0x17, &amp;messaggione, sizeof(Messaggione));

// ResponseStatus rs = e22ttl.sendFixedMessage(0, 0, 0x17, "Ciao");

Fixed transmission have more scenarios

LoRa E22 transmitting scenarios, lines are channels

If you send to a specific device (second scenarios Fixed transmission) you must add ADDL, ADDH and CHAN to identify It directly.

ResponseStatus rs = e22ttl.sendFixedMessage(2, 2, 0x17, "Message to a device");

If you want send a message to all device in a specified Channel you can use this method.

ResponseStatus rs = e22ttl.sendBroadcastFixedMessage(0x17, "Message to a devices of a channel");

If you want receive all broadcast message in the network you must set your ADDH and ADDL with BROADCAST_ADDRESS.

ResponseStructContainer c;

c = e22ttl100.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 = BROADCAST_ADDRESS;

configuration.ADDH = BROADCAST_ADDRESS;

// Set configuration changed and set to not hold the configuration

ResponseStatus rs = e22ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);

Serial.println(rs.getResponseDescription());

Serial.println(rs.code);

printParameters(configuration);
c.close();

###Wireless configuration

This device support wireless configuration with sepecial command, but seems not work, i ask to EBYTE but no response received.

I implement a command that send the packet in the correct way (tested with logic analizer) but seems not work.

By the way, first you muset activate RSSI noise environment, than you can use the command like so:

    Configuration configuration;
 
  configuration.ADDL = 0x13;
  configuration.ADDH = 0x13;
  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;

Thanks

Now you have all information to do your work, but I think It’s important to show some realistic examples to undestand better all the possibility.

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: settings and basic usage

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: library

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: configuration

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

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: power saving and sending structured data

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: repeater mode and remote settings

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: WOR microcontroller and Arduino shield

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: WOR microcontroller and WeMos D1 shield

  • Ebyte LoRa E22 device for Arduino, esp32 or esp8266: WOR microcontroller and esp32 dev v1 shield

ebyte_lora_e22_series_library's People

Contributors

xreef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebyte_lora_e22_series_library's Issues

esp32-idf

Do you intend to support the library esp32-idf?

NodeMCU wiring

Hi,

Thank you for your great work.

I'm using E22-900T30S with NodeMCU V3, so I guess I should use the wiring and code for esp8266.
Here is my wiring:

E22	esp8266
------------------
M0	D7
M1	D6
TX	PIN D2 (PullUP 4,7KΩ)
RX	PIN D3 (PullUP 4,7KΩ)
AUX     PIN D5 (PullUP 4,7KΩ)
VCC	3.3v
GND	GND

To get started I use the esp8266_e22_getConfiguration code.
But got error:

No response from device! (Check wiring)
12
----------------------------------------
HEAD : 0 0 0
 
AddH : 0
AddL : 0
NetID : 0
 
Chan : 0 -> 410MHz
 
SpeedParityBit     : 0 -> 8N1 (Default)
SpeedUARTDatte     : 0 -> 1200bps
SpeedAirDataRate   : 0 -> 0.3kbps
 
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: 0 -> Transparent transmission (default)
----------------------------------------
No response from device! (Check wiring)
12
----------------------------------------
HEAD: 0 0 0
Model no.: 61
Version  : 72
Features : 65
----------------------------------------

Did I do something wrong? Or NodeMCU if supported use different wiring?

Thanks

E22-900M30S support

Hi,
I have E22-900M30S. It says it has SPI connection. I think serial should also be possible. What sketch should I use?

This code only works 72 times with arduino

`#include "LoRa_E22.h"
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);

/*
   Pinler     Arduino Nano    Lora E32 433T20d
                  11                3
                  10                4
*/

LoRa_E22 E22(&mySerial);

struct Signal {
  char type[4] = "Urfa";
  byte role[4];
} data;


#define M0 7
#define M1 6
#define BTN 2
#define LED 9


byte i = 0;

void setup() {
  pinMode(M0, OUTPUT);
  pinMode(M1, OUTPUT);
  digitalWrite(M0, LOW);
  digitalWrite(M1, LOW);

  Serial.begin(9600);
  E22.begin();

}

void loop() {

  struct Signal {
    char type[4] = "Urfa";
    byte role[4];
  } data;

  i = i + 1;

  *(int*)( data.role) = i;

  ResponseStatus rs = E22.sendFixedMessage(0, 1, 25, &data, sizeof(Signal));
//  Serial.println(rs.getResponseDescription());
  Serial.print ("data: "); Serial.println(i);

  delay(1000);
}`

this works until i = 72 after that struct is loosing itselfs

Output:

20:58:09.000 -> data: 1 20:58:10.118 -> data: 2 20:58:11.282 -> data: 3 20:58:12.404 -> data: 4 20:58:13.529 -> data: 5 20:58:14.649 -> data: 6 20:58:15.813 -> data: 7 20:58:16.933 -> data: 8 20:58:18.051 -> data: 9 20:58:19.215 -> data: 10 20:58:20.331 -> data: 11 20:58:21.453 -> data: 12 20:58:22.571 -> data: 13 20:58:23.740 -> data: 14 20:58:24.860 -> data: 15 20:58:25.976 -> data: 16 20:58:27.140 -> data: 17 20:58:28.258 -> data: 18 20:58:29.375 -> data: 19 20:58:30.510 -> data: 20 20:58:31.673 -> data: 21 20:58:32.791 -> data: 22 20:58:33.913 -> data: 23 20:58:35.031 -> data: 24 20:58:36.190 -> data: 25 20:58:37.308 -> data: 26 20:58:38.427 -> data: 27 20:58:39.589 -> data: 28 20:58:40.705 -> data: 29 20:58:41.824 -> data: 30 20:58:42.941 -> data: 31 20:58:44.106 -> data: 32 20:58:45.226 -> data: 33 20:58:46.344 -> data: 34 20:58:47.506 -> data: 35 20:58:48.623 -> data: 36 20:58:49.741 -> data: 37 20:58:50.906 -> data: 38 20:58:52.020 -> data: 39 20:58:53.140 -> data: 40 20:58:54.306 -> data: 41 20:58:55.424 -> data: 42 20:58:56.540 -> data: 43 20:58:57.704 -> data: 44 20:58:58.821 -> data: 45 20:58:59.935 -> data: 46 20:59:01.099 -> data: 47 20:59:02.217 -> data: 48 20:59:03.370 -> data: 49 20:59:04.492 -> data: 50 20:59:05.608 -> data: 51 20:59:06.727 -> data: 52 20:59:07.890 -> data: 53 20:59:09.009 -> data: 54 20:59:10.126 -> data: 55 20:59:11.291 -> data: 56 20:59:12.408 -> data: 57 20:59:13.529 -> data: 58 20:59:14.692 -> data: 59 20:59:15.811 -> data: 60 20:59:16.925 -> data: 61 20:59:18.090 -> data: 62 20:59:19.210 -> data: 63 20:59:20.328 -> data: 64 20:59:21.447 -> data: 65 20:59:22.609 -> data: 66 20:59:23.729 -> data: 67 20:59:24.846 -> data: 68 20:59:26.012 -> data: 69 20:59:27.129 -> data: 70 20:59:28.243 -> data: 71 20:59:29.406 -> data: 72 20:59:30.523 -> data: y�UrfaI 20:59:31.639 -> da6 20:59:31.639 -> tz�UrfaJ

Need your help with transporting audio over Lora

I have been using your great library for testing range of Ebyte E22 modules and it works perfectly.

I have following sketch which send sine wave data over ESPNow wireless link and playing it on other side via headphone connected to ESP32's internal DAC. It works fine.

Now I want to send same sine wave data using E22 modules (broadcast mode) instead of ESPNow for longer range.

Is it possible ? If so can please show me example ?

My sketch is below:

#include <WiFi.h>
#include <esp_now.h>

#define lineIn ADC1_CHANNEL_0          // ADC 1 channel 0 GPIO36 for analog microphone connecttion
#define lineOut 25                     // DAC pin for headphone or amplified speaker connection
#define touchThreshold 50              // TTT (Touch To Transmit) threshold
#define audioBytes  240                // ESPNow allow upto 250 bytes packets

uint8_t audioData[audioBytes] = 
   
   // Sin wave
    {
    0x80, 0x83, 0x87, 0x8A, 0x8E, 0x91, 0x95, 0x98, 0x9B, 0x9E, 0xA2, 0xA5, 0xA7, 0xAA, 0xAD, 0xAF,
    0xB2, 0xB4, 0xB6, 0xB8, 0xB9, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBF, 0xBF, 0xC0, 0xBF, 0xBF, 0xBF,
    0xBE, 0xBD, 0xBC, 0xBB, 0xB9, 0xB8, 0xB6, 0xB4, 0xB2, 0xAF, 0xAD, 0xAA, 0xA7, 0xA5, 0xA2, 0x9E,
    0x9B, 0x98, 0x95, 0x91, 0x8E, 0x8A, 0x87, 0x83, 0x80, 0x7C, 0x78, 0x75, 0x71, 0x6E, 0x6A, 0x67,
    0x64, 0x61, 0x5D, 0x5A, 0x58, 0x55, 0x52, 0x50, 0x4D, 0x4B, 0x49, 0x47, 0x46, 0x44, 0x43, 0x42,
    0x41, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x49, 0x4B,
    0x4D, 0x50, 0x52, 0x55, 0x58, 0x5A, 0x5D, 0x61, 0x64, 0x67, 0x6A, 0x6E, 0x71, 0x75, 0x78, 0x7C
   };
  
// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

void OnDataRecv(const uint8_t * mac, const uint8_t *data, int len) {
  uint8_t audioIn;
  for (int i=0;i<len;i++) {
    audioIn += (uint8_t)data[i];
   dacWrite(lineOut, audioIn);
  }
}

void setup() {
  Serial.begin(115200);
  while(!Serial){};
  delay(500);
  Serial.println();

  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  esp_now_register_recv_cb(OnDataRecv);
 
  // Register peer
  esp_now_peer_info_t peerInfo;
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;
  
  // Add peer        
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }

  Serial.println("Setup complete, move over to the Loop");
}
 
void loop() {
  
  if (touchRead(12) < touchThreshold )
  {     
       // Send audio packet via ESP-NOW
       esp_err_t result = esp_now_send(broadcastAddress, (const uint8_t *) audioData, audioBytes); 
   }
} //End of Loop

Thanks.

Wrong interpretation of returned string on WRITE_CFG_PWR_DWN_LOSE

When saving configuration on E22 UART module, C2 is the command that saves settings only temporary (not on persistent memory).
Unfortunately, code does not understand that the response command is still C1 as per eByte datasheet, but expects it to be the same as the command sent (C2).

Configuration saves fine anyways.

if (RETURNED_COMMAND != ((Configuration *)&configuration)->COMMAND || REG_ADDRESS_CFG!= ((Configuration *)&configuration)->STARTING_ADDRESS || PL_CONFIGURATION!= ((Configuration *)&configuration)->LENGHT){

Potential memory leak

In LoRa_E22.cpp a buffer is allocated in each call

...
ResponseStructContainer LoRa_E22::receiveMessageComplete(const uint8_t size, bool rssiEnabled){
ResponseStructContainer rc;

rc.data = malloc(size);
   ...

However, in all of the samples, you appear not to release the memory, for example esp32_e22_04_SendFixedTransmission.ino:

...
if (e22ttl.available()>1) {
// read the String message
#ifdef ENABLE_RSSI
ResponseContainer rc = e22ttl.receiveMessageRSSI();
#else
ResponseContainer rc = e22ttl.receiveMessage();
#endif
...

Isn't rc.close() required to release the memory? Also, is there a way to avoid malloc() every time you receive a message to avoid fragmentation?

How many device can send data a center Simultaneously?

When I look at the information sheet of the e22 modules, it says that the buffer length is 1000 bytes and the subpackages of the Lora module can be reduced to 32 bytes. This is how I understand it 1 lora center can receive data from 1000/32 = 31 devices simultaneously. Please correct me if I'm wrong.

image

So, how can I retrieve data from these 30-odd points at the same time without losing data? I saw the following code "e32ttl.receiveMessageUntil();" on your website but I couldn't see the usage example. Can you make an example? In addition, what is the reading speed of Lora modules, that is, how long should the waiting time be between messages from 30 points, ideally.

Support E32868T30D based on SEMTECH's SX1276 RF

Hi there
i try setup E32868T30D Lora Module using this library with no success
is there any guide about how i can setup and get it work?
when i setup wiring and run arduinoGetConfiguration
i get now response from module check wiring
best regards

configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;

configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;

this commend not effect lora module parameters setting for E22 only transmitter works

actualy it work reverse, if I set receiver it goes transmitter mode and if I set transmitter it goes receiver mode

//configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_TRANSMITTER;
configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;

FREQUENCY_915 is incorrect

Thank you in advance!

'OPERATING_FREQUENCY' is set to 850
I set it to 902 in my copy of statesNaming.h
But I am not sure if that is correct.
Is it supposed to be bottom of the band?

#elif defined(FREQUENCY_868)
#define OPERATING_FREQUENCY 850
#elif defined(FREQUENCY_915)

// This is incorrect? #define OPERATING_FREQUENCY 850. <<<<<
#define OPERATING_FREQUENCY 902 // LORA_HBO 2022-12-27
#else
#define OPERATING_FREQUENCY 410
#endif

setConfiguration reports
Chan : 0 -> 902MHz

https://www.baranidesign.com/faq-articles/2019/4/23/lorawan-usa-frequencies-channels-and-sub-bands-for-iot-devices

configuration.getChannelDescription() reports wrong E22 frequency

I'm using some E22-900T30D modules. When I run your example at

https://github.com/xreef/EByte_LoRa_E22_Series_Library/tree/master/examples/esp32_e22_setConfiguration)
/esp32_e22_setConfiguration.ino

it returns Chan : 23 -> 433MHz, when I expect it to return 850 + 23 -> 873MHz.

Does this matter? In other words, is it just informational, or does it result in wrong commands to the module?

A related problem is it returns an error "POWER_30 was not declared" when attempting to set the configuration to POWER_30. I can't find "#define E22_22" or "#define E22_30" in the repository so I guess TRANSMISSION_POWER gets enumerated as though for E22-400 in line 467 of statesNaming.h. Adding "#define FREQUENCY_915" and "#define E22_30" in the example code seems to fix it.

Guru meditation error triggered within receiveStruct routine(s)

Hello,

I am using your library in a project that has an ESP32 in the master device and a Raspberry Pi PICO in the slave device.

The modules I am using are the E22-900T30S.

I am using the platformIO environment and have enabled the exception decoder to help diagnose the dump provided by the ESP32 when the Guru Meditation error occurs.

The the system operates for some time (say 5 minutes or more) where the master is sending packets to the slave and the slave responds. This is occuring at about 3 times per second.

When the crash occurs, this is the exception decode captured:

Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x400db8af PS : 0x00060b30 A0 : 0x80112d00 A1 : 0x3ffca3f0
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000074 A5 : 0x3ffc1fc0
A6 : 0x00060120 A7 : 0x00000001 A8 : 0x800db8ac A9 : 0x3ffca3d0
A10 : 0x00000000 A11 : 0x00001800 A12 : 0x3f40bb9e A13 : 0x00000003
A14 : 0x00000008 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4008626c LEND : 0x40086276 LCOUNT : 0x00000000

Backtrace:0x400db8ac:0x3ffca3f00x40112cfd:0x3ffca410 0x400da07d:0x3ffca430 0x400da4f0:0x3ffca450 0x400da59c:0x3ffca490 0
x400d6533:0x3ffca4c0

#0 0x400db8ac:0x3ffca3f0 in Stream::readBytes(char*, unsigned int) at C:/Users/T520/.platformio/packages/framework-ar
duinoespressif32/cores/esp32/Stream.cpp:286
#1 0x40112cfd:0x3ffca410 in Stream::readBytes(unsigned char*, unsigned int) at C:/Users/T520/.platformio/packages/fra
mework-arduinoespressif32/cores/esp32/Stream.h:103
#2 0x400da07d:0x3ffca430 in LoRa_E22::receiveStruct(void*, unsigned short) at lib/EByte_LoRa_E22_Series_Library/LoRa_
E22.cpp:463
#3 0x400da4f0:0x3ffca450 in LoRa_E22::receiveMessageComplete(unsigned char, bool) at lib/EByte_LoRa_E22_Series_Librar
y/LoRa_E22.cpp:781
#4 0x400da59c:0x3ffca490 in LoRa_E22::receiveMessageRSSI(unsigned char) at lib/EByte_LoRa_E22_Series_Library/LoRa_E22
.cpp:774
#5 0x400d6533:0x3ffca4c0 in Task_RadioLink(void*) at src/main.cpp:558

As you can see, the top level call is to receiveMessageRSSI()

I have a struct that I am passing and this is 116 bytes long.

I was using the following in my call;

rsc = e22ttl.receiveMessageRSSI(sizeof(padControllerData));

but due to this problem occuring I thought I should try a dedicated variable set to this size

rsc = e22ttl.receiveMessageRSSI(padControllerDataSize); where padControllerDataSize is defined as an unsigned char

This has had no effect.

I then looked into your library and found the call I believe is causing this fault: (I added some debug prints to help isolate the issue)

`Status LoRa_E22::receiveStruct(void *structureManaged, uint16_t size_) {
Status result = E22_SUCCESS;

DEBUG_PRINT(" structure size: ");		// added CS 9/11
DEBUG_PRINTLN(size_);					// added CS 9/11
DEBUG_PRINT("calling readBytes ");      // added CS 9/11

uint8_t len = this->serialDef.stream->readBytes((uint8_t *) structureManaged, size_);

DEBUG_PRINT("Available buffer: ");
DEBUG_PRINT(len);

/* DEBUG_PRINT(" structure size: ");
DEBUG_PRINTLN(size_);
*/
if (len!=size_){
if (len==0){
result = ERR_E22_NO_RESPONSE_FROM_DEVICE;
}else{
result = ERR_E22_DATA_SIZE_NOT_MATCH;
}
}
if (result != E22_SUCCESS) return result;

result = this->waitCompleteResponse(1000);
if (result != E22_SUCCESS) return result;

return result;

}
`

The last debug just prior to the Guru Meditation error is:

structure size: 116
calling readBytes Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

So this shows the error is occuring on the call;

uint8_t len = this->serialDef.stream->readBytes((uint8_t *) structureManaged, size_);

Is there something that can be done to ensure the pointer 'structureManaged' is valid before making this call to readBytes?

Super keen to get assistance on this as my project is not stable or usable with this error.

How to add key for e22 lora modules

Well i can cahnge all parameters with your library thanks 🙏. But i cant change the password which is key labelled as at the Rf setting software.

Screenshot_20230110_044234_Chrome

Use the module to send data to TTN

Hello, is there any information available regarding the usage with ttn? Can't find anything about that in the repo like AppKey, EUI etc..

Warning : Save mode returned not recognized!

Hello, I set up esp32 and e22 400t 20d model as described and I open setConfiguration example I upload code. I see "save mode returned not recognized" warning on the serial monitor. What can i do to fix it ?

ESP32-E22 No response from device

Hello,
First of all thank you for your work in this library, looks good!
I am having E22 Connected to ESP 32 I loaded couple examples, I have the following definition for ESP32 pins:
// ---------- esp32 pins --------------
LoRa_E22 e22ttl100(&Serial2, 15, 21, 19); // RX AUX M0 M1
I Always gets "No response from device! (Check wiring)"
wiring is ok.
Module actually transmits, I am able to see when transmitting using SDR sharp.
I just get the error at initialization.
I also tried the example Arduino_e22_getConfiguration, and I got this:

No response from device! (Check wiring)
12
No response from device! (Check wiring)
12

Model no.: 112
Version : 111
Features : 1101110

these are my connections with ESP32

  • E22 ----- esp32
  • M0 ----- 21
  • M1 ----- 19
  • RX ----- TX2 (PullUP, 4.7k)
  • TX ----- RX2 (PullUP, 4.7k )
  • AUX ----- 15 (PullUP 4.7k)
  • VCC ----- 3.3v
  • GND ----- GND

Build error on

I am receiving a build error on the EByte library. It is related to the following conflict.
termios.h:
#define B110 3

binary.h:
#define B011 3
#define B110 6

Building this LoRa library generates the following error when the VFS framework for ESP32 is included.
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h: In function 'String getUARTBaudRateDescriptionByParams(byte)':
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h:157:4: error: duplicate case value
case UART_BPS_57600:
^
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h:148:4: error: previously used here
case UART_BPS_9600:
^
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h: In function 'String getAirDataRateDescriptionByParams(byte)':
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h:203:4: error: duplicate case value
case AIR_DATA_RATE_110_384:
^
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h:194:4: error: previously used here
case AIR_DATA_RATE_011_48:
^
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h: In function 'String getWORPeriodByParams(byte)':
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h:294:4: error: duplicate case value
case WOR_3500_000:
^
C:\Users\blue_\Documents\Arduino\libraries\EByte_LoRa_E22_Series_Library-master/includes/statesNaming.h:285:4: error: previously used here
case WOR_2000_011:
^

I have detailed the source of the problem in the following ticket. But I don't anticipate it being fixed any time soon.

espressif/esp-idf#7678 (comment)

The best workaround for this is to avoid using the BXXX macros for your enumerations in statesNaming.h. This will resolve the problem.

questions about E22-900M22S

Hello,
I am looking into the E22-900M22S chip. Can i use it with your library?
Also, in your examples you use the E22-900T22S U chip which has the pins M0, M1 and AUX but the E22-900M22S has DI01 and DIO2 and BUSY. Can i assume that DIO1 is M0, DIO2 is M1 and BUSY is AUX?

thanks

Help

416027946_1106567173810547_8344353452171204456_n

Hello im trying to use this code for the receiver with the connections above

#define E22_30
#define FREQUENCY_868

#include "Arduino.h"
#include "LoRa_E22.h"

LoRa_E22 e22ttl(3, 1, &Serial2, 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);

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

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

configuration.ADDL = 0x18; // First part of address
configuration.ADDH = 0x00; // Second part
configuration.NETID = 0x00; // NETID used for repeater function
configuration.CHAN = 18;
configuration.OPTION.transmissionPower = POWER_24;
}

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){
rc.status.getResponseDescription();
}else{
// Print the data received
Serial.println(rc.data);
}
}
if (Serial.available()) {
String input = Serial.readString();
e22ttl.sendMessage(input);
}
delay(5000);
}

Compile Error for STM32 Core for Arduino

Hello I know this libary is not supposed to work with STM32 but it does with a little fix.
Right now there is a conflict in naming:
statesNaming.h:20:13: error: 'SUCCESS' conflicts with a previous declaration 20 | SUCCESS = 1,
with
stm32f1xx.h:166:3: note: previous declaration 'ErrorStatus SUCCESS' 166 | SUCCESS = 0U,

The compile error can be avoided if SUCCESS gets renamed.

No support for 0.3k and 1k2 modes in E22 modules V2.1 (and V2.0)

Hello, this is not a bug in library itself, just a warning and maybe suggestion for enhancement (adding the check or documentation). The new V2.1 modules (PCB versions 10498-V1.1 and 10497-V1.0) - and after confirming from EBYTE also the V2.0 modules - do not correctly set up speeds 0.3k and 1k2 and silently ignore the setting (they probably stay at the 2k4 speed like E220s). It seems the SX127x has been replaced in them by LLCC68 inside, which does not support spreading factors needed by these modes.

They can be identified by querying register 0x82 (C1 82 01), which returns 0x40 instead of 0x10 or 0x11 seen in previous versions. Older modules set to these speeds cannot communicate with the V2.1 ones on these speeds and vice versa.

I had this just confirmed from EBYTE, my guess is that they are in fact re-labeled E220-400T30D/E220-900T30D modules with modified interface to observe E22 communication protocol and register map

So my suggestion is adding a warning to README.md concerning those speeds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.