I have 2 esp32-c6 devboards and i am using the below code.
I am facing 2 issues
1.)Whenever sender is trying to send data and making AUX High, i get Serial disconnected.
2.)Receiver Unit is not receiving the data.
Sending Data
//Sender
#include "Arduino.h"
#define E32_TTL_1W
#include "LoRa_E32.h"
#define AUX 23
#define M0 10
#define M1 11
//HardwareSerial serial1(2);
//LoRa_E32 e32ttl1w(&serial1,RX,TX, 18, UART_BPS_RATE_9600,SERIAL_8N1);
LoRa_E32 e32ttl1w(&Serial1, AUX, M0, M1);
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() {
//Inicio comunicacion serie con monitor
Serial.begin(9600);
delay(500);
Serial.println();
e32ttl1w.begin();
//Configuro el nodo LoRa
nodeConfig();
}
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);
ResponseStatus rs = e32ttl1w.sendFixedMessage(0x0, 0x3, 0x4, trama);
Serial.println("Sending " + trama);
Serial.println(rs.getResponseDescription());
lastSendTime = millis(); // timestamp the message
msgCount++;
}
delay(100);
}
void nodeConfig(){
ResponseStructContainer c;
c = e32ttl1w.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDH = 0x0;
configuration.ADDL = 0x1;
configuration.CHAN = 0x4;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.fec = FEC_1_ON;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.transmissionPower = POWER_21;
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_SAVE);
Serial.print("Config: ");
Serial.println(rs.getResponseDescription());
}
Receiver Unit Code
//Receiver Code
#include "Arduino.h"
#define E32_TTL_1W
#include "LoRa_E32.h"
#define AUX 1
#define M0 10
#define M1 11
LoRa_E32 e32ttl1w(&Serial1, AUX, M0, M1);
void setup() {
//Inicio comunicacion serie con monitor
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e32ttl1w.begin();
//Configuro el nodo LoRa
nodeConfig();
//delay(4000);
//fetchConfig();
}
void loop() {
if (e32ttl1w.available() > 0) {
Serial.println("———-");
ResponseContainer rc = e32ttl1w.receiveMessage();
// If something goes wrong print error
if (rc.status.code != 1) {
rc.status.getResponseDescription();
} else {
// Print the data received
Serial.println(rc.data);
}
}
delay(100);
}
void nodeConfig() {
ResponseStructContainer c;
c = e32ttl1w.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
configuration.ADDH = 0x0;
configuration.ADDL = 0x3;
configuration.CHAN = 0x4;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.fec = FEC_1_ON;
configuration.OPTION.fixedTransmission = FT_FIXED_TRANSMISSION;
configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
configuration.OPTION.transmissionPower = POWER_30;
configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;
// Set configuration changed and set to not hold the configuration
Serial.println("Updtaed config is ");
ResponseStatus rs = e32ttl1w.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Serial.print("Config: ");
Serial.println(rs.getResponseDescription());
}
Hi,
the code is correct, the only thing you must do is close the ResponseStructContainer c;
like so c.close();
Check the power supply. The 1W module needs a lot of power to work, so now use an external power supply and add a 100uF electrolytic capacitor (or more) and a 0.1uF ceramic capacitor to it.
Then use a getConfiguration sketch and send me the result.
Bye Renzo
I’m using in my project an esp32 devkit v1 and also an E32-900t30d from Ebyte. I would like to test your sender and receiver codes but my question is: which pins are you using in your esp32 for Vcc, gnd, aux, txd, rxd, m0 and m1?
Another question is if the rxd and txd pins must be attached to the tx2 and rx2 respectively in the esp32.
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.