Temperature Sensor

DS18B20 and LM35 temperature sensor illustration

What is a Temperature Sensor?

A temperature sensor converts heat into an electrical signal or digital value. DS18B20 and LM35 modules are common in Arduino weather stations, incubators, battery packs, thermal alarms, and IoT logging projects.

The DS18B20 is digital, supports long cable runs, and can share one data wire across multiple sensors. The LM35 is analog and simple: its output voltage rises linearly with temperature.

Key Features

๐ŸŒก๏ธ

Direct Temperature Reading

Measures ambient, surface, liquid, or enclosure temperature depending on package style.

๐Ÿ”ข

Digital or Analog Options

DS18B20 uses OneWire digital data; LM35 outputs 10mV per degree Celsius.

๐Ÿ’ง

Waterproof Probe Option

Sealed DS18B20 probes are popular for aquariums, soil temperature, and outdoor projects.

๐Ÿ“ก

Long Cable Friendly

Digital probes can work over longer wires when pull-up resistance and cable quality are chosen well.

๐Ÿงช

Easy Calibration Check

Ice water and room-temperature references help verify sensor offset.

๐Ÿญ

Useful Everywhere

Used in HVAC, battery safety, fermentation, weather logging, and electronics thermal testing.

Pin Configuration

VCC

Power input. DS18B20 commonly supports 3.0-5.5V; LM35 modules are often powered from 5V.

DATA / OUT

Digital OneWire data for DS18B20 or analog voltage output for LM35. Connect to a suitable GPIO or ADC pin.

GND

Ground reference shared with the microcontroller.

How It Works

๐Ÿงช

The Science Behind It

An LM35 uses semiconductor junction behavior to produce a voltage proportional to Celsius temperature. The microcontroller ADC converts that voltage into a temperature estimate.

A DS18B20 contains sensing, conversion, and digital interface circuitry in one package. Each device has a unique address, so several sensors can share a single data pin.

Common Conversions:

LM35 temperature C = Vout(mV) / 10
ADC voltage = reading x Vref / ADC_max
DS18B20 value = digital reading from OneWire library

For ESP32 analog measurements, account for ADC nonlinearity and keep the sensor output within the 3.3V ADC range.

Wiring Tips & Best Practices

๐Ÿ”ด

Use a Pull-up Resistor

DS18B20 data usually needs a 4.7k pull-up resistor from DATA to VCC.

๐Ÿ“

Manage Cable Length

For long DS18B20 cables, use twisted pair, good grounding, and slower sampling.

๐ŸงŠ

Check Calibration

Compare against ice water, room temperature, or a trusted thermometer before relying on absolute values.

โšก

Separate Heat Sources

Keep the sensor away from regulators, microcontrollers, and power resistors unless measuring board heat.

๐Ÿ’ง

Seal Outdoor Connections

Waterproof probe tips are sealed, but connectors still need heat-shrink or enclosure protection.

โฑ๏ธ

Sample Slowly

Temperature changes slowly. One reading per second is enough for most beginner projects.

Related Resources

DHT Humidity Sensor

Measure air temperature and humidity together.

Voltage Divider Tool

Scale analog signals for ADC inputs.

IoT Roadmap

Log temperature data to connected systems.