Why is my car overheating at idle or in heavy traffic?

A bad temperature sensor wouldn’t trigger the check engine light?