So I took the plunge and tinker with LoRa.
Got 5 Lora RA-02 modules... and connected these to Arduino Pro Minis to run all at 3.3 V.
I installed the LoRa libraries, use the sender and receiver sketch and expected this to work, but it doesn't.
The connections:
// LoRa-02 SX1278 module PINs:
// 3.3 V and ground
// 9 = RST
// 10 = NSS
// 11 = MOSI
// 12 = MISO
// 13 = SCK
// LORA_DEFAULT_SPI_FREQUENCY 8E6
// LORA_DEFAULT_SS_PIN 10
// LORA_DEFAULT_RESET_PIN 9
// LORA_DEFAULT_DIO0_PIN 2
Now while writing this post, I looked at the enclosed cover for the chip and it says ISM:410-526 MHz. This may sound silly, but this lets me believe this module cannot send/receive at 915 MHz, which is the setting in my example programs.
Well, I changed LoRa.begin(433E6);
... however, no luck either.
How can I test, whether the 'sender' is actually sending?
This is my slightly modified code allowing me to use one file, while changing only one constant: bool B_IS_LORA_TRANCEIVER_ROLE_SENDER {false};
here for being a receiver.
/*
SX1278 LoRa Module Ai-Thinker
*/
#include <Arduino.h>
#include <SPI.h>
#include <LoRa.h>
const uint32_t G_BAUD_RATE_HW {57600}; // hardware serial baud rate
bool B_IS_LORA_TRANCEIVER_ROLE_SENDER {false};
void sender()
{
static int counter {0};
// wait until the radio is ready to send a packet
while (0 == LoRa.beginPacket())
{
Serial.print(F("Waiting for radio ..."));
delay(100);
}
Serial.print(F("Sending packet: "));
Serial.println(counter);
LoRa.beginPacket();
LoRa.print(F("Hello: "));
LoRa.print(counter);
// true = async / non-blocking mode
//LoRa.endPacket(true);
LoRa.endPacket();
counter++;
return;
}
// code for receiving
void receiver()
{
// try to parse packet
int packetSize = LoRa.parsePacket();
if (true == packetSize)
{
// received a packet
Serial.print(F("Received packet '"));
// read packet
while (LoRa.available())
{
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print(F("' with RSSI "));
Serial.println(LoRa.packetRssi());
}
else
{
Serial.println(F("No packet received :("));
delay(5000);
}
}
void setup()
{
Serial.begin(G_BAUD_RATE_HW);
while (!Serial);
if (true == B_IS_LORA_TRANCEIVER_ROLE_SENDER)
{
Serial.println(F("LoRa Sender..."));
}
else
{
Serial.println(F("LoRa Receiver..."));
}
if (false == LoRa.begin(433E6)) // fit for AU 915E6
{
Serial.println(F("Starting LoRa failed!"));
while (1);
}
}
void loop()
{
if (true == B_IS_LORA_TRANCEIVER_ROLE_SENDER)
{
sender();
delay(5000);
}
else
{
receiver();
}
}
Any hints appreciated.