Try   HackMD

Connecting a temperature sensor to an Arduino is a great beginner-friendly project. Here's a simple step-by-step guide using the most common sensor types:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Option 1: LM35 (Analog Temperature Sensor)
What You Need:

  • Arduino Uno (or compatible)
  • LM35 temperature sensor
  • Breadboard + jumper wires

Wiring:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Arduino Code:

cpp

const int sensorPin = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int rawValue = analogRead(sensorPin);
  float voltage = rawValue * (5.0 / 1023.0);
  float temperatureC = voltage * 100.0;  // 10 mV per °C
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.println(" °C");
  delay(1000);
}

Option 2: DS18B20 (Digital 1-Wire Sensor)
What You Need:

  • Arduino
  • DS18B20 sensor
  • 4.7kΩ resistor (pull-up)
  • Jumper wires

Wiring:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Libraries Required:

  • OneWire
  • DallasTemperature

Install them via: Sketch > Include Library > Manage Libraries

Arduino Code:

cpp

#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);
}

Other Temperature Sensors

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →