First of all diagnostic fault codes never say to replace parts or that they're bad. They only indicate the circuit or system that needs further diagnosis. When a part is referenced in a code it is only the cause of that code about half of the time. This appears to be one of those times something else is the cause.
Engine temperature can not change rapidly as you described. It takes time to heat up the coolant and cool it off. Even if the thermostat were to stick open or closed unexpectedly, you wouldn't see the result of that for a minute or two. Most likely you have an electrical issue with the coolant temperature sensor circuitry. The sensor will have two wires and either one could have a "spread" terminal in the connector making intermittent connection. There could be corrosion on one of the terminals, or a splice could be corroded. Your mechanic will perform tests on that circuitry to rule out everything other than the sensor itself, then he will replace it when no other cause is found.
Even replacing a part can aggravate or change the symptoms. In the case of corrosion, for example, the terminals in a connector may scratch a clean spot and make good contact for a little while, then the problem will come right back. It is also possible to dislodge some corrosion that gets stuck between the mating terminals and causes new problems.
Friday, July 5th, 2013 AT 9:25 AM