Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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-01-12 11:43:32
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* read temperature in every 5 mins */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <DHT.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t DHTPIN = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- DHT dht(DHTPIN, DHT11);
- void setup(void)
- {
- // put your setup code here, to run once:
- dht.begin();
- Serial.begin(9600);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- float temperature = dht.readTemperature();
- if (isnan(temperature)) {
- Serial.println("Error reading temperature!");
- } else {
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.println("°C");
- }
- float humidity = dht.readHumidity();
- if (isnan(humidity)) {
- Serial.println("Error reading humidity!");
- } else {
- Serial.print("Humidity: ");
- Serial.print(humidity);
- Serial.println("%");
- }
- delay(300000); // Delay for 5 minutes (300000 milliseconds)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement