ESP32 and LoRa

malcmail
Posts: 6
Joined: Tue May 16, 2023 1:56 pm

ESP32 and LoRa

Postby malcmail » Tue May 16, 2023 2:06 pm

New here, and fairly new to the whole electronics thing but giving some projects a go.

Right now I have an ESP32-WROOM-32 from AZ Delivery which I've been having fun with. Recently picked up a LoRa module (this one https://uk.farnell.com/seeed-studio/113 ... derack-GLB) but can't for the life of me get any joy. I have taken the Grove connector and jammed some leads in the end and attached them to 3.3v, GND, the RX to pin 16 and the TX to pin 17 (following the pin diagram these should be UART2).

Then I have this code:

Code: Select all

#include <RH_RF95.h>

#define RX_PIN 16
#define TX_PIN 17

int led = 13;

RH_RF95 rf95(TX_PIN, RX_PIN); // Initialize RH_RF95 object with specified TX and RX pins

void setup() {
  Serial.begin(115200);
  while (!Serial);
  Serial.println("RF95 server test.");

  if (!rf95.init()) {
    Serial.println("init failed");
    while (1);
  }

  rf95.setFrequency(434.0);
}

void loop() {
  if (rf95.available()) {
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (rf95.recv(buf, &len)) {
      digitalWrite(led, HIGH);

      Serial.print("got request: ");
      Serial.println((char*)buf);

      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");

      digitalWrite(led, LOW);
    } else {
      Serial.println("recv failed");
    }
  }
}
In the serial monitor I see that the init has failed. That at least is a massive improvement on what I've had for 2 days but I can't get passed it. Does anyone have any ideas? TIA.

a2800276
Posts: 78
Joined: Sat Jan 23, 2016 1:59 pm

Re: ESP32 and LoRa

Postby a2800276 » Wed May 17, 2023 11:41 am

Lora is a pretty horrid technology to work with. You'll spend a lot of time banging your head.

Since you don't mention what error you're getting specifically or what you're trying to accomplish, there's not much more we can do than to commiserate and wish you good luck and patience.

MicroController
Posts: 1710
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 and LoRa

Postby MicroController » Wed May 17, 2023 12:23 pm

What driver library are you using?

Looking at https://github.com/Seeed-Studio/Grove_L ... server.ino it seems you'd have to parametrize & initialize the RH_RF95 with an instance of a serial port. But then again, this library does not mention support for ESP chips.

a2800276
Posts: 78
Joined: Sat Jan 23, 2016 1:59 pm

Re: ESP32 and LoRa

Postby a2800276 » Wed May 17, 2023 2:03 pm

What driver library are you using?
I'm not using Arduino. Previously, I used an lmic based idf library (forgot which one specifically at the moment) and am currently writing my own because all the existing options are terrible/hubris.
But then again, this library does not mention support for ESP chips.
That should not make a difference, the whole point of Arduino is to abstract all that away (though from the code you linked to, it looks like you may need to make some tweaks : ). I'd consider asking in a forum specialized either on that grove sensor or the radiohead library. Are you using the specific grove sensor? I'm asking because the rfm95 sensors I've come across all use SPI and that sample code is using serial...

In case micropython is an option for you Freakwan might be an alternative. It's by far the sanest Lora implementation I've come across. (And the sx1276 is the same chip as the rfm95)

malcmail
Posts: 6
Joined: Tue May 16, 2023 1:56 pm

Re: ESP32 and LoRa

Postby malcmail » Wed May 17, 2023 2:51 pm

a2800276 wrote:
Wed May 17, 2023 11:41 am
Lora is a pretty horrid technology to work with. You'll spend a lot of time banging your head.

Since you don't mention what error you're getting specifically or what you're trying to accomplish, there's not much more we can do than to commiserate and wish you good luck and patience.
All I have is the serial monitor giving the statement, from the code, that the init has failde so i guess its this bit of code that is dying somehow

Code: Select all

 if (!rf95.init()) {
    Serial.println("init failed");
    while (1);
  }


All I am trying to do right now is get it to be live ie initialise and be ready.

malcmail
Posts: 6
Joined: Tue May 16, 2023 1:56 pm

Re: ESP32 and LoRa

Postby malcmail » Wed May 17, 2023 2:55 pm

MicroController wrote:
Wed May 17, 2023 12:23 pm
What driver library are you using?

Looking at https://github.com/Seeed-Studio/Grove_L ... server.ino it seems you'd have to parametrize & initialize the RH_RF95 with an instance of a serial port. But then again, this library does not mention support for ESP chips.
Tried a few. When I get back I'll see which one it is and get back to you

malcmail
Posts: 6
Joined: Tue May 16, 2023 1:56 pm

Re: ESP32 and LoRa

Postby malcmail » Wed May 17, 2023 2:57 pm

a2800276 wrote:
Wed May 17, 2023 2:03 pm
What driver library are you using?
I'm not using Arduino. Previously, I used an lmic based idf library (forgot which one specifically at the moment) and am currently writing my own because all the existing options are terrible/hubris.
But then again, this library does not mention support for ESP chips.
That should not make a difference, the whole point of Arduino is to abstract all that away (though from the code you linked to, it looks like you may need to make some tweaks : ). I'd consider asking in a forum specialized either on that grove sensor or the radiohead library. Are you using the specific grove sensor? I'm asking because the rfm95 sensors I've come across all use SPI and that sample code is using serial...

In case micropython is an option for you Freakwan might be an alternative. It's by far the sanest Lora implementation I've come across. (And the sx1276 is the same chip as the rfm95)
The serial is simply from the fact that the board has the Grove UART socket on it. Seemed like the easy play. Oh how wrong was I??

a2800276
Posts: 78
Joined: Sat Jan 23, 2016 1:59 pm

Re: ESP32 and LoRa

Postby a2800276 » Fri May 19, 2023 11:19 am

The serial is simply from the fact that the board has the Grove UART socket on it. Seemed like the easy play. Oh how wrong was I??
Presumably fairly wrong, because there is no such thing as a Grove UART socket :? Grove connectors are the same for any supported protocol. Like I said: Lora really sucks, I wasn't kidding. Again, you would need to provide more details, e.g. which Lora board and esp board you are using because, unfortunately, I can't read your mind.

Incidentally: have you had a look at the Radiohead documentation for the library you are trying to use and checked what needs to be provided to the RF95 constructor?

malcmail
Posts: 6
Joined: Tue May 16, 2023 1:56 pm

Re: ESP32 and LoRa

Postby malcmail » Sun May 21, 2023 9:18 pm

a2800276 wrote:
Fri May 19, 2023 11:19 am
The serial is simply from the fact that the board has the Grove UART socket on it. Seemed like the easy play. Oh how wrong was I??
Presumably fairly wrong, because there is no such thing as a Grove UART socket :? Grove connectors are the same for any supported protocol. Like I said: Lora really sucks, I wasn't kidding. Again, you would need to provide more details, e.g. which Lora board and esp board you are using because, unfortunately, I can't read your mind.

Incidentally: have you had a look at the Radiohead documentation for the library you are trying to use and checked what needs to be provided to the RF95 constructor?

The ESP32 board is this one https://www.amazon.co.uk/dp/B07Z83H831? ... ct_details
The LoRa is this one https://uk.farnell.com/seeed-studio/113 ... derack-GLB (with Grove connector so when it said UART in the description I presumed it was effectively providing UART over it). Not looked at the RadioHead library as it was the Grove LoRa library in the tutorial on https://www.farnell.com/datasheets/3759204.pdf Haven't had any further luck with this (albeit time has been very limited on it this week).

a2800276
Posts: 78
Joined: Sat Jan 23, 2016 1:59 pm

Re: ESP32 and LoRa

Postby a2800276 » Mon May 22, 2023 6:22 am

Ah. The Lora module you linked to has its own atmega on board, so you may be able to use it directly without an esp32. This may even be the expected mode of operation.

Unfortunately that documentation is really a pain to read though, and you are right, they mention UART and are configuring TX and RX into Radiohead.

The Radiohead docs I linked to assume an SPI connection, though.

So who knows where the truth lays?

My only advice at this point it: carefully read the god-awful Seeed datasheet and try to get the Lora module running without the ESP first. Also, there's a reference to the Seeed technical forum that might be better suited for questions concerning this particular module.

Good luck!

Who is online

Users browsing this forum: No registered users and 51 guests