Read a TMP36 Temperature Sensor Accurately: Offset, ADC Reference and Placement
A TMP36 temperature sensor is simple to connect, but a plausible temperature reading can still be wrong. Two common causes are forgetting its voltage offset and assuming the ADC reference equals the board's nominal supply. A third is measuring the temperature of a warm circuit board while calling the result room temperature.
The TMP36 two-pack is a straightforward analogue option in PMD Way's analogue temperature sensor collection. This guide follows the signal from the sensor package to the displayed number and shows how to check each stage separately.
Use the TMP36 transfer relationship
The Analog Devices TMP35/TMP36/TMP37 datasheet gives the TMP36 a 10 mV/°C scale factor and a 500 mV offset. Its typical output at 25°C is therefore 750 mV. With output voltage expressed in volts:
temperature in °C = (output voltage − 0.500) / 0.010
For example, 0.820 V corresponds to 32°C. A reading of 0.450 V corresponds to −5°C. Keep the units explicit: subtracting 0.500 from a value stored in millivolts produces a very different answer.
Do not substitute this equation for another sensor merely because its package looks similar. The related TMP35 and TMP37 have different transfer characteristics. The TMP36's specified temperature range is −40°C to +125°C; extending the straight-line equation to −50°C does not establish specified operation there.
Identify the package orientation before applying power
The TMP36 operates from 2.7–5.5 V. For the TO-92 package, the datasheet identifies pin 1 as supply, pin 2 as output and pin 3 as ground, with the pin diagram explicitly shown from the bottom. Match that view to the actual part rather than relying on an unexplained “left pin” instruction.
Build the first circuit with power disconnected. Check the breadboard rows, supply polarity and common ground, then add the supply decoupling recommended by the datasheet. Keep the initial output lead short and away from switching power wiring.
After applying power, use a suitable meter to check the supply at the sensor and the output relative to its ground. An output around the expected room-temperature region is a useful first check, but it is not a calibration. If the sensor warms unexpectedly or the voltage is implausible, disconnect power and inspect the wiring.
Convert ADC counts using the actual configuration
The ADC returns a code representing an input voltage relative to its reference and transfer function. Check the board's ADC resolution, reference source, allowed input range and any attenuation settings. A code copied from an older Arduino example may not describe the board in front of you.
For an ideal unipolar N-bit ADC with reference Vref, the nominal code-step size is Vref / 2^N. Use the device's documented transfer convention when reconstructing voltage from a code. The distinction between code steps and endpoints is small compared with many practical errors, but the resolution and reference must be correct.
As a scale example, an ideal 10-bit ADC with a 5.00 V reference has approximately 4.88 mV per step. With the TMP36's slope, that is about 0.49°C per step. A 12-bit ADC at 3.30 V gives approximately 0.806 mV, or 0.081°C per step. These are quantisation examples, not promises of temperature accuracy.
Arduino's analogReadResolution reference explains that requesting more bits than the hardware supports does not create additional real resolution. Record both the configured return format and the hardware capability.
Check reference error before blaming the sensor
Suppose the actual reference is 4.80 V, but the conversion code uses 5.00 V. A true 0.750 V sensor output is then reconstructed at roughly 0.781 V, corresponding to about 28.1°C rather than 25°C. A modest voltage-reference error has become several degrees of temperature error.
Measure or characterise the reference using the board manufacturer's recommended method. If it is derived from a supply that changes with USB loading or battery condition, repeat the check under those conditions. Do not assume that averaging removes a wrong scale factor.
A lower reference can improve code resolution over a limited temperature range, but it must accommodate the sensor's maximum expected output. Follow the controller's reference-selection instructions and limits; do not connect an external voltage to a reference pin without checking how that pin is configured.
Decide which temperature you want
The sensor reports its own temperature. Its package reaches that temperature through contact with air, its leads, the board and nearby surfaces. The application must make that thermal relationship match the intended measurement.
Analog Devices' temperature-sensor selection guide discusses thermal paths and the challenges of ambient measurements. A sensor beside a regulator may accurately report a locally warmed environment while differing from the room away from the electronics.
For room-air experiments, keep it away from unnecessary heat sources and direct sunlight, and provide an appropriate air path through the enclosure. For component monitoring, establish repeatable thermal contact with the intended surface while maintaining electrical insulation. Those are different mounting problems.
Allow the assembly to settle after handling or moving it. Holding the package between fingers is a simple response demonstration, but the result is affected by contact and time; it is not a calibrated body-temperature measurement.
Verify the complete chain with a reference
- Place the sensor and a suitable reference thermometer close together in a stable, safe environment.
- Wait for both readings to settle.
- Record ADC code, output voltage, reference setting and both temperatures.
- Repeat at another stable temperature within the intended operating range.
- Return to the first condition to check repeatability.
Keep an unsealed sensor and exposed wiring out of liquids. A water-bath comparison requires an appropriately designed and verified sealed assembly, whose response may differ from the bare package. An ambient-air comparison is often enough to reveal a major conversion error.
If the discrepancy is nearly constant, inspect offset and reference uncertainty. If it grows with temperature, inspect the conversion scale. If it changes when the enclosure or processor workload changes, investigate thermal placement. Correct the identified cause before applying an arbitrary software adjustment.
Finally, show only useful decimal places and keep the original measurements with the project. A reliable TMP36 thermometer comes from a correct equation, a checked voltage measurement and a thermal installation that matches the question being asked.