0% found this document useful (0 votes)
1 views1 page

Prac 11

This Arduino code reads temperature data from a DHT11 sensor connected to pin 12. It continuously monitors and updates the maximum and minimum temperatures recorded, displaying them in both Celsius and Fahrenheit. The program includes error handling for sensor reading failures and prints relevant temperature information to the serial monitor.

Uploaded by

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

Prac 11

This Arduino code reads temperature data from a DHT11 sensor connected to pin 12. It continuously monitors and updates the maximum and minimum temperatures recorded, displaying them in both Celsius and Fahrenheit. The program includes error handling for sensor reading failures and prints relevant temperature information to the serial monitor.

Uploaded by

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

#include <Arduino.

h>
#include <DHT.h>
#define outPin 12 // Pin to which the sensor is connected
#define DHTTYPE DHT11

DHT dht(12, DHT11);

float maxTemp = -9999;


float minTemp = 9999;

void setup() {
Serial.begin(9600);
Serial.println("Working properly !");
dht.begin();
}

void loop() {
delay(2000);

float c = dht.readTemperature();

if (isnan(c)) {
Serial.println("Failed to read temperature from the sensor!");
return;
}

if (c > maxTemp) {
maxTemp = c;
}
if (c < minTemp) {
minTemp = c;
}

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

Serial.print("Max Temperature: ");


Serial.print(maxTemp);
Serial.println(" °C");

Serial.print("Min Temperature: ");


Serial.print(minTemp);
Serial.println(" °C");

delay(2000);

float f = dht.readTemperature(true);
if (isnan(f))
{
Serial.println("Not Working !");
}

Serial.println("Temperature (in Farheniet) is :");


Serial.println(f);
delay(1000);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy