Do an Arduino project with a temperature sensor, how to find libraries and resources?

2 min read

1. Popular Temperature Sensors for Arduino
Sensor | Type | Features |
DHT11 / DHT22 | Digital | Measures temperature & humidity, easy to use |
LM35 | Analog | Accurate analog temperature, 10 mV/°C |
DS18B20 | Digital (1-Wire) | High precision, available waterproof |
TMP36 | Analog | Simple analog temperature sensor |
BME280 / BMP280 | I2C/SPI | Measures temperature, humidity, pressure (BME280) |
🧰 2. Required Libraries
Here are the matching Arduino libraries (install via Library Manager):
Sensor | Library |
DHT11/DHT22 | DHT sensor library by Adafruit + Adafruit Unified Sensor |
LM35/TMP36 | No special library – use analogRead() |
DS18B20 | OneWire + DallasTemperature |
BME280 | Adafruit BME280 |
BMP280 | Adafruit BMP280 or SparkFun BMP280 |
📦 3. Example Code for DHT22 (Digital Sensor)
cpp
#include <DHT.h>
#define DHTPIN 2 // Pin where the sensor is connected
#define DHTTYPE DHT22 // DHT11 or DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float temp = dht.readTemperature(); // Temperature in °C
float hum = dht.readHumidity(); // Humidity in %
if (isnan(temp) || isnan(hum)) {
Serial.println("Sensor error!");
} else {
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" °C");
}
delay(2000);
}
💡 4. Where to Find Examples and Help
Source | Description |
Arduino Project Hub | Search for “DHT22” or “temperature sensor” |
Adafruit Learn | Great tutorials for DHT, BME280, etc. |
Random Nerd Tutorials | Comprehensive examples for DS18B20, BME280, ESP32 |
Instructables | DIY projects with photos & step-by-step guides |
Arduino Forum | Get help with problems & project ideas |
✅ Tip: Choose the Sensor Based on Your Application
Use Case | Recommended Sensor |
Indoor climate measurement | DHT22, BME280 |
Outdoor / waterproof use | DS18B20 (in waterproof casing) |
Industrial / analog measurement | LM35, TMP36 |
High precision & multiple values | BME280 (I2C) |
0
Subscribe to my newsletter
Read articles from ampheo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
