Interfacing LoRa and ESP32, Cannot connect to LoRa Module

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!!

Schematics would tell how. No idea to look at code before the hardware is found to be fault free.

1 Like

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

ESP32 serial1  test Rx pin 17 Tx pin 16
+AT: OK
+VER: 4.0.11
+ID: DevAddr, xxxxxxxxxxxxx
+ID: DevEui, zzzzzzzzzzzzzzzzzzzzzz
+ID: AppEui, uuuuuuuuuuuuuuuuuu
1 Like

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

photo

looks like you may have the E5 TX and RX the wrong way around

1 Like

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.

is it to another Grove LoRa E5 module using point-to-point communication
if so have a look at Grove-LoRa-E5-P2P-Example

Hi, I'm having a similar issue, but can't debug it looking at your action. Do you have an advice in verifying that the device is not faulty?

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?

Hi @horace, thanks for your feedback.

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

It only says on it "Grove Lora Radio" 868 MHz and V1.0 09/09/2016

I still can't communicate and am not sure of the defaut baud rate (I assumed 9600 but could be different?)

could you post a photo of the module?
are you sure the Grove LoRa E5 is 868MHz?

some time since I used the Grove E5

  1. had it working communicating over LoRaWAN OTAA with the Things V3 server OK
  2. P2P tested with the Grove-LoRa-E5-P2P-Example - cannot find any results - not sure what I was communicating with

9600baud does appear to be the default

Here is the picture of my two "lora" module and one "lora E5"

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.

the two modules look like Grove - Long Range 868MHz RFM95 modules
can you get them to communicate with each other - sample code is in the link

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.

the code compiles OK for a UNO but gives the #include error for a ESP32 - looks as though it is not supported

post on the seeedstudio forum ???

EDIT: or get another E5?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.