Wifi LoRa 32 V3: LoRa not working

I am an employee doing some research utilizing the Wifi LoRa 32 V3 board as command communication. I have used the V2 version of the board in the past and had success. Recently my boss and I upgraded to the V3 version, uploaded the LoRa Sending and Receiving code into two different boards, set them both to the same transmission frequency, and then no communication occurred. The boards I received were both the 863~928 frequency boards, so I set the frequency to 915E6 (915 MHz). The code I am using for the sender is as follows:
#include <SPI.h>
#include <LoRa.h>

int counter = 0;

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

Serial.println(“LoRa Sender”);

if (!LoRa.begin(915E6)) {
Serial.println(“Starting LoRa failed!”);
while (1);
}
}

void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);

// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();

counter++;

delay(5000);
}
The code for the receiver is:
#include <SPI.h>
#include <LoRa.h>

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

Serial.println(“LoRa Receiver”);

if (!LoRa.begin(915E6)) {
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());

}
}
The sketches are compiled and then uploaded successfully, but when I power both devices no communication ensues. Any advice on what to do going forward?

The LoRa.h library does not support the SX1262 LoRa node chip in the V3 modules. You need to be using either the Heltec LoRaWan_APP.h library or another library, like the RadioLib.h library, that provides support fo the SX1262 LoRa node chip. Refer to the following post for discussion on this and related V3 issues:

Just search this forum for “RadioLib” for discussion on the subject of that library.

If you have loaded the latest Heltec support software, you will find an appropriate example sketch under Examples > Heltec-Example > Factory_Test > WiFi_LoRa_32_V3_FactoryTest.

I have just seen your response. I have removed and then reinstalled “Heltec ESP32 Series Dev-Boards” by Heltec which says it included the Wifi Lora 32(V3) board. Then, when I go to Files, and then Examples, there is no instance of Heltec-Example. There is however the option under “Examples from custom libraries,” in which there is the “Factory_Test > WiFi_LoRa_32_V3_FactoryTest” option you referred to. The only issue with this however is that one of the libraries included is “Wifi.h” and in the code, it has a function that scans for Wifi connection. I am in an environment where I am unable to connect IoT devices to the Wifi as it’s against policy. That said, it did not compile anyways. I got the error "/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino: In function ‘void setup()’:
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino:21:5: error: ‘LoRa’ was not declared in this scope
LoRa.onReceive(onReceive);
^~~~
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino: In function ‘void loop()’:
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino:33:9: error: ‘LoRa’ was not declared in this scope
LoRa.receive();
^~~~
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino: In function ‘void send()’:
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino:39:5: error: ‘LoRa’ was not declared in this scope
LoRa.beginPacket();
^~~~
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino: In function ‘void onReceive(int)’:
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino:56:12: error: ‘LoRa’ was not declared in this scope
while (LoRa.available()) {
^~~~
/private/var/folders/91/d_3zpf5n5692740r7l09g71w0000gn/T/.arduinoIDE-unsaved2024219-22644-kqjwpx.1xz0p/sketch_mar19a/sketch_mar19a.ino:61:30: error: ‘LoRa’ was not declared in this scope
rssi = "RSSI: " + String(LoRa.packetRssi(), DEC);
^~~~

exit status 1

Compilation error: ‘LoRa’ was not declared in this scope". Then, I figured I could rewrite the code to only utilize LoRa because I don’t need the wifi capabilities anyways. Then when I compiled it, the same error occurred.

Are you sure the sketch you are using is WiFi_LoRa_32_V3_FactoryTest and not just WiFi_LoRa_32FactoryTest?

Either way, I suspect that you still haven’t selected the correct board definition. I have just checked one of my current installations, which probably still has some remnants of my original attempts to get things working. The important thing I notice is that there are actually two board definitions that look like they should be appropriate: Heltec WiFi LoRa 32(V3) / Wireless shell(V3) / Wireless stick lite (V3) and WiFi LoRa 32(V3) / Wireless shell(V3) / Wireless stick lite (V3) (without the Heltec at the beginning). If I select the first one, the one preceded by ‘Heltec’, I don’t see the Heltec-Example folder under Examples, and the Factory_Test folder under Examples from Custom Libraries > Heltec ESP32 Dev-Boards contains the sketch WiFi_LoRa_32FactoryTest, which uses the heltec.h library and which is not compatible with the V3 boards. If I select the second board definition I mention above, the one without the Heltec prefix, I see the examples as I originally advised, under Examples > Heltec-Example.

If you can’t see the WiFi LoRa 32(V3) / Wireless shell(V3) / Wireless stick lite (V3) option when attempting to select a board, there’s still a problem with your software environment, which I’m sure we can get to the bottom of. But you have to have selected this board before looking for any examples, as the Examples menu, in this case at least, is specifically customised for the board definition that has been selected.

Don’t worry about the fact that you can’t make a WiFi connection—the connection parameters are just generic and won’t connect to anyone’s WiFi without modification. The test sketch will then just scan and report available WiFi networks, it won’t try to connect to any of them (by default).

Hey UniquePete,

 So three things, 
  1. I was in fact doing the wrong example “WiFi_LoRa_32FactoryTest” but also did not have the correct example (and still don’t) “WiFi_LoRa_32_V3_FactoryTest”. I believe something went wrong when I did the library download, probably in a folder somewhere that doesn’t show up in examples.

  2. I got it to work utilizing RadioLib, so thank you for that advice.

Overall thank you for your help and advice getting it to work.

  1. For everyone else:

My code for the sender:
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <RadioLib.h>

// Pin Definitions for LoRa module
#define LoRa_MOSI 10
#define LoRa_MISO 11
#define LoRa_SCK 9

#define LoRa_nss 8
#define LoRa_dio1 14
#define LoRa_nrst 12
#define LoRa_busy 13

// Create an instance of the LoRa module
SX1262 radio = new Module(LoRa_nss, LoRa_dio1, LoRa_nrst, LoRa_busy);

void setup() {
// Initialize Serial communication
Serial.begin(9600);

// Initialize SPI communication for LoRa module
SPI.begin(LoRa_SCK, LoRa_MISO, LoRa_MOSI, LoRa_nss);

// Initialize LoRa module
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.begin();
if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
} else {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while (true);
}

// Set the frequency (in Hz)
// Range: 150-960 MhZ 900 MHz frequency
radio.setFrequency(915000000);  // 900 MhZ

// Set other configurations as needed

}

void loop() {
// Transmit a message
Serial.print(F("[SX1262] Transmitting packet … "));

// Send the message
int state = radio.transmit("Hello from Transmitter!");

// Check transmission status
if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("success!"));
} else {
    Serial.print(F("failed, code "));
    Serial.println(state);
}

delay(5000); // Wait for 5 seconds before transmitting again

}

My code for the receiver:
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <RadioLib.h>

#define LoRa_MOSI 10
#define LoRa_MISO 11
#define LoRa_SCK 9

#define LoRa_nss 8
#define LoRa_dio1 14
#define LoRa_nrst 12
#define LoRa_busy 13

SX1262 radio = new Module(LoRa_nss, LoRa_dio1, LoRa_nrst, LoRa_busy);

void setup() {
Serial.begin(9600);
Serial.println(F(“Serial communication initialized.”));

SPI.begin(LoRa_SCK, LoRa_MISO, LoRa_MOSI, LoRa_nss);
Serial.println(F("SPI communication initialized."));

// Initialize LoRa module
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.begin();
if (state == RADIOLIB_ERR_NONE) {
    Serial.println(F("Initialization successful!"));
} else {
    Serial.print(F("Initialization failed, code "));
    Serial.println(state);
    while (true);
}

// Set the frequency (in Hz)
// Range: 150-960 MhZ 900 MHz frequency
radio.setFrequency(915000000);  // 433 MHz

}

void loop() {
// Receive a packet

String str;
int state = radio.receive(str);

if (state == RADIOLIB_ERR_NONE) {
    // Packet received successfully
    Serial.println(F("Received packet successfully!"));


    // Print the RSSI (Received Signal Strength Indicator) of the last received packet
    Serial.print(F("[SX1262] RSSI:\t\t"));
    Serial.print(radio.getRSSI());
    Serial.println(F(" dBm"));

    // Print the SNR (Signal-to-Noise Ratio) of the last received packet
    Serial.print(F("[SX1262] SNR:\t\t"));
    Serial.print(radio.getSNR());
    Serial.println(F(" dB"));


    // Print the received data
    Serial.print(F("[SX1262] Voltage:\t\t"));
    Serial.println(str);

    //Print the voltage
    //Serial.print(F("[SX1262] Voltage:\t\t"));
    //Serial.println(str);

} else if (state != RADIOLIB_ERR_RX_TIMEOUT && state != RADIOLIB_ERR_CRC_MISMATCH) {
    // Some other error occurred (excluding timeout and CRC mismatch)
    Serial.print(F("Failed to receive packet, code "));
    Serial.println(state);
}

}

Thank YOU!
You saved my day!