Interfacing Nano with rfm96 - basic help needed

New to arduinos and my electronics experience dates back to when I last used it in the Navy in 1984 - think valves and more latterly senility :slight_smile:

I am playing with trying to set up an arduino mesh Lora radio network. It will be pretty basic. I have a few different arduinos lying around and I have managed ot get the radiohead code working on a feather m0 with built in lora, or rather I have got two of them working and talking to each other. All well and good so far.

I have also got some RFM96 boards and a few arduino nanos. Stupidly I connected the nano direct to a rfm96 and may have fried it as I used no logic converter between the two boards. I should have known better as this was pointed out to me but then I read something online that the rfm96 could take 5v - anyway I screwed up...

I have rewired my jury rigged breakout board with a 220 and 330 ohm resister for each logic wire. So the signal comes from the nano into a 220 ohm resitser - take the 3.3 volts from here and also the 330 ohm resister then gounds to a common ground that connects the nano and the rfm96. The rfm96 takes its power from the nanos 3.3v pin.

I think I am happy that I am doing OK up to here. Happy to be corrected though :slight_smile:

Where I am less sure is the pin to pin wiring from the nano to the rfm96 and the nano and also the initialisation code to tell the nano what programmable pins to use.

I have taken my lead from here, but am a bit unsure whether I have it right and want to check before I use another rfm96 module:

my pins go as follows (via the logic level shifters for all bar Vin and gnd)

nano rfm96

3.3v -> Vin
gnd -> gnd
D13 -> SCLK
D12 -> MISO
D11 -> MOSI
D4 -> CS
D2 -> RST
D3 -> G0

My code is as follows - manager fails to initialise and correspondingly my Feather that is running as a Rx gets nothing

#define RH_MESH_MAX_MESSAGE_LEN 50
 
#include <RHMesh.h>
#include <RH_RF95.h>
#include <SPI.h>

#if !defined (__Nano__) // arduino nano
  #define RFM96_CS      4
  #define RFM96_INT     3
  #define RFM96_RST     2
  #define LED           13
#endif

#define Torleven 1
#define Peverell 3

// Singleton instance of the radio driver
RH_RF95 rf95(RFM96_CS, RFM96_INT); // Slave Select, interrupt

// Class to manage message delivery and receipt, using the driver declared above
RHMesh manager(rf95, Peverell);

const long interval = 1000;           // interval at which to blink (milliseconds)
 
void setup() 
{
  Serial.begin(9600);
  delay(1000);
  Serial.println("Setup");

  // following wasnt needed with the feather	
  pinMode(RFM96_RST, OUTPUT);
  digitalWrite(RFM96_RST, LOW);

  // manual reset - neither was this
  digitalWrite(RFM96_RST, HIGH);
  delay(10);
  digitalWrite(RFM96_RST, LOW);
  delay(10);
    
  if (!manager.init())
    Serial.println("failed");
  // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
  Serial.println("Fin");

   pinMode(LED_BUILTIN, OUTPUT);
}

uint8_t data[] = "Backatcha";
// Dont put this on the stack:
uint8_t buf[RH_MESH_MAX_MESSAGE_LEN];
unsigned long previousMillis = 0;        // will store last time LED was updated

void loop()
{
  Serial.println("Peverell Tx");
  delay(10000); // every 10 seconds  
  if (manager.sendtoWait(data, sizeof(data), Torleven) == RH_ROUTER_ERROR_NONE)
  {
    uint8_t len = sizeof(buf);
    uint8_t from;    
    String s;
  
    Serial.println("sendtoWait OK");  
    if (manager.recvfromAckTimeout(buf, &len, 3000, &from))
    {
      s = "Reply : 0x" + String(from, HEX) + ": " + String((char*)buf);
      Serial.println(s);
    }
    else
    {
      Serial.println("No reply");
    }
  }
  else
    Serial.println("Failed");  
 }

Thank You

Are you using that exact Adafruit Module or a different board? The adafruit module tolerates 3.3-5V on all the pins. If you are using a different module, just get a level shifting chip like this: TXB0104 Bi-Directional Level Shifter [TXB0104] : ID 1875 : $3.50 : Adafruit Industries, Unique & fun DIY electronics and kits
and then you can run all your connections through it.

The adafruit link you provided also has example code - did that work?

Thank You

I am using this board

Adafruit RFM96W LoRa RF Transceiver Breakout Board 433MHz 3073 with the nano

So I probably haven't fried it :slight_smile:

and this for the other two radios

As I said the two feathers talk to each other OK, but the nano won't talk to them

I only have one nano/lora breakout board

When I use the example code it runs OK on both devices and I can get the two feathers talking, but when I use a feather and a nano the feather hears the nano but not vice versa:

[nano]
Sending Hello World #29
Sending...
Waiting for packet to complete...
Waiting for reply...
No reply, is there a listener around?
Sending to rf95_server
Sending Hello World #30

[feather]
Received:
48 65 6C 6C 6F 20 57 6F 72 6C 64 20 23 35 37 0
20 20 20 0
Got: Hello World #57
RSSI: -20
Sent a reply
Received:

I suspect I am making a school boy error.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.