#include <ESP8266WiFi.h>
#include "DHT.h"
#include "ThingSpeak.h"

#define DHTPIN D2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";

WiFiClient client;

// ThingSpeak channel info
unsigned long myChannelNumber = Your_Channel_ID;
const char * myWriteAPIKey = "Your_API_Key";

void setup()
{
  Serial.begin(9600);
  WiFi.begin(ssid, pass);
  dht.begin();

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  ThingSpeak.begin(client);
}
void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Serial.print("Humidity: "); Serial.println(h);
  Serial.print("Temperature: "); Serial.println(t);

  ThingSpeak.setField(1, t);
  ThingSpeak.setField(2, h);
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

  delay(15000); // ThingSpeak Update Interval
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: