Group B

Q12: Write a program to show the temperature and display a graph of the recent measurements.

Temperature Graph

Solution and implementation for Q12 from Internet of Things (iotl).

temperature.cpp Download
// For question 10 --> open the serial monitor for output
// For question 12 --> open the serial plotter for output

#include <dht.h>

dht DHT;
#define DHT11_PIN A1

void setup()
{
  Serial.begin(9600);
  Serial.println("Humidity (%),\tTemperature (C)");
}

void loop()
{
  // READ DATA
  int chk = DHT.read11(DHT11_PIN);

  // DISPLAY DATA (Humidity and Temperature)
  Serial.print("Humidity: ");
  Serial.print(DHT.humidity, 1);  // Print humidity with one decimal place
  Serial.print("%\t");

  Serial.print("Temperature: ");
  Serial.println(DHT.temperature, 1);  // Print temperature with one decimal place

  delay(1000);  // Wait 1 second before reading again
}

Other Questions in Internet of Things

See All Available Questions
Download