0

I am using Arduino-uno, attached ESP-01 module

I want to give interrupt when I send some wifi-signal to arduino, which is in sleep mode.

so I write this code:

SoftwareSerial esp(2, 3); // RX, TX

void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600);

  esp.begin(9600);

  attachInterrupt(digitalPinToInterrupt(2),work,RISING);

  delay(1000);

  init_sleep(); // go to sleep
}

void work(){
    light = ! light;

    digitalWrite(12,light);

}

when I don't write down the init_sleep, this interrupt is able to work.

but when the arduino is in sleep mode, because of writing 'init_sleep' It does not react signal by interrupt.

Is it impossible to wake up sleeping arduino by attachInterrupt() ? please give me some solution.

  • Why the delay()? If the interrupt happens while in delay(), it won't wake up the Arduino that is not sleeping yet. – Edgar Bonet Jul 15 at 8:16
  • oh I had some mistake. but I deleted the delay, result is same. – lee du Jul 15 at 8:34
  • Where does init_sleep() come from? I did my a little differently by directly accessing registers but I know you have to disable sleep mode in your "wake up" ISR as the first thing before anything will happen. Watch this tutorial, it is very good. youtube.com/watch?v=urLSDi7SD8M – HavocRC Jul 16 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.