#include
#include "DHT.h"
#define DHT11_PIN 2
#define DHTTYPE DHT11
DHT dht(DHT11_PIN, DHT11);
// The commented out fragments will be useful during debugging,
// if we have the ability to display information on the serial port monitor.
// They can be removed during final production.
const char* ssid = "WIFI_SSID";
const char* password = "WIFI_PASSWORD";
// username and password for HTTP Basic Authentication
const char* authUsername = "AUTHORIZATION_USERNAME";
const char* authPassword = "AUTHORIZATION_PASSWORD";
void setup () {
WiFi.begin(ssid, password);
// Serial.begin(9600);
//
// while (WiFi.status() != WL_CONNECTED) {
//
// delay(1000);
// Serial.println("Connecting...");
//
// }
}
void loop() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.
http.setAuthorization(authUsername,authPassword);
http.addHeader("Content-Type", "application/json");
int httpCode = http.POST("{\"temp\":" + String(temp) + ",\"humidity\":" +
// printing HTTP response
//
// if (httpCode > 0) {
// Serial.println(httpCode);
// String payload = http.getString();
// Serial.println(payload);
// }
http.end();
}
delay(300000);
}