Hi Folks:
This stumped ChatGPT (paid version). You will see this one is weird! Any help i appreciated.
// Sender.ino
/*********
Modified from the examples of the Arduino LoRa library
More resources: https://randomnerdtutorials.com
*********/
#include <SPI.h>
#include <LoRa.h>
//define the pins used by the transceiver module
#define ss 5
#define rst 14
#define dio0 2
int counter = 0;
void setup() {
//initialize Serial Monitor
Serial.begin(115200);
while (!Serial);
Serial.println("LoRa Sender");
//setup LoRa transceiver module
LoRa.setPins(ss, rst, dio0);
//replace the LoRa.begin(---E-) argument with your location's frequency
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
while (!LoRa.begin(915E6)) {
Serial.println(".");
delay(500);
}
// Change sync word (0xF3) to match the receiver
// The sync word assures you don't get LoRa messages from other LoRa transceivers
// ranges from 0-0xFF
LoRa.setSyncWord(0xF3);
Serial.println("LoRa Initializing OK!");
}
void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);
//Send LoRa packet to receiver
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(10000);
}
// Receiver.ino
/*********
Modified from the examples of the Arduino LoRa library
More resources: https://randomnerdtutorials.com
*********/
#include <SPI.h>
#include <LoRa.h>
//define the pins used by the transceiver module
#define ss 5
#define rst 14
#define dio0 2
void setup() {
//initialize Serial Monitor
Serial.begin(115200);
while (!Serial);
Serial.println("LoRa Receiver");
//setup LoRa transceiver module
LoRa.setPins(ss, rst, dio0);
//replace the LoRa.begin(---E-) argument with your location's frequency
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
while (!LoRa.begin(915E6)) {
Serial.println(".");
delay(500);
}
// Change sync word (0xF3) to match the receiver
// The sync word assures you don't get LoRa messages from other LoRa transceivers
// ranges from 0-0xFF
LoRa.setSyncWord(0xF3);
Serial.println("LoRa Initializing OK!");
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
while (LoRa.available()) {
String LoRaData = LoRa.readString();
Serial.print(LoRaData);
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
}
Sender.ino prints Sending packet: and a monotonically increasing number every 10 seconds
Receiver.ino prints a . every 500ms. It never gets out of the inicialization loop:
while (!LoRa.begin(866E6)) {
Serial.println(".");
delay(500);
}
The two devices are inches apart on my desk
I am in a place that little 915MHz communications occurs.
To see if it might be hardware related I switched the roles, flashing the Receiver code on what was the Sender and the Sender code onto what was the Receiver.
The output remained the same, the problem follows the program, not the hardware.
I even did the switching among 3 boards changing the roles and the boards. The problem followed the program every single time.
You can see that both parts of the setup differ in only the Serial.print statement. It would be expected that the programs, in that section, would behave identically.
You can see the sync word is not being changed anywhere in the code
You ca see that SPI is use only for LoRa, nothing else oth programs are flashed from the exact same Arduino IDE bersion 2.3.1 typically seconds apart so board definitions, software versions and libraries are exactly the same.
Both are using "ESP32 Dev Module"
What is wrong