sleep mode and pin states

Hi!

My sketch uses SLEEP_MODE_PWR_DOWN to save battery and I have a PIR sensor attached to +5v, ground and a digital pin set to input. Every 8 seconds, the chip wakes up and checks the digital pin. If digital pin reads high, the chip registers the time on the epprom and stays awake for two minutes. Then it goes back to sleep. It works fine, until the chip goes to sleep. It immediately wakes up and the digital pin reads high, so it enters a loop and registers an event every time it goes to sleep, even if nothing is activating the PIR.

My question: When the SLEEP_MODE_PWR_DOWN enables, what happens to the digital pin set to input? Does it go high?

I appreciate all the help you can give.

Nothing happens to an input pin when the chip goes into power down mode. What are you using to wake up the chip every 8s, the watchdog or something else? Why not use a pin change interrupt to wake up the mcu on a low to high transition of the PIR output? Post your code.

dc42:
Nothing happens to an input pin when the chip goes into power down mode.

Then it's probably the PIR itself reacting to a fluctuation in voltage and resetting when the MCU goes into sleep mode. It could only be the Pin going high or the PIR resetting. The PIR enters a calibration mode for 20 seconds and during that it goes high. Gonna try a capacitor to smooth the voltage.

dc42:
What are you using to wake up the chip every 8s, the watchdog or something else? Why not use a pin change interrupt to wake up the mcu on a low to high transition of the PIR output? Post your code.

I'm using the watchdog. Can't use any of the interrupts available cause I’m already using them for other events... Every single pin on the Atmega 328 is already used (some with more than one task). Gonna start fiddling with other models for the next project cause the 328 is limiting.

Thanks!

vander:
I'm using the watchdog. Can't use any of the interrupts available cause I’m already using them for other events... Every single pin on the Atmega 328 is already used (some with more than one task). Gonna start fiddling with other models for the next project cause the 328 is limiting.

  1. You can still enable the pin-change interrupt on the input pin you are already using.

  2. In many designs, it is possible to use some of the pins to interface to more than one device. It sounds like you are already doing this, but maybe you can take it further. I frequently re-use 5 of the pins for driving a character LCD display as multiplex pins for connecting push buttons or rotary encoders.

dc42:

  1. You can still enable the pin-change interrupt on the input pin you are already using.

How? Can I add a 3rd interrupt and assing it to Digital13? (no LED on the D13;)

http://playground.arduino.cc/Main/PinChangeInt

It doesn't resolve my problem, but WOW! That is very nice to know, thanks!

Oh well, back to the multimeter... =(

If the mcu is immediately waking up when you put it into sleep mode, it is fairly clear that something is wrong with your code. But you haven't posted it.

Sorry for the late answer, but I only figured out yesterday what was the problem.
It was the freaking wind! I had my project on my terrace, which is a pretty windy place. I thought the MCU was resetting because of power fluctuations, but it was the wind wobbling the setup and causing the PIR sensor to be constantly active.
When you hear hoof beats, think of horses, not zebras...
Also, always test your projects indoors first!