The ESP32-CAM is in deep sleep mode with external wake up enabled. When motion is detected, the PIR motion sensor sends a signal to wake up the ESP32. The ESP32-CAM takes a photo and saves it on the microSD card. It goes back to deep sleep mode until a new signal from the PIR motion sensor is received.