RFM69HCW on Arduino Uno

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
hspooner
 
Posts: 7
Joined: Fri Apr 28, 2017 11:42 pm

RFM69HCW on Arduino Uno

Post by hspooner »

First time poster here. I'm using the Radiohead library for two RFM69HCW radios. I've got one hooked up to an Arduino Micro and the other hooked up to an Uno. The micro works perfectly with the radio. The Uno does not. Even the most basic raw transmit and raw receive examples provided for the Feather do not work.

The serial monitor for the micro prints exactly what the code should, regardless of whether it's acting as the transmitter or receiver. The Uno will display a few lines of text confirming the initialization and one acknowledgement, but then just prints garbage. It displays the same behavior regardless of whether it's the transmitter or receiver. To me, it looks like they are communicating with each other, it's just that whenever the Uno receives a message, it doesn't print properly.

I've triple checked my wiring on both units and have tried swapping around the radios, but I'm shakiest on the coding side of things.

Thanks!
Attachments
Uno Receiver.PNG
Uno Receiver.PNG (12.51 KiB) Viewed 872 times
Uno Transmitter.PNG
Uno Transmitter.PNG (15.31 KiB) Viewed 872 times
Micro Receiver.PNG
Micro Receiver.PNG (19.83 KiB) Viewed 872 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RFM69HCW on Arduino Uno

Post by adafruit_support_rick »

Post some pictures of your wiring and soldering.

Post the code you're running on the Uno

User avatar
hspooner
 
Posts: 7
Joined: Fri Apr 28, 2017 11:42 pm

Re: RFM69HCW on Arduino Uno

Post by hspooner »

The example Uno receiver code. The only modification I made was to comment out the part defining LED as pin 13: this radio requires pin 13 for CLK.

Code: Select all

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

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


#define RF69_FREQ 915.0

/*
#if defined (__AVR_ATmega32U4__) // Feather 32u4 w/Radio
  #define RFM69_CS      8
  #define RFM69_INT     7
  #define RFM69_RST     4
  #define LED           13
#endif

#if defined(ARDUINO_SAMD_FEATHER_M0) // Feather M0 w/Radio
  #define RFM69_CS      8
  #define RFM69_INT     3
  #define RFM69_RST     4
  #define LED           13
#endif
*/
#if defined (__AVR_ATmega328P__)  // Feather 328P w/wing
  #define RFM69_INT     3  // 
  #define RFM69_CS      4  //
  #define RFM69_RST     2  // "A"
  //#define LED           13
#endif
/*
#if defined(ESP8266)    // ESP8266 feather w/wing
  #define RFM69_CS      2    // "E"
  #define RFM69_IRQ     15   // "B"
  #define RFM69_RST     16   // "D"
  #define LED           0
#endif

#if defined(ESP32)    // ESP32 feather w/wing
  #define RFM69_RST     13   // same as LED
  #define RFM69_CS      33   // "B"
  #define RFM69_INT     27   // "A"
  #define LED           13
#endif

/* Teensy 3.x w/wing
#define RFM69_RST     9   // "A"
#define RFM69_CS      10   // "B"
#define RFM69_IRQ     4    // "C"
#define RFM69_IRQN    digitalPinToInterrupt(RFM69_IRQ )
*/
 
/* WICED Feather w/wing 
#define RFM69_RST     PA4     // "A"
#define RFM69_CS      PB4     // "B"
#define RFM69_IRQ     PA15    // "C"
#define RFM69_IRQN    RFM69_IRQ
*/


RH_RF69 rf69(RFM69_CS, RFM69_INT);

int16_t packetnum = 0; 

void setup() 
{
  Serial.begin(115200);
  //while (!Serial) { delay(1); } 

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

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

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);
  
  if (!rf69.init()) {
    Serial.println("RFM69 radio init failed");
    while (1);
  }
  Serial.println("RFM69 radio init OK!");
  

  if (!rf69.setFrequency(RF69_FREQ)) {
    Serial.println("setFrequency failed");
  }


  rf69.setTxPower(20, true);  // range from 14-20 for power, 2nd arg must be true for 69HCW


  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() {
 if (rf69.available()) {
    uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (rf69.recv(buf, &len)) {
      if (!len) return;
      buf[len] = 0;
      Serial.print("Received [");
      Serial.print(len);
      Serial.print("]: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf69.lastRssi(), DEC);

      if (strstr((char *)buf, "Hello World")) {
        uint8_t data[] = "And hello back to you";
        rf69.send(data, sizeof(data));
        rf69.waitPacketSent();
        Serial.println("Sent a reply");
        //Blink(LED, 40, 3); //blink LED 3 times, 40ms between blinks
      }
    } else {
      Serial.println("Receive failed");
    }
  }
}


void Blink(byte PIN, byte DELAY_MS, byte loops) {
  for (byte i=0; i<loops; i++)  {
    digitalWrite(PIN,HIGH);
    delay(DELAY_MS);
    digitalWrite(PIN,LOW);
    delay(DELAY_MS);
  }
}
The Micro transmitter code:

Code: Select all

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

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

#define RF69_FREQ 915.0

#if defined (__AVR_ATmega32U4__) // Feather 32u4 w/Radio
  #define RFM69_CS      8
  #define RFM69_INT     7
  #define RFM69_RST     4
  #define LED           13
#endif
/*
#if defined(ARDUINO_SAMD_FEATHER_M0) // Feather M0 w/Radio
  #define RFM69_CS      8
  #define RFM69_INT     3
  #define RFM69_RST     4
  #define LED           13
#endif

#if defined (__AVR_ATmega328P__)  // Feather 328P w/wing
  #define RFM69_INT     3  // 
  #define RFM69_CS      4  //
  #define RFM69_RST     2  // "A"
  #define LED           13
#endif

#if defined(ESP8266)    // ESP8266 feather w/wing
  #define RFM69_CS      2    // "E"
  #define RFM69_IRQ     15   // "B"
  #define RFM69_RST     16   // "D"
  #define LED           0
#endif

#if defined(ESP32)    // ESP32 feather w/wing
  #define RFM69_RST     13   // same as LED
  #define RFM69_CS      33   // "B"
  #define RFM69_INT     27   // "A"
  #define LED           13
#endif

/* Teensy 3.x w/wing
#define RFM69_RST     9   // "A"
#define RFM69_CS      10   // "B"
#define RFM69_IRQ     4    // "C"
#define RFM69_IRQN    digitalPinToInterrupt(RFM69_IRQ )
*/
 
/* WICED Feather w/wing 
#define RFM69_RST     PA4     // "A"
#define RFM69_CS      PB4     // "B"
#define RFM69_IRQ     PA15    // "C"
#define RFM69_IRQN    RFM69_IRQ
*/

RH_RF69 rf69(RFM69_CS, RFM69_INT);

int16_t packetnum = 0;  

void setup() 
{
  Serial.begin(115200);
  //while (!Serial) { delay(1); } 

  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);
  
  if (!rf69.init()) {
    Serial.println("RFM69 radio init failed");
    while (1);
  }
  Serial.println("RFM69 radio init OK!");

  if (!rf69.setFrequency(RF69_FREQ)) {
    Serial.println("setFrequency failed");
  }

  rf69.setTxPower(20, true);  // range from 14-20 for power, 2nd arg must be true for 69HCW


  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);  

  char radiopacket[20] = "Hello World #";
  itoa(packetnum++, radiopacket+13, 10);
  Serial.print("Sending "); Serial.println(radiopacket);
  

  rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
  rf69.waitPacketSent();


  uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (rf69.waitAvailableTimeout(500))  { 

    if (rf69.recv(buf, &len)) {
      Serial.print("Got a reply: ");
      Serial.println((char*)buf);
      Blink(LED, 50, 3); //blink LED 3 times, 50ms between blinks
    } else {
      Serial.println("Receive failed");
    }
  } else {
    Serial.println("No reply, is another RFM69 listening?");
  }
}

void Blink(byte PIN, byte DELAY_MS, byte loops) {
  for (byte i=0; i<loops; i++)  {
    digitalWrite(PIN,HIGH);
    delay(DELAY_MS);
    digitalWrite(PIN,LOW);
    delay(DELAY_MS);
  }
}
Attachments
Uno.JPG
Uno.JPG (870.79 KiB) Viewed 849 times
Micro.JPG
Micro.JPG (896.42 KiB) Viewed 849 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RFM69HCW on Arduino Uno

Post by adafruit_support_rick »

I don't see anything wrong in the pictures.

I'm wondering if it's a problem with your Uno. You'll notice that it's dropped characters in serial monitor even before the garbage shows up.
Like, you see "K!" instead of "RFM69 radio init OK!"

Have you tried swapping the modules between the Uno and the Micro? Have you tried swapping TX and RX between the Micro and the Uno?

User avatar
hspooner
 
Posts: 7
Joined: Fri Apr 28, 2017 11:42 pm

Re: RFM69HCW on Arduino Uno

Post by hspooner »

Yes, I've tried swapping the radios around and I've tried the Uno as both the transmitter and receiver. Doesn't make a difference what role it's playing: the reply message is always garbled.

It's weird because I've used this board for several other things and it seems to be ok. It will print other sensor data to the serial monitor just fine.

Would it be worthwhile to try a new board?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RFM69HCW on Arduino Uno

Post by adafruit_support_rick »

Seems like it can't have anything to do with the radios. If you've swapped the radios, and you've swapped the RX TX code, and the problem always stays with the Uno, then the Uno must be the problem.

I suppose you could try lowering the baud rate for Serial Monitor. Try 9600.

I suppose it might also be the USB cable on the Uno. You could try replacing that.

User avatar
jonathanleistiko
 
Posts: 22
Joined: Sat Mar 10, 2018 10:31 am

Re: RFM69HCW on Arduino Uno

Post by jonathanleistiko »

FWIW: I had a similar problem and lowering the baud rate worked for me.

User avatar
dustmodebros
 
Posts: 2
Joined: Tue Nov 06, 2018 9:33 pm

Re: RFM69HCW on Arduino Uno

Post by dustmodebros »

Getting the same issue, baud rate is already at 9600...
jonathanleistiko wrote:FWIW: I had a similar problem and lowering the baud rate worked for me.

Code: Select all

Feather RFM69 TX TeK!
RFM69 radio @915 MHz
Sending Hello World #0
No reply, is another RFM69 listening?
Sending Hello World #1
⸮K⸮⸮⸮⸮⸮⸮⸮⸮⸮Z⸮⸮<⸮
⸮⸮<_⸮
N<⸮⸮⸮⸮⸮⸮қ⸮L=u⸮⸮⸮⸮<⸮9⸮⸮⸮9⸮⸮Z⸮⸮\⸮Z⸮⸮\⸮⸮⸮⸮NΖ⸮⸮⸮_⸮⸮
⸮

User avatar
dustmodebros
 
Posts: 2
Joined: Tue Nov 06, 2018 9:33 pm

Re: RFM69HCW on Arduino Uno

Post by dustmodebros »

dustmodebros wrote:Getting the same issue, baud rate is already at 9600...
jonathanleistiko wrote:FWIW: I had a similar problem and lowering the baud rate worked for me.

Code: Select all

Feather RFM69 TX TeK!
RFM69 radio @915 MHz
Sending Hello World #0
No reply, is another RFM69 listening?
Sending Hello World #1
⸮K⸮⸮⸮⸮⸮⸮⸮⸮⸮Z⸮⸮<⸮
⸮⸮<_⸮
N<⸮⸮⸮⸮⸮⸮қ⸮L=u⸮⸮⸮⸮<⸮9⸮⸮⸮9⸮⸮Z⸮⸮\⸮Z⸮⸮\⸮⸮⸮⸮NΖ⸮⸮⸮_⸮⸮
⸮
NEVER MIND
baud rate was set as 115200 for some reason...

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”