Temperature sensor using Arduino Uno

A temperature sensor project with Arduino can be useful for monitoring temperature in various applications. Here's a simple guide:

Components Needed
- Arduino Board (e.g., Arduino Uno)
- Temperature Sensor (e.g., LM35 or DS18B20)
- Breadboard and jumper wires

Circuit Setup
1. Connect the temperature sensor to the Arduino:
    - VCC to 5V pin
    - GND to GND pin
    - Signal pin to an analog input pin (e.g., A0)

Code
For LM35:
const int tempPin = A0;

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

void loop() {
  int tempValue = analogRead(tempPin);
  float temperature = (tempValue * 5.0 / 1024.0) * 100;
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println("°C");
  delay(1000);
}
For DS18B20:
#include <OneWire.h>
#include <DallasTemperature.h>

const int tempPin = 2;
OneWire oneWire(tempPin);
DallasTemperature sensors(&oneWire);

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

void loop() {
  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println("°C");
  delay(1000);
}
How it Works
1. The temperature sensor reads the temperature value.
2. The Arduino reads the sensor value and converts it to a temperature reading.
3. The temperature reading is printed to the serial monitor.

Applications
- Temperature monitoring in greenhouses
- Temperature control systems
- Weather stations

Do you have any specific questions about this project or would you like to explore more advanced temperature sensing applications?

Popular posts from this blog

Blink led light using Arduino r3

Traffic light using Arduino Uno