sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.63k stars 625 forks source link

Arduino MEGA getting "starting LORA Failed" #205

Closed Flavio-da-Brescia closed 5 years ago

Flavio-da-Brescia commented 5 years ago

Hello and thank you in advance for the help. I have Arduino Mega and Lora-02 module.

The Module works fine with Arduino UNO, as I tried, but when I wire it to the Arduino Mega it is not able to communicate with the module.

I wired it like this:

LORA------------MEGA

MOSI------------51 SCK-------------52 MISO-----------50 NSS-------------10 RESET-----------9 DIO0-------------2

I am using SPI.h and LoRa.h Library

What can be the reason? Thank you.

morganrallen commented 5 years ago

Are you calling setPins? https://github.com/sandeepmistry/arduino-LoRa/blob/master/API.md#set-pins

Flavio-da-Brescia commented 5 years ago

Yes I am calling it, and it works with UNO, I can arbitrarily choose them. But not with MEGA. Did you personally ever manage to do it with Arduino Mega?

/*

The transmitter code arduino for sending data packet lora radio module 433MHz  ra02 lora

*/

#include <SPI.h> // arduino spi library

#include <LoRa.h> // arduino libraries ra02 lora

int counter = 0;

void setup() {

 LoRa.setPins(10, 9, 2);//NSS, NRESET, and DIO0 pins can be changed by using LoRa.setPins(ss, reset, dio0).
  Serial.begin(9600);

  while (!Serial);

  Serial.println("LoRa Sender");

  if (!LoRa.begin(433E6)) {

    Serial.println("Starting LoRa failed!");

    while (1);

  }

 LoRa.setSpreadingFactor(10);

 LoRa.setSignalBandwidth(62.5E3);

 LoRa.crc();

}

void loop() {

  Serial.print("Sending packet: ");

  Serial.println(counter);

   // send packet

  LoRa.beginPacket();

  LoRa.print("Halo Like Circuit");

  Serial.println(counter);

  LoRa.endPacket();

  counter++;

  delay(2000);

}
Flavio-da-Brescia commented 5 years ago

By the way I also tried with 3 different Mega, even a brand new one, and I still get no commmunication

Flavio-da-Brescia commented 5 years ago

Ok I solved it. I simply forgot to connect the 5V of the logic converter. My bad. Thank you very much for all your support

ranaahtishamali commented 4 years ago

Ok I solved it. I simply forgot to connect the 5V of the logic converter. My bad. Thank you very much for all your support

Please can you upload the circuit diagram of it. its not working!

feras33 commented 4 years ago

hello everyone i am using lora sx1278 ra-02 , and i have tried this method with connecting exactly the same as mention above .Unfortunately it still not working i dont know why can any one help ?.

IoTThinks commented 4 years ago

@feras33 Why dont you create a new thread?

ranaahtishamali commented 4 years ago

hello everyone i am using lora sx1278 ra-02 , and i have tried this method with connecting exactly the same as mention above . Unfortunately it still not working i dont know why can any one help ?.

Send your circuit diagram.

feras33 commented 4 years ago

I wired it like this:

LORA------------MEGA

MOSI------------51 SCK-------------52 MISO-----------50 NSS-------------10 RESET-----------9 DIO0-------------2

I am using SPI.h and LoRa.h Library Same as it is mentioned in this thread

ranaahtishamali commented 4 years ago

Attach DIO1 to 3. Is your lora module of 433mhz?

feras33 commented 4 years ago

Yes it is 433MHZ

feras33 commented 4 years ago

I have changed the frequency in the code from the library

agisyahrain commented 4 years ago

do you have source code for the receiver? and using arduino mega too?

IoTThinks commented 4 years ago

Your mapping to SS to 10 may be wrong. LoRa - Mega 2560 MISO - 50 MOSI - 51 SCK - 52 SS - 53 RST - 9 DIO0 - 8 ( I always want to avoid using GPIO 0 and 2)

Ah, 3.3v in Mega said up to 50mA!!!! => LoRa may need up to 100mA => You may not have enough power to send packets far. Try to use external power.

GND - GND

And add the two magic lines:

  pinMode(LORA_SS, OUTPUT);
  digitalWrite(LORA_SS, HIGH);  

image

Full of my code

include // arduino spi library

include // arduino libraries ra02 lora

define LORA_SS 53

define LORA_RST 9

define LORA_DIO0 8

int counter = 0; void setup() { // SS, RST, DIO0 pinMode(LORA_SS, OUTPUT); digitalWrite(LORA_SS, HIGH);

LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0); Serial.begin(115200);

while (!Serial); Serial.println("LoRa Sender");

if (!LoRa.begin(433E6)) { Serial.println("Starting LoRa failed!"); while (1); }

// LoRa.setSpreadingFactor(10); // LoRa.setSignalBandwidth(62.5E3); }

void loop() { Serial.print("Sending packet: "); Serial.println(counter);

// send packet LoRa.beginPacket(); LoRa.print("Halo Like Circuit"); Serial.println(counter); LoRa.endPacket(); counter++; delay(2000);

}

IoTThinks commented 4 years ago

I'm too lazy to write a receiver so I turn on my SDR. Something is sending at 433Mhz. in the middle. Hope it works for you guys.

image

IoTThinks commented 4 years ago

Overview of my physical wiring. image

alfantamamy commented 4 years ago

Overv- iew of my physical wiring. image

I tried too, but still not working. I used arduino mega as transmitter, and uno as receiver. Both are using lora.

alfantamamy commented 4 years ago

Overview of my physical wiring. image

WhatsApp Image 2020-04-16 at 10 44 28 PM my physical wiring

IoTThinks commented 4 years ago

As an IT, define "not working".

alfantamamy commented 4 years ago

As an IT, define "not working".

Starting Lora Failed

IoTThinks commented 4 years ago

Did you put this in front of LoRa.begin()

 pinMode(LORA_SS, OUTPUT);
 digitalWrite(LORA_SS, HIGH); 

If still failed, your LoRa is likely faulty. Beware that LoRa is 3.3v.

alfantamamy commented 4 years ago

Did you put this in front of LoRa.begin()

 pinMode(LORA_SS, OUTPUT);
 digitalWrite(LORA_SS, HIGH); 

If still failed, your LoRa is likely faulty. Beware that LoRa is 3.3v.

Already, previously I tried to connect LoRa with arduino uno, it works to sending data, which is my LoRa is good. But I tried to connect arduino mega, failed.

*I copied your code, and your set pins to my project

IoTThinks commented 4 years ago

What GPIO you use to connect to NSS/SS of LoRA?

alfantamamy commented 4 years ago

Digital pin 53

IoTThinks commented 4 years ago

Try to use external 3.3v for LoRa If still failed then you have to rely on your own already. Very likely some error on your side or your board.

JanRealAcc commented 1 year ago

Hehe just found out the solution to this problem. It was LoRa.h that make this error. Just change the SS 10 to 53 if you wish to use arduino mega.

image

There's another method, but I prefer the 1st method. Read the notepad.

image

Hope it helps :)