Ok to use D2 as GPIO when using RFM69 Library?

Started by brandock, May 10, 2025, 10:51:07 PM

brandock

My understanding is that D2 is only used with the transceiver in interrupt-based libraries such as JeeLib. With polling-based libraries like RFM69 it is my understanding that D2 goes unused. However, on the Moteino it is still connected to DIO0 of the transceiver. My question is: can the D2 pin be used as a GPIO pin without concern? No conflicts? No potential damage to the transceiver given normal GPIO usage (write high, write low, use a 10k pull-up, etc.)?

Felix

With my RFM69 library you poll the RFM69 object to see if data was received, that's software polling. But the data gets filled in as soon as it arrives using interrupts.
So RFM69 is interrupt based. I would not use D2 with the RFM69 on a Moteino.
Did you run out of pins?
D3 is also a hardware interrupt. Most other pins can be used as pin change interrupts.
And other than A6 and A7 which are analog only, there are many other digital pins available.

brandock

Thanks. I may be off on my terminology regarding interrupt vs. polling. Over at OpenEnergyMonitor one reason they've moved from JeeLib to your RFM69 is that it reduces "the requirement to interrupt the main microcontroller (useful for energy monitoring)". https://docs.openenergymonitor.org/emontx4/technical.html#rfm69-radio.

In any case, I've been building some boards with the Arduino footprint and onboard RFM transceiver. One of them has AVR128DB28 as the MCU and therefore can be used for prototyping with the AVRDB libraries from OpenEnergyMonitor for the new EMONTX4 and EMONTX5/emonPi2.

(I am starting to put some documentation together in case it is useful to anyone else. https://github.com/brandock/Threeno)

As I worked with the AVRDB 28-pin part and EMONTX4/5 libraries I realized it is very unlikely anyone would ever use the D2 pin for the transceiver, because there is no JeeLib (D2-IRQ-based) library that works with AVRDB to receive packets. And if anyone worked on a receiving library for AVRDB, they'd probably base it on your RFM69 library, not JeeLib, since RFM69 is the go-forward library for OEM. (They call their fork "RFM69_LPL".)

So I thought, even though I am not running out of pins, why connect DIO0 to IRQ on these boards permanently? There's plenty of room to add a solder jumper (normally open).

Then I wondered, and asked here - is that overkill? Does it matter if D2 is connected to DIO0 when DIO0 is not being used with the transceiver library?

Sounds like the answer is: yes.