Sleep_n0m1 library using two different pins for wake up

Hello

I'm using the Sleep_n0m1 library for laying an arduino mini pro to sleep.

 sleep.sleepPinInterrupt(intPin, HIGH); //(interrupt Pin Number, interrupt State)

It works for with one interrupt pin but I would like to use a second pin for wake up as well.

How can I implement or use this with the library?

Thank you

but I would like to use a second pin for wake up as well.

So, what is the problem?

where can I define the second pin?

if I put two "sleep.sleepPinInterrupt" below each other, after the first the mcu is in sleep

timtailors:
where can I define the second pin?

if I put two "sleep.sleepPinInterrupt" below each other, after the first the mcu is in sleep

It is NOT clear from the method name that sleepPinInterrupt() actually puts the device to sleep.

If you need help using a non-core library, wouldn't you think that posting a link to it would be useful?

Hello,

thanks for your reply.
I tested this library and for one interrupt Pin it works great

but I need at least another Pin which is capable to wake the atmega328

What is the interrupt source? Is this a 3.3V or a 5V Pro Mini?

A quick look at the library files seems to show that it can't be done directly.

Can you use additional hardware?
Or do you want to hack the library?

Hi,

it's a 3.3V Pro Mini.

Additional hardware would be the best solution because I need low power consumption and two different pins for different interrupts.

Yes, if it's possible to modify the library?

You did not answer the question what the source for the interrupt is.

If it's two buttons, you can use diodes; you will have to rewire so the buttons read LOW when pressed. I think 1N4148 diodes will work; see calculations below.

Connect two diodes to one Arduino pin, anode at the Arduino, cathode at the button; other side of the button to ground. Below ASCII art is an attempt to make it clear.

              D1
              |\|    ____
           +--| |----o  o---- GND
           |  |/|   button 1
           |
           |
Arduino ---+
           |
           |  D2
           |  |\|    ____
           +--| |----o  o---- GND
              |/|   button 2

If you need to determine which button is pressed, you need to wire at least one of the buttons to another pin as well. If that pin reads low when the 328P wakes up, that button was pressed, else the other button was pressed.

Instead of using

sleep.sleepPinInterrupt(intPin, HIGH); //(interrupt Pin Number, interrupt State)

use

sleep.sleepPinInterrupt(intPin, LOW);  // react when button goes low (was high)

This will enable the internal pull-up (see source code of library); worst case, this will be 20 kOhm, so a current of 3.3/20k = 0.17 mA. An 1N4148 diode will have a voltage drop (at that current) of around 0.5V (see 1N4148 datasheet, figure 2) which is below the high limit (Vil, 0.3 x Vcc; see 328P datasheet, table 30-1) that the 328P will see as low.

I would say, give it a try.

Hacking the library is probably more work.