Temp sensor with dht22

I have written the code for the DHT22 with Aduino ide but i the serial print to hold the max temperature this where I am lost.
I don't know how to write the code to print the max temperature and the current temperature.
I need to know the maximum temperature for the day or week before resetting it.

Welcome to the forum

You started a topic in the Uncategorised category of the forum when its description explicitly tells you not to

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

1 Like

This is my code:

#include <DHT.h>

#include <DHT.h>

#define Type DHT22
int sensePin= 2;
DHT HT(sensePin, Type);
float humidity;
float tempC;
float tempF;

int setTime = 1000;
int dt=0;
int whitePin =8;


void setup() {
  // put your setup code here, to run once:
  
  Serial.begin(9600);
  pinMode (sensePin, INPUT);
  pinMode(whitePin, OUTPUT);

  Serial.println(tempC);

  HT.begin();
  delay (setTime);

}

void loop() {
  // put your main code here, to run repeatedly:
  humidity=HT.readHumidity();
  tempC=HT.readTemperature();
  tempF=HT.readTemperature();
  
  Serial.print("Humidity: ");
  Serial.println(humidity);
  Serial.print(" Temperature C  ");
  Serial.println(tempC);
  Serial.print(" C ");
  Serial.println(tempF);
  Serial.println(" F ");

  delay(1000);
  if ( tempF > 34.0) {
    digitalWrite (whitePin, HIGH);

  }
  if (tempC <34.0) {
    digitalWrite (whitePin, LOW);
  }


type or paste code here

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.