Why Use Temperature Sensors with Arduino?
Temperature sensors are easy to use and perfect for learning Arduino basics. They let you build digital thermometers, smart home projects, weather stations, and more. This guide will help you get started with the most popular temperature sensors for Arduino.
Popular Temperature Sensors for Arduino
- LM35: Analog sensor, outputs voltage proportional to temperature (°C). Simple and accurate for room temperature projects.
- DS18B20: Digital sensor, uses 1-Wire protocol, supports multiple sensors on one pin. Waterproof versions available.
- NTC Thermistor: Analog sensor, resistance decreases as temperature increases. Inexpensive and widely used.
Wiring Diagrams
LM35 to Arduino

Vout to A0, Vcc to 5V, GND to GND
DS18B20 to Arduino

DQ to digital pin, Vcc to 5V, GND to GND, 4.7kΩ pull-up resistor
NTC Thermistor to Arduino

Thermistor and fixed resistor in voltage divider, center to A0
Sample Arduino Code
LM35 Example
// LM35 on A0
const int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(sensorPin);
float voltage = value * (5.0 / 1023.0);
float tempC = voltage * 100.0;
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println(" C");
delay(1000);
}
DS18B20 Example
// DS18B20 on pin 2
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println(" C");
delay(1000);
}
NTC Thermistor Example
// NTC Thermistor on A0, 10k resistor to GND
const int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(sensorPin);
float voltage = value * (5.0 / 1023.0);
// Calculate resistance and temperature (simplified)
float resistance = (5.0 - voltage) * 10000.0 / voltage;
// Use a lookup table or Steinhart-Hart equation for accuracy
Serial.print("Thermistor resistance: ");
Serial.println(resistance);
delay(1000);
}
Troubleshooting Tips
- Check wiring and sensor orientation carefully.
- Use the correct libraries for digital sensors (e.g., DallasTemperature for DS18B20).
- Verify your Arduino board is selected and the correct COM port is used.
- If readings are erratic, use short wires and avoid electrical noise sources.
- For thermistors, use the correct resistor value and calibration method.
Project Ideas for Beginners
- Digital room thermometer with LCD display
- Temperature-controlled fan or heater
- Data logger with SD card or cloud upload
- Weather station with temperature and humidity
- Fridge/freezer temperature monitor with alarm
Resources
Conclusion
Using temperature sensors with Arduino is a great way to learn electronics and start building real-world projects. With just a few components, you can measure, display, and control temperature in your own DIY creations!