LowPowerLab Forum

Hardware support => Moteino => Topic started by: Lensdigital on December 26, 2014, 04:53:42 PM

Title: How to wake up moteino with radio signal?
Post by: Lensdigital on December 26, 2014, 04:53:42 PM
I nkow RFM's module IRQ pin is attached to D2 (INT0) on Moteinos.  But how can I use it to wake up moteino when it receives signal?  I tried attachinterrupt function, but I think it conflicts with RFM library...
Title: Re: How to wake up moteino with radio signal?
Post by: Felix on December 27, 2014, 10:02:37 PM
Just put everything to sleep except the radio, leave it in RX mode. That will generate an interrupt on D2 and wake the Moteino, similar to how the MotionMote code wakes it.
Title: Re: How to wake up moteino with radio signal?
Post by: Lensdigital on January 06, 2015, 10:00:50 PM
Quote from: Felix on December 27, 2014, 10:02:37 PM
Just put everything to sleep except the radio, leave it in RX mode. That will generate an interrupt on D2 and wake the Moteino, similar to how the MotionMote code wakes it.
Ah I see! Thank you! :) I've been putting radio to sleep, cause it draws too much current...
Title: Re: How to wake up moteino with radio signal?
Post by: scott216 on January 14, 2015, 07:01:43 PM
Quote from: Felix on December 27, 2014, 10:02:37 PM
Just put everything to sleep except the radio, leave it in RX mode. That will generate an interrupt on D2 and wake the Moteino, similar to how the MotionMote code wakes it.

Is that the whole purpose of D2, to wake up the radio?
Title: Re: How to wake up moteino with radio signal?
Post by: Felix on January 15, 2015, 09:20:43 AM
Not exactly, it is an interrupt from the radio to the host (atmega328). It could actually wake the mega, but not the radio.
Title: Re: How to wake up moteino with radio signal?
Post by: Lensdigital on January 19, 2015, 12:27:53 PM
I finally had chance to experiment, and it doesn't seem to be working :(
If I put AVR to sleep LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
It's never woken by RFM69...
If I attach interrupt to INT0, I think it conflicts with RFM69 library as everything freezes after first receipt of data...
attachInterrupt(0, myISR, RISING);
Does any have example code of this working? :)
Title: Re: How to wake up moteino with radio signal?
Post by: Felix on January 19, 2015, 02:35:53 PM
You can't share interrupts, I think that is common sense. Use another interrupt, INT1 or something else.
Title: Re: How to wake up moteino with radio signal?
Post by: Lensdigital on January 19, 2015, 02:37:54 PM
Quote from: Felix on January 19, 2015, 02:35:53 PM
You can't share interrupts, I think that is common sense. Use another interrupt, INT1 or something else.
But RFM69 is hardwired to INT0 (D2) on Moteino...  I wanted Radio to wake up AVR chip :)
Title: Re: How to wake up moteino with radio signal?
Post by: Felix on January 19, 2015, 02:43:00 PM
So then what are you trying to by doing this:

attachInterrupt(0, myISR, RISING);
Title: Re: How to wake up moteino with radio signal?
Post by: Lensdigital on January 19, 2015, 03:02:59 PM
Quote from: Felix on January 19, 2015, 02:43:00 PM
So then what are you trying to by doing this:

attachInterrupt(0, myISR, RISING);
I figured I have nothing to lose and tried it just in case. As expected it didn't work...  :P
So how do you wake up AVR with radio signal? 
Title: Re: How to wake up moteino with radio signal?
Post by: Felix on January 19, 2015, 09:36:55 PM
You have to leave the radio in RX mode (call receiveDone() before sleeping the mega).
Then sleep the mega chip and wait for the INT0 interrupt to trigger when the packet is received, simple as Pi.
Title: Re: How to wake up moteino with radio signal?
Post by: Lensdigital on January 19, 2015, 09:45:35 PM
Quote from: Felix on January 19, 2015, 09:36:55 PM
You have to leave the radio in RX mode (call receiveDone() before sleeping the mega).
Then sleep the mega chip and wait for the INT0 interrupt to trigger when the packet is received, simple as Pi.
Ah I see, i thought it was always in recieve mode. Thanks, I'll give it a go :)
Title: Re: How to wake up moteino with radio signal?
Post by: Felix on January 19, 2015, 09:50:54 PM
Yes, and make sure you don't mix other interrupts with INT0!
Title: Re: How to wake up moteino with radio signal?
Post by: Lensdigital on January 20, 2015, 12:15:26 PM
It worked! Thanks again! :)

Although I didn't realize that since RFM69 uses a lot of current (15mA), power savings were so negligent...
If anyone interested here are 2 test sketches.