I am converting my Jeenodes to talk to RF69.
I am using the modified RFM12B libraries and RFM12 can talk indeed to RF69. Nice!
However on my jeenode that I am using as an pulse reader to measure my power consumption in the house I ran into problems.
This code ran OK with the Jeelib library. I replaced the library and the calls to the the modified RFM12B libraries.
I have an Ledblink() subroutinge that is attached to interrupt 1. In LedBlink() another call is made to SendWatts which contains de radio.Send command.
After some debuggin I found the following:
- When radio.Send is executed when LedBlink() is called by the interupt the code hangs.
- When radio.Send is executed when LedBlink() is called without the interrupt the packed is nicely sent and the code keeps running.
Is there anything I need to be aware of when running the Moteino libraries on Jeenodes?
Yeah my best guess is you might have to disable interrupts while you're inside an interrupt so they don't step on each other.
Use cli() and sei() for that or if you prefer more verbose equivalents use interrupts() and noInterrupts()
Just call noInterrupts() when you step into your IRQ then interrupts() before you exit.
Thanks for you suggesttion. Unfortunately this doesn't work.
In fact adding cli() or noInterrupts() alone makes the code hang. Even when disabling the attachInterrupt.
This I could also reproduce on one of the Basics sample codes that came with IDE: adding noInterrupts(); makes the code hang.
It even hangs then without loading and calling the RF12M library altogether..
Tried another Jeenode and arduinos with same results. I must be missing something obvious but I just don't get it....
Yep it sounds like you are having some other issue
I had some time to do some more testing.
Apparently the cli() and sei(); commands hang the code only when no interrupt is attached.
When the attachInterrupt is set the code is not hindered by the the cli() and sei() commands and the code runs OK when radio.Send command is commented out.
When the radio.Send not commented out is used the code hangs as soon the radio.Send command is executed.
I also made a node with the RFM69 module using the same code but using the RFM69 library. There I can send a message from withing the interrupt routine without problems.
Since the are no problems with RFM69.h and Jeelib RF12.h, but hangs with RFM12B.h I do think this is an issue with the RFM12B library.
It's not the best idea to send a message from within an interrupt.
Lots of people are using the RFM12B library without issues so until proven otherwise with well documented code I don't have reason to believe there is a bug.
I also don't endorse mixing RFM12B with RFM69 even though it's possible. The reason being the RFM12B is too limited and lacks many features that RFM69 has.
I was indeed a simple fix to move the send command out of the interrupt. Everything is working fine now.
RF12 is sending happily to RF69 gateway on RPi.
thanks..
Cool!
In cases where you have a lot of legacy RFM12B nodes you invested in and that sleep most time and wake periodically to just report data they could probably work just fine with a RFM69 gateway. But I would probably not put RFM12B in critical nodes going forward.