/********* 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: Monitoring System - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-04-23 21:52:11 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* measure values of temperature and humidity every */ /* 10 seconds */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t dhtsensor_DHT11_DOUT_PIN_D4 = 4; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ DHT dht(dhtsensor_DHT11_DOUT_PIN_D4, DHT11); WiFiClient client; // System Requirements: Measure values of temperature and humidity every 10 seconds void setup(void) { // put your setup code here, to run once: Serial.begin(9600); delay(10); dht.begin(); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); } } void loop(void) { // put your main code here, to run repeatedly: float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { return; } if (client.connect(server, 80)) { String postStr = apiKey + "&field1=" + String(t) + "&field2=" + String(h) + "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n"); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); } client.stop(); delay(10000); } /* END CODE */