Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Radiohead example fails with Feather M0 RFM9x
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Radiohead example fails with Feather M0 RFM9x

by igeekinc on Wed Nov 22, 2017 2:41 am

I purchased 2 Feather M0 RFM9x boards. I'm trying to get the sample code to work but both of them fail in the RH_RF95 init() call. I have selected the Feather M0 parameters:

Code: Select all | TOGGLE FULL SIZE
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3


and these also seem to correspond to the recommended settings for a Feather M0 board from the Radiohead readme that says:

For Adafruit Feather M0 with RFM95, construct the driver like this:

Code: Select all | TOGGLE FULL SIZE
RH_RF95 rf95(8, 3);


Any tips or tricks for making this work? Both boards fail the same way, so I don't think it's a hardware problem. I have connected an antenna to both.

Here's the full code of the example with my modifications

Code: Select all | TOGGLE FULL SIZE
      // Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// 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 Feather9x_RX

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

/* for feather32u4 */
/*
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7
*/
/* for feather m0  */

#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3


/* for shield
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 7
*/


/* for ESP w/featherwing
#define RFM95_CS  2    // "E"
#define RFM95_RST 16   // "D"
#define RFM95_INT 15   // "B"
*/

/* Feather 32u4 w/wing */
/*
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     2    // "SDA" (only SDA/SCL/RX/TX have IRQ!)
*/

/* Feather m0 w/wing */
/*
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     6    // "D"
*/

/* Teensy 3.x w/wing
#define RFM95_RST     9   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     4    // "C"
*/

// 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);

void setup()
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  while (!Serial);
  Serial.begin(9600);
  delay(100);

  Serial.println("Feather 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);
    delay(1000);
  }
  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()
{
  Serial.println("Sending to rf95_server");
  // Send a message to rf95_server
 
  char radiopacket[20] = "Hello World #      ";
  itoa(packetnum++, radiopacket+13, 10);
  Serial.print("Sending "); Serial.println(radiopacket);
  radiopacket[19] = 0;
 
  Serial.println("Sending..."); delay(10);
  rf95.send((uint8_t *)radiopacket, 20);

  Serial.println("Waiting for packet to complete..."); delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply..."); delay(10);
  if (rf95.waitAvailableTimeout(1000))
  {
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);   
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }
  delay(1000);
}
   

igeekinc
 
Posts: 3
Joined: Wed Nov 22, 2017 2:33 am

Re: Radiohead example fails with Feather M0 RFM9x

by adafruit_support_mike on Thu Nov 23, 2017 12:38 am

What are the symptoms of the failure?

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Radiohead example fails with Feather M0 RFM9x

by igeekinc on Thu Nov 23, 2017 1:11 pm

rf95.init() returns false. There's no other diagnostics from the Radiohead library that I can see. Is there a way to enable debugging? Am I using the correct parameters for the Feather M0 RFM9x board?

Thanks!

igeekinc
 
Posts: 3
Joined: Wed Nov 22, 2017 2:33 am

Re: Radiohead example fails with Feather M0 RFM9x

by igeekinc on Mon Nov 27, 2017 12:19 am

This line in setup causes the init to fail

pinMode(RFM95_RST, OUTPUT);

I commented it out and init finishes OK now. I'm going to try to get the two boards to talk next.

igeekinc
 
Posts: 3
Joined: Wed Nov 22, 2017 2:33 am

Re: Radiohead example fails with Feather M0 RFM9x

by adafruit_support_mike on Mon Nov 27, 2017 4:30 am

Hmm.. that's really unusual.

Try putting that line back and increasing the delay() time after the manual reset in setup().

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Radiohead example fails with Feather M0 RFM9x

by rathole on Fri May 10, 2019 10:00 am

Did you ever find a solution to your issue... I have the same problem.

Bluefruit Feather M0

Have most recent github files -> Example -> Radiohead -> Feather -> Feather9x ...

#define RF69_FREQ 915.0

#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13

RH_RF69 rf69(RFM69_CS, RFM69_INT);

fails here on 2 different boards

if (!rf69.init()) {
Serial.println("RFM69 radio init failed");
while (1);
}

increased delay as mentioned in this post to no avail

rathole
 
Posts: 8
Joined: Fri Jan 18, 2013 11:18 am

Re: Radiohead example fails with Feather M0 RFM9x

by adafruit_support_mike on Sat May 11, 2019 2:20 am

Does commenting out the line:

Code: Select all | TOGGLE FULL SIZE
pinMode(RFM95_RST, OUTPUT);
make any difference?

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Radiohead example fails with Feather M0 RFM9x

by JohnnyBG on Fri May 17, 2019 6:28 pm

rathole wrote:Did you ever find a solution to your issue... I have the same problem.

Bluefruit Feather M0

Have most recent github files -> Example -> Radiohead -> Feather -> Feather9x ...

#define RF69_FREQ 915.0

#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13

RH_RF69 rf69(RFM69_CS, RFM69_INT);

fails here on 2 different boards

if (!rf69.init()) {
Serial.println("RFM69 radio init failed");
while (1);
}

increased delay as mentioned in this post to no avail

Exactly the same issue here, bluefruit nRF52 will not init RFM69, just keep stuck indefinitely there, but I see your are using the wrong pins, corresponding to the Feather M0, not the Bluefruit M0

JohnnyBG
 
Posts: 3
Joined: Tue May 14, 2019 10:57 pm

Re: Radiohead example fails with Feather M0 RFM9x

by sirjano on Mon Sep 09, 2019 10:22 am

Hi,

I have exactly same problem with my Adafruit Feather 32u4.
Commenting out
Code: Select all | TOGGLE FULL SIZE
pinMode(RFM95_RST, OUTPUT);
solves init problem, but doesn't it break the code?
My pins defined:
Code: Select all | TOGGLE FULL SIZE
/* for feather32u4 */
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7

sirjano
 
Posts: 1
Joined: Mon Sep 09, 2019 10:14 am

Re: Radiohead example fails with Feather M0 RFM9x

by pserotta on Mon May 25, 2020 12:53 am

Hello,
I am seeing the same problem as the original post.
I don't think it is a good idea to comment out the line
Code: Select all | TOGGLE FULL SIZE
 pinMode(RFM95_RST, OUTPUT);
as then I suspect the radio is not reset.
I tried various delays as was suggested by Adafruit support but that does not solve the issue.
I don't see a proper solution in this thread, can we please get more assistance with this issue as the 2 feather M0 with RFM9x radios are not working at all for me?
Thanks!

pserotta
 
Posts: 9
Joined: Sun Jan 31, 2016 12:54 am

Re: Radiohead example fails with Feather M0 RFM9x

by jerryn on Mon May 25, 2020 6:24 am

What library are you using? Have you tried the examples from this guide https://learn.adafruit.com/adafruit-feather-m0-radio-with-lora-radio-module/using-the-rfm-9x-radio?preview_token=IU2C_sI1Vkd78VJQTNxu1w#radiohead-rfm9x-library-example-2567678-4

If you post the code you are trying, I'll be happy to see if I can reproduce you're issue.

Just to be clear, I do not represent Adafruit, Just trying to help.

jerryn
 
Posts: 1299
Joined: Sat Sep 14, 2013 9:05 am

Re: Radiohead example fails with Feather M0 RFM9x

by pserotta on Mon May 25, 2020 10:45 am

Hello,
Thank you, any help is welcome.
I am using RadioHead 1.62 with the sample application from Adafruit:
Feather9x_TX.zip
Feather9x from Adafruit
(1.99 KiB) Downloaded 2 times
.
The only modification made was to uncomment the M0 defines.
This is the error:
Code: Select all | TOGGLE FULL SIZE
 
Serial.println("LoRa radio init failed");
 Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug


The statement to uncomment the SERIAL_DEBUG define does not match the RH_RF95.cpp file included in RadioHead 1.62 so I suspect the library has changed.
Perhaps version 1.62 no longer works with the sample?

pserotta
 
Posts: 9
Joined: Sun Jan 31, 2016 12:54 am

Re: Radiohead example fails with Feather M0 RFM9x

by jerryn on Mon May 25, 2020 1:14 pm

I just ran this code -- on a feather M0 RFM9x Lora -- with both Radiohead 1.62 and the latest v 1.02

and it executes normally for me with both versions.

What Board are you selecting? -- I used Adafruit Feather M0


Code: Select all | TOGGLE FULL SIZE
// Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// 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 Feather9x_RX

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

/* for feather32u4
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7
*/

/* for feather m0 
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3
*/

/* for shield
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 7
*/

/* Feather 32u4 w/wing
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     2    // "SDA" (only SDA/SCL/RX/TX have IRQ!)
*/

/* Feather m0 w/wing
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     6    // "D"
*/
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3

// 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);

void setup()
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  Serial.begin(115200);
  while (!Serial) {
    delay(1);
  }

  delay(100);

  Serial.println("Feather 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");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    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()
{
  delay(1000); // Wait 1 second between transmits, could also 'sleep' here!
  Serial.println("Transmitting..."); // Send a message to rf95_server
 
  char radiopacket[20] = "Hello World #      ";
  itoa(packetnum++, radiopacket+13, 10);
  Serial.print("Sending "); Serial.println(radiopacket);
  radiopacket[19] = 0;
 
  Serial.println("Sending...");
  delay(10);
  rf95.send((uint8_t *)radiopacket, 20);

  Serial.println("Waiting for packet to complete...");
  delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply...");
  if (rf95.waitAvailableTimeout(1000))
  {
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);   
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }

}

jerryn
 
Posts: 1299
Joined: Sat Sep 14, 2013 9:05 am

Re: Radiohead example fails with Feather M0 RFM9x

by pserotta on Mon May 25, 2020 7:26 pm

I am also using board: Adafruit Feather M0
When you say: with both Radiohead 1.62 and the latest v 1.02
What do you mean by latest v1.02?

Also, what versions of the board support packages are you running?
I have attached the versions I am using.
samd1.png
samd1.png (25.98 KiB) Viewed 122 times

samd2.png
samd2.png (26.95 KiB) Viewed 122 times

Thanks again for helping!

pserotta
 
Posts: 9
Joined: Sun Jan 31, 2016 12:54 am

Re: Radiohead example fails with Feather M0 RFM9x

by jerryn on Mon May 25, 2020 7:56 pm

Sorry that was a typo .the latest is v1.102. https://www.airspayce.com/mikem/arduino/RadioHead/

I’ll check BSP version when I can get back to my computer but they are recent if not latest.

jerryn
 
Posts: 1299
Joined: Sat Sep 14, 2013 9:05 am

Please be positive and constructive with your questions and comments.