Detection of Loss of Power Source

I wish to use the Wio Terminal with the Chassis Battery to detect loss of the mains power supply (110 v). When this power source is lost, the 3v to 5v source (from a small USB adapter) will stop providing USB voltage to the Chassis Battery. How can a program running in the Wio Terminal detect this loss of power? When this is detected, I wish to take appropriate actions. Is there a way to sense this situation without adding external components?