RFM95@900MHz Feather+Aduino MEGA2560 Problem

I am coding a sketch for wireless communication with Radio-Head LoRa module.
I modified the example sketch, reliable_server and client, in Aduino IDE that Adafruit recommend.
I use RFM95@900MHz feather.
Wireless communication works well with RFM95@900 and Aduino UNO combination, but "init failed" error occurs with RFM95@900 and Aduino MEGA 2560 combination.

#include <RadioHead.h>
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

RH_RF95 driver;
RHReliableDatagram manager(driver,CLIENT_ADDRESS);

#define Lora.setPins(53, 40, 21)// MEGA
//#define Lora.setPins(10, 9, 2)//UNO
.......
while (!Serial) ; // Wait for serial port to be available
if (!manager.init())
Serial.println("init failed");
else
Serial.println("initialization success");

Which module is that ? Can you provide a link ?

To what pins on the UNO and Mega have youconnected the SPI pins SCK, MOSI, MISO needed for the LoRa module ?

#define Lora.setPins(53, 40, 21)// MEGA, 53(Chip select), 40(reset), 21(Interrupt)
//#define Lora.setPins(10, 9, 2)//UNO, 10(Chip select),9(reset), 2(Interrupt)
// MEGA MISO(50), MOSI(51), SCK(52)
// UNO MISO(12), MOSI(11), SCK(13)

I think wiring is OK because the module do LoRa communication works well with the above wiring and other LoRa sketch.

[https://cdn-learn.adafruit.com/downloads/pdf/radio-featherwing.pdf]

I am confused.

You need to make clear to the forum exactly what code you have working, and what code does not.

Do the basic library examples work, both on UNO and Mega ?

What voltage level conversion circuits are you using between the UNO\Mega and the RFM95 Feather ?

I can't upload the code because I am new user.

The working codes both on MEGA and UNO are "rf95_client" and "rf95_server".
"rf95_reliable_datagram_client" and "rf95_reliable_datagram_server" work on UNO, but don't work on MEGA.

The codes are from Aduino's examples.

MEGA and UNO 3.3V have supply pins, so I can supply 3.3V to module. I don't need voltage level conversion from 5V to 3.3V.

#include <RadioHead.h>
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

RH_RF95 driver;
RHReliableDatagram manager(driver,CLIENT_ADDRESS);

#define Lora.setPins(53, 40, 21)// MEGA
//#define Lora.setPins(10, 9, 2)//UNO
.......
while (!Serial) ; // Wait for serial port to be available
if (!manager.init())
Serial.println("init failed");
else
Serial.println("initialization success");

Why do you think you do not ?

Because MEGA and UNO can supply 3.3V to module and several codes work with 3.3V from MEGA and UNO board.

Plain wrong.

Supplying the 3.3v logic level LoRa device with 3.3v from the UNO\Mega does not turn their 5v logic level pins into 3.3v ones.

Wire the modules correctly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.