ThingSpeak Nodemcu ESP8266, Send Sensors Data to ThingSpeak

(Last Updated On: July 7, 2020)

ThingSpeak Nodemcu ESP8266

ThingSpeak Nodemcu ESP8266 Introduction:

ThingSpeak Nodemcu ESP8266, Send Sensors Data to ThingSpeak– This is a getting started tutorial in which you will learn how to start with the ThingSpeak IoT platform, explaining how to create different ThingSpeak channels. We will go through some basic examples; we will be using Nodemcu ESP8266 with ThingSpeak IoT platform.

We will send the sensors data to the ThingSpeak channel fields and finally, we will display the sensors data through Gauges and Charts. If you really want to learn the basics then read this article from start to the very end. Because in this tutorial, I am going to explain the extreme basics, which will help you in advanced level projects.

Without any further delay, let’s get started!!!

The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Nodemcu ESP8266 WiFi Module:

DHT11 Temperature and Humidity Module:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Nodemcu ESP8266 WiFi Module:

ThingSpeak Nodemcu ESP8266

As this tutorial is based on the Nodemcu Module, so, first let’s start with the NodeMCU Module. NodeMCU ESP8266 Wifi Module is an open-source Lua based firmware and development board specially targeted for IoT based Applications. It includes firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.

Nodemcu ESP8266 Specifications & Features

Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106

Operating Voltage: 3.3V

Input Voltage: 7-12V

Digital I/O Pins (DIO): 16

Analog Input Pins (ADC): 1

UARTs: 1

SPIs: 1

I2Cs: 1

Flash Memory: 4 MB


Clock Speed: 80 MHz

USB-TTL based on CP2102 is included onboard, Enabling Plug n Play

PCB Antenna

Small Sized module to fit smartly inside your IoT projects

Nodemcu ESP8266 Pinout:

For practical purposes ESP8266 NodeMCU V2 and V3 boards present identical pinouts. While working on the NodeMCU based projects we are interested in the following pins.

Power pins (3.3 V).

Ground pins (GND).

Analog pins (A0).

Digital pins (D0 – D8, SD2, SD3, RX and TX – GPIO XX)

Most ESP8266 NodeMCU boards have one input voltage pin (Vin), three power pins (3.3v), four ground pins (GND), one analog pin (A0) and several digital pins (GPIO XX).

Pin      Code               Arduino alias

A0       A0                               A0

D0       GPIO 16                     16

D1       GPIO 5                       5

D2       GPIO 4                       4

D3       GPIO 0                       0

D4       GPIO 2                       2

D5       GPIO 14                     14

D6       GPIO 12                     12

D7       GPIO 13                     13

D8       GPIO 15                     15

SD2     GPIO 9                       9

SD3     GPIO 10                     10

RX      GPIO 3                       3

TX       GPIO 1                       1

Applications of Nodemcu

Prototyping of IoT devices

Low power battery operated applications

Network projects

Projects requiring multiple I/O interfaces with Wi-Fi and Bluetooth functionalities

Want to know more about the Nodemcu Module?

Setting ThingSpeak & Getting API Key:

  • Go to and create an account if you do not have one. The registration process on the ThingSpeak IoT platform is very simple. After your account is ready.
  • Login to your account.

ThingSpeak Nodemcu ESP8266

Click on the Channels menu and then click on the New Channel. This will open a new page as you can see in the picture below.

ThingSpeak Nodemcu ESP8266

I selected the name as ThingSpeak Nodemcu and followed by the description. To activate a field, simply click on the check box, and you can assign different names to the fields, I selected Value1 to Value5.

Scroll down, check the show status check box, and click on the Save Channel Button. For now you can forget about other fields. So, after you click on the Save button, a new page will open as you can see in the picture below.

ThingSpeak Nodemcu ESP8266

As you can see the channel name at the top “ThingSpeak Nodemcu”. The Channel ID:1088758, and other things. All the selected fields are automatically added, if you scroll down the page. To Copy the API Keys, click on the API Keys,

ThingSpeak Nodemcu ESP8266

You can always generate new keys. For now we will only be using the Channel ID and the Write API key, as we will only be sending data from the Nodemcu ESP8266 to the ThingSpeak IoT Platform.

ThingSpeak Nodemcu ESP8266, Example 1:

In example number1 we don’t need to connect any sensors with the Nodemcu Module. All you need is to connect the Nodemcu module with the Laptop USB port. The next most important thing is to download the ThingSpeak Library. Download other libraries.

The purpose of this example is to send some random multiple values to the ThingSpeak, to check if our programming is working. Later we can modify the same program for other Sensors.

Send Multiple Values to ThingSpeak, Nodemcu Programming:

Open the Arduino IDE and copy and paste the following code.

Save the program as the secrets.h. The secrets.h file consists of the WiFi credentials, the channel ID, and the Write API key. Each time you create a channel you get a unique channel ID and a unique Write API key.

Now open a new window, and copy and paste the code given below.

Make sure you save the above to programs in the same folder. If you have installed the correct libraries at this point your program should compile and upload without any problem. I uploaded the above program and I was able to send some random values from the Nodemcu ESP8266 to the ThingSpeak IoT platform.

ThingSpeak Nodemcu ESP8266

I successfully received the data. Now, I am 100% sure, my Nodemcu code is working, my ThingSpeak channel settings are ok. Now this time I can go ahead and connect a sensor with the Nodemcu Module.

ThingSpeak Nodemcu ESP8266, Example 2:

In example number2, we will connect a Potentiometer with the Analog pin A0 of the Nodemcu Module. This time we will be using only one field, for this example, I will deactivate the remaining field, while the secrets.h file will remain the same on the programming side.

I simply uploaded this code. Opened my channel settings and deactivated the other fields and also change the name of the field1 to the Potentiometer.


ThingSpeak Nodemcu ESP8266

You can see a change in the graph, this is because I rotated the knob of the Potentiometer. As there are delays, so it takes time to display the value.

ThingSpeak Nodemcu ESP8266, Example 3:

In example number 3, we will make a weather station using DHT11, ThingSpeak, and Nodemcu ESP8266. The Humidity and Temperature values will be displayed on the Charts.

DHT11 with Nodemcu ESP8266 Circuit Diagram:

ThingSpeak Nodemcu ESP8266

If you have never used the DHT11 Temperature and Humidity Sensor then read my article. The circuit diagram is very simple. You only need to connect the VCC, DATA OUT, and GND pins of the DHT11 Temperature and Humidity sensors with the Nodemcu Module.

ThingSpeak Nodemcu Weather Station Programming:

The purpose of the following program is to send the Humidity and Temperature values to the ThingSpeak IoT platform where these values are displayed on the charts. This time I added another library for the DHT11 Sensor.

If you have any questions regarding this article, let me know in a comment.

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply