Ruis Santos at www.RandomNerdTutorials.com (https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/) has very complete instructions as to how this is done. I've done it on a TTGO-ESP32 as a weather station collecting weather data and it's been running almost non-stop for 2 years off a solar charged battery.