Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Last active October 26, 2020 21:35
Show Gist options
  • Save nazrdogan/88d95d287ee080c097c5 to your computer and use it in GitHub Desktop.
Save nazrdogan/88d95d287ee080c097c5 to your computer and use it in GitHub Desktop.
arduino 1 hour delay
#include <dht.h>
dht DHT;
#define DHT11_PIN 5
const long oneSecond = 1000; // a second is a thousand milliseconds
const long oneMinute = oneSecond * 60;
const long oneHour = oneMinute * 60;
const long oneDay = oneHour * 24;
void setup()
{
Serial.begin(115200);
// Serial.println("DHT TEST PROGRAM ");
//Serial.print("LIBRARY VERSION: ");
//Serial.println(DHT_LIB_VERSION);
// Serial.println();
// Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop()
{
// READ DATA
//Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
// Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.println("delay for 1 millisecond");
delay(1);
Serial.println("delay for 1 second");
delay(oneSecond);
Serial.println("delay for 1 minute");
delay(oneMinute);
//
Serial.print(DHT.humidity, 1);
Serial.print(",");
Serial.println(DHT.temperature, 1);
//
delay(oneHour);
}
//
// END OF FILE
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment