ESP32 Thing Plus (USB-C) - determine powered by USB-C or battery?

I’m building a refrigerator monitor.

I live in hurricane country and want an external indicator of the temp in the refrigerator and freezer compartment of my kitchen’s fridge.

One thing I want to be able to monitor and report on is if the fridge has wall power. Figure to plug the monitor’s power supply into the same outlet as the fridge.

So I need a way to determine if the Thing+C is receiving power from the usb-c port or from the battery port.

There is the integrated MAX17048 Fuel Gauge – but that does not appear to report power input.

I could probably look at the battery charge level and assume if discharging then wall power is off.

Other features I’m planning:

  • 1-3 temp sensors (SEN-21273 on a qwiic wire)

  • eInk display for temperature and alert display

  • MQTT reporting ( report to my home assistant server )

  • battery for monitoring during power outages - plan to reduce update frequency and turn off wifi during power outage to extend battery life. Monitoring would be ‘walk around and look at the display’ but I would not have to open the door to check temps.

To determine whether your refrigerator monitor is receiving power from the USB-C port or from the battery port, you can use a power management IC, such as the Texas Instruments BQ25895, which includes a built-in input voltage monitor and switching circuitry that automatically switches between USB-C and battery power sources. This is a reliable power solution.

It’s a rare occasion for a battery to be at 100%, so checking the SoC of the battery from the MAX fuel gauge is a pretty simple way to have a guess at whether USB-C is connected. I think your idea as a solution is a pretty good one for little effort on your part.