Ai-Thinker ESP32-CAM:Problems using Pin 13 as input after setting 14 & 15 output

End goal: I want to wake up the ESP32 based on a PIR motion sensor, do something and then if motion is still detected do it again until there is no more motion. When that is done it should send 2 PWM signals (using 2 pins total) and an activation signal (1 pin).

I'm able to read from pin 13 with digital read which I have the motion sensor signal hooked up to. As long as I don't set pins 14 or 15 to output it works but as soon as I set them to output pin 13 stops reading.

There are very limited pins on the Ai-Thinker ESP32-CAM and according to ESP32-CAM AI-Thinker Pinout Guide: GPIOs Usage Explained | Random Nerd Tutorials pin 13 is used for the SD card if it's in use but I am not using it and have not called any functions to initialize it. That means it should be available. I'm also using it to wake the board up from a deep sleep and that works (other pins such as 12 do not work for that in my experience) but once the board is woken up once and pins 14 and 15 set to output then everytime afterwards even after waking up from deep sleep pin 13 is not readable.

Setting pin 2 as output however does not affect Pin 13's ability to perform a digital read.

Thanks for any help, tips or advice. This problem has been perplexing me for a couple days now.

Note I've also posted this on Stackoverflow and Reddit

It turns out that there is no problem with Pin 13 but with my reference voltages. I was powering the motion sensor from a secondary power supply that had more amperage capacity but the reference voltages (ground) were not the same. Once I switched the motion sensor to use the same power supply as the ESP32 then the ESP32 was able to wake up based on pin 13 as well as read it once it was awake. The issue with the reference voltages being different manifested in the ESP32 only detecting the PIR motion sensor signal as being 0.92 V when high instead of the required ~3.3V.