Narrative:

Lost GPS garmin 430 over ZZZ. Tried to troubleshoot GPS; by resetting avionics. Proceeded to shoot GPS at a safe distance from practice area near ZZZ1. Lost track of how long I spent trouble shooting. Noticed my fuel tank gauge[s] were on empty; but I didn't realize this was only due to an electrical failure. Attempted to contact ZZZ1 tower via cell phone but was unable to receive a good cellular signal. Tested electrical system once more by attempting to lower flaps; but they failed. I then concluded I had a total electrical failure and was unsure how long I had been circling or how much fuel I burned. With my fuel gauges still reading empty I made the decision to land on runway xx remembering that it was the active runway on my departure and observing aircraft taking off.

Google
 

Original NASA ASRS Text

Title: The pilot of a Cessna 172L reported that while trying to reset the avionics he discovered he lost all electrical power.

Narrative: Lost GPS Garmin 430 over ZZZ. Tried to troubleshoot GPS; by resetting Avionics. Proceeded to shoot GPS at a safe distance from practice area near ZZZ1. Lost track of how long I spent trouble shooting. Noticed my fuel tank gauge[s] were on empty; but I didn't realize this was only due to an electrical failure. Attempted to contact ZZZ1 tower via cell phone but was unable to receive a good cellular signal. Tested electrical system once more by attempting to lower flaps; but they failed. I then concluded I had a total electrical failure and was unsure how long I had been circling or how much fuel I burned. With my fuel gauges still reading empty I made the decision to land on Runway XX remembering that it was the active runway on my departure and observing aircraft taking off.

Data retrieved from NASA's ASRS site and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.