esp-idf icon indicating copy to clipboard operation
esp-idf copied to clipboard

Risc-v esp32-s2 GPIO example with a PIR sensor (IDFGH-15199)

Open DylanGWork opened this issue 7 months ago • 1 comments

Answers checklist.

  • [x] I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • [x] I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • [x] I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Hi All,

I am using custom hardware with the ESP32-S2-Mini-U1 module and the latest esp-idf with a HC-SR501 PIR module attached to GPIO 21.

Here is my github repo using the risc-v gpio example code: https://github.com/DylanGWork/PIRTest

The issue is that when I remove the while loop in the co-processor (so that the device goes into deep-sleep), the PIR sensor going HIGH is no longer detected. The main processor is never woken up.

I have the PIR sensor hooked up to an oscilloscope so I can see when the GPIO is going HIGH.

I've tried a few variations which are commented in the sample code provided but I am yet to have a working version.

The goal is to have the device in deep sleep until the PIR sensor goes HIGH, while having the main processor wake up ever hour or timer period to send a heartbeat message.

Cheers, Dylan

DylanGWork avatar Apr 28 '25 12:04 DylanGWork

Please try this sample.

https://github.com/espressif/esp-idf/tree/master/examples/system/deep_sleep

This sample works correctly with ESP32S3 + HC-SR50x + GPIO21.

HC-SR50x sensor is powered by 5V.

It works fine with either External wake up 0 or External wake up 1.

  • EXT0
I (219) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (226) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (233) main_task: Started on CPU0
I (253) main_task: Calling app_main()
Enabling EXT0 wakeup on pin GPIO21
Wake up from ext0
I (253) main_task: Returned from app_main()
Entering deep sleep
  • EXT1
I (219) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (226) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (233) main_task: Started on CPU0
I (253) main_task: Calling app_main()
Enabling EXT1 wakeup on pins GPIO21, GPIO4
Wake up from GPIO 21
I (253) main_task: Returned from app_main()
Entering deep sleep

When HC-SR50x sensor detects motion, it will keep outputting 3.3V for a while.

nopnop2002 avatar May 08 '25 07:05 nopnop2002