Here there, recently I am testing Lora Ra-02 module I saw many videos and it is easy to set up, according to this schematic:
LoRa SX1278 Module-----Arduino Nano Board
3.3V-------
Gnd---------Gnd
En/Nss------D10
G0/DIO0------D2
SCK---------D13
MISO----------D12
MOSI----------D11
RST-------------D9
I am using a very common library called sandeepmistry. and I tried this code:
#include <SPI.h>
#include <LoRa.h>
int counter = 1;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
if (!LoRa.begin(433E6)) {
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(500);
}
When I run it, it just sticks in this line {Serial.println("Starting LoRa failed!");}
Then I updated the code and tried to reduce the SPI Frequency because I am using Arduino Nano now the code is this:
#include <SPI.h>
#include <LoRa.h>
int counter = 1;
int frequency = 8E6; // Set the desired frequency here
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
LoRa.setSPIFrequency(frequency); // Add the missing semicolon here
if (!LoRa.begin(433E6)) {
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(500);
}
This code passes the line Starting LoRa failed! but it again stuck in here
LoRa Sender Sending packet: 1
So why won't it do LoRa.beginPacket();
and loop the code? Why does it stop here?
2 Answers 2
Have you set the pins properly? Try doing:
LoRa.setPins(csPin, resetPin, irqPin);// set CS, reset, IRQ pin
There is a problem with the way your SX1276 is connected to the board, which is why .begin()
returns false.
-
By saying
csPin
- do you mean SS pin?? and irq - DIO0 pin?giri– giri2024年11月17日 10:39:48 +00:00Commented Nov 17, 2024 at 10:39
From my experience, I was facing exact same error!!
After reviewing lot of forums and troubleshooting session, I've identified the root cause - I was connecting the Arduino Uno / Nano
board to my laptop which was receiving a 5V supply
. As Arduino boards (when connected to higher current source), always supplies 5V power from the 3.3V pin, in my case the LoRa module was receiving 5V power supply!! As the LoRa module can't handle the 5V power
, it was throwing error.
After using a Level Shifter
and connecting to Arduino Nano
board, I was able to fix the error!!
Hoping my response would be helpful for someone facing similar issue!!
-
1you have a board which has 5 V on pin labeled as 3.3 V pin? that is very wrong.2024年11月23日 12:24:07 +00:00Commented Nov 23, 2024 at 12:24
-
@Juraj - I've an official arduino board, can't say the incorrect pin issue. However, It was mentioned in the Official Arduino forums that 3.3V pin emits 5V if connected to higher current - please follow this link - forum.arduino.cc/t/using-lora-with-arduino-nano/1266604giri– giri2024年11月23日 12:41:24 +00:00Commented Nov 23, 2024 at 12:41
-
you misunderstood one or more things there. 1) io pins are 5 V. 2) 3.3 V pin can't supply enough current2024年11月23日 14:08:47 +00:00Commented Nov 23, 2024 at 14:08
-
FYI - forum.arduino.cc/t/using-lora-with-arduino-nano/1266604/15giri– giri2024年11月23日 14:58:06 +00:00Commented Nov 23, 2024 at 14:58
-
@Juraj Could you please elaborate ?? if either 5V or 3.3V can't supply enough current, then why are we connecting 3.3V arduino pin with 3.3V pin LoRa ??giri– giri2024年11月23日 14:58:28 +00:00Commented Nov 23, 2024 at 14:58
Explore related questions
See similar questions with these tags.