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 ![]()
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 ![]()
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