nRF52832 + LoRa

Hi all,

I am trying to use the RFM95W chipset from adafruit with my nRF52832 feather. However, I am experiencing problems initializing the chipset and communicating with it (I am using the RadioHead library). I have previously tried the LoRa chipset with the SAMD21 feather (sans LoRa), and it worked fine. This problem may be due to a couple of issues:

  • wrong pins being used on the feather
  • SPI library integration

The pins I am currently using:
SCK, MOSI, and MISO between LoRa and feather
RST- pin 7
CS - pin 11
INT - pin 31

After further debugging, I have found that the processor hangs when spiRead(RH_RF95_REG_01_OP_MODE) is called in rf95.init(). Full code below:

Hi all,

I am trying to use the RFM95W chipset from adafruit with my nRF52832 feather. However, I am experiencing problems initializing the chipset and communicating with it (I am using the RadioHead library). I have previously tried the LoRa chipset with the SAMD21 feather (sans LoRa), and it worked fine. This problem may be due to a couple of issues:
- wrong pins being used on the feather
- SPI library integration

The pins I am currently using:
SCK, MOSI, and MISO between LoRa and feather
RST- pin 7
CS - pin 11
INT - pin 31

After further debugging, I have found that the processor hangs when spiRead(RH_RF95_REG_01_OP_MODE) is called in rf95.init(). Full code below:
[code]// 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>
/*
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
  // Required for Serial on Zero based boards
  #define Serial SERIAL_PORT_USBVIRTUAL
#endif*/

#define RFM95_RST     7
#define RFM95_CS      11
#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);

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

  Serial.begin(115200);
  delay(100);

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

Thank you very much!

HAve Adafruit published any working examples for the nRF52832 with the RFM95W ?

@ddesousa hey, could you try it with GitHub - jgromes/RadioLib: Universal wireless communication library for Arduino? I don't have nRF52 to test, but it might work. Let me know if it does, so I can add nRF52 to the supported platforms :wink:

srnet:
HAve Adafruit published any working examples for the nRF52832 with the RFM95W ?

They say on their site that they support it. In their code example for the LoRa chipset, they mention compatibility with the nRF52 pinout.

ddesousa:
They say on their site that they support it. In their code example for the LoRa chipset, they mention compatibility with the nRF52 pinout.

Its not an Adafruit board that i recall getting mentioned a lot on here, could be worth asking Adafruit if there are any known issues with their board.

I have asked. They are not reporting any issues with the board.

ddesousa:
I have asked. They are not reporting any issues with the board.

How helpful, no problems with the board, but it does not run standard software.