Author Topic: RMF69W RFM69HW and Arduino MEGA, ATMega2560, 2560  (Read 24922 times)

sntlewis

  • NewMember
  • *
  • Posts: 17
RMF69W RFM69HW and Arduino MEGA, ATMega2560, 2560
« on: December 10, 2013, 11:07:32 AM »
I am pretty new to this forum and I am excited to find the Moteino/RFM69W...

I am trying to hookup the RMF69W on an Arduino Mega2560.  The Mega2560 will run a graphic/touch LCD and act as a controller on a network of Moteino's (glad I found them).

I want to double check the issues before I run into problems.

1) Mega2560 outputs to the RMF69W will need to run through a 4.7k/10K voltage divider on the RMF69W's NSS, SCK, and MOSI.  The rest are outputs from the RFM69W back to the Mega2560 and do not need to run through a divider

2) tap v3.3 and gnd off of the Mega to run the RMF69W

3) Connect as follows

Mega2560 pin D21 to RMF69W DIO0 
Mega2560 pin D53 to RMF69W NSS
Mega2560 pin D52 to RMF69W SCK
Mega2560 pin D50 to RMF69W MISO
Mega2560 pin D51 to RMF69W MOSI

I feel good about all except the DIO0 connection.  As best as I can tell, the library is looking for INT0 which is mapped to D21 on the Mega2560.  Is this a correct assumption? Or do I connect it to the Mega2560 D2 (which is OC3B/INT4)?

Lastly, I use I2C on the Mega2560 as well and the D21 is the Mega2560's SCL line.  Is this going to mess up I2C?  The I2C on the Mega2560 runs a RTC.
« Last Edit: April 30, 2015, 10:58:38 AM by Felix »
Stan

sntlewis

  • NewMember
  • *
  • Posts: 17
Re: RMF69W and Arduino ATMega2560
« Reply #1 on: December 10, 2013, 11:11:19 AM »
I forgot to add that I would need to override the compiler RF69_IRQ_PIN with 21 instead of the default 2?
Stan

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: RMF69W and Arduino ATMega2560
« Reply #2 on: December 10, 2013, 07:44:21 PM »
1), 2), 3) I would say YES you are spot on.

For the DIO0 .. that's the interrupt INPUT. So if you plan to wire it to the SCL then that might be an issue since SCL is a clock .. which is an OUTPUT. So I'd say that won't work.
Pin D2 in atmega328 is tied to hardware interrupt "0". So when you attach an interrupt you have to pass 0 or 1 for atmega328. In my case the argument is 0 - corresponding to INT0 or D2. The other definition for D2 is for setting up that pin. So for mega2560 you'd have to probably move to another interrupt and there are many available. Just choose one that does't look very common, get the digital pin # and the interrupt # and replace them in the library.

Let us know how it goes...

sntlewis

  • NewMember
  • *
  • Posts: 17
Re: RMF69W and Arduino ATMega2560
« Reply #3 on: December 11, 2013, 09:49:15 AM »
Well no joy yet...  Running the Gateway code on the Moteino and Node code on the Mega2560 (figured to test this way as a the Moteino will act more as a receiver in the main project).

Hooked up with 4.7K/10K divider no joy.  Radio temp readings are not valid...

Hooked up with 1K/2.2K divider some joy.  I can get radio temps to respond (on Mega2560).  Packets are sent, but not acknowledged (INT0 issue most likely), BUT.

I get the initial packet sent and acknowledged, then Mega2560/Node hangs (if I use the INT0-D21)....

If I let the Gateway run in "promiscuous" mode I see the packets come across but IDs (both sender and receiver ids) and Data are "damaged" after the first one/two (possibly spurious packets).  Changed baud rate to 4800, no joy....

still working... maybe a level shifter such as the 74HC4050 (reading the NXP AN10441 Level shifting App Note now...)

Stan
Stan

sntlewis

  • NewMember
  • *
  • Posts: 17
Re: RMF69W and Arduino ATMega2560
« Reply #4 on: December 11, 2013, 01:02:37 PM »
More updates and more joy (still more joy to be found  :-\ )

1) use Arduino Mega2560 D2 to DIO0 and the 1k/2.2K divider
2) modified "Node" code example to use "send" instead of "sendwithretry"  still working on this one.  And set transmission time to 2000 ms.

Works almost without failure (at least on breadboard).  Some packets are dropped..

looking into why "send" works but not "sendwithretry"...
Stan

camdenl

  • NewMember
  • *
  • Posts: 13
Re: RMF69W and Arduino ATMega2560
« Reply #5 on: December 19, 2013, 03:14:03 PM »
Just wanted to say thanks for posting this.  Attaching to the mega's hardware spi and using D2 as the interrupt works just fine for me using the struct_send/receive sketches.  I have no luck with the gateway/node sketches however. 


sntlewis

  • NewMember
  • *
  • Posts: 17
Re: RMF69W and Arduino ATMega2560
« Reply #6 on: December 19, 2013, 08:33:55 PM »
no joy either with gateway/node sketches either... will try level shifters as soon as they get here...  I will look into the structure receive/send.

Did you use any level shifters/voltage dividers?
Stan

camdenl

  • NewMember
  • *
  • Posts: 13
Re: RMF69W and Arduino ATMega2560
« Reply #7 on: December 19, 2013, 09:59:19 PM »
Used a 2.2/1k voltage divider.  I have a bi-directional level shifter but the voltage divider actually worked better. 


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: RMF69W and Arduino ATMega2560
« Reply #8 on: December 20, 2013, 08:52:49 AM »
I always used 10K-4.7K to divide the signals, never had an issue.

camdenl

  • NewMember
  • *
  • Posts: 13
Re: RMF69W and Arduino ATMega2560
« Reply #9 on: December 20, 2013, 10:23:50 AM »
@Felix did you use a voltage divider for the interrupt pin as well?  If I don't have a voltage divider my board resets every time a message is received.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: RMF69W and Arduino ATMega2560
« Reply #10 on: December 20, 2013, 12:52:49 PM »
No. It's an input to the Arduino so no need to do that. Only the input to the transceiver should be divided.

sntlewis

  • NewMember
  • *
  • Posts: 17
Re: RMF69W and Arduino ATMega2560
« Reply #11 on: December 20, 2013, 07:03:58 PM »
It doesn't seem that the RFM69 attached to the Mega2560 is getting the interrupt.  Maybe the 3V3 is too close on my Mega2560 for an input.  I tried two different RFM69s, both work same.

I did get the Node (on Mega2560) to Gateway (on Moteino) working (somewhat) by using "Send" instead of "SendWithRetry" and ignore the ACK back to the Mega2560.  It gets sent by the Moteino but the Mega2560 side never gets it.  Which is why I am suspecting interrupt level issues.  When I load the Gateway code on the Mega2560 and Node (on Moteino and using "send"), it does not work at all as the Mega2560 is largely in "receive mode," which again points a finger (at least in my line of reasoning) towards the interrupt signal on the Mega2560.

I suppose the line itself could be dead, really shouldn't be but I've seen crazier things....

I'm still hunting...  I could not get the 4.7K/10K divider to give any results which is why I switched to the 1K/2.2K divider..

I'm working on some other aspects of my coding endeavor (remote control of LED lights on reef/saltwater fish tank), while waiting for my level shifters to come in.

Stan

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: RMF69W and Arduino ATMega2560
« Reply #12 on: December 20, 2013, 07:13:28 PM »
Your reasoning is reasonable, the 3.3V might be just below the mega's logic "1" limit.
Maybe a bidirectional voltage shifter could solve the issue...

camdenl

  • NewMember
  • *
  • Posts: 13
Re: RMF69W and Arduino ATMega2560
« Reply #13 on: December 22, 2013, 10:22:22 AM »
Are you using the default interrupt pin or did you change your library config?

sntlewis

  • NewMember
  • *
  • Posts: 17
Re: RMF69W and Arduino ATMega2560
« Reply #14 on: December 22, 2013, 07:56:14 PM »
Now I must admit that the interrupt pin issue is not yet resolved in my mind (it wont be until it all works).  But according to the arduino AttachInterrupt documentation Digital Pin 2 is "magically" attached to INT0 even though the pin out of the ATMega2560 chip shows it going to the D21 (iirc).

And so my dilemma.   I have tried moving the electrical connection to D21 but without success.  Still hunting....

The level shifters came in yesterday, but I've been too busy to try them out (maybe tomorrow).

Stan
Stan