Upload Sensor Data to ThingSpeak using NodeMCU

Upload Sensor Data to ThingSpeak using NodeMCU

ThingSpeak is an Open-Source IoT application and API to store and retrieve data from Hardware devices and Sensors. It uses HTTP Protocol over the Internet or LAN for its communication. The MATLAB analytics is included to analyze and visualize the data received from your Hardware or Sensor Devices.

We can create channels for each and every sensor data. These channels can be set as private channels or you can share the data publically through Public channels. The commercial features include additional features. But we will be using the free version as we doing it for educational purpose.

You can make projects like Weather Station, Tide Prediction, Counter and Many More.


  • Collect data in private channels.
  • Share Data with Public Channels
  • MATLAB® Analytics and Visualizations.
  • Worldwide Community

In this tutorial, we will be using an LDR to plot its light Intensity level on ThingSpeak using NodeMCU. We will program the NodeMCU to read and store the LDR data into a variable and then upload it to ThingSpeak using its channel name and API key. The NodeMCU should be connected to the internet via Wi-Fi. We will see how to create ThingSpeak Channels and configure it on NodeMCU.

Hardware Required:

  • NodeMCU
  • LDR Module
  • 10K Ohm Resistor
  • Jumper Wires
  • Breadboard (Optional)

Circuit Diagram:

NodeMCU LDR_bb


Once the hardware is set up, We can go ahead and create our ThingSpeak Channel.

Step 1: Go to https://thingspeak.com/ and create your ThingSpeak Account if you don’t have. Login to Your Account.

Step 2: Create a Channel by clicking ’New Channel’.

1.Sign In

Step 3: Enter the channel details.

Name: Any Name

Description: Optional

Field 1: Light Intensity LDR – This will be displayed on the analytics graph. If you need more than 1 Channels you can create for additional Sensor Data.

Save this setting.

3.Channel Details

Step 4: Now you can see the channels. Click on the ‘API Keys’ tab. Here you will get the Channel ID and API Keys. Note this down.

4.Channel ID API Key

Step 5: Open Arduino IDE and Install the ThingSpeak Library. To do this go to Sketch>Include Library>Manage Libraries. Search for ThingSpeak and install the library.

5.Install Thingspeak Library

Step 6: Now we need to modify the program with your credentials.

In the below code you need to change your Network SSID, Password and your ThingSpeak Channel and API Keys.

Replace the following content in the code,

Your SSID Here’ – Your Wi-Fi Name

Your Password Here’ – Your Wi-Fi Password

YYYYYY’ – Your ThingSpeak Channel Number (without Quotes)

XXXXXXXXXXX’ – Your Thing Speak API Key.



Upload the code. Once it is connected to Wi-Fi the data will start uploading to the ThingSpeak Channel. You can now open your Channel and see the data changes plotted on the ThingSpeak.

6.Channel Output

Share this post

Leave a Reply

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