Sleep Interupt Voltages 0.11 to 4.56??

Hi

I have a PIR sensor which is on a pull down when motion is detected it pulls down to 0.11v and bounces around but is mostly 4.56v.

I want to wake the arduino uno up from a SLEEP_MODE_PWR_DOWN mode.

The sleep code I have works with a jump from GRD to Pin 2.

BUT it doesnt work from the PIR and I think this is because its not exactly 0v or 5v - is this the case and if so how do I fix it?

thanks

The sleep code I have works with a jump from GRD to Pin 2.

What is jumping from ground to pin 2?

BUT it doesnt work from the PIR and I think this is because its not exactly 0v or 5v - is this the case and if so how do I fix it?

The PIR is a digital device. It outputs a signal that is HIGH or LOW. It should be connected to a digital pin. Determine whether HIGH means motion sensed or all quiet. Then, using either RISING or FALLING in the attachInterrupt() call to be notified when the device senses motion.

Any output from the device that is above 3.0V will be seen as HIGH. Anything lower will be LOW.

The same code does not work when I plug in the PIR, but without the sleep code the PIR works flawlessly on LOW and HIGH…

How is the PIR powered? If powered off when the Arduino is sleeping, that could explain the problem.

Seeing the code might help, too.

Did you measure the voltages output by the PIR while it was actually connected to pin 2?

 // will be called when pin D2 goes low  
  attachInterrupt (0, wake, CHANGE);

The comments don't match the code. FALLING is when the pin goes low. Also make sure the interrupt event is cleared before you do the attach.

  1. Only interrupt modes LOW and HIGH are guaranteed to wake the device up from sleep mode.

  2. If the PIR pulls the input low for a short while before letting it go high again, the mcu will wake up from sleep mode but will not execute the ISR.

  3. Never do a Serial.print from an ISR.

I suggest you make the following changes to your code:

  1. Use interrupt mode LOW instead of CHANGE.

  2. Move the Serial.println("Woke Up") line into loop(), immediately after the sleep call.

  3. Have the ISR do a detachInterrupt and nothing else.

dc42:

  1. Only interrupt modes LOW and HIGH are guaranteed to wake the device up from sleep mode.

He's right about LOW being the only mode that wakes you from deep sleep.

There is no HIGH interrupt mode.

Does the PIR signal bounce around all the time, or only when movement is detected?

Are you sure that it is the PIR generating the signal that is waking up the mcu, or could it be interference? If you have long wires between the PiR detector and the Arduino, they may well pick up interference. Using screened cable and/or a lower value pullup resistor will help to avoid this.

You could slow down the PIR signal by adding a resistor between the PIR detector and the pin (around 2K to 4K) and a capacitor between the pin and ground. The mcu has hysteresis on the input pins, so it can cope with slowly-changing signals, although inputs that are not close to +5v or 0V do cause the current consumption in sleep mode to increase. You could also use the analog comparator to monitor the signal, if you choose a sleep mode in which the comparator can be enabled.