How to detect if board WRL-15663 is running on USB or Battery?

SparkFun Thing Plus - ESP32 WROOM In stock WRL-15663

Hi, Is it possible to detect by code in the sketch if the board is actually powered by USB or Battery?

I’d like to let my board running powered via USB but with batteries attached as a back-up and trigger a message in the moment the USB power supply fails and the board switches to battery power.

If so, initiate a software reset.

Thanks in advance!

The hardware needed to do this isn’t on the board, you’d have to build an external monitoring circuit and have that signal the ESP32 that something has changed.