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

ampheoampheo
2 min read
SensorTypeFeatures
DHT11 / DHT22DigitalMeasures temperature & humidity, easy to use
LM35AnalogAccurate analog temperature, 10 mV/°C
DS18B20Digital (1-Wire)High precision, available waterproof
TMP36AnalogSimple analog temperature sensor
BME280 / BMP280I2C/SPIMeasures temperature, humidity, pressure (BME280)

🧰 2. Required Libraries

Here are the matching Arduino libraries (install via Library Manager):

SensorLibrary
DHT11/DHT22DHT sensor library by Adafruit + Adafruit Unified Sensor
LM35/TMP36No special library – use analogRead()
DS18B20OneWire + DallasTemperature
BME280Adafruit BME280
BMP280Adafruit 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

SourceDescription
Arduino Project HubSearch for “DHT22” or “temperature sensor”
Adafruit LearnGreat tutorials for DHT, BME280, etc.
Random Nerd TutorialsComprehensive examples for DS18B20, BME280, ESP32
InstructablesDIY projects with photos & step-by-step guides
Arduino ForumGet help with problems & project ideas

✅ Tip: Choose the Sensor Based on Your Application

Use CaseRecommended Sensor
Indoor climate measurementDHT22, BME280
Outdoor / waterproof useDS18B20 (in waterproof casing)
Industrial / analog measurementLM35, TMP36
High precision & multiple valuesBME280 (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

ampheo
ampheo