Setup Thingspeak With ESP & DHT11

Setup Thingspeak With ESP & DHT11

ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. You can send data to ThingSpeak from your devices, create instant visualization of live data, and send alerts.

ThingSpeak has integrated support from the numerical computing software MATLAB from MathWorks,[4] allowing ThingSpeak users to analyze and visualize uploaded data using MATLAB without requiring the purchase of a MATLAB license from MathWorks.[5]

Getting started with thingspeak

Step 1 – Open this website

Step 2- Click on Get Started For Free.

Step 3 –  Click on Create one! To create a login account

Step 4 –  Click on Channels and then click on My Channels

Step 5 –  Click on New Channel.

Step 6 –  Write the Name of the channel and field .

Step 7 –  Write the Name of the channel and field .

Step 8 – Click the Save Channel button to create and save your channel.

Step 9 –  Go to your Private View tab and click on the edit icon.

Step 10 –  You can give a title to your chart, customize the background color, x and y axis, and much more.

Step 11 –  To send values from the Node MCU to ThingSpeak, you need the Write API Key. Open the “API Keys” tab and copy the Write API Key.

Connect ESP to upload the DHT-11 sensor Data to Thingspeak

Setup a programming environment for ESP in Arduino IDE – Setup ESP 8266 in Arduino IDE

Interface DHT 11 Sensor with ESP8266

✘ Connect Vcc pin of the sensor to 3V3 pin of Node MCU.

✘ Connect GND pin of the sensor to GND pin of Node MCU.

✘ Connect signal pin of the sensor to D5 pin of Node MCU.


#include <ESP8266WiFi.h>
#include "ThingSpeak.h"
#include <Adafruit_BMP280.h>
#include <DHT.h>	
const char* ssid = "xxxxxxxxxx"; // Name of the Network.
const char* password = "xxxxxxxxxx"; // Password of the Network.
WiFiClient client; // Create a Wi-Fi client to connect to ThingSpeak.
unsigned long myChannelNumber = 1; // Channel No
const char * myWriteAPIKey = "xxxxxxxxxx"; // API write key.
#define DHTPIN D5
#define DHTTYPE DHT11
void setup() {
  WiFi.begin(ssid, password); // This will connect the Node MCU with WiFi.
  WiFi.mode(WIFI_STA); // Set the Node MCU as a Wi-Fi station.
  ThingSpeak.begin(client); // Initialize ThingSpeak.
void loop() {
  while (WiFi.status() != WL_CONNECTED) {
  float h = dht.readHumidity();
  Serial.println("\nConnected. ");
  ThingSpeak.writeField(myChannelNumber, 1, h, myWriteAPIKey);
  //the channel number.
  //the field number (in our case, we just have one field).
  //the value you want to publish (x).
  //your write API key.

Leave a Reply

Your email address will not be published. Required fields are marked *