define MY_RF69_IRQ_PIN has no affect


  • Hero Member

    #define MY_RF69_IRQ_PIN 4
    

    Does not seem to work for RFM69 nodes or Serial GW based on ATmega328.

    Adding IRQ pin definition to a sketch for a RFM69 node or the serial GW does not seem to have any affect. I still have to have DIO0 connected to pin 2 for the node to communicate at all.

    Is this because it has to be connected to an interrupt pin and for a ATmega328 it is hard coded to be pin 2?

    Here is a comment I found from the RFM69.h file:

    // INT0 on AVRs should be connected to RFM69's DIO0 (ex on ATmega328 it's D2, on ATmega644/1284 it's D2)
    

    Hare is an example of a sketch where I need to move the IRQ pin to some other pin because I need both interrupt pins for something else (do I need to get some other MCU for the job? Or should I just use NRF24 instead).

    //
    //
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    #define MY_BAUD_RATE 9600
    
    //#define MY_RADIO_NRF24
    #define MY_RF69_IRQ_PIN 4
    #define MY_RFM69_FREQUENCY RF69_433MHZ
    #define MY_RADIO_RFM69
    
    
    #define MY_NODE_ID 101
    #define SN "Wiegand"
    #define SV "1.0"
    
    #include <MySensors.h>
    #include <MyConfig.h>
    #include <SPI.h>
    #include <Wiegand.h>
    
    #define ID 1
    
    MyMessage msg(ID, S_CUSTOM);
    
    #define pinD0 2
    #define pinD1 3
    
    WIEGAND wg;
    
    void setup() {
      //Serial.begin(9600);
    
      sendSketchInfo("Wiegand", "1.0");
      present(ID, S_CUSTOM);
      //wg.begin(3,1,4,2);
      wg.begin(pinD0, digitalPinToInterrupt(pinD0), pinD1, digitalPinToInterrupt(pinD1));
    }
    
    void loop() {
      if (wg.available())
      {
        Serial.print("Wiegand HEX = ");
        Serial.print(wg.getCode(), HEX);
        Serial.print(", DECIMAL = ");
        Serial.print(wg.getCode());
        Serial.print(", Type W");
        Serial.println(wg.getWiegandType());
        send(msg.set(wg.getCode()));
      }
    }
    

  • Hardware Contributor

    @korttoma
    for 328p, only d2 and d3 pin INTs are well handled as hardware int by Arduino. unfortunately the pin change int is not so friendly to use compared to these. that's why you often see d3/d3 as the ultimate int pins! but there are more, but not handled yet by Mys, nor lowpowerlab lib as you can see.
    That said, this means that even if you change for nrf, that will be the same, no d4 available.

    Finally, if you want to use the well known d3 for you radio int :

    you need to do this in your sketch:

    #define MY_RF69_IRQ_PIN  3   // Arduino pin
    #define MY_RF69_IRQ_NUM  1  // IRQ number
    

  • Hero Member

    Thanks for you answer @scalz but changing from 2 to 3 will not help me because the Wiegand library uses both 2 and 3 interrupt pins and I don't think it can be changed either. Seems like my only remaining solution for this node is to use a gateway without radio attached or an MCU with more then 2 interrupt pins available.


Log in to reply
 

Suggested Topics

  • 3
  • 15
  • 2
  • 2
  • 2
  • 3

3
Online

11.2k
Users

11.1k
Topics

112.5k
Posts