0% found this document useful (0 votes)
13 views4 pages

Reading Temperature (And Humidity)

The document outlines an Arduino experiment to read temperature data from either an LM35 or DHT11 sensor and display the values on the Serial Monitor. It includes required components, circuit connections, and sample Arduino code for both sensors. The output shows how temperature and humidity readings are displayed in a specified format.

Uploaded by

prathameshkate15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Reading Temperature (And Humidity)

The document outlines an Arduino experiment to read temperature data from either an LM35 or DHT11 sensor and display the values on the Serial Monitor. It includes required components, circuit connections, and sample Arduino code for both sensors. The output shows how temperature and humidity readings are displayed in a specified format.

Uploaded by

prathameshkate15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXPERIMENT NO.

– 11

Problem Statement:
Write an Arduino program that:
• Reads temperature data from a temperature sensor (e.g., LM35
or DHT11).
• Sends the temperature values to the Serial Monitor or the
computer.

Components Required:
• Arduino Board (UNO, Mega, etc.)
• Temperature Sensor (LM35 or DHT11)
• Breadboard
• Jumper Wires
• Arduino IDE

Circuit Connections:

LM35 Temperature Sensor Pinout


• VCC → 5V
• GND → GND
• Output → Analog Pin A0
DHT11 Temperature Sensor Pinout
• VCC → 5V
• GND → GND
• Data Pin → Digital Pin 2
• Use a 10kΩ pull-up resistor between the VCC and Data Pin for
stability.
Arduino Code (for LM35 Sensor):

#define TEMP_PIN A0

void setup() {
Serial.begin(9600);
Serial.println("Reading Temperature Sensor...");
}

void loop() {
int rawValue = analogRead(TEMP_PIN);
float voltage = rawValue * (5.0 / 1023.0);
float temperature = voltage * 100.0;

Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");

delay(1000);
}
Arduino Code (for DHT11 Sensor):

#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
dht.begin();
Serial.println("Reading Temperature and Humidity...");
}

void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();

if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT11 sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");

Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");

delay(2000);
}
Output:

For LM35:
1. The program reads the temperature from the LM35 sensor every
second.
2. The Serial Monitor displays the temperature in the following
format:
o Temperature: 25.3 °C
o Temperature: 26.1 °C
o Temperature: 24.8 °C
For DHT11:
1. The program reads the temperature and humidity from the
DHT11 sensor every 2 seconds.
2. The Serial Monitor displays the values in the following format:
o Temperature: 27.5 °C
o Humidity: 55.2 %

Output:

1. When you turn the potentiometers, the color of the RGB LED
changes based on the combined Red, Green, and Blue intensity
values.
2. The Serial Monitor displays the current RGB values in the
format:
• Red: 120
• Green: 200
• Blue: 45
3. The LED color dynamically changes as you adjust the
potentiometers, creating a range of color combinations.

You might also like