/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: Dust
- Source Code compiled for: Arduino Mega
- Source Code created on: 2023-12-05 14:42:53
- Source Code generated by: Johnny van Aardt
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Display temperature and humidity values */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Display temperature and humidity values */
/****** END SYSTEM REQUIREMENTS *****/
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t Enviro_DHT22_DOUT_PIN_D2 = 2;
/****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
DHT dht(Enviro_DHT22_DOUT_PIN_D2, DHT22);
void setup(void)
{
// put your setup code here, to run once:
pinMode(Enviro_DHT22_DOUT_PIN_D2, INPUT_PULLUP);
Serial.begin(9600);
dht.begin();
}
void loop(void)
{
// put your main code here, to run repeatedly:
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f))
{
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F"));
Serial.println();
}