A thermostat is a component which senses the temperature of a system so that the system's temperature is maintained near a desired setpoint. The thermostat does this by switching heating or cooling devices on or off, or regulating the flow of a heat transfer fluid as needed, to maintain the correct temperature. Thermostats are used in any device or system that heats or cools to a setpoint temperature, examples include building heating, central heating, air conditioners, HVAC systems.

A thermostat is often the main control unit for a heating or cooling system, through setting the target temperature. Thermostats can be constructed in many ways and may use a variety of sensors to measure the temperature, commonly a thermistor or bimetallic strip. The output of the sensor then controls the heating or cooling apparatus. A thermostat is most often an instance of a "bang-bang controller" as the heating or cooling equipment interface is not typically controlled in a proportional manner to the difference between actual temperature and the temperature setpoint. Instead, the heating or cooling equipment runs at full capacity until the set temperature is reached, then shuts off. Increasing the difference between the thermostat setting and the desired temperature therefore does not shorten the time to achieve the desired temperature. A thermostat may have a maximum switching frequency, or switch heating and cooling equipment on and off at temperatures either side of the setpoint. This reduces the risk of equipment damage from frequent switching.