Error code P1166 is a primary indicator that the ECU/ECM is receiving negative feedback from an O2 sensor or a bad O2 sensor control. Running a Oscilloscope is actually not a bad idea in this case, and if it proves to be an O2 sensor, it is most likely the one behind the catalyst control. The only other thing that comes to mind that may trigger a P1166 is a leaky air intake system, and that can be solved by doing a simple smoke test before you end up taking the vehicle to Hyundai. I would definitely recommend doing this first. If it turns out to be a leaking intake, then that will save you a lot of time and money. The reaction that your car is having at this time is typical for a faulty air system or O2 sensory as well.
From:
http://tinyurl.com/7ma2e9
Expert: Randall
You cannot use the 2004 Hyundai Sonata body parts on a 2003 Hyundai Sonata.
The 2004 Hyundai Sonata has 16 valves.
The 2004 Hyundai Sonata has a 5-speed manual.
The 2004 Hyundai Sonata is a gas-powered vehicle.
The 2004 Hyundai Sonata has an inline 4 engine.
The 2004 Hyundai Sonata's turning circle is 34.4 ft..
The 2004 Hyundai Sonata runs on regular unleaded.
The height of the 2004 Hyundai Sonata is 4 ft. 8 in. (56 in.).
The 2004 Hyundai Sonata has double overhead cam (DOHC).
The curb weight of the 2004 Hyundai Sonata is 3181 lbs..
The 2004 Hyundai Sonata is 15 ft. 6.9 in. (186.9 in.) long.
The 2004 Hyundai Sonata has 37.6 in. of rear head room.