I recommend you test the idle air control valve. See procedure below. If this is not the problem, please read additional possibilities at the link below.
The Idle Air Control (IAC) valve controls the amount of air that bypasses the throttle valve, which controls the engine idle speed. The IAC valve consists of windings, an armature, a return spring, and a rotary slide. The engine control module (ECM) pulses the voltage to the winding, the opposing forces on the armature by the return spring cause it to maintain a fixed position, adjusting the amount of bypass air to maintain the correct idle speed.
Removal & Installation
Turn the ignition switch to the OFF position.
Disconnect the idle air control valve harness electrical connector.
Using a suitable tool, remove idle air control valve.
Installation is in reverse order of removal.
Checking Idle Air Control Valve (IAC) Triggering
Check IAC valve is electrically OK.
Slide up boot on the IAC valve connector.
Fig. IAC Connector
Use scan tool 'Output Diagnostic Test Mode' function 03 to trigger the IAC valve - N71.Connect VAG 1527B voltage tester, or equivalent, between terminal 1 and engine ground (GND). Voltage tester must flash.Connect VAG 1527B voltage tester, or equivalent, between terminal 2 and battery positive voltage (B+). Voltage tester must light up.If specified results are not obtained:Connect VAG 1598/19 test box, or equivalent, to ECM harness connector.Check the wiring between harness and connector terminal 1 (in engine compartment) to test box socket D11 . Then check the wiring between harness connector terminal 2 and test box socketD9 using wiring diagram. Repair as necessary.If the wiring is okay, but triggering still does not occur, replace the ECM.If the triggering signal and the wiring are okay and the valve does not react, replace the IAC valve. Checking Mechanical Function
Remove the idle air control (IAC) valve.Visually check the surface of the rotary slide (arrow) for signs of wear.
Fig. Showing the IAC Valve
Do NOT check for ease of movement by prying on the rotary slide with a screwdriver or other tools that could cause scratching or other damage.
Reconnect the IAC valve, while still removed, to the harness connector.Use scan tool 'Output Diagnostic Test Mode' function 03 to trigger IAC valve - N71.Check whether rotary slide moves freely from stop to stop.If there are signs of scoring, or if the rotary slide does not move freely in both directions, replace the IAC valve.If the IAC valve does not respond (not triggered) during the Output Diagnostic Test Mode, check triggering. Resistance Test
Remove the idle air control valve harness connector.Use a suitable Digital Multimeter (DMM) to measure the resistance between the 2 terminals of the idle air control valve.The correct measurement should be 7-11 ohms. If not, replace the idle air control valve.
At room temperature, the resistance value will be lower. The resistance value will be higher if the Idle Air Control (IAC) valve is measured at under-hood operating temperatures.
Reconnect the idle air control valve harness connector.The idle air control valve should hum and vibrate slightly when the ignition is turned 'ON'. If not, the ECM or harness may be defective. Do It Yourself Diagnosis and Repair