Closed Flavio-da-Brescia closed 5 years ago
Are you calling setPins
?
https://github.com/sandeepmistry/arduino-LoRa/blob/master/API.md#set-pins
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);
}
By the way I also tried with 3 different Mega, even a brand new one, and I still get no commmunication
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
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!
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 ?.
@feras33 Why dont you create a new thread?
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.
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
Attach DIO1 to 3. Is your lora module of 433mhz?
Yes it is 433MHZ
I have changed the frequency in the code from the library
do you have source code for the receiver? and using arduino mega too?
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);
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);
}
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.
Overview of my physical wiring.
Overv- iew of my physical wiring.
I tried too, but still not working. I used arduino mega as transmitter, and uno as receiver. Both are using lora.
Overview of my physical wiring.
my physical wiring
As an IT, define "not working".
As an IT, define "not working".
Starting Lora Failed
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.
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
What GPIO you use to connect to NSS/SS of LoRA?
Digital pin 53
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.
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.
There's another method, but I prefer the 1st method. Read the notepad.
Hope it helps :)
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.