SparkFun Forums 

Where electronics enthusiasts find answers.

#205859
I bought the above sensor, got it to work as per the example on sparkfun website.

I want to start using hardware interrupts and I thought this sensor looks simple enough to use as a starting point. However I have tried using example code from other websites that use similar 3 pin PIR sensors but to no avail. Can you suggest example codes I can use where the alert pin connects to Arduino interrupt pin 2?

It maybe too that this sensor does not support use of hardware interrupts. If so please let me know.

You also have the temperature sensor:

SparkFun Digital Temperature Sensor Breakout - TMP102 (SEN-13314 RoHS)

It too supports use of interrupts and the pdf data sheet is well detailed/documented but it is a little too complicated to follow. Can you help me with an Arduino circuit where the interrupt/alert pin is used and maybe an led is lit when a certain temperature threshold is passed? I just need a very simple illustration and maybe very simple code that highlights key interrupt functions and switching from comparator mode to interrupt mode.

I have searched the internet for examples but to know avail. Maybe you know a good weblink, that would be great too.
#205949
Hi jbspfn,

This PIR sensor should work just fine as a hardware interrupt with the right circuit and code. Unfortunately, we do not have any specific examples available to help you with this. Just make sure to set it up correctly and remember the signal on the PIR is an open-collector so it needs to be pulled HIGH with a pullup resistor or it will float. The Hookup Guide covers this in more detail. For help setting this up as a hardware interrupt, I would recommend reading our Processor Interrupts with Arduino tutorial. You should be able to substitute the PIR's signal for one of the button press examples in that tutorial.

The TMP102 will function similarly but you will need to set up the TMP102 and the Alert pin in your code and connect the Alert pin to an Interrupt pin on your Arduino. The TMP102 Library and Example Code section of the Hookup Guide for this sensor has more information on how to do this. The example code has extensive notes on each function and how to set them and the Hookup Guide has explanations of the various functions in the library. The Source CPP File for the library will also have descriptions and notes for each function.

I hope this helps you get started using these as interrupts for your project.
#206126
Thanks very much TS-Mark.
I got the PIR to work as an interrupt. To say I was happy to see it work is an understatement. I was excited because this is my first attempt at doing hardware interrupt processing.

I will now proceed to try using interrupts with the temperature sensor.

I am told that it is also possible to put Arduino into low power or sleep mode and then use a hardware interrupt to wake it up. I have not yet tried this but I will try it using the PIR.
If it works I will try it with the temperature sensor too. This is exciting because my current temperature sensor does not use low power and about a year ago I tried to run it on a 9V battery and the battery drained within 8 hours. Using interrupts and low power technique I hope to make both the PIR and Temperature sensor run on a 9V battery for much longer than just a day lol.

Thanks again for your help.