Teensy 4.0 and RFM9x Not initialising.

cosmoprior

New member
Hi,

First time poster here, I am attempting to use a Teensy 4.0 and an Adafruit RFM9x 433Mhz module for 1 way transmission and reception. My issue is that no matter what i try the RFM9x will not initiallise, i am using the Teensy specific version of RadioHead. any help would be greatly appreciated.

schematic:

1709840254258.png


the serial output:

1709840417621.png




Code:
// 

rf69 demo tx rx.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_RF69 class. RH_RF69 class does not provide for addressing or
// reliability, so you should only use RH_RF69  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example rf69_server.
// Demonstrates the use of AES encryption, setting the frequency and modem
// configuration

#include <SPI.h>
#include <RH_RF69.h>

/************ Radio Setup ***************/

// Change to 434.0 or other frequency, must match RX's freq!
#define RF69_FREQ 434.0

//For Teensy 3.x and T4.x the following format is required to operate correctly
//This is a limitation of the RadioHead radio drivers
#define RFM69_RST     2
#define RFM69_CS      4
#define RFM69_INT     digitalPinToInterrupt(3)

// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS,RFM69_INT);


//----- END TEENSY CONFIG

int16_t packetnum = 0;  // packet counter, we increment per xmission

void setup()
{
  Serial.begin(115200);
  //while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer

  //For Teensy 3.x and T4.x the following format is required to operate correctly
  //pinMode(LED, OUTPUT);     
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, LOW);

  Serial.println("Feather RFM69 TX Test!");
  Serial.println();

  // manual reset
  //digitalWrite(RFM69_RST, HIGH);
  delay(10);
  //digitalWrite(RFM69_RST, LOW);
  delay(10);
  //----- END TEENSY CONFIG

rf69.init() ;

  if (!rf69.init()) {
    Serial.println("RFM69 radio init failed");
    while (1);
  }
  Serial.println("RFM69 radio init OK!");
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module)
  // No encryption
  if (!rf69.setFrequency(RF69_FREQ)) {
    Serial.println("setFrequency failed");
  }

  // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the
  // ishighpowermodule flag set like this:
  rf69.setTxPower(20);  // range from 14-20 for power, 2nd arg must be true for 69HCW

  // The encryption key has to be the same as the one in the server
  uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
  rf69.setEncryptionKey(key);
 
  //pinMode(LED, OUTPUT);

  Serial.print("RFM69 radio @");  Serial.print((int)RF69_FREQ);  Serial.println(" MHz");
}



void loop() {
  delay(1000);  // Wait 1 second between transmits, could also 'sleep' here!
  Serial.println(rf69.init());
 
}
 
Looking into the Teensy RadioHead library, in the examples/Teensy folder, I noticed the README.md states:
According to libraries for the RF69, RF95, RF24, RF22, MRF89 and the CC110 radios you have to pass interruptnumber-to-interruptpin mapping as opposed to just the pin number. This is accoplished by passing digitalPinToInterrupt n where "n" can be 0, 1, or 2 for the allowable interrupt pins.
In your code, you use #define RFM69_INT digitalPinToInterrupt(3). Perhaps you should connect the G0 (IRQ) signal to Teensy pin 0 or 1?

Paul
 
Last edited:
Hi, thanks for such a quick response. I will try that but won’t it interfere with the first serial port on upload?
 
Teensy does not use a hardware serial port for uploading. Instead it uses a "virtual' serial port over USB [under the hood, it is a bit more complex than that but for basic understanding OK to work with]. That same virtual serial port is also used to send data to/from the Arduino IDE Serial Monitor.

This is different from an Arduino Uno/Nano/Due that occupy a hardware serial port for uploading.
You can read more about it here.

Paul
 
Back
Top