as @srnet stated mixing different LoRa modules/libraries etc can be difficult and one should start with a simple sent/receive example
for example, a simple receiver using a grove-E5 LoRa module connected to an ESP32 using the LoRaE5 library
// ESP32 <> Grove-E5 LoRa module
// example p2p_rx.ino from https://github.com/idreamsi/LoRaE5
#include <LoRaE5.h>
unsigned char buffer[128] = {0};
#define GROVE_TX 15//21
#define GROVE_RX 16//20
void setup(void)
{
Serial.begin(115200);
delay(2000);
Serial.println("ESP32 Grove-E5 receiver");
lora.init(GROVE_RX, GROVE_TX);
lora.init();
char id[200]={0};
char version[50]={0};
lora.getVersion(version, 50);
Serial.printf("Version = %s \n",version);
lora.getId(id, 200);
Serial.printf("ID = %s\n", id);
lora.initP2PMode(866, SF7, BW125, 12, 8, 8);
}
void loop(void)
{
short length = 0;
short rssi = 0;
memset(buffer, 0, 128);
length = lora.receivePacketP2PMode(buffer, 128, &rssi, 1);
if(length)
{
Serial.print("Length is: ");
Serial.println(length);
Serial.print("RSSI is: ");
Serial.println(rssi);
Serial.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
Serial.print("0x");
Serial.print(buffer[i], HEX);
Serial.print(" ");
}
Serial.println();
}
}
a Heltec ESP32 LoRa (V2) SX1278 transmitter using SX12XX-LoRa library (which should work with the LILYGO LoRa32 T3 V1.6.1 OK)
// Heltec ESP32 LoRa (V2) SX1278 transmitter
/*******************************************************************************************************
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.
*******************************************************************************************************/
/*******************************************************************************************************
Program Operation - This is a simple LoRa test transmitter for an ESP32 device. A packet containing
ASCII text is sent according to the frequency and LoRa settings specified in the 'Settings.h' file.
The pins to access the SX127X need to be defined in the 'Settings.h' file also.
The program also has the option of using a logic pin to control the power to the lora and SD card
devices, which can save power in sleep mode. If the hardware is fitted to your board these devices are
powered on by setting the VCCPOWER pin low. If your board does not have this feature set VCCPOWER to -1.
The details of the packet sent and any errors are shown on the Serial Monitor, together with the transmit
power used, the packet length and the CRC of the packet. The matching receive program, '4_LoRa_Receive'
can be used to check the packets are being sent correctly, the frequency and LoRa settings (in Settings.h)
must be the same for the Transmit and Receive program. Sample Serial Monitor output;
10dBm Packet> {packet contents*} BytesSent,23 CRC,DAAB TransmitTime,54mS PacketsSent,1
Serial monitor baud rate is set at 9600
*******************************************************************************************************/
#include <SPI.h> //the SX127X device is SPI based so load the SPI library
#include <SX127XLT.h> //include the appropriate library
#include "Settings.h" //include the setiings file, frequencies, LoRa settings etc
SX127XLT LT; //create a library class instance called LT
uint8_t TXPacketL;
uint32_t TXPacketCount, startmS, endmS;
uint8_t buff[] = "0Hello World 1234567890";
void loop()
{
Serial.print(TXpower); //print the transmit power defined
Serial.print(F("dBm "));
Serial.print(F("Packet> "));
Serial.flush();
TXPacketL = sizeof(buff); //set TXPacketL to length of array
buff[TXPacketL - 1] = '*'; //replace null character at buffer end so its visible on reciver
LT.printASCIIPacket(buff, TXPacketL); //print the buffer (the sent packet) as ASCII
digitalWrite(LED1, HIGH);
startmS = millis(); //start transmit timer
if (LT.transmit(buff, TXPacketL, 5000, TXpower, WAIT_TX)) //will return packet length sent if OK, otherwise 0 if transmit error
{
endmS = millis(); //packet sent, note end time
TXPacketCount++;
packet_is_OK();
}
else
{
packet_is_Error(); //transmit packet returned 0, there was an error
}
digitalWrite(LED1, LOW);
Serial.println();
// increment buff[0] or reset to '0'
if(buff[0]=='9') buff[0]='0';
else buff[0]++;
delay(5000);//packet_delay); //have a delay between packets
}
void packet_is_OK()
{
//if here packet has been sent OK
uint16_t localCRC;
Serial.print(F(" BytesSent,"));
Serial.print(TXPacketL); //print transmitted packet length
localCRC = LT.CRCCCITT(buff, TXPacketL, 0xFFFF);
Serial.print(F(" CRC,"));
Serial.print(localCRC, HEX); //print CRC of sent packet
Serial.print(F(" TransmitTime,"));
Serial.print(endmS - startmS); //print transmit time of packet
Serial.print(F("mS"));
Serial.print(F(" PacketsSent,"));
Serial.print(TXPacketCount); //print total of packets sent OK
}
void packet_is_Error()
{
//if here there was an error transmitting packet
uint16_t IRQStatus;
IRQStatus = LT.readIrqStatus(); //read the the interrupt register
Serial.print(F(" SendError,"));
Serial.print(F("Length,"));
Serial.print(TXPacketL); //print transmitted packet length
Serial.print(F(",IRQreg,"));
Serial.print(IRQStatus, HEX); //print IRQ status
LT.printIrqStatus(); //prints the text of which IRQs set
}
void led_Flash(uint16_t flashes, uint16_t delaymS)
{
uint16_t index;
for (index = 1; index <= flashes; index++)
{
digitalWrite(LED1, HIGH);
delay(delaymS);
digitalWrite(LED1, LOW);
delay(delaymS);
}
}
void setup()
{
pinMode(LED1, OUTPUT); //setup pin as output for indicator LED
led_Flash(2, 125); //two quick LED flashes to indicate program start
if (VCCPOWER >= 0)
{
pinMode(VCCPOWER, OUTPUT); //For controlling power to external devices
digitalWrite(VCCPOWER, LOW); //VCCOUT on. lora device on
}
Serial.begin(115200);
delay(3000);
Serial.println();
Serial.println(F("3_LoRa_Transmitter_ESP32 Starting"));
//SPI.begin(); //default setup can be used be used
SPI.begin(SCK, MISO, MOSI); //alternative format for SPI3, VSPI; SPI.begin(SCK,MISO,MOSI,SS)
//SPI beginTranscation is normally part of library routines, but if it is disabled in library
//a single instance is needed here, so uncomment the program line below
//SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
//setup hardware pins used by device, then check if device is found
if (LT.begin(NSS, NRESET, DIO0, LORA_DEVICE))
{
Serial.println(F("LoRa Device found"));
led_Flash(2, 125); //two further quick LED flashes to indicate device found
delay(1000);
}
else
{
Serial.println(F("No device responding"));
while (1)
{
led_Flash(50, 50); //long fast speed LED flash indicates device error
}
}
//The function call list below shows the complete setup for the LoRa device using the information defined in the
//Settings.h file.
//The 'Setup LoRa device' list below can be replaced with a single function call;
//LT.setupLoRa(Frequency, Offset, SpreadingFactor, Bandwidth, CodeRate, Optimisation);
//***************************************************************************************************
//Setup LoRa device
//***************************************************************************************************
LT.setMode(MODE_STDBY_RC); //got to standby mode to configure device
LT.setPacketType(PACKET_TYPE_LORA); //set for LoRa transmissions
LT.setRfFrequency(Frequency, Offset); //set the operating frequency
LT.calibrateImage(0); //run calibration after setting frequency
LT.setModulationParams(SpreadingFactor, Bandwidth, CodeRate, LDRO_AUTO); //set LoRa modem parameters
LT.setBufferBaseAddress(0x00, 0x00); //where in the SX buffer packets start, TX and RX
LT.setPacketParams(8, LORA_PACKET_VARIABLE_LENGTH, 255, LORA_CRC_ON, LORA_IQ_NORMAL); //set packet parameters
LT.setSyncWord(LORA_MAC_PRIVATE_SYNCWORD); //syncword, LORA_MAC_PRIVATE_SYNCWORD = 0x12, or LORA_MAC_PUBLIC_SYNCWORD = 0x34
LT.setHighSensitivity(); //set for highest sensitivity at expense of slightly higher LNA current
LT.setDioIrqParams(IRQ_RADIO_ALL, IRQ_TX_DONE, 0, 0); //set for IRQ on RX done
//***************************************************************************************************
Serial.println();
LT.printModemSettings(); //reads and prints the configured LoRa settings, useful check
Serial.println();
LT.printOperatingSettings(); //reads and prints the configured operating settings, useful check
Serial.println();
Serial.println();
LT.printRegisters(0x00, 0x4F); //print contents of device registers, normally 0x00 to 0x4F
Serial.println();
Serial.println();
Serial.print(F("Transmitter ready"));
Serial.println();
}
Heltec 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 34 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> 0Hello World 1234567890* BytesSent,24 CRC,3382 TransmitTime,62mS PacketsSent,1
10dBm Packet> 1Hello World 1234567890* BytesSent,24 CRC,481 TransmitTime,62mS PacketsSent,2
10dBm Packet> 2Hello World 1234567890* BytesSent,24 CRC,5D84 TransmitTime,62mS PacketsSent,3
10dBm Packet> 3Hello World 1234567890* BytesSent,24 CRC,6A87 TransmitTime,62mS PacketsSent,4
10dBm Packet> 4Hello World 1234567890* BytesSent,24 CRC,EF8E TransmitTime,62mS PacketsSent,5
10dBm Packet> 5Hello World 1234567890* BytesSent,24 CRC,D88D TransmitTime,62mS PacketsSent,6
type or paste code here
Grove-E5 receiver serial monitor output
ESP32 Grove-E5 receiver
Version =
ID = +ID: DevAddr, 42:00:33:26
+ID: DevEui, 2C:F7:F1:20:42:00:33:26
+ID: AppEui, 80:00:00:00:00:00:00:06
Length is: 24
RSSI is: -25
Data is: 0x30 0x48 0x65 0x6C 0x6C 0x6F 0x20 0x57 0x6F 0x72 0x6C 0x64 0x20 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x2A
Length is: 24
RSSI is: -25
Data is: 0x31 0x48 0x65 0x6C 0x6C 0x6F 0x20 0x57 0x6F 0x72 0x6C 0x64 0x20 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x2A
Length is: 24
RSSI is: -25
Data is: 0x32 0x48 0x65 0x6C 0x6C 0x6F 0x20 0x57 0x6F 0x72 0x6C 0x64 0x20 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x2A
Length is: 24
RSSI is: -25
Data is: 0x33 0x48 0x65 0x6C 0x6C 0x6F 0x20 0x57 0x6F 0x72 0x6C 0x64 0x20 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x2A
Length is: 24
RSSI is: -35
Data is: 0x34 0x48 0x65 0x6C 0x6C 0x6F 0x20 0x57 0x6F 0x72 0x6C 0x64 0x20 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x30 0x2A
once you have simple transmit/receive test working you know the hardware is working with the libraries etc and can start adding your project code
photo of test setup
