I am facing is with the LoRa communication between the NodeMCU ESP8266 transmitter and the ESP32 receiver.
Both modules have exactly the same LoRa configuration parameters, and I have verified that all the settings match on both sides. Despite this, I am still getting an RSSI value of -164 dBm and an SNR value of 0.00.
I have tried several troubleshooting methods, but the problem keeps occurring. I cannot understand what is causing this issue.
What could be the main reason behind this problem, and how can I resolve it?
I will also provide the transmitter and receiver codes. Please check both programs carefully, identify any mistakes, and help me determine whether the problem is related to the code, SPI communication, LoRa configuration, or hardware
The received packets are empty; there is no actual data in them. This indicates that the receiver is not receiving valid packets properly. Therefore, I suspect the issue might be related to the hardware rather than the code. Could you please help me identify the exact hardware issue?
Transmitter code node mcu :
#include <SPI.h>
#include <LoRa.h>
// SX1278 connections
#define SS D8
#define RST D0
#define DIO0 D1
#define LORA_FREQ 433E6
unsigned long packetCounter = 0;
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println();
Serial.println("===== ESP8266 LoRa TRANSMITTER =====");
// SPI initialization
SPI.begin();
SPI.setFrequency(1000000);
// LoRa pins
LoRa.setPins(SS, RST, DIO0);
// LoRa initialization
if (!LoRa.begin(LORA_FREQ))
{
Serial.println("LoRa initialization FAILED!");
while (1)
{
delay(1000);
}
}
// LoRa configuration
LoRa.setSyncWord(0x12);
LoRa.setTxPower(2);
LoRa.setSpreadingFactor(7);
LoRa.setSignalBandwidth(500E3);
LoRa.setPreambleLength(16);
LoRa.setCodingRate4(7);
LoRa.setTxPower(17);
LoRa.setPreambleLength(8);
LoRa.enableCrc();
Serial.println("LoRa initialization SUCCESS!");
Serial.println("Frequency: 433 MHz");
Serial.println("SPI Clock: 1 MHz");
Serial.println("Sync Word: 0x12");
Serial.println("Spreading Factor: SF7");
Serial.println("Bandwidth: 500 kHz");
Serial.println("Coding Rate: 4/7");
Serial.println("CRC: Enabled");
Serial.println();
Serial.println("TRANSMITTER READY");
}
void loop()
{
packetCounter++;
String message = "HELLO ESP32 | PACKET: ";
message += String(packetCounter);
Serial.print("Transmitting: ");
Serial.println(message);
LoRa.beginPacket();
LoRa.print(message);
int result = LoRa.endPacket();
if (result == 1)
{
Serial.println("TRANSMISSION COMPLETED!");
}
else
{
Serial.println("TRANSMISSION FAILED!");
}
Serial.println("-----------------------------");
delay(2000);
}
Receiver code esp 32 :
#include <SPI.h>
#include <LoRa.h>
// SX1278 connections
#define SS 5
#define RST 14
#define DIO0 26
#define LORA_FREQ 433E6
unsigned long receivedCount = 0;
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println();
Serial.println("===== ESP32 LoRa RECEIVER =====");
// SPI initialization
SPI.begin(18, 19, 23, SS);
SPI.setFrequency(1000000);
// LoRa pins
LoRa.setPins(SS, RST, DIO0);
// LoRa initialization
if (!LoRa.begin(LORA_FREQ))
{
Serial.println("LoRa initialization FAILED!");
while (1)
{
delay(1000);
}
}
// Same LoRa configuration as transmitter
LoRa.setSyncWord(0x12);
LoRa.setSpreadingFactor(7);
LoRa.setSignalBandwidth(500E3);
LoRa.setPreambleLength(16);
LoRa.setCodingRate4(7);
LoRa.setPreambleLength(8);
LoRa.enableCrc();
Serial.println("LoRa initialization SUCCESS!");
Serial.println("Frequency: 433 MHz");
Serial.println("SPI Clock: 1 MHz");
Serial.println("Sync Word: 0x12");
Serial.println("Spreading Factor: SF7");
Serial.println("Bandwidth: 500 kHz");
Serial.println("Coding Rate: 4/7");
Serial.println("CRC: Enabled");
Serial.println();
Serial.println("RECEIVER READY");
}
void loop()
{
int packetSize = LoRa.parsePacket();
if (packetSize > 0)
{
String receivedMessage = "";
while (LoRa.available())
{
receivedMessage += (char)LoRa.read();
}
receivedCount++;
Serial.println();
Serial.println("===== PACKET RECEIVED =====");
Serial.print("Packet Count: ");
Serial.println(receivedCount);
Serial.print("Received Data: ");
Serial.println(receivedMessage);
Serial.print("RSSI: ");
Serial.print(LoRa.packetRssi());
Serial.println(" dBm");
Serial.print("SNR: ");
Serial.print(LoRa.packetSnr());
Serial.println(" dB");
Serial.println("===========================");
}
}