0

NRF52 feather + RFM95 lora wing doesn't work
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NRF52 feather + RFM95 lora wing doesn't work

by TravisRideout on Wed May 24, 2017 5:04 pm

The driver init() fails. Looks like there is an issue with SPI writes. I get 0x0 returned from spiRead(RH_RF95_REG_01_OP_MODE) after a 0x80 write to that address. This is within RH-RF95.cpp of the RadioHead library recommended from the tutorial. Any ideas whats going wrong? Has anyone used this pairing before?

I've verified it is not hardware by switching out the wings and checking they work with a teensy3.6. I've tried different CS and INT pins thinking it might be and interrupt issue. The SPI examples in the core library seem to work, i see output on a o'scope anyways.

TravisRideout
 
Posts: 12
Joined: Sun Mar 05, 2017 10:20 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by adafruit_support_mike on Thu May 25, 2017 1:55 am

Let's make sure the code and connections line up.

Post the code where you've configured the pins for the radio module, plus a photo showing the corresponding hardware connections please. 800x600 images usually work best.

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

Re: NRF52 feather + RFM95 lora wing doesn't work

by TravisRideout on Thu May 25, 2017 2:41 pm

adafruit_support_mike wrote:Let's make sure the code and connections line up.

Post the code where you've configured the pins for the radio module, plus a photo showing the corresponding hardware connections please. 800x600 images usually work best.


Connections are as if stacked. The RFM95 board jumpers are per the tutorial. Code is simple as can be, I've left out the loop section as it's irrelevant for this issue.
Mike, can you try with hardware and let me know if it works for you?

Code: Select all | TOGGLE FULL SIZE
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

#define RFM95_CS 27
#define RFM95_RST 30
#define RFM95_INT 11

// Singleton instance of the radio driver
RH_RF95 driver(RFM95_CS, RFM95_INT);

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

void setup()
{
  Serial.begin(115200);
  while (!Serial) ; // Wait for serial port to be available

  delay(100);

  //Manual reset of radio, have tried this with no change in init() fail
  /*digitalWrite(RFM95_RST, LOW);
  pinMode(RFM95_RST, OUTPUT);
  delayMicroseconds(100);
  pinMode(RFM95_RST, INPUT);
  delay(10);*/
 
  if (!manager.init()) {
     Serial.println("manager init failed");
  } else {
     Serial.println("manager init passed");
  }
 
  if (!driver.setFrequency(915.0)) {
     Serial.println("setFrequency failed");
  } else {
     Serial.println("Frequency set to 915.0 MHz");
  }
 
  // 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:
  driver.setTxPower(23, false);
}


NRF52_RFM95_BreadBoard.jpg
NRF52_RFM95_BreadBoard.jpg (571.96 KiB) Viewed 771 times

TravisRideout
 
Posts: 12
Joined: Sun Mar 05, 2017 10:20 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by TravisRideout on Wed May 31, 2017 10:49 am

I'm still struggling with this. Best i can tell the RadioHead SPI driver is incompatible with the nrf52 feather. SPI stops functioning once <RH_RF95.h> is included. Some help getting to root of the problem would be appreciated.

TravisRideout
 
Posts: 12
Joined: Sun Mar 05, 2017 10:20 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by adafruit_support_mike on Fri Jun 02, 2017 3:03 am

I don't happen to have a LoRa FeatherWing on hand that I can test with the nRF52, but I'll have someone check to see how they work with the RadioHead library.

Just to check, are you using our fork of the RadioHead library?

https://github.com/adafruit/RadioHead

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

Re: NRF52 feather + RFM95 lora wing doesn't work

by TravisRideout on Fri Jun 02, 2017 8:49 am

I was able to pin point the issue and get this functioning. It came down to SPI.begin() not being called.

In RadioHead.h nrf52 boards are #defined as a nrf51 platform:

Code: Select all | TOGGLE FULL SIZE
#elif defined(NRF51) || defined(NRF52)
  #define RH_PLATFORM RH_PLATFORM_NRF51

To get hardware SPI to work I had to add a couple lines to the nrf51 block lower down in the code:

Code: Select all | TOGGLE FULL SIZE
#elif (RH_PLATFORM == RH_PLATFORM_NRF51)
 #define RH_HAVE_HARDWARE_SPI   // <--Added this
 #include <SPI.h>                 // <--and this
 #define RH_HAVE_SERIAL
 #define PROGMEM
  #include <Arduino.h>

Then in RHHardwareSPI.cpp I added a couple lines to start SPI:

Code: Select all | TOGGLE FULL SIZE
#elif (RH_PLATFORM == RH_PLATFORM_NRF51)
   SPI.begin();

This works but might not be portable between a nrf51 board or different configurations of nrf52's. Likely, differentiating between nrf51 and nrf52 platforms is the best course of action. I also didn't know what other configurations to add to the RHHardwareSPI.cpp file. I see the other platforms take into account frequency and modes. Like I said, this got my setup working, Hopefully you can take it from here and roll the changes into the adafruit fork of RadioHead.

TravisRideout
 
Posts: 12
Joined: Sun Mar 05, 2017 10:20 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by adafruit2 on Fri Jun 02, 2017 11:27 am

the header file i could see needing a change but in the SPI.cpp file this chunk should be called

Code: Select all | TOGGLE FULL SIZE
   _settings = SPISettings(frequency32, bOrder, dataMode);

   //Serial.println("SPI has transactions");
   SPI.begin();


can you uncomment the println and tell us if you get the "SPI has transactions" printout on serial?

adafruit2
Site Admin
 
Posts: 19032
Joined: Fri Mar 11, 2005 7:36 pm

Re: NRF52 feather + RFM95 lora wing doesn't work

by TravisRideout on Fri Jun 02, 2017 1:05 pm

I'm not able to find the line of code above in the nrf52 SPI.cpp file https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/libraries/SPI/SPI.cpp

Were you perhaps talking about the RadioHead RHHardwareSPI.cpp file? Without adding a SPI.begin() for the RH_PLATFORM_NRF51 somewhere, it does not get called.

TravisRideout
 
Posts: 12
Joined: Sun Mar 05, 2017 10:20 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by nraymond on Mon Feb 12, 2018 2:23 am

Hello,

Was there any conclusion with this topic? I am using the nRF52 Feather with a RFM9x breakout board and am also not able to get them to work together.

I've verified that the RFM9x works with an UNO board and the provided example code. Also checked the continuity when wired to the nRF52. Do I need to explicitly define an interrupt pin in the code for the IRQ pin on the LoRa board when using the nRF52 Feather? Or is this possibly related to the above mentioned issue?

Thanks-


Code: Select all | TOGGLE FULL SIZE
// Feather9x_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 Feather9x_TX

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

/* for Feather nRF52 */
#define RFM95_CS 27
#define RFM95_RST 30
#define RFM95_INT 31

// 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);
  digitalWrite(RFM95_RST, HIGH);

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

  Serial.println("Feather LoRa RX 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);
}

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);
      delay(10);
      // Send a reply
      delay(200); // may or may not be needed
      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");
    }
  }
}
Attachments
IMG_0623.jpg
IMG_0623.jpg (886.68 KiB) Viewed 523 times
IMG_0621.jpg
IMG_0621.jpg (934.95 KiB) Viewed 523 times
IMG_0622.jpg
IMG_0622.jpg (1012.12 KiB) Viewed 523 times

nraymond
 
Posts: 12
Joined: Sat Jun 01, 2013 1:13 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by adafruit2 on Fri Mar 02, 2018 1:40 pm

hiya, we're going to take a look in the next couple days
we put up an issue here
https://github.com/adafruit/RadioHead/issues/4
to help us track our progress :)
thank you!

adafruit2
Site Admin
 
Posts: 19032
Joined: Fri Mar 11, 2005 7:36 pm

Re: NRF52 feather + RFM95 lora wing doesn't work

by nraymond on Sat Mar 03, 2018 12:06 am

SUPER! thx

nraymond
 
Posts: 12
Joined: Sat Jun 01, 2013 1:13 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by wrightwx on Wed Apr 11, 2018 11:36 am

I seem to be running into this problem with wiring the RFM95 breakout to the Feather 32u4 Adalogger. Could this be related?

wrightwx
 
Posts: 11
Joined: Fri Mar 09, 2018 1:34 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by wrightwx on Wed Apr 11, 2018 4:55 pm

Looks like initialization was fixed. I had to make some changes to the code per my wiring. :P See below: Now to try and send some packets!

#define RFM95_CS 5 // was 10 in sample code
#define RFM95_RST 6 //was 9 in sample code

wrightwx
 
Posts: 11
Joined: Fri Mar 09, 2018 1:34 am

Re: NRF52 feather + RFM95 lora wing doesn't work

by adafruit2 on Thu Apr 12, 2018 7:04 pm

ok sat down and did a bunch of testing, the latest version in github now works both RX and TX examples tested with lora wing and nRF52 feather! the pins we tried are commited into the examples. please try it!
https://github.com/adafruit/RadioHead/

adafruit2
Site Admin
 
Posts: 19032
Joined: Fri Mar 11, 2005 7:36 pm

Re: NRF52 feather + RFM95 lora wing doesn't work

by nraymond on Sun May 20, 2018 8:39 pm

Back up and running! Thanks so much for both the RX and TX examples.

nraymond
 
Posts: 12
Joined: Sat Jun 01, 2013 1:13 am

Please be positive and constructive with your questions and comments.