Cannot receive data through LoRa between RAK 4631 and T-Beam

I am trying to send gas sensor values from RAK 4631 to T-Beam through LoraP2P. RAK 4631 uses the SX126x-RAK4630 Library for Lora and the T-Beam uses LoRa by sandeep mistry for Lora. I cannot seem to receive the data from the receiver.

#include <Adafruit_TinyUSB.h>
#include <SX126x-RAK4630.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Wire.h>
#include "ADC121C021.h"

//defining the functions for reading the gas sensor values
#define EN_PIN WB_IO6	 //Logic high enables the device. Logic low disables the device
#define ALERT_PIN WB_IO5 //a high indicates that the respective limit has been violated.
#define MQ2_ADDRESS 0x51 //the device i2c address
#define RatioMQ2CleanAir (1.0) //RS / R0 = 1.0 ppm
#define MQ2_RL (10.0)		   //the board RL = 10KΩ  can adjust

//defining the parameters for the lora peer to peer communication
// Define LoRa parameters
#define RF_FREQUENCY 923000000 // Hz
#define TX_OUTPUT_POWER 22		// dBm
#define LORA_BANDWIDTH 0		// [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
#define LORA_CODINGRATE 1		// [1: 4/5, 2: 4/6,  3: 4/7,  4: 4/8]
#define LORA_PREAMBLE_LENGTH 8  // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0   // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
#define RX_TIMEOUT_VALUE 5000 //changed from original value of 3000
#define TX_TIMEOUT_VALUE 5000 //changed from original value of 3000

//Lora function declarations
void OnTxDone(void);
void OnTxTimeout(void);

#ifdef NRF52_SERIES
#define LED_BUILTIN 35
#endif

//for mq2 sensor
ADC121C021 MQ2;
//for lorawan sensor
static RadioEvents_t RadioEvents;
static uint8_t TxdBuffer[64];

void setup()
{
  //mq2 sensor start
	pinMode(ALERT_PIN, INPUT);
	pinMode(EN_PIN, OUTPUT);
	digitalWrite(EN_PIN, HIGH); //power on RAK12004
	delay(5);
  //initialize the lora chip
  lora_rak4630_init();
	time_t timeout = millis();
	Serial.begin(115200);
	while (!Serial)
	{
		delay(100); //delaying for 100 milliseconds indefinitely
	}
	//********ADC121C021 ADC convert init ********************************
	while (!(MQ2.begin(MQ2_ADDRESS, Wire)))
	{
		Serial.println("please check device!!!");
		delay(200);
	}
	Serial.println("MQ2 gas sensor seems to be working fine");
  //testing the lora p2p test
  Serial.println("============");
  Serial.println("Lorap2p Tx Test");
  Serial.println("=========");

  //Initialize radio call backs
  RadioEvents.TxDone = OnTxDone;
  RadioEvents.RxDone = NULL; //since this is for transmission
  RadioEvents.TxTimeout = OnTxTimeout;
  RadioEvents.RxTimeout = NULL;
  RadioEvents.RxError = NULL;

  //Initialize the radio
  Radio.Init(&RadioEvents);

  //Set the radio channel
  Radio.SetChannel(RF_FREQUENCY);

  //Set Radio Tx configuration
  Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0 , LORA_BANDWIDTH, LORA_SPREADING_FACTOR, LORA_CODINGRATE, LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE);
  //send();
  delay(3000);
  //sending some data to establish connection

	//**************init MQ2 *****************************************************
	MQ2.setRL(MQ2_RL);
	/*
   *detect Propane gas if to detect other gas  need to reset A and B value,it depend on MQ sensor datasheet 
   */
	MQ2.setA(-0.890);			//A -> Slope, -0.685
	MQ2.setB(1.125);			//B -> Intersect with X - Axis  1.019
								//Set math model to calculate the PPM concentration and the value of constants
	MQ2.setRegressionMethod(0); //PPM =  pow(10, (log10(ratio)-B)/A)

	float calcR0 = 0;
	for (int i = 1; i <= 100; i++)
	{
		calcR0 += MQ2.calibrateR0(RatioMQ2CleanAir);
	}
	MQ2.setR0(calcR0 / 10);
	if (isinf(calcR0))
	{
		Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply");
		while (1)
			;
	}
	if (calcR0 == 0)
	{
		Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply");
		while (1)
			;
	}

	float r0 = MQ2.getR0();
	Serial.printf("R0 Value is:%3.2f\r\n", r0);
}
void loop()
{
	float sensorPPM;
	float PPMpercentage;
  float tempPPM; //need to fix this part

  //handle radio events
  Radio.IrqProcess();

	Serial.println("Getting Conversion Readings from ADC121C021");
	Serial.println(" ");
	sensorPPM = MQ2.readSensor();
  tempPPM = sensorPPM; //no need to fix this variable
	Serial.printf("sensor PPM Value is: %3.4f\r\n", sensorPPM);
	PPMpercentage = sensorPPM / 10000;
  sensorPPM = (round(tempPPM*100));
  sensorPPM = sensorPPM/100;
  Serial.printf ("The new rounded value of sensorPPM is %3.4f\r\n ", sensorPPM); //to test the value of the new rounded file
	Serial.printf("PPM percentage Value is:%3.2f%%\r\n", PPMpercentage);
	Serial.println(" ");
	Serial.println("        ***************************        ");
	Serial.println(" ");
  
  int intPart = (int)sensorPPM;
  float decPart = sensorPPM - (float)intPart;
  if (sensorPPM >= 1000 ){
    int temp = intPart;
    uint8_t ppmbuf[7];
    for (int i=3 ; i >=0  ; i--){
      ppmbuf[i] = temp % 10;
      temp /= 10;
    }
    ppmbuf[4] = 0;
    ppmbuf[5] =  (int)(decPart *100) / 10 ;
    ppmbuf[6] =  (int)(decPart *100) % 10;
    Radio.Send(ppmbuf, 7);
    //tesing lines
    Serial.println("The contents of the packet are :");
    for (int j=0 ; j <=6 ; j++){
      const char buffer = (char)ppmbuf[j];
      Serial.println(ppmbuf[j]);
    }
  }
  else {
    uint8_t ppmbuf[6];
    int temp = intPart;
    for (int i=2 ; i >= 0 ; i--){
      ppmbuf[i] = temp % 10;
      temp = temp / 10; 
    }
    ppmbuf[3] = 0;
    ppmbuf[4] = (int)(decPart *100) / 10;
    ppmbuf[5] = (int)(decPart *100) % 10;
    Radio.Send(ppmbuf, 6);
    //tesing lines
    Serial.println("The contents of the packet are :");
    for (int j=0 ; j <=5 ; j++){
      const char buffer = (char)ppmbuf[j];
      Serial.println(ppmbuf[j]);
    }
  }
	delay(60000);
  Serial.printf("The delay partt of the function has been reached");
  //yielld();
}

void OnTxDone(void){
  Serial.println("onTxDone");
  delay(15000);
  //send();
}

void OnTxTimeout(void)
{
  Serial.println("OnTxTimeout");
}

The Lora Receiver code is as below

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <LoRa.h>
//#include "Adafruit_SSD1306.h"

//defining the parameters for the lora peer to peer communication
#define SCK     5    // GPIO5  -- SX1278's SCK
#define MISO    19   // GPIO19 -- SX1278's MISO
#define MOSI    27   // GPIO27 -- SX1278's MOSI
#define SS      18   // GPIO18 -- SX1278's CS
#define RST     23   // GPIO14 -- SX1278's RESET
#define DI0     26   // GPIO26 -- SX1278's IRQ(Interrupt Request)
#define BAND    923E6

// //defining OLED pins
// #define OLED_SDA 21
// #define OLED_SCL 22
// #define SCREEN_WIDTH 128
// #define SCREEN_HEIGHT 64

//creating OLED display object
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
String LoraData;
String rssi = "RSSI --";
String packSize = "--";
String packet ;

//to display data on the lora screen
// void loraData(){
//   display.clearDisplay();
//   //display.setTextAlignment(TEXT_ALIGN_LEFT);
//   display.setTextColor(WHITE);
//   display.setCursor(0,0);
//   display.println("Received "+ packSize + " bytes");
//   display.display();
//   delay(2000);
//   display.clearDisplay();
//   display.setTextColor(WHITE);
//   display.setCursor(0,0);
//   display.println("Packet is "+ packet);
//   display.display();
//   delay(2000);
//   //display.drawStringMaxWidth(0 , 26 , 128, packet);
//   //display.drawString(0, 0, rssi); 
//   display.clearDisplay();
//   display.setTextColor(WHITE);
//   display.setCursor(0,0);
//   display.println("RSSI is "+ rssi);
//   display.display();
//   delay(2000);

// }
//function is called when the data has been received
// void cbk(int packetSize) {
//   packet ="";
//   packSize = String(packetSize,DEC);
//   for (int i = 0; i < packetSize; i++) { packet += (char) LoRa.read(); }
//   rssi = "RSSI " + String(LoRa.packetRssi(), DEC) ;
//   loraData();
// }

void setup()
{
	//pinMode(16, INPUT);
	//digitalWrite(16, LOW); 
	//delay(50);
  //digitalWrite(16, HIGH);
	Serial.begin(115200);
	while (!Serial)
	{
		delay(100); //delaying for 100 milliseconds indefinitely
	}
  //Wire.begin(OLED_SDA, OLED_SCL);
  // if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)){
  //   Serial.println("SSD1306 allocation failed");
  // }
	//********ADC121C021 ADC convert init ********************************
	Serial.println("Lora Receiver Callback");
  SPI.begin(SCK,MISO,MOSI,DI0);
  LoRa.setPins(SS,RST,DI0);
  LoRa.setSpreadingFactor(7);
  LoRa.setSignalBandwidth(125000);
  LoRa.setCodingRate4(1);
  LoRa.setPreambleLength(8);
  if(!LoRa.begin(BAND)){
    Serial.println("Starting Lora failed!");
    while(1);
  }
  //Lora signal has been received
  LoRa.receive();
  Serial.println("init ok");
  //display.begin();
  //display.flipScreenVertically();  
  delay(1500);
}
void loop()
{
	int packetSize = LoRa.parsePacket();
  Serial.printf("The tbeam has entered the loop cycle\n");
  if (packetSize) { 
    //received a packet
    //read packet
    while(LoRa.available()){
      LoraData = LoRa.readString();
      Serial.print(LoraData);
    }
    //print rssi of packet
    int rssi = LoRa.packetRssi();
    Serial.println(" with RSSI");
    Serial.println(rssi);
  }
  delay(10000);
}

On the serial monitor for the transmitter, it displays the sensor values and TxDone. On the receiver end, I can see that LoRa has started yet the device doesn't receive any values.

Thats a lot of program for someone to check for you.

Perhaps reduce the programs to a simple 'Hello World' type transmission and reception, with no sensors are displays.

An SDR is useful so that you can check that the transmitter actually is transmitting.

Also much much easier to have two identical LoRa devices so you can use the simple transmit and receive examples from the same library so that you can prove that both transmitter and receiver are actually working.

Oh yes I can understand that. I replaced the code with the hello world and it also doesn't work. I suspect because of something with the different libraries.
I actually tried to use the LoRa library by sandeep mistry for my transmitter as well but I there isn't clear enough information about the pin assignment.
Moreover, how can I use an SDR? Is it a software or a hardware device?
Thanks.

That library is for SX127X LoRa devices and wont work with a SX126X on the RAK 4631

Try this library;

https://github.com/StuartsProjects/SX12XX-LoRa

If you have the pins set correctly, including the SPI pin definitions for the T-Beam the basic examples from the SX127X part of the Library will work without change with the matching examples from the SX126X part of the library.

Try a Google search on 'how can I use an SDR?'

what is unclear regarding Pin assignment on the t-beam?
What exact hardware-revision of the t-beam are you using? Some newer ones have very specific power management IC and you have to activated the power for the lora module.

I just have a few more doubts about my code.

#define LORA_BANDWIDTH 0		// [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]

Here, do I define the bandwidth as '0' or as '125000' (The comment gives an option but the parameters could be different)

#define LORA_CODINGRATE 1		// [1: 4/5, 2: 4/6,  3: 4/7,  4: 4/8]

Similar question here. Do I enter the option number or direct coding rate?

int packetSize = LoRa.parsePacket();

This statement is in the setup part of the receiver code. However, I want to know if I need another statement which is LoRa.receive() before this in the loop for the device to receive the packet because in the sample code, LoRa.receive() was only in the setup code and the LoRa.parsePacket() was in the loop.

Thanks again!

The pin assignment on the T-beam isn't the problem I assume since the I don't get the error message "Lora failed" according to my program.
The problem I had earlier was the pin assignment of RAK 4631, SX1262 pin which I was planning to use for the LoRa library by Sandeep Mistry but as the above commenter mentioned, won't be necessary since that LoRa library only supports the SX127x LoRa devices.
For my RAK 4631, I used the standard LoRa library written for the core module specifically. I believe I have set all LoRa parameters properly yet the transmitter fails to receive any packets which leads me to believe that the library that I previously used (SX126x-RAK4630) is specifically designed for LoRa p2p with RAK modules only and not ESP32 based devices such as the T-Beam.

You might be right. Just spotted that the RAK4630 is a LoRaWAN module that 'supports' LoRa P2P, exactly how it does that is not clear.

LoRa P2P with standard LoRa SPI based modules is heaps easier.

Apologies for asking about this again. Do I keep the receiver code for the T-Beam unchanged as in keep the LoRa library and just use this library for the transmitter code(the RAK)?

Thanks

You can try it, but you still then have the problem of two potentially un-matched libraries and examples.

Which was the point of post #4; the examples quoted are known to be compatible between SX126X and SX127X, all you you need to do is get the pin definitions correct.

Hello I've been trying to get the programs to work but the pin definitions have a problem. For the RAK 4631 board, DIO2 pin needs to be set as RF switch control and DIO3 pin needs to be used as TCXO.
However, the library doesn't involve the DIO2 or DIO3 pins anywhere and hence the LoRa of the RAK 4631 would not work.

Which library ?

experimented using StuartsProjects/SX12XX-LoRa Library reference by @srnet in post 4

Heltec ESP32S3 LoRa (V3) SX1262 receiver running File>Examples>SX12XXLT_LoRa_library>SX126x_examples>ESP32>Basics>104_LoRa_Receiver_Detailed_Setup_ESP32 using Settings.h

// Heltec ESP32S3 LoRa (V3) SX1262 receiver 

/*******************************************************************************************************
  Programs for Arduino - Copyright of the author Stuart Robinson - 04/04/20

  This program is supplied as is, it is up to the user of the program to decide if the program is
  suitable for the intended purpose and free from errors.
*******************************************************************************************************/

//*******  Setup hardware pin definitions here ! ***************

//These are the pin definitions for one of my own boards, a ESP32 shield base with my BBF board shield on
//top. Be sure to change the definitions to match your own setup. Some pins such as DIO2, DIO3, BUZZER
//may not be in used by this sketch so they do not need to be connected and should be included and be 
//set to -1.

#define SCK 9                                  //SCK on SPI3
#define MISO 11                                 //MISO on SPI3 
#define MOSI 10                                 //MOSI on SPI3 

#define NSS 8                                   //select pin on LoRa device
#define NRESET 12                               //reset pin on LoRa device
#define RFBUSY 13                               //busy line

#define LED1 2                                  //on board LED, high for on
#define DIO1 14                                 //DIO1 pin on LoRa device, used for RX and TX done 

#define LORA_DEVICE DEVICE_SX1262               //we need to define the device we are using


//*******  Setup LoRa Parameters Here ! ***************

//LoRa Modem Parameters
const uint32_t Frequency = 866000000;           //frequency of transmissions in hertz
const uint32_t Offset = 0;                      //offset frequency for calibration purposes

const uint8_t Bandwidth = LORA_BW_125;          //LoRa bandwidth
const uint8_t SpreadingFactor = LORA_SF7;       //LoRa spreading factor
const uint8_t CodeRate = LORA_CR_4_5;           //LoRa coding rate
const uint8_t Optimisation = LDRO_AUTO;         //low data rate optimisation setting, normally set to auto

const int8_t TXpower = 10;                      //LoRa transmit power in dBm
const uint16_t packet_delay = 1000;             //mS delay between packets

#define RXBUFFER_SIZE 32                        //RX buffer size  

Heltec ESP32 LoRa (V2) SX1278 transmitter running File>Examples>SX12XXLT_LoRa_library>SX1278 transmitter>ESP32>Basics>3_LoRa_Transmitter_ESP32 using Settings.h

/*******************************************************************************************************
  Programs for Arduino - Copyright of the author Stuart Robinson - 20/01/20

  This program is supplied as is, it is up to the user of the program to decide if the program is
  suitable for the intended purpose and free from errors.
*******************************************************************************************************/

//*******  Setup hardware pin definitions here ! ***************

//These are the pin definitions for one of the Tracker boards, the ESP32_Micro_Node, be sure to change
//them to match your own setup. You will also need to connect up the pins for the SPI bus, which on the
//ESP32_Micro_Node are SCK on pin 18, MISO on pin 19 and MOSI on pin 23.

#define NSS 18                                   //select pin on LoRa device
#define SCK 5                                  //SCK on SPI3
#define MISO 19                                //MISO on SPI3 
#define MOSI 27                                 //MOSI on SPI3 

#define NRESET 14                               //reset pin on LoRa device
#define LED1 2                                  //on board LED, high for on
#define DIO0 26                                 //DIO0 pin on LoRa device, used for RX and TX done 
#define VCCPOWER 14                             //pin controls power to external devices

#define LORA_DEVICE DEVICE_SX1278               //we need to define the device we are using


//*******  Setup LoRa Parameters Here ! ***************

//LoRa Modem Parameters
const uint32_t Frequency = 866000000;           //frequency of transmissions in hertz
const uint32_t Offset = 0;                      //offset frequency for calibration purposes

const uint8_t Bandwidth = LORA_BW_125;          //LoRa bandwidth
const uint8_t SpreadingFactor = LORA_SF7;       //LoRa spreading factor
const uint8_t CodeRate = LORA_CR_4_5;           //LoRa coding rate
const uint8_t Optimisation = LDRO_AUTO;         //low data rate optimisation setting, normally set to auto

const int8_t TXpower = 10;                      //LoRa transmit power in dBm

const uint16_t packet_delay = 1000;             //mS delay between packets

Heltec ESP32 LoRa (V2) SX1278 transmitter serial monitor output

3_LoRa_Transmitter_ESP32 Starting
LoRa Device found

SX1278_PABOOST,866000000hz,SF7,BW125000,CR4:5,LDRO_Off,SyncWord_0x12,IQNormal,Preamble_8
SX1278_PABOOST,SLEEP,Version_12,PacketMode_LoRa,Explicit,CRC_On,AGCauto_On,LNAgain_1

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  EC 81 1A 0B 00 52 D8 80 00 4F 09 2B 23 01 00 00 
0x10  00 00 00 00 00 00 00 00 10 00 00 00 00 72 74 64 
0x20  00 08 FF FF 00 00 04 00 00 00 00 00 00 50 14 45 
0x30  55 C3 05 27 1C 0A 03 0A 42 12 49 1D 00 AF 00 00 
0x40  70 00 12 24 2D 00 03 00 04 23 00 09 05 84 32 2B 


Transmitter ready
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,63mS  PacketsSent,1
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,62mS  PacketsSent,2
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,62mS  PacketsSent,3
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,62mS  PacketsSent,4
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,62mS  PacketsSent,5
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,62mS  PacketsSent,6
10dBm Packet> Hello World 1234567890*  BytesSent,23  CRC,DAAB  TransmitTime,62mS  PacketsSent,7

Heltec ESP32S3 LoRa (V3) SX1262 receiver serial monitor output

104_LoRa_Receiver_Detailed_Setup_ESP32 Starting

LoRa Device found

SX1262,866000000hz,SF7,BW125000,CR4:5,LDRO_Off,SyncWord_0x1424,IQNormal,Preamble_8
SX1262,PacketMode_LoRa,Explicit,LNAgain_Boosted

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x900  30 00 00 00 00 64 00 00 00 00 00 00 24 04 47 04 
0x910  00 2F 00 00 00 03 0A 00 15 35 09 00 02 2A 6F 08 
0x920  07 04 05 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x930  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x940  00 07 00 03 02 00 10 00 0A 00 03 04 00 14 0C 00 
0x950  00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 
0x960  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x970  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x980  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x990  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x9A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x9B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x9C0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x9D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x9E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x9F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 


Receiver ready - RXBUFFER_SIZE 32

20s  Hello World 1234567890*,CRC,DAAB,RSSI,-29dBm,SNR,11dB,Length,23,Packets,1,Errors,0,IRQreg,16
21s  Hello World 1234567890*,CRC,DAAB,RSSI,-29dBm,SNR,11dB,Length,23,Packets,2,Errors,0,IRQreg,16
22s  Hello World 1234567890*,CRC,DAAB,RSSI,-29dBm,SNR,11dB,Length,23,Packets,3,Errors,0,IRQreg,16
23s  Hello World 1234567890*,CRC,DAAB,RSSI,-28dBm,SNR,11dB,Length,23,Packets,4,Errors,0,IRQreg,16
25s  Hello World 1234567890*,CRC,DAAB,RSSI,-27dBm,SNR,12dB,Length,23,Packets,5,Errors,0,IRQreg,16
26s  Hello World 1234567890*,CRC,DAAB,RSSI,-29dBm,SNR,11dB,Length,23,Packets,6,Errors,0,IRQreg,16

it is worth noting that a Adafruit FEather 32u4 Lora ( RFM95) using the arduino-LoRa library running

#include <SPI.h>
#include <LoRa.h>

void setup() {
  Serial.begin(115200);
  while (!Serial);

  Serial.println("LoRa Receiver");
  // void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);

  LoRa.setPins(8,4,7);   // for Lora 32u4

  if (!LoRa.begin(866E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

void loop() {
  // try to parse packet
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    // received a packet
    Serial.print("Received packet '");
    // read packet
    while (LoRa.available()) {
      Serial.print((char)LoRa.read());
    }

    // print RSSI of packet
    Serial.print("' with RSSI ");
    Serial.println(LoRa.packetRssi());
  }
}

also receive the signal

LoRa Receiver
Received packet 'Hello World 1234567890*' with RSSI -67
Received packet 'Hello World 1234567890*' with RSSI -66
Received packet 'Hello World 1234567890*' with RSSI -67
Received packet 'Hello World 1234567890*' with RSSI -66
Received packet 'Hello World 1234567890*' with RSSI -66
Received packet 'Hello World 1234567890*' with RSSI -66
Received packet 'Hello World 1234567890*' with RSSI -66

although I would not recommend using different libraries

For referance, a library for SX1216X modules, like that on the RAK 4631, should not need Arduino pin allocations for DIO2 and DIO3.

Yes these pins on the LoRa device are used by the LoRa device as RF switch control and for powering the TCXO, but that is handled internally by the SX126X driving the pins to control hardware on the module directly, the Arduino itself does not need to control these pins.

Hello! Thank you very much for the detailed response. I was also able to establish connection even with the different libraries.
I was confused with the pin definitions and the compatibility of the libraries with SX126x and SX127x chips but it also got cleared thanks to @srnet .