Hello, I can’t get my LoRa e32 modules working. I have developed two sketch. One of them generates and sends a random number. The other reads the packet sent by writer. I am working with ESP32. Thanks in advance for your advice.
Sketch A, write
#include "Arduino.h"
#define E32_TTL_1W
#define FREQUENCY_915
#include
#include
#define RX 16
#define TX 17
#define M0 35
#define M1 32
HardwareSerial serial1(2);
LoRa_E32 e32ttl1w(&serial1,RX,TX, UART_BPS_RATE_9600,SERIAL_8N1);
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
// Variables globales
unsigned long interval = 15000; // interval between sends
unsigned long lastSendTime = 0; // last send time
byte msgCount = 0; // count of outgoing messages
long randNumber;
void setup() {
pinMode(M0, OUTPUT);
pinMode(M1, OUTPUT);
//Inicio comunicacion serie con monitor
Serial.begin(9600);
delay(500);
// Establezco M0 y M1 en alto para configurar LoRa
digitalWrite(M0, HIGH);
digitalWrite(M1, HIGH);
// Startup all pins and UART
e32ttl1w.begin();
//Configuro el nodo LoRa
nodeConfig();
// Establezco M0 y M1 en bajo para trabajar con LoRa
digitalWrite(M0, LOW);
digitalWrite(M1, LOW);
}
void loop() {
// Wait a few seconds between measurements.
if (millis() - lastSendTime > interval) {
// print a random number from 10 to 19
randNumber = random(10, 20);
String trama = String(randNumber);
e32ttl1w.sendFixedMessage(0, 3, 0x10,trama);
Serial.println("Sending " + trama);
lastSendTime = millis(); // timestamp the message
msgCount++;
}
delay(100);
}
void nodeConfig(){
ResponseStructContainer c;
ModuleInformation modInfo;
c = e32ttl1w.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDH = 0x0;
configuration.ADDL = 0x1;
configuration.CHAN = 0x10;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartBaudRate = UART_BPS_1200;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.fec = FEC_0_OFF;
configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.transmissionPower = POWER_30;
configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;
//printParameters(configuration);
// Set configuration changed and set to not hold the configuration
ResponseStatus rs = e32ttl1w.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
}
Sketch B
#include "Arduino.h"
#define E32_TTL_1W
#define FREQUENCY_915
#include
#include
#define RX 16
#define TX 17
#define M0 35
#define M1 32
HardwareSerial lora(2);
LoRa_E32 e32ttl1w(&lora,RX,TX, UART_BPS_RATE_9600,SERIAL_8N1);
void setup() {
pinMode(M0, OUTPUT);
pinMode(M1, OUTPUT);
//Inicio comunicacion serie con monitor
Serial.begin(9600);
delay(500);
// Establezco M0 y M1 en alto para configurar LoRa
digitalWrite(M0, HIGH);
digitalWrite(M1, HIGH);
// Startup all pins and UART
e32ttl1w.begin();
//Configuro el nodo LoRa
nodeConfig();
// Establezco M0 y M1 en bajo para trabajar con LoRa
digitalWrite(M0, LOW);
digitalWrite(M1, LOW);
}
void loop() {
if (e32ttl1w.available() > 0) {
Serial.println("----------");
ResponseContainer rc = e32ttl1w.receiveMessage();
Serial.println(rc.data);
// Is something goes wrong print error
if (rc.status.code != 1) {
rc.status.getResponseDescription();
} else {
// Print the data received
Serial.println(rc.data);
}
}
delay(500);
}
void nodeConfig(){
ResponseStructContainer c;
c = e32ttl1w.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDH = 0x0;
configuration.ADDL = 0x3;
configuration.CHAN = 0x10;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartBaudRate = UART_BPS_1200;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.fec = FEC_0_OFF;
configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.transmissionPower = POWER_30;
configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;
//printParameters(configuration);
// Set configuration changed and set to not hold the configuration
ResponseStatus rs = e32ttl1w.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
}
I check your code, and there are some issue, first is the type of communication setted to TRANSPARENT
But I have found an issue/problem in the library and I change It, two constructor of esp32 is ambiguous, so I change the disposition of the constructor that have specifies setting of HardwareSerial,
Hi Renzo. I appreciate your help.
But this is driving me nut. I’m almost ready to throw all this to hell.
I have to admit that perhaps part of the problem is mine.
Still I put all the desire to solve this and that both work.
As I said before I developed a test scenario.
One of them name “write” (from now on A) to generete a trame, the other one “read” (from now on B) to read the suppose trame write sends to the air.
I am working with two E32 915T30D (1W) and two ESP32 (Esspresif) kit V.1
M0 and M1 are managed by esp32 to put in High and Low (high to setup and low to work).
The sketch I send you is fully working and tested (I do it with an esp32 devkit v1 and WeMos, I try It with an Arduino also and 2 e32 433, that you can see on photo).
Pay attention I comment the first 2 define anche change power to adapt to my devices.
We can go by step, send me your connection schema, I’m going to do the same connection, and tell me what kind of pull-up resistor you have used.
My packet are longer than 58 bytes. As Ebyte says, 58 is not a limit, but the start to send the byte storage in the buffer. The length can be as long as I want. is it? or I am wrong?. Thanks for your clarification.
that if you receive more than one String message at the same time can read single message instead all message in the buffer.
but if you had the same doubt you too, I can try to send 58 bytes and then the rest.
But if the size is not relevant the upgraded version e22 (I’m doing the library now) have packet size variable (max 240byte) but if there are no limit why to manage packet size?
The single packet limit is 58 bytes. It means one transmission can only send 58 bytes. it will cut your data into serveral 58-byte packet to send.
The buffer is 512 bytes, it means you can input maximum 512 bytes of data by UART, and the module will cut the 512-byte of data into several packet to send all those 512 byte data in serveral times.
---------------------------------
Best Regards,
The packet size is 58Bytes if you put a stream of packet the device send they one to one not like a single package.
I think, a good feature to add to library it will be to send a packet longer than 58 bytes in several chunks of 58 bytes up to the total length, without overflow the internal buffer (512). I don’t know if you catch my idea. It is just very trivial, but very useful.
I mean, the function receive the packet with its original length (more than 58 bytes) and the function itself is in charge of divide it in chunk of 58 and send it. Obviousley the last it could be less than 58 bytes. It is a nice workaround and your library will be ok.
yes, can be an usefully features, but not so simple to develop, the message in the buffer can be not in sequence, and the order in a long transmission can change with the enviroenment condition.
// Set configuration changed and set to not hold the configuration
ResponseStatus rs = e32ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Serial.println(“Config: “);
Serial.print(rs.getResponseDescription());
}
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: share_your_ideas@mischianti.org
The content displayed on this website is protected under a CC BY-NC-ND license. Visitors are prohibited from using, redistributing, or altering any content from this website for commercial purposes, including generating revenue through advertising. Any unauthorized use is a violation of the license terms and legal action may be taken against individuals or entities found to be in violation.
You must also provide the link to the source.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.