/********* 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: Sensor Readings
- Source Code compiled for: Arduino Uno
- Source Code created on: 2024-04-15 09:42:59
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* The Arduino project shall read temperature data */
/* only from a DHT11 sensor connected to a pump. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t DHT11_PIN = 2;
/****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
DHT dht(DHT11_PIN, DHT11);
void setup(void)
{
// put your setup code here, to run once:
pinMode(DHT11_PIN, INPUT_PULLUP);
dht.begin();
Serial.begin(9600);
}
void loop(void)
{
// put your main code here, to run repeatedly:
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature))
{
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Print temperature and humidity values.
Serial.print(F("Humidity: "));
Serial.print(humidity);
Serial.print(F("% Temperature: "));
Serial.print(temperature);
Serial.println(F("°C"));
delay(2000);
}