ESP32 and Radiohead. Locks up after 1st transmission

I’m just familiarizing myself with the Wifi_Lora_32_v2 module and having a problem. I’m using the Arduino IDE (1.8.13) to program. Blink example program and serial communication are working fine. When I upload the Radiohead library example program (rf95_reliable_datagram_client), the Lora radio will transmit once and then the ESP32 locks up. It will not continue to send serial to my computer nor will the heartbeat LED blink. If I push RST button, then it will transmit once and lock up again.

My receiver is a Moteino (ATMEGA328 microcontroller with HopeRF RFM95W radio) running the RadioHead library. I cannot change this since I have many of these already running.

In the Boards Manager I have tried the Heltec settings:
https://resource.heltec.cn/download/package_heltec_esp32_index.json

and also the board settings from here. (recommended by Radiohead webpage)
https://dl.espressif.com/dl/package_esp32_index.json

The Radiohead library states the ESP32 is compatible under the Platforms section. I do receive the first transmission so I know there is some compatibility.
https://www.airspayce.com/mikem/arduino/RadioHead/

How can I avoid the lockup issue on the ESP32?
Thank you.

My test code:

// rf95_reliable_datagram_client.pde
// -- mode: C++ --
// Example sketch showing how to create a simple addressed, reliable messaging client
// with the RHReliableDatagram class, using the RH_RF95 driver to control a RF95 radio.
// It is designed to work with the other example rf95_reliable_datagram_server
// Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with the RFM95W

#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_RF95 driver;

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

uint8_t data[] = “Hello World!”;
// Dont put this on the stack:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];

void setup()
{
Serial.begin(38400);
while (!Serial) ; // Wait for serial port to be available
if (!manager.init())
Serial.println(“init failed”);
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
// driver.setTxPower(23, false);
// If you are using Modtronix inAir4 or inAir9,or any other module which uses the
// transmitter RFO pins and not the PA_BOOST pins
// then you can configure the power transmitter power for -1 to 14 dBm and with useRFO true.
// Failure to do that will result in extremely low transmit powers.
// driver.setTxPower(14, true);
// You can optionally require this module to wait until Channel Activity
// Detection shows no activity on the channel before transmitting by setting
// the CAD timeout to non-zero:
// driver.setCADTimeout(10000);

driver.setFrequency(915.0); //SHIFT FREQ TO MAKE HARDER TO INTERCEPT SIGNAL
driver.setTxPower(10, false);

pinMode(LED_BUILTIN, OUTPUT);
Serial.println(“starting”);
}

void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
Serial.println(“Sending to rf95_reliable_datagram_server”);

// Send a message to manager_server
if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
{
// // Now wait for a reply from the server
// uint8_t len = sizeof(buf);
// uint8_t from;
// if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
// {
// Serial.print(“got reply from : 0x”);
// Serial.print(from, HEX);
// Serial.print(": ");
// Serial.println((char*)buf);
}
// else
// {
// Serial.println(“No reply, is rf95_reliable_datagram_server running?”);
// }
// }
// else {
// Serial.println(“sendtoWait failed”);
// }

delay(750);
}

I finally found a solution at:
https://github.com/RattyDAVE/Arduino-Lora

For anybody else with a similar issue add lines:

#define SS 18
#define RST 14
#define DI0 26

then replace

RH_RF95 driver;

with

RH_RF95 driver(SS,DI0);

1 Like