Re: Moteino interrupt question on PD2 (interrupt 0) [SOLVED]

Started by xavier, February 28, 2015, 08:29:45 PM

xavier

hey there,

I'll debug this some more but just in case someone out there knows what the hell I did wrong, I'll ask the question first :-)

My understanding is if I don't ask the RFM69 object to use interrupts (or if I don't even init RFM69) I should be able to use PD2 as an external interrupt, but somehow I can't seem to get this to work...

I have a moteino with a wind sensor and a rain gauge - the wind speed sensor is connect to PD3 of the arduino and the rain gauge to PD2. I defined both as follow:
const byte WSPEED = 3;
const byte RAIN = 2;


then in setup I attach the interrupts as follow: (inspired by sparkFun code for their weather station)
  pinMode(WSPEED, INPUT_PULLUP); // input from wind meters windspeed sensor
  pinMode(RAIN, INPUT_PULLUP); // input from wind meters rain gauge sensor

  attachInterrupt(0, rainInterruptFunc, FALLING);
  attachInterrupt(1, wspeedInterruptFunc, FALLING);
  interrupts();

now the part I don't get:
the wind speed interrupt works - no issues
rain interrupt function is never called

I take the cable that goes to pin 2 (the rain) and connect it to pin 3: interrupt is called - If I connect the windspeed cable to pin 2 still no go (callback is not called) so I suppose my code is wrong?  Let me know if anyone has any idea...
thanks!

TomWS

Why don't you use a different pin?  Moteino has plenty spares and you can use PinChangeInt library to enable the interrupt... (see http://playground.arduino.cc/Main/PinChangeIntExample)

Tom

xavier

sorry about that - did not know about the pinChangeInterrupt library. Works like a charm now. I'm thinking I can just use that for the wind vane as well and just compute data per min and send it through the radio every 14m!  thanks again for the help!

for reference library is here: https://code.google.com/p/arduino-pinchangeint/

TomWS

Quote from: xavier on March 01, 2015, 12:04:36 PM
sorry about that - did not know about the pinChangeInterrupt library.<snip...>
No problem!  THAT is why we have this forum and WHY you ask questions.  The more we ask, the more we learn.

:D

mattmunee

Hey, all,
I just ran into this same problem.  Can someone explain why INT0 doesn't work on the Moteino?
~Matt
Fail fast. Fail often.

TomWS

Quote from: mattmunee on July 10, 2015, 09:02:12 PM
Hey, all,
I just ran into this same problem.  Can someone explain why INT0 doesn't work on the Moteino?
~Matt
INT0 works fine - for the radio which is what it is connected to.   Consequently it is not available to any other function.

Tom

EloyP

Quote from: TomWS on July 10, 2015, 10:11:24 PM
Quote from: mattmunee on July 10, 2015, 09:02:12 PM
Hey, all,
I just ran into this same problem.  Can someone explain why INT0 doesn't work on the Moteino?
~Matt
INT0 works fine - for the radio which is what it is connected to.   Consequently it is not available to any other function.


There's always the possibility of desoldering the transceiver, or ordering a Moteino without transceiver (if the application doesn't have the need to transmit wireless, which I think is very unlikely these days) so one can use the ATmega's INT0 ;-)

Seriously, though, most applications should have more than enough I/O and interrupt pin options on the Arduino and Moteino platforms.

Cheers,

Eloy Paris.-