0

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?

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.