# Code got stuck after initialization with RFM69

**URL:** <https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179>\
**Category:** Networking, Protocols, and Devices\
**Created:** [March 17, 2022, 1:46am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179 "2022-03-17T01:46:13Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 17, 2022, 1:46am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/1 "2022-03-17T01:46:13Z")

</div>

Hello. I'm working on RFM69 connected to an Arduino Uno. Currently, I was able to initialize the RFM69 using the a code I modified from the internet. However, my Receiver part always encounters error. It doesn't sometimes proceed and sometimes got stuck in the initialization loop. Yesterday, my Transmitter managed to work properly but today, sometimes I also observed same problem with my Receiver.

Here's my wiring.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/2/d/6/2d619fb50723f8aa265c8119cb6767f8a3fdb5e3.jpeg)

The code I'm using for both Transmitter and Receiver

```cpp
#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

#define RFM69_CS 10
#define RFM69_INT 2
#define RFM69_RST 9
#define LED 13

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

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

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

  pinMode(LED, OUTPUT);     
  pinMode(RFM69_RST, OUTPUT);
  //digitalWrite(RFM69_RST, LOW);
  //from this point I added it
  digitalWrite (RFM69_RST, HIGH);
  delay (100);
  digitalWrite (RFM69_RST, LOW);
  delay (100);

  Serial.println("LoRa Daughter Board (RFM69) - Transmitter");
  Serial.println();

  // manual reset
  digitalWrite(RFM69_RST, HIGH);
  delay(10);
  digitalWrite(RFM69_RST, LOW);
  delay(10);
  
  if (!rf69.init()) {
    Serial.println("RFM69 Initialization Failed!");
    while (1);
  }
  Serial.println("RFM69 Initialization Success!");
  // 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, true); // 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 Frequency: "); Serial.print((int)RF69_FREQ); Serial.println(" MHz");
}

void loop() {
  delay(1000); // Wait 1 second between transmits, could also 'sleep' here!

  char radiopacket[20] = "Hello World #";
  itoa(packetnum++, radiopacket+13, 10);
  Serial.print("Sending "); Serial.println(radiopacket);
  
  // Send a message!
  rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
  rf69.waitPacketSent();

  // Now wait for a reply
  uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (rf69.waitAvailableTimeout(500)) { 
    // Should be a reply message for us now   
    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);
  }
}

```

Here's a screenshot of the result  
Taken yesterday: Mar 16

 ![Jzc2Po1r8R](https://europe1.discourse-cdn.com/arduino/original/4X/3/6/e/36e93d9f5f7fe12afe34cdc01d400bc87a492096.png)

Taken today: Mar 17

 ![YvOCbKznZ6](https://europe1.discourse-cdn.com/arduino/original/4X/2/4/e/24e6d59f2448fffdf6ca91f2d6d6f9a13bb42e62.png)

I hope someone could help me with. Thank you in advance.

---

<div class="post-metadata">

**Author:** ![mrburnette](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mrburnette/32/702556_2.png) [@mrburnette](https://forum.arduino.cc/u/mrburnette)\
**Post date:** [March 17, 2022, 2:54am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/2 "2022-03-17T02:54:41Z")

</div>

> [@lostresearcher](#):
>
> However, my Receiver part always encounters error. It doesn't sometimes proceed and sometimes got stuck in the initialization loop.

IMO, best approach is to change the library/sketch code; lots of examples.  
This tutorial covers several boards, hookup, and LowPowerLab's radio library:

[RFM69HCW Hookup Guide - learn.sparkfun.com](https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide/all)

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 17, 2022, 3:17am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/3 "2022-03-17T03:17:21Z")

</div>

Hi @mrburnette thank you for always responding to my questions. I appreciate it a lot since I'm newbie here.

Actually, when I started this project that article was my basis. I followed everything on that blog, however, every time I used that, RFM69 were not communicating at all. That's the start when I looked for other codes in the internet such as the one I posted in this thread.

---

<div class="post-metadata">

**Author:** ![mrburnette](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mrburnette/32/702556_2.png) [@mrburnette](https://forum.arduino.cc/u/mrburnette)\
**Post date:** [March 17, 2022, 3:28am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/4 "2022-03-17T03:28:33Z")

</div>

> [@lostresearcher](#):
>
> That's the start when I looked for other codes in the internet such as the one I posted in this thread.

Very Interesting!

Felix @ [lowpowerlab.com](http://lowpowerlab.com) is an exceptional programmer, but libraries and Arduino "cores" can get out-of-sync.

Give Limor's code a try:  
[Using the RFM69 Radio | Adafruit RFM69HCW and RFM9X LoRa Packet Radio Breakouts | Adafruit Learning System](https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/using-the-rfm69-radio)

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 17, 2022, 6:36am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/5 "2022-03-17T06:36:38Z")

</div>

Hi @mrburnette actually the code I posted here is based on the link that you've shared.

Tbh, I already tried numerous codes from different libraries I found in the internet. Some worked then eventually failed. I'm losing all possible ways I know

---

<div class="post-metadata">

**Author:** ![racpi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/racpi/32/1126829_2.png) [@racpi](https://forum.arduino.cc/u/racpi)\
**Post date:** [March 17, 2022, 7:07am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/6 "2022-03-17T07:07:48Z")

</div>

two thoughts  
1 the level shifters are too slow for spi [i use simple resistive divider]  
2 the 3.3v supply from the uno is not able to run a rfm69hw  
i run a ldo 3,3v reg [with suitable caps] from the 5v rail

---

<div class="post-metadata">

**Author:** ![markd833](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/markd833/32/1186928_2.png) [@markd833](https://forum.arduino.cc/u/markd833)\
**Post date:** [March 17, 2022, 7:58am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/7 "2022-03-17T07:58:37Z")

</div>

Have to agree with @mrburnette here. I tried the MySensors library and the RadioHead library with my RFM69 boards and got nowhere. The LowPower library worked perfectly for me.

What i would suggest, and what got me out of many frustrating hours of programming/debugging, is to add in the Reset signal to the RFM69 module from a spare digital output. You can use a potential divider to drop the 5v down to 3v3 and then generate a hard reset at the start of your sketch.

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 17, 2022, 8:37am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/8 "2022-03-17T08:37:07Z")

</div>

Oww I see. Thanks for this @racpi I appreciated it.

Currently, the 3.3V of the RFM69 comes from a regulator that outputs 3.3V and 150 mA Imax. My assumption is that the problem comes from the level shifters huhuhu. So youre suggesting to use a resistive divider instead?

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 17, 2022, 8:41am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/9 "2022-03-17T08:41:15Z")

</div>

Okay. I cant remember if I tried already the LowPower library. Thanks for this @markd833

> What i would suggest, and what got me out of many frustrating hours of programming/debugging, is to add in the Reset signal to the RFM69 module from a spare digital output. You can use a potential divider to drop the 5v down to 3v3 and then generate a hard reset at the start of your sketch.

Actually, I assigned pin 9 of the Uno for the RESET. And add this(see attached code) in the code. That's the time it initialized. However my problem is that, it got stock and sometimes they weren't communicating.

```arduino
pinMode(LED, OUTPUT);     
  pinMode(RFM69_RST, OUTPUT);
  //digitalWrite(RFM69_RST, LOW);
  //from this point I added it
  digitalWrite (RFM69_RST, HIGH);
  delay (100);
  digitalWrite (RFM69_RST, LOW);
  delay (100);

```

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [March 17, 2022, 8:55am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/10 "2022-03-17T08:55:31Z")

</div>

Hi,  
What are you using for antennas for the two RFM units?

Can you please post some images of your project so we can see your component layout?

Thanks.. Tom... 😃 👍 🇦🇺 ☕

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 17, 2022, 9:15am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/11 "2022-03-17T09:15:22Z")

</div>

Hello @TomGeorge thanks for responding.

I only soldered a piece of wire measuring 164 mm to the antenna pads, as discussed here [RFM69 Hook-up Guide by SparkFun](https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide/all). Is it okay @TomGeorge ???

---

<div class="post-metadata">

**Author:** ![markd833](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/markd833/32/1186928_2.png) [@markd833](https://forum.arduino.cc/u/markd833)\
**Post date:** [March 17, 2022, 10:39am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/12 "2022-03-17T10:39:11Z")

</div>

Just a bit of clarification, which RFM69 module do you have. Is it the HCW variant shown in the fritzing diagram in post #1, or another variant.

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [March 18, 2022, 12:58am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/13 "2022-03-18T00:58:45Z")

</div>

Hello @markd833 I'm using RFM69HCW module.

---

<div class="post-metadata">

**Author:** ![markd833](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/markd833/32/1186928_2.png) [@markd833](https://forum.arduino.cc/u/markd833)\
**Post date:** [March 18, 2022, 4:23pm UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/14 "2022-03-18T16:23:29Z")

</div>

If you try the LowPowerLab RFM69 library - mine is at v1.5.1 - available through the IDE library manager - look for RFM69\_LowPowerLab, then have a look through the extensive examples for one called TxRxBlinky. I recall that it is one of the simplest examples and the one that I used to get me going when I started out with RFMs.

Make sure that you check the #define IS\_RFM69HW\_HCW is uncommented - I think it is in the examples.

---

<div class="post-metadata">

**Author:** ![cmatt](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@cmatt](https://forum.arduino.cc/u/cmatt)\
**Post date:** [March 29, 2022, 7:37pm UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/15 "2022-03-29T19:37:44Z")

</div>

I am reporting the same issue. I have a nano 33 IoT board connected to a Sparkfun RFM69HCW board - so no level shifter - all running at 3.3V.

It was working perfectly until a few days ago it started giving the same error as above. Tested multiple radio boards. Same result.

I didn't install any new board package. But something obviously changed.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/2/3/4/23445705d8242ad22fbd2cf31347dda9e3d77176.png)

---

<div class="post-metadata">

**Author:** ![lostresearcher](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@lostresearcher](https://forum.arduino.cc/u/lostresearcher)\
**Post date:** [June 7, 2022, 3:05am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/16 "2022-06-07T03:05:52Z")

</div>

Hi @cmatt were you able to solve this project? Because personally, I didn't solve the issue.

---

<div class="post-metadata">

**Author:** ![cmatt](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@cmatt](https://forum.arduino.cc/u/cmatt)\
**Post date:** [June 7, 2022, 4:59am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/17 "2022-06-07T04:59:52Z")

</div>

I have a system working that's using the RadioHead library version 1.121 (as listed in the _library.properties_ file. I used the _rf69\_reliable\_datagram\_client/server.pde_ sketches but have modified them for my own application.

I found that I had several different libraries on my system. I quarantined the libraries, testing one by one until I found the version that worked. I also tested each one with various  
BSP versions.

Here are notes from my sketch header:

Radiohead Library checksum:

- 193 files
- 104 folders
- Size on disk: 1.92 MB (2,015,232 bytes)

Arduino Board Package:

- Arduino SAMD21 M0
- 1.8.11

I'm using the Sparkfun RFM69 Breakout (915MHz).

Regarding the antenna, the length for 915Mhz should be 74mm.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 4, 2022, 5:00am UTC](https://forum.arduino.cc/t/code-got-stuck-after-initialization-with-rfm69/970179/18 "2022-12-04T05:00:25Z")

</div>

Closed on December 4, 2022, 5:00am UTC

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