Date: 202109
Local time of day: 1801-2400
Location: ZZZ.Airport, US
Flight conditions: VMC
Weather elements / visibility: 25
Light: Daylight
Aircraft: Small Aircraft; Low Wing; 1 Eng; Fixed Gear
Operator: Personal
Operating under: Part 91
Flight plan: IFR
Mission: Personal
Flight phase: Cruise
Airspace: Class E ZZZ4
ATC / advisory: Center ZZZ4
Reporter organization: Personal
Reporter function: Pilot Flying; Single Pilot
Reporter qualification: Flight Crew Instrument; Flight Crew Private
Human factors: Workload; Situational Awareness; Human-Machine Interface; Distraction
Anomaly: Deviation - Track / Heading All Types; Deviation / Discrepancy - Procedural Clearance; Inflight Event / Encounter CFTT / CFIT; Inflight Event / Encounter Weather / Turbulence
Detector: Person Air Traffic Control
When detected: In-flight
Result: Air Traffic Control Issued New Clearance; Air Traffic Control Provided Assistance; Flight Crew Requested ATC Assistance / Clarification; Flight Crew Diverted
Contributing factors: Human Factors; Procedure; Airspace Structure; Software and Automation; Weather
Primary problem: Airspace Structure

Narrative: At approximately XB:45 PM Mountain daylight time I departed ZZZ on an IFR flight plan to ZZZ1.  I had an estimated 14 gallons of fuel upon arrival earlier in the day and I instructed the FBO at ZZZ2 to add 50 gallons total; 25 per side to the tanks giving me an estimated fuel load of 64 gallons. I set up the avionics in my airplane showing that I had 60 gallons of fuel; which is what my flight plans said I needed including legal minimums leaving the four extra gallons as my 'Just in case' which was as I was taught.I had previously created a flight plan (2 weeks prior to the actual date of the flight) in ForeFlight that I updated almost daily including the day prior to the flight and again at approximately XA:00 PM that afternoon (on the day of the flight; approximately 30 minutes prior to departure)using the winds as of XA:00 Zulu and the TAF as of XA:25 Zulu. I have saved all of these documents for the record and have copies of the original filings and the original NAV logs and terminal air forecast data. Winds were estimated to be average 23 knot headwind at 260 and the NAV log showed that the block fuel required was 60 gallons including a 14 gallon legal reserve for the flight. Since I landed with 14-15 gallons in the tanks and added 50 gallons total; 25 per side I felt confident that I had a sufficient amount of fuel for the flight based on the current and forecast winds; the aircraft performance and my ForeFlight briefing and NAV log and should land at ZZZ1 with 14 to 18 gallons of fuel.Upon departure from ZZZ2; ZZZ3 Approach vectored me to a 250 heading and left us on that heading for vectors around a military operating area. ZZZ3 Approach handed us off to ZZZ4 Center which kept us on the 250 heading for quite some time.  In checking my direct to function on ForeFlight (which I had operational on my knee board)I could have went direct to ZZZ5 VOR and kept well south of the military operating area. Wanting to get back on course; I made a radio call to ZZZ4 Center asking if we could go direct at this point to the ZZZ5 VOR. ZZZ4 Center did not clear us direct ZZZ5.  They then cleared us to ZZZ6 VOR. Then direct ZZZ5 then ZZZ2 AT 14;000.  The flight proceeded normally except that winds were showing to be 35 to 45 knots direct headwind. The fuel totalizer showed 17 to 18 gallons fuel over destination so I continued the flight keeping an eye on the fuel over destination. Conditions were VMC The entire flight.At approximately ZZZ7 VOR; the winds began to pick up dramatically and instruments start showing 45 to 50 knot direct headwind. At this point the fuel totalizer began to show 8 to 10 gallons fuel over destination. I activated the nearest function on my avionics to find an airport where I could deviate to; in order to take on more fuel and then finish the flight. The nearest function showed that ZZZ8 had 24 hour self-service fuel and was approximately 30 miles to my south.  At this point I had over 20 gallons of fuel good for over an hours worth of flight time and ZZZ8 was a 10 to 15 minute diversion and decided to divert to ZZZ8 for fuel.I decided that if the winds did not die down and the fuel totalizer returned to a minimum of 14 gallons fuel over destination within the next 10 minutes that I would divert to ZZZ8 and take on fuel.  The winds persisted and I advised ZZZ4 Center that I would need to divert to ZZZ8 for fuel due to the wind being much stronger than anticipated or forecasted and that I did not want to be minimum or emergency fuel arriving into the ZZZ1 area. The center controller asked me if I wished to declare an emergency. I said no that I had sufficient fuel to reach ZZZ8 which was approximately 30 miles away and not into a direct headwind and that I plan to land at ZZZ8 take on fuel and resume the flight.The controller cleared me to ZZZ8; l and I had a bearing up on my nearest screen and it showed a bearing of 218 to ZZZ8 so I switched from NAV on the auto pilot to heading and dialed in 220 and started toward ZZZ8.  The controller asked me what approach I wanted at ZZZ8 and I looked on ForeFlight and noticed the ZZZ8 had a GPS approach to runway XX.Add this point I put what I thought was the identifier for ZZZ8 in my avionics as 'ZZZ9' which is an airport in [completely different state]. I selected NAV on the auto pilot and the airplane made a turn to the left from a hearing of 220 approximately 090 turning the aircraft back toward a mountain range.  I immediately saw that I was turning away from the airport but at this point did not understand why as at this moment.  I didn't realize that I had put the airport identifier in the avionics incorrectly as ZZZ9 instead of ZZZ8. I attempted to re-enter the airport identifier as ZZ8 again and the avionics again tried to guide me toward the wrong airport. At this point I did not realize that I was entering the wrong airport identifier but I could see ZZZ8 on my moving map and knew that I was navigating away from ZZZ8.  Although I was in VMC conditions it took me approximately one to two minutes to realize my error and to reprogram the avionics to the correct airport identifier and locate the approach charts for ZZZ8 for the GPS runway XX. During this time the controller told me that it appeared I was navigating away from ZZZ8 and the airport off to my right was not the ZZZ8 airport and gave me a heading to ZZZ8 and the controller issued me a low altitude alert.   I started a right turn toward ZZZ8 and attempted to load the approach to ZZZ8 but my avionics had ZZZ1 as my final destination and wanted to load approaches to ZZZ1 and not ZZZ8. I deleted the remainder of my flight plan out of my avionics except for ZZZ8 located the approach and flew the GPS to ZZZ8 and landed normally without incident.  I found the frequency on the approach plate for the lights at ZZZ8 and using the pilot controlled lighting at ZZZ8; l turned the lights on positively identified the runway and landed safely without incident at ZZZ8.I told the controller at ZZZ4 Center that I had the airport in sight (identified the airport by turning on the runway lights) and was established on the approach and would land  normally and take on fuel. The controller issued me a possible pilot deviation notice and asked me to call  when I landed.  I landed the airplane and took on 40 gallons of fuel and called ZZZ4 Center on the number provided.The person who answered the phone was polite asked me my name and then asked me 'Hey what happened here?' I related the basic details of the events above (although not in the detail provided here).  They thanked me for calling and asked me for my name address and pilot certificate number all of which I gave to them. They told me thank you and if anyone else had any questions they would be in contact with me.I continued the flight to ZZZ1 by getting an IFR clearance from Center out of ZZZ8 to ZZZ5 direct ZZZ1 was cleared for an ILS approach to Runway XY Via a 15 DME arc and landed normally at ZZZ1 at approximately XG:50 PM MDT.I've had a lot of time to think about this at length.  As the avionics attempted to turn the airplane toward ZZZ9 I immediately realized that I was going in the wrong direction but for a period of about 1 to 2 minutes I didn't understand why the airplane was attempting to take me an airport in [different state].  I knew it was taking me in the wrong direction but I didn't understand why; initially.  As I was turning the airplane back toward ZZZ8 as I could see it on my map I was trying to figure out why the avionics wasn't taking me there. Then I realized that I had put in the wrong airport identifier; by one digit. When I fixed that I tried to load the approach for ZZZ8 edit brought up the ZZZ1 approach charts. That took me a few seconds to realize that the avionics was thinking I wanted at my destination was ZZZ1 and I'm now landing at ZZZ8. I deleted the rest of my flight plan leaving ZZZ8  as my destination located the approach chart activated the approach to ZZZ8; l and landed there.  I did all of this during a right turn and flying back toward ZZZ8 and lining up to the runway.In retrospect I realize that the controller at ZZZ4 Center had no idea why I was turning in the wrong direction except that I was turning toward high elevation terrain.  The controller was doing his job in notifying me that I was headed the wrong direction and giving me Low altitude alert. However I was also doing my job in Aviating first; navigating second and communicating third.  At this point the controller was trying to correct my direction of flight and I was flying the airplane in VMC conditions while trying to correct my avionics to direct me to ZZZ8. In my estimation of what happened; both the controller and I were doing our jobs to the best of our abilities.  I made the unfortunate mistake of entering the fix for ZZZ8 airport in my avionics incorrectly which took me in the wrong direction however I realized the error immediately and corrected the error promptly and remained in VMC conditions throughout.I believe that my decision making was sound; correct and timely to divert to ZZZ8 to take on additional fuel and I also believe that my flight planning utilizing ForeFlight the terminal air forecast and predicted winds were all carefully studied and factored into the decision on how much fuel to take on for the flight to ZZZ1 considering weight and balance.If I had this all to do over again I would probably have continued my flight toward ZZZ1 for an additional 5 minutes or so and reprogrammed ForeFlight on my IPad; reviewed the route and approach options; and then once I had it where I wanted it; requested it from center and then once approved; send it from my tablet to the panel and activated the new route from the panel.  The day following this event I flew from ZZZ1 to ZZZ10 and then from ZZZ10 TO ZZZ11.  On departure from ZZZ1 I was assigned the ZZZZZ4 departure  ZZZ12 transition from runway XY @ZZZ1.  As I was preparing for taxing out ZZZ1 switched runways from XY to YX.  I was still on the ramp and although it is the same SID procedure it has different routing and I had to take out the runway XY routing and replace it with the YX routing.  The controller acted a little aggravated as he asked me if I was ready for taxi but I told him I needed a minute to update my SID routing.  What I didn't want to do is being taxing out 'heads down' reprogramming my route.  Why not do it while stopped and in the ramp?  About a minute later I advised ground that I had the route reprogrammed and was ready for taxi.  They taxied me to Runway YX and I did it with heads up and eyes out.  Minutes later they cleared me for takeoff; and canceled the SID routing while issuing me the takeoff clearance and put me on a departure heading.  No problem. ZZZ13 Approach directed me off heading to an interim fix on the SID which I navigated to and executed without problem.  But ATC  is busy and used to giving immediate instructions to be complied with immediately; and moving on to the next guy.  But now that I am on the other side of the mike; I now understand what it takes to fly the airplane; take into consideration the concerns of non-pilot passengers and reprogram avionics on the fly due to changing conditions.  The day following this incident I flew 1;365 NM in two legs and practiced during the 3 hour en-route phase; practiced my reaction to this incident by selecting a nearest to airport and then entering the fix into the avionics and walking through the steps to delete the rest of the flight plan and load a deviation airport approach.  I also use ForeFlight as my back up NAV source and practiced programming a divert flight plan an exporting it to the panel.During the leg from KZZZ10 to ZZZ11 I got to put it to the test due to weather.  My route taking me from SZZZ14 TO ZZZ11 was through a line of severe thunderstorms.  I was able to see this developing at my destination an hour ahead




Synopsis: A single engine Pilot reported they entered the wrong destination into their avionics resulting in turning the wrong direction and receiving a Low Altitude Alert from ATC. The reporter was diverting from their original clearance destination to refuel the aircraft.