0

RFM9X Init Failed
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

RFM9X Init Failed

by murata1 on Wed Jan 25, 2017 4:37 pm

Hello,

I recently ordered 9x RFM9X LoRa modules. I followed the tutorial linked below for wiring purposes. I slightly changed the sample code provided there. I hooked up the radio modules to Arduino Mega's. However, the serial monitor usually outputs "init failed" for both receiving and the transmitting modules, while seldom running OK.

I tried powering the modules through my PC and external power sources (with USB port again), still no luck.

I dumped registers by using a function of the RH_RF95 class. When the failure occurs, all the registers are set to zeros.

I would be glad if you let me know how to diagnose the problem and start using the radio modules.


Thanks a lot in advance.

Bests,
Murat

Tutorial:
https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/
Wiring:

RFM9X ___ MEGA
VIN <---> 5V
GND <---> GND
EN x---x
G0 <---> 2
SCK <---> 52
MISO <---> 50
MOSI <---> 51
CS <---> 53
RST <---> 50


Transmitting Code
Code: Select all | TOGGLE FULL SIZE
// Arduino9x_RX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (receiver)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Arduino9x_TX
 
#include <SPI.h>
#include <RH_RF95.h>
 
#define RFM95_CS 53
#define RFM95_RST 9
#define RFM95_INT 2
 
// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0
 
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);
 
// Blinky on receipt
#define LED 13
 
void setup()
{
  pinMode(LED, OUTPUT);     
  pinMode(RFM95_RST, OUTPUT);
  pinMode(RFM95_CS, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
 
  while (!Serial);
  Serial.begin(9600);
  delay(100);
 
  Serial.println("Arduino LoRa RX Test!");
 
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
 
  while (!rf95.init()) {
    rf95.printRegisters();
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");
 
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
 
  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
 
  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);
}
 
void loop()
{
  if (rf95.available())
  {
    // Should be a message for us now   
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
   
    if (rf95.recv(buf, &len))
    {
      digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
      Serial.println((char*)buf);
       Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
     
      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}


Receiving Code
Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <RH_RF95.h>
 
#define RFM95_CS 53
#define RFM95_RST 9
#define RFM95_INT 2
 
// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0
 
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

String NODE_ID = "CMS3";
 
void setup()
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
 
  while (!Serial);
  Serial.begin(9600);
  delay(100);
 
  Serial.println("Arduino LoRa TX Test!");
 
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
 
  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");
 
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
 
  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
 
  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);
}
 
int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{
  unsigned long timeStamp = millis();
  transmitReceive(timeStamp, NODE_ID);
  delay(10);
}

void transmitReceive(unsigned long timeStamp, String node_id){
  String message = node_id + "|" + timeStamp;
  char* package;
 
  package = createPackage(message);
 
  Serial.print("Sending ");
  Serial.println(message);
  delay(10);
   
  rf95.send(package, 25);

  Serial.println("Waiting for packet to complete...");
  delay(10);
  rf95.waitPacketSent();
}

char* createPackage(String message){
  char pack[25];
  message.toCharArray(pack, message.length());
  pack[24] = 0;
  return pack;
}

murata1
 
Posts: 3
Joined: Wed Jan 25, 2017 4:18 pm

Re: RFM9X Init Failed

by PhatJustice on Thu May 18, 2017 3:51 pm

Have you gotten an answer?

I had a Feather with LMiC on it, and it was working fine until one day... the RFM9x stopped init. I sanity checked everything and it would crash during radio_init when it's checking the radio version and it would trip an assert... The version is supposed to be 0x12 while the register read returns 0xFF. I'm guessing that my RFM9x module is b0rk'd.

I've also encountered other issues just before this... like trying to get the bootloader to run consistently. I'd have to hit the RST button a bunch and flash the ROM with blink sketch, then try to re-upload my sketch.

PhatJustice
 
Posts: 2
Joined: Thu May 18, 2017 3:45 pm

Re: RFM9X Init Failed

by murata1 on Thu May 18, 2017 4:10 pm

PhatJustice wrote:Have you gotten an answer?

I had a Feather with LMiC on it, and it was working fine until one day... the RFM9x stopped init. I sanity checked everything and it would crash during radio_init when it's checking the radio version and it would trip an assert... The version is supposed to be 0x12 while the register read returns 0xFF. I'm guessing that my RFM9x module is b0rk'd.

I've also encountered other issues just before this... like trying to get the bootloader to run consistently. I'd have to hit the RST button a bunch and flash the ROM with blink sketch, then try to re-upload my sketch.


Oh no, I could not find a way to make them work. Thus, I bought XBee's working at the same frequency band and started using them.

murata1
 
Posts: 3
Joined: Wed Jan 25, 2017 4:18 pm

Re: RFM9X Init Failed

by PhatJustice on Thu May 18, 2017 7:11 pm

Ah ok. I'll have to look at the XBee stuff too, since most have LoRaWAN built into them... Are you using the Multitech modules?

PhatJustice
 
Posts: 2
Joined: Thu May 18, 2017 3:45 pm

Re: RFM9X Init Failed

by murata1 on Fri May 19, 2017 4:38 pm

PhatJustice wrote:Ah ok. I'll have to look at the XBee stuff too, since most have LoRaWAN built into them... Are you using the Multitech modules?


The ones I bought was XBee 900 Pro S3B. They are pretty reliable, I can say

murata1
 
Posts: 3
Joined: Wed Jan 25, 2017 4:18 pm

Please be positive and constructive with your questions and comments.