Hello,
It seems to me my RFM9x is not sending a packet and I can not find a solution. It is getting stuck in my code during command - rf95.waitPacketSent();
If I remove this command then it goes on and when trying to send a second packet it gets stuck. I believe it does that because it is not able to send the first packet.
I have a arduino uno m0 pro and uno R4 Minima both equipped with adafruit RFM9x module. I got r4 minima working, but can not seem to do it with the M0 Pro.I have also tested minima code also with no success.
I have also switched the modules between boards to make sure the module is not broken. No change was seen.
Pinouts:
- VIN - 3,3V
- GND - GND
- EN - N/A did not connected and used
- G0 - D2
- SCK - SPI 3
- MISO - SPI 1
- MOSI - SPI 4
- CS - D10
- RST - D9
SPI pinout refernce: https://docs.arduino.cc/resources/pinouts/ABX00003-full-pinout.pdf
#include <SPI.h>
#include <RH_RF95.h>
// Define LoRa module pins and frequency
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2
#define RF95_FREQ 433.0
RH_RF95 rf95(RFM95_CS, RFM95_INT);
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
void setupLoRa() {
// Manual reset
Serial.println("Performing manual reset...");
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
delay(10);
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
rf95.init();
Serial.println("init done");
if (!rf95.init()) {
Serial.println("LoRa init failed!");
while (1); // Stay here if initialization fails
}
Serial.println("LoRa init OK!");
if (!rf95.setFrequency(RF95_FREQ)) {
Serial.println("setFrequency failed!");
while (1); // Stay here if setting frequency fails
}
Serial.print("Set frequency to: ");
Serial.println(RF95_FREQ);
rf95.setTxPower(13, false); // Set transmission power (13 dBm)
}
struct Packet {
int ECU;
int Ser1;
int Err;
int PH1;
};
void setup() {
Serial.begin(9600);
delay(1000);
setupLoRa(); // Call the setupLoRa function to initialize the LoRa module
}
void loop() {
Serial.println("Debug1");
Packet Send = {101, 202, 0, 999};
Serial.println("Debug2");
rf95.send((uint8_t *)&Send, sizeof(Send));
Serial.println("Debug3");
rf95.waitPacketSent();
Serial.println("Packet sent");
}
Serial Monitor outputs:
- Performing manual reset...
- init done
- LoRa init OK!
- Set frequency to: 433.00
- Debug1
- Debug2
- Debug3
I am using IDE 2.3.6
Thank you for looking into this!