Xinyuan-LilyGO / LilyGo-T-PCIE

89 stars 35 forks source link

Problem waking up from IMU interrupt #36

Open sporkyduck opened 6 months ago

sporkyduck commented 6 months ago

Hi,

I have a T-PCIE v1.2 (WROVER-E) and an MPU 6050 IMU with INT connected to GPIO 36 on the T-PCIE. I am trying to make the IMU wake up a sleeping MCU when motion is detected on the IMU. My problem is that the MCU is immediately woken up after going to sleep with wake reason ESP_SLEEP_WAKEUP_EXT0. I have this issue reported before, but no actual soluations. Anyone here has experience with waking up MCU from motion detection?

My setup and sleep code is as follows:

// Motion detection setup
mpu.setHighPassFilter(MPU6050_HIGHPASS_0_63_HZ);
mpu.setMotionDetectionThreshold(10);
mpu.setMotionDetectionDuration(20);
mpu.setInterruptPinLatch(true); // Keep it latched.  Will turn off when reinitialized.
mpu.setInterruptPinPolarity(true);
mpu.setMotionInterrupt(true);
// Go to sleep if running time is up
  if (millis() > TIME_TO_RUN * MS_TO_S_FACTOR)
  {
      Serial.println("Going to sleep.");

      // Configure PIN 36 for INT input
      pinMode(GPIO_NUM_36, INPUT);

      //esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * US_TO_S_FACTOR);;
      if (esp_sleep_enable_ext0_wakeup(GPIO_NUM_36, LOW) != ESP_OK)
      {
          Serialprintln("Error enabling interrupt wakeup!");
      }
      esp_deep_sleep_start();
  }

Thanks!