2

I give some help for students working on the Cansat Contest.

I am trying to connect a RFM69 Radio Module to an Arduino Nano Every.

Nothing works : compiling the simpliest program:

#include <RH_RF69.h>

void setup() {}

void loop() {}

gives the answer:

[BlaBlaBla...]
exit status 1
Erreur de compilation pour la carte Arduino Nano Every

while everythings works on arduino M0 Feather Express or Arduino Uno.

Is there a specific problem with the Nano Every?

2
  • 2
    the BlaBla would be important here. and the link to the library, because now there is nothing to work with
    – Juraj
    Dec 11, 2020 at 18:24
  • Thanks a lot for your ansmers, I have cutted the Blablabla because it seems very long for a first point of view and introduce the library problem. I will check the supported boards. But I think it will be confusing to install both the libraries for the M0 feather and the nano on the same compiler. All the students (and me) are complete beginers! It seems unusefull to work with different processors for a first try. I think I'll buy another uno. It will be easier. (I just need it for a simple reception part). The files you've shown seems indeed helpfull to check compatibility. Thanks again for y Dec 11, 2020 at 20:40

2 Answers 2

1

The Nano Every uses an ATMega4809 processor, so it is different from most Arduino's. It could well be that it isn't supported by the Radiohead library.

The error you shortened to [BlaBlaBla...] could possibly give more information on that.

A full list of what is supported by the Radiohead library is here; you should check if the Arduino Nano Every or the ATMega4809 is on there; alternatively, all the #defines for the supported boards are in the header file.

If it turns out your board is not supported, you could ask the library's authors if they would consider supporting it, or you could use a different board (it should work with an Arduino Nano 33 IoT, I think, but please check first).

2
0

I was never able to make this work with the RadioHead library but did get it to work with LowPowerLab RFM69 library. Not here to debate which one is better just stating which one i got to work without having to change any of their code.

The environment used was VSCode on M2 Mac with latest PlatformIO plugin.

Transmitter MCU = Arduino Nano Every (just because i had it) Radio = Adafruit RFM69HCW (915Mhz) Breakout

Receiver MCU+Radio = Adafruit RFM69HCW Feather

For LowPowerLab libary there were two items that where gotchas for me. The first is that I was trying to use a different IRQ pin. Once i learned that the default defined in RFM69.h was 2 then things were easy going and more or less followed all the code examples that used no arg constructors for radio.

The second was that i needed to reset the radio. I got this from some example adafruit(thank you) code.

#define RFM69_RST     4
...
...
...
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, LOW);

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);

So here is my working receiver code (with a bunch of other junk)

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RFM69.h>
#include <SPI.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library. 
// On an arduino UNO:       A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO:   2(SDA),  3(SCL), ...
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NETWORKID     0   // Must be the same for all nodes
#define MYNODEID      3   // My node ID
#define FREQUENCY     RF69_915MHZ
#define RFM69_RST     4

// SPIClassMegaAVR ccc(12, 13, 11, RFM69_CS, 0);
RFM69 radio;//(RFM69_CS, RFM69_INT, true, &SPI);

void setup() {
  Serial.begin(115200);

  // put your setup code here, to run once:
  // pinMode(LED, OUTPUT);
  // digitalWrite(LED, HIGH);

  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, LOW);

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);

  if(!radio.initialize(FREQUENCY, MYNODEID, NETWORKID)) {
    Serial.println(F("radio init failed"));
    for(;;); // Don't proceed, loop forever
  }
  radio.setHighPower(); // Always use this for RFM69HCW


  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.clearDisplay();
  display.display();
  delay(2000); // Pause for 2 seconds
  

  display.setTextSize(2);      // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.setCursor(0, 0);     // Start at top-left corner
  display.cp437(true);         // Use full 256 char 'Code Page 437' font

  display.print(F("Kris"));
  // display.startscrollright(0x00, 0x0F);

  display.display();
  Serial.println("Starting up");
  // radio.spyMode(true);
}

bool displayOnTop = true;
void displayMsg(char* msg) {
  display.clearDisplay();
  if (displayOnTop) 
    display.setCursor(0,0);
  else
    display.setCursor(0, 16);
  displayOnTop = !displayOnTop;
  display.print(msg);
  display.display();
}

void loop() {
  
    if (radio.receiveDone()) // Got one!
  {
    // Print out the information:

    Serial.print("received from node ");
    Serial.print(radio.SENDERID, DEC);
    Serial.print(", message [");

    // The actual message is contained in the DATA array,
    // and is DATALEN bytes in size:

    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);

    // RSSI is the "Receive Signal Strength Indicator",
    // smaller numbers mean higher power.

    Serial.print("], RSSI ");
    Serial.println(radio.RSSI);

    char rssi[12];
    sprintf(rssi, "RSSI: %d\0", radio.RSSI);
    displayMsg(rssi);

    // Send an ACK if requested.
    // (You don't need this code if you're not using ACKs.)

    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.println("ACK sent");
    }
  }
}

#platformio
[env:nano_every]
platform = atmelmegaavr
board = nano_every
board_build.mcu = atmega4809
framework = arduino
lib_deps = 
    adafruit/Adafruit SSD1306@^2.5.7
    lowpowerlab/RFM69@^1.5.2
monitor_speed = 115200

and here is my working tranmitter code (a little cleaner)

#include <Arduino.h>
#include <Wire.h>
#include <RFM69.h>
#include <SPI.h>


const int LED = 13;

#define NETWORKID     0   // Must be the same for all nodes
#define MYNODEID      4   // My node ID

// RFM69 frequency, uncomment the frequency of your module:

#define FREQUENCY     RF69_915MHZ

#define RFM69_RST     4

RFM69 radio;

void notifyme() {
  Serial.println("I got the call!");
}

void setup() {
radio.setIsrCallback(notifyme);
  Serial.begin(115200);

  // put your setup code here, to run once:
  pinMode(LED, OUTPUT);
  digitalWrite(LED, HIGH);

  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, LOW);

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);

  pinMode(RFM69_INT, INPUT);

  if(!radio.initialize(FREQUENCY, MYNODEID, NETWORKID)) {
    Serial.println(F("radio init failed"));
    for(;;); // Don't proceed, loop forever
  }
  radio.setHighPower(); // Always use this for RFM69HCW

  Serial.println("Starting up");
}


void loop() {
  if (!radio.sendWithRetry(3, "hello", 5, 1)) {
    Serial.println("Failed to send on radio");
    digitalWrite(LED, LOW);
  } else {
    Serial.println("message sent");
    digitalWrite(LED, HIGH);
  }
 
  delay(5000);
}

Keep in mind, i'm a copy/paste warrior with the mindset of a Donkey. If I think it can be done then i will find a way, but it won't mean I understand anything about it. With that in mind, happy to answer any questions. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.