void setup() {
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 17, 16);
delay(2000); // Allow time for the setup
Serial.println("Loopback test started...");
// Send initial test message
sendCommand("AT");
delay(1000); // Wait for a response
// Check for response
if (Serial2.available()) {
String response = Serial2.readString();
Serial.println("Response: " + response);
// Clear serial buffer after reading
while (Serial2.available()) Serial2.read();
// Check responses for specific AT commands
if (response.startsWith("OK")) {
// Example: Send AT command to check firmware version
sendCommand("AT+VERSION");
} else if (response.startsWith("+AT: ")) {
// Process other AT command responses
// Example: Check firmware version
if (response.startsWith("+AT: v")) {
Serial.println("Firmware version: " + response.substring(5)); // Extract version number
}
// Example: Send AT command to check address
sendCommand("AT+ADDR?");
}
} else {
Serial.println("No response from LoRa module.");
}
}
void loop() {
// No need for code in the loop since this is a setup/test phase
}
void sendCommand(String cmd) {
Serial.print("Sending command: ");
Serial.println(cmd);
Serial2.println(cmd);
delay(1000); // Wait for a response
// Check for response
if (Serial2.available()) {
String response = Serial2.readString();
Serial.println("Response: " + response);
} else {
Serial.println("No response from LoRa module.");
}
}
Hi, I am trying to interface my Grove LoRa e5 Module to my ESP32 using this code. I believe that there is nothing wrong with the wiring, but running this code, I get this response; "No response from LoRa module". I have tried everything the net has advised and the problems still persists. I am not sure whether the problem lies in the hardware or firmware. I am relatively new to LoRa or in long distance communication in general. I hope that any of you could teach this young individual with what it needs to be done to get this LoRa setup working. Thanks!!
the sendCommand() function does not exist in the code of post 1
try the following
// ESP32 Serial1 test
// for loopback test connect pins 16 and 17
#define RXD1 17
#define TXD1 16
void setup() {
// initialize both serial ports:
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1);
Serial.println();
Serial.println("ESP32 serial1 test Rx pin 17 Tx pin 16");
}
void loop() {
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.write(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
//Serial.write(inByte);
Serial1.write(inByte);
}
}
a run when I enter commands AT< CR > then AT+VER< CR > then AT+ID< CR > displays on serial monitor
I've read the documentations about ESP32 and LoRa Module and found no problem with integrating them in my system. Though I haven't tried manual checking if there is fault in the ESP32 and LoRa. But I have already tried using a sensor that utilizes the same UART protocol as the LoRa which is the GPS Module with the same pin configuration (VCC - 3.3V, GND - GND, Pin17 - RX, and Pin16 - TX) and it works just fine.
The sendCommand() function is under the void loop() sir. It is a simple function used for sending AT Commands to the LoRa and display the responses in the serial monitor. I'm yet to try the code you just posted...
missed that!
if I run your code of post 1 on my ESP32 and Grove LoRa E5 I get
Loopback test started...
Sending command: AT
Response: +AT: OK
No response from LoRa module.
so the E5 is responding OK then your program gives no response error message
connections are
E5 VCC to ESP32 3.3V
E5 GND to ESP32 GND
E5 RX to ESP32 GPIO16
E5 TX to ESP32 GPIO17
Yess! Found out that that was the problem, and some typos (should I say) in sending my AT Commands. Thanks for that, I really appreciate it!! Now unto figuring out how I should send my sensor data to the receiver end of this setup.
confirm you are using a Grove LoRa e5 Module
what host microcontroller are you using?
how have you connected the modules together?
what software have you used to test the modules?
Your first question is to the point : I have one module Grove Lora E5 and one module Grove lora (not E5). Indeed I finally managed to have the system working with the grove lora E5, and I realized that this setup is not adequate for the "not" E5.
what is the module Grove lora (not E5)? e.g. E32, E220, ??
although it is (sometimes) possible to get different modules communicating (LoRa parameters have to be identical) it is generally wise to use the same LoRa module throughout the system
After working on them, I don't have a problem with the "Lora E5". It seems to be working as expecting and yes, it is 868 MHz. Unfortunately, I'm stuck with the "Lora", which is the one I have in double.
Yes, that is correct, that is the module. Unfortunately, I can't use the proposed code, because I'm using an NodeMCU ESP32 controller and I can't compile the code.
It stops with the error "#include <util/atomic.h>"
I realize that my attempt to use a similar code than with the E5-lora with a direct serial communication could not be successful because the "lora Long Range" require UART to SPI conversion functions. So I am stuck because my ESP32 is not compatible with the provided conversion library from seeedstudio.