Q: Rattle noise on 2005 Mazda Mazda6

Rookie cbe0621eac06868b3efe0d8d1d3611e23c60d3114864ea2ec19a68cfbd3eebab
I have notice for sometime now that a rattle type noise is coming from the engine area. it seems to be more persistant when the a/c is on too. Also a check engine light came on and a code of P0128 came up. Car still runs great just want to fix these problems.
(1) Answer
I don't think these are related. I would determine where the noise is coming from, I would guess the drive belt area. And for the code, start with replacing the thermostat and change the coolant while your at it.

Here is the info for the p0128 code:
Trouble Code: P0128 (2.3L L4 - Auto)
Thermostat Malfunction
Trouble Code Conditions:
Cold startup requirement met (ECT (Engine Coolant Temp Sensor) input less than 95ºF, IAT (Intake Air Temperature) sensor more than 14ºF and the difference between the ECT and IAT sensor signals less than 43ºF), VSS (Vehicle Speed Sensor) input over 15 mph and the MAF, IAT and ECT sensor signals all within normal range, the PCM det

Possible Causes:
* Check the operation of the thermostat (it may be stuck open)
* ECT sensor has failed
* PCM has failed