A temperature sensor is a transducer that converts thermal energy into an electrical signal—either a continuous voltage, a varying resistance, or a discrete digital packet—that a microcontroller can measure. If you are asking what is temp sensor hardware actually doing on your workbench, it is bridging the physical world of thermodynamics to the logical world of your MCU's GPIO pins and ADC registers. Choosing the wrong one leads to jittery readings, self-heating errors, or fried I/O pins.
The Physics: How Temperature Sensors Actually Work
Integrated silicon temperature sensors (like the TMP36 or the internal sensor inside an ESP32) rely on the predictable voltage drop across a forward-biased PN junction. As the silicon die's temperature rises, the bandgap energy required for electrons to cross the junction changes, altering the forward voltage by a highly predictable rate (typically around -2mV/°C). The IC's internal circuitry amplifies and offsets this tiny shift into a usable, linear output.
Other sensing principles exist for different physical constraints. Thermistors (NTC/PTC) use sintered semiconductor ceramics where resistance changes exponentially with heat, requiring complex Steinhart-Hart math to linearize. RTDs (Resistance Temperature Detectors) use pure metals like platinum (Pt100/Pt1000) where resistance increases linearly, but they require expensive constant-current excitation circuits. For 95% of hobbyist and commercial embedded projects operating between -40°C and +125°C, integrated silicon ICs dominate because they handle the linearization and signal conditioning on-die.
Analog vs. Digital: What the Output Actually Is
The most common beginner mistake is conflating analog voltage outputs with digital data outputs. Your microcontroller reads them in fundamentally different ways, and the math to convert the raw reading into physical units (°C or °F) changes entirely based on the interface.
Analog Output (Voltage)
An analog sensor like the TMP36 outputs a continuous DC voltage proportional to temperature. The TMP36 specifically outputs 10mV per degree Celsius, with a 500mV (0.5V) offset so it can read sub-zero temperatures without a negative supply rail.
The Raw-to-Unit Math (Arduino 10-bit ADC, 5V Reference):
- Convert raw ADC to Voltage:
V_out = (Raw_ADC * 5.0) / 1024.0 - Subtract the 0.5V offset:
V_shifted = V_out - 0.5 - Scale by 10mV/°C (multiply by 100):
Temp_C = V_shifted * 100.0
Combined Formula: Temp_C = (((Raw_ADC * 5.0) / 1024.0) - 0.5) * 100.0
Digital Output (1-Wire / I2C)
A digital sensor like the DS18B20 (1-Wire) or BME280 (I2C) contains the sensing element, an onboard ADC, and a digital communication controller. The output is a discrete data packet. The microcontroller doesn't measure voltage; it reads a register.
The Raw-to-Unit Math (DS18B20 12-bit resolution):
The DS18B20 outputs temperature as a 16-bit two's complement integer. The math is handled by the library, but under the hood, the raw 16-bit register value is simply divided by 16.0.
Formula: Temp_C = Raw_16bit_Register / 16.0
Wiring Pinouts and Supply Requirements
Before soldering, verify your supply voltage. Feeding 5V into a 3.3V I2C sensor will permanently brick the silicon. Below are the specifications for the most common embedded temperature ICs.
| Sensor Model | Interface | Supply Range | Pinout (Flat side facing you, L to R) | Quiescent Current |
|---|---|---|---|---|
| TMP36 | Analog (Voltage) | 2.7V to 5.5V | 1: VCC, 2: V_OUT, 3: GND | ~50 µA |
| DS18B20 (TO-92) | 1-Wire (Digital) | 3.0V to 5.5V | 1: GND, 2: Data (DQ), 3: VDD | 1 mA (active), 1.5 µA (standby) |
| BME280 | I2C / SPI | 1.71V to 3.6V | Breakout dependent (Usually VCC, GND, SCL, SDA) | ~3.6 µA (standby) |
| LM35 | Analog (Voltage) | 4.0V to 30V | 1: VCC, 2: V_OUT, 3: GND | ~60 µA |
Signal Interference and Calibration Realities
Sensors don't exist in a vacuum. The physical environment and your wiring topology will introduce errors that the datasheet's 'typical' specifications won't warn you about.
Analog Interference: Wire Resistance and EMI
Analog sensors output millivolt-level signals. If you run a TMP36 over 20 feet of 24AWG wire, the copper resistance (approx. 25.7Ω per 1000ft) adds voltage drop. More critically, long unshielded analog wires act as antennas, picking up electromagnetic interference (EMI) from nearby switching power supplies, AC mains, or PWM-driven motor controllers. This injects high-frequency noise directly into your MCU's high-impedance ADC pin. Fix: Keep analog sensor wires under 3 feet, use twisted-pair shielded cable, and add a 0.1µF ceramic bypass capacitor directly across the sensor's VCC and GND pins.
Digital Interference: Bus Capacitance
Digital sensors solve the EMI problem, but introduce capacitive loading. The 1-Wire protocol relies on precise microsecond timing. Standard CAT5 cable has a capacitance of roughly 15pF per foot. If you run a DS18B20 probe 50 feet away, you add 750pF of capacitance to the bus. Combined with the standard 4.7kΩ pull-up resistor, the RC time constant smears the rising edge of the data signal, causing CRC (Cyclic Redundancy Check) errors and dropped readings. Fix: For long digital runs, drop the pull-up resistor to 2.2kΩ or even 1kΩ to charge the parasitic capacitance faster.
Self-Heating and Calibration
Integrated silicon sensors are factory-trimmed and rarely require user calibration (unlike NTC thermistors, which require Steinhart-Hart coefficient mapping). However, they suffer from self-heating. If a sensor draws 1mA of continuous current in still air, the silicon die will heat itself by 0.1°C to 0.5°C above ambient. If you are logging data every second, keep the sensor in standby mode between reads, or use 'parasite power' mode carefully, ensuring the MCU sleeps during the 750ms conversion window to prevent bus-current heating.
The Decision Tree: Which Sensor Should You Buy?
Stop guessing based on what is in your starter kit. Use this decision matrix to select the right IC for your specific physical constraints.
| If Your Project Requires... | Then Choose... | Why? |
|---|---|---|
| Waterproofing, liquid immersion, or cable runs > 5 feet. | DS18B20 (Stainless Probe) | Digital signal ignores wire resistance voltage drops; stainless steel housing survives moisture and corrosive environments. |
| Indoor ambient weather station (needs humidity + barometric pressure). | BME280 | Provides temp, humidity, and pressure on a single I2C bus with excellent factory calibration and low self-heating. |
| Ultra-cheap, short-distance (breadboard) basic analog learning. | TMP36 | Costs ~$1.50, requires no pull-ups or libraries, but fails on ESP32 due to ADC non-linearity. |
| Measuring high-current PCB traces or battery cell surfaces. | NTC 10k Thermistor | Tiny physical footprint (0805 SMD or 2mm bead) allows direct thermal bonding to copper pours or cell wrappers. |
The Default Recommendation
If you do not have a strict constraint forcing you into analog or I2C multi-sensor territory, buy the waterproof DS18B20 probe. At roughly $2.50 to $3.50 per unit, it eliminates ADC scaling math entirely, bypasses the ESP32's noisy analog pins, ignores voltage drop over long wire runs, and survives being dropped in a bucket of water or buried in soil. It is the undisputed workhorse of embedded temperature sensing.






