Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

How to Read Data from ThingSpeak using ESP32: Complete Guide

How to Read Data from ThingSpeak using ESP32: Complete Guide
-
Written By - Robocraze -
๐Ÿ“… Updated on 10 Oct 2025
โœจ Summarize with AI
โœ… Prompt copied

Summary

ThingSpeak is a cloud-based IoT analytics platform developed by MathWorks that allows users to collect, visualize, and analyze live data streams from connected devices.

This platform provides RESTful APIs and MQTT support for easy integration with microcontrollers like ESP32, making it ideal for IoT applications requiring real-time data monitoring and storage.

ThingSpeak offers free accounts with up to 8,000 API requests per day, making it accessible for hobbyist and educational projects involving data fetching from ThingSpeak.

How to Read Data from ThingSpeak using ESP32: Complete Guide - Cover image

Why Use ESP32 with ThingSpeak for IoT Projects

The ESP32 microcontroller is perfectly suited for an ESP32 project with ThingSpeak integration due to its built-in Wi-Fi capabilities, dual-core processing power, and extensive memory resources.

Unlike the SP8266, the ESP32 offers superior processing capabilities and supports both Wi-Fi and Bluetooth connectivity, making it versatile for complex IoT applications.

The combination enables seamless data transmission to cloud platforms, real-time monitoring capabilities, and cost-effective solutions for weather stations, sensor networks, and automation systems.

Components and Supplies

๐Ÿ”ฅ Trending
ESP32 NodeMCU (38-Pin) WiFi + BLE โ€“ Ideal for IoT. -Nodemcu ESP Board -RobocrazeESP32 NodeMCU (38-Pin) WiFi + BLE โ€“ Ideal for IoT. -Nodemcu ESP Board -Robocraze

    ESP32 (38 Pin) WiFi + Bluetooth NodeMCU-32 Development Board

    ESP32 (38 Pin) WiFi + Bluetooth NodeMCU Development Board The ESP32 (38 Pin) WiFi + Bluetooth NodeMCU Development Board is a powerful microcontroller designed for IoT, home automation, robotics, and embedded system development. Built around the ESP-WROOM-32 module, it combines a high-performance dual-core processor...
    Rs 381/-
    Rs 381/-
    Rs 599/-
    Save Rs 218/-
    ESP32-C6-WROOM-1-N8 Dev Board โ€“ IoT & AIoT-ready with WiFi & BLE support. -Nodemcu ESP Board -RobocrazeESP32-C6-WROOM-1-N8 Dev Board โ€“ IoT & AIoT-ready with WiFi & BLE support. -Nodemcu ESP Board -Robocraze

      ESP32-C6-WROOM-1-N8 Development Board with Headers

      ESP32-C6-WROOM-1-N8 Development Board with Headers The ESP32-C6-WROOM-1-N8 Development Board is a high-performance, general-purpose module designed for Wi-Fi, IEEE 802.15.4, and Bluetooth LE applications. Operating in the 2.4 GHz frequency band, it features a 1T1R configuration for efficient wireless communication. The module includes 4MB SPI...
      Rs 1,089/-
      Rs 1,089/-
      Rs 1,999/-
      Save Rs 910/-
      ESP32-WROVER Dev Fixture Board โ€“ For programming & testing ESP32. -Nodemcu ESP Board -Robocraze

        ESP32-WROVER Development Fixture Board

        ESP32-WROVER Development Fixture Board The ESP32-WROVER Development Fixture Board is the ultimate solution for developers working with ESP32-WROVER chips. This compact board is designed for easy and efficient programming, offering one-click firmware download and support for bulk programming without the need for individual chip...
        Rs 749/-
        Rs 749/-
        Rs 869/-
        Save Rs 120/-
        Micro:bit USB 2.0 Micro B Cable 300mm High-Speed Data Cable - GreenMicro:bit USB 2.0 Micro B Cable 300mm High-Speed Data Cable - Green

          Micro:bit USB 2.0 Micro B Cable 300mm High-Speed Data Cable - Green

          Micro:bit USB 2.0 Micro B Cable 300mm High-Speed Data Cable - Green This USB Type A to Micro B cable is the perfect choice to power and transfer data to your micro:bit. It is 300mm long (0.3m), making it easy to use without extra...
          Rs 177/-
          Rs 177/-
          Rs 249/-
          Save Rs 72/-
          12V 2A Power Adapter AC to DC โ€“ High-performance adapter for LED strips, routers, and DIY. -Power Adapter -Robocraze12 Volt 2 Amp Power Adapter AC to DC

            12 Volt 2 Amp Power Adapter AC to DC

            12 Volt 2 Amp Power Adapter AC to DC This 12V 2A 5.5mm Power adapter is a regulated center-positive power supply with a compact size and lightweight design. It provides stable voltage, high quality, and is an SMPS-based adapter. Suitable for LED monitors, it...
            Rs 180/-
            Rs 180/-
            Rs 214/-
            Save Rs 34/-
            24 in 1 Sensors DIY Learning Kit โ€“ Arduino sensor kit with 24 modules for electronics & IoT. -DIY Sensor Kit -Robocraze24 in 1 Sensors DIY Learning Kit โ€“ Arduino sensor kit with 24 modules for electronics & IoT. -DIY Sensor Kit -Robocraze

            24 in 1 Sensors DIY Learning Kit

            24-in-1 Sensors DIY Learning Kit The DIY sensors learning kit is an amazing way to learn about embedded systems and electronics engineering. This sensors kit contains 24 components that are compatible with Arduino. These sensors are easy to use and understand and therefore do...
            Rs 1,955/-
            Rs 1,955/-
            Rs 2,188/-
            Save Rs 233/-

            Hardware and Software Requirements

            Hardware Components

            • ESP32 development board (ESP32 DevKit or similar)ย 
            • USB cable for programming and powerย 
            • Stable power supply (optional for standalone operation)ย 
            • Sensors (optional, for actual data collection)

            Software Requirements

            • Arduino IDE with ESP32 board supportย 
            • WiFi library (built-in ESP32 library)ย 
            • HTTPClient library for HTTP requestsย 
            • ArduinoJson library for parsing JSON responsesย 
            • ThingSpeak library (optional, for simplified integration)

            Setting Up a ThingSpeak Channel for Data Storage

            Creating a ThingSpeak channel is essential for reading data from ThingSpeak using ESP32. First, create a free account at thingspeak.com and navigate to the "Channels" section.

            Create a new channel by specifying field names (Field1, Field2, etc.) that correspond to your data types. After creation, locate your Channel ID in the channel URL and copy the Read API Key from the "API Keys" tab.

            These credentials are crucial for authentication when your ESP32 makes data requests to the ThingSpeak servers.

            Connecting ESP32 to Wi-Fi Network

            The ESP32 WiFi connection setup is fundamental for cloud communication. The process involves initializing the WiFi library, connecting to your network using SSID and password credentials, and establishing a stable connection before attempting data operations. Here's the essential setup code:

            
            #include  <WiFi.h>
             
            const char* ssid = "YOUR_WIFI_SSID"; 
            const char* password = "YOUR_WIFI_PASSWORD"; 
             
            void setup() { 
              Serial.begin(115200); 
              WiFi.begin(ssid, password); 
               
              while (WiFi.status() != WL_CONNECTED) { 
                delay(500); 
                Serial.print("."); 
              } 
               
              Serial.println("WiFi connected!"); 
            }
            

            The connection status should be verified before attempting any HTTP operations to ensure reliable data transmission.

            Steps to Read Data from ThingSpeak using ESP32

            Required Libraries

            • Install the necessary libraries in your Arduino IDE :ย 
            • WiFi: Built-in ESP32 library for wireless connectivityย 
            • HTTPClient: For making HTTP requests to ThingSpeak APIย 
            • ArduinoJson: For parsing JSON responses from ThingSpeakย 
            • ThingSpeak: Official library for easier ThingSpeak integration

            Installing Libraries

            1. Open Arduino IDEย 
            2. Go to Sketch > Include Library > Manage Librariesย 
            3. Search and install "ThingSpeak" by MathWorksย 
            4. Search and install "ArduinoJson" by Benoit Blanchon

            ThingSpeak Channel Setup

            Get Your Channel Information

            1. Log into your ThingSpeak account at thingspeak.comย 
            2. Navigate to your channel or create a new oneย 
            3. Note down your Channel ID (visible in the channel URL)ย 
            4. Go to the API Keys tab and copy your Read API Key

            Hardware Setup

            Connect your ESP32 to your computer via USB cable. No additional hardware is required for basic data reading but ensure your ESP32 has stable power supply.

            Code Implementation

            Basic HTTP GET Method

            Here's the complete code to read data from ThingSpeak using HTTP GET requests:

            
            #include <WiFi.h>
            #include <HTTPClient.h> 
            #include <ArduinoJson.h> 
             
            // WiFi credentials 
            const char* ssid = "YOUR_WIFI_SSID"; 
            const char* password = "YOUR_WIFI_PASSWORD"; 
             
            // ThingSpeak settings 
            unsigned long channelID = YOUR_CHANNEL_ID; 
            const char* readAPIKey = "YOUR_READ_API_KEY"; 
            const char* server = "api.thingspeak.com"; 
             
            // Variables to store sensor data 
            float field1Value = 0; 
            float field2Value = 0; 
             
            void setup() { 
            
              Serial.begin(115200); 
               
              // Connect to WiFi 
              WiFi.begin(ssid, password); 
              Serial.print("Connecting to WiFi"); 
               
              while (WiFi.status() != WL_CONNECTED) { 
                delay(500); 
                Serial.print("."); 
              } 
               
              Serial.println(); 
              Serial.println("WiFi connected!"); 
              Serial.print("IP address: "); 
              Serial.println(WiFi.localIP()); 
            } 
             
            void loop() { 
              if (WiFi.status() == WL_CONNECTED) { 
                readThingSpeakData(); 
                delay(20000); // Read data every 20 seconds 
              } 
            } 
             
            void readThingSpeakData() { 
              HTTPClient http; 
               
              // Construct the URL for reading data 
              String url = "http://api.thingspeak.com/channels/" + String(channelID) +  
                           "/feeds.json?api_key=" + String(readAPIKey) + "&results=1"; 
               
              http.begin(url); 
              int httpResponseCode = http.GET(); 
               
              if (httpResponseCode > 0) { 
                String payload = http.getString(); 
                Serial.println("HTTP Response: " + String(httpResponseCode)); 
                Serial.println("Payload: " + payload); 
                 
                // Parse JSON response 
                parseJSON(payload); 
              } else { 
                Serial.println("Error in HTTP request: " + String(httpResponseCode)); 
              } 
               
              http.end(); 
            } 
             
            void parseJSON(String jsonString) { 
              DynamicJsonDocument doc(2048); 
              deserializeJson(doc, jsonString); 
               
              // Extract channel information 
              int channelId = doc["channel"]["id"]; 
              String channelName = doc["channel"]["name"]; 
               
              Serial.println("Channel ID: " + String(channelId)); 
              Serial.println("Channel Name: " + channelName); 
               
              // Extract feed data (most recent entry) 
              if (doc["feeds"].size() > 0) { 
                JsonObject feed = doc["feeds"][0]; 
                 
                String createdAt = feed["created_at"]; 
                field1Value = feed["field1"].as<float>(); 
                field2Value = feed["field2"].as<float>(); 
                 
                Serial.println("Latest Entry:"); 
                Serial.println("Timestamp: " + createdAt); 
                Serial.println("Field 1: " + String(field1Value)); 
                Serial.println("Field 2: " + String(field2Value)); 
              } 
               
              Serial.println("------------------------"); 
            }
             

            Using ThingSpeak Library Method

            Alternative approach using the official ThingSpeak library:

            
            #include <WiFi.h> 
            #include "ThingSpeak.h" 
             
            const char* ssid = "YOUR_WIFI_SSID"; 
            const char* password = "YOUR_WIFI_PASSWORD"; 
             
            WiFiClient client; 
             
            unsigned long channelID = YOUR_CHANNEL_ID; 
            const char* readAPIKey = "YOUR_READ_API_KEY"; 
             
            void setup() { 
              Serial.begin(115200); 
              WiFi.mode(WIFI_STA); 
               
              WiFi.begin(ssid, password); 
              while (WiFi.status() != WL_CONNECTED) { 
                delay(500); 
                Serial.print("."); 
              } 
               
              Serial.println("WiFi connected!"); 
              ThingSpeak.begin(client); 
            } 
             
            void loop() { 
              // Read specific field value 
              float field1 = ThingSpeak.readFloatField(channelID, 1, readAPIKey); 
              int statusCode = ThingSpeak.getLastReadStatus(); 
               
              if (statusCode == 200) { 
                Serial.println("Field 1: " + String(field1)); 
              } else { 
                Serial.println("Problem reading channel. HTTP error code " + String(statusCode)); 
              } 
               
              delay(20000); // ThingSpeak allows updates every 15 seconds 
            }
            

            Configuration Steps

            Update Code Parameters

            Replace the following placeholders in your code:ย 

            • YOUR_WIFI_SSID: Your WiFi network nameย 
            • YOUR_WIFI_PASSWORD: Your WiFi passwordย 
            • YOUR_CHANNEL_ID: Your ThingSpeak channel ID numberย 
            • YOUR_READ_API_KEY: Your channel's Read API Key

            URL Structure Understanding

            ThingSpeak uses RESTful API endpoints for data retrieval:

            Data Rate Limits

            ThingSpeak has rate limits for data retrieval:ย 

            • Maximum 8,000 requests per day for free accountsย 
            • Recommended minimum interval: 15-20 seconds between requestsย 
            • Use results parameter to limit returned data and reduce bandwidth

            Advanced Features

            Reading Multiple Fields

            To read specific fields individually:

            
            // Read multiple fields separately 
            float temperature = ThingSpeak.readFloatField(channelID, 1, readAPIKey); 
            float humidity = ThingSpeak.readFloatField(channelID, 2, readAPIKey); 
            float pressure = ThingSpeak.readFloatField(channelID, 3, readAPIKey);
            

            Reading Historical Data

            Modify the URL to get historical entries:

            
            String url = "http://api.thingspeak.com/channels/" + String(channelID) +  
                         "/feeds.json?api_key=" + String(readAPIKey) + "&results=10";
            

            This implementation provides a complete foundation for reading data from ThingSpeak using ESP32, with both HTTP client and ThingSpeak library approaches for different use cases.

            Conclusion

            Reading data from ThingSpeak using ESP32 provides a powerful and cost-effective solution for IoT monitoring applications.

            The ESP32's built-in Wi-Fi capabilities combined with ThingSpeak's cloud platform enable remote data access from anywhere in the world.

            This integration offers real-time visualization, data analysis, and reliable communication for weather stations, sensor networks, and automation projects.

            With proper implementation of rate limiting and error handling, the ESP32-ThingSpeak combination delivers a robust foundation for scalable IoT data retrieval systems.

            Excerpt

            Learn how to read data from ThingSpeak using ESP32 through step-by-step setup of Wi-Fi connection, ThingSpeak channel creation, library installation, and code..

            Frequently Asked Questions

            Do I need a paid ThingSpeak account to use ESP32 for reading data?

            No, you do not need a paid account. ThingSpeak offers a free plan that is sufficient for most personal and educational projects, allowing up to 3 million messages per year (about 8,200 per day). This free tier is ideal for getting started with IoT data collection and retrieval using an ESP32.

            Can I read multiple fields from a ThingSpeak channel using ESP32?

            Yes, you can read multiple fields from a ThingSpeak channel. You can either make a single API request to fetch the latest feed, which returns a JSON object containing all field data, or use the ThingSpeak.readFloatField() function multiple times, once for each field you wish to read.

            How often can ESP32 request data from ThingSpeak?

            The free ThingSpeak plan allows one channel update every 15 seconds. While read requests may have different limits, it is best practice to space out your data requests by at least 15-20 seconds. This avoids hitting the daily API request limit and prevents potential connection throttling by the server.

            Do I need sensors to read data from ThingSpeak using ESP32?

            No, sensors are not required simply to read data. The ESP32 only needs an internet connection to make an API request and fetch data that is already stored on the ThingSpeak cloud. Sensors are only necessary for the device that is collecting and writing the data to the ThingSpeak channel in the first place.

            What libraries are required to connect ESP32 with ThingSpeak?

            The essential libraries are WiFi.h (for internet connectivity) and HTTPClient.h (for making API requests). Additionally, the ArduinoJson.h library is crucial for parsing the JSON data returned by ThingSpeak. For a simpler implementation, you can use the official ThingSpeak.h library, which abstracts these operations.

            Can I use ESP8266 instead of ESP32 with ThingSpeak?

            Yes, the ESP8266 can be used with ThingSpeak in the same way as an ESP32. The official ThingSpeak library for Arduino is compatible with both the ESP8266 and ESP32 platforms. The underlying principles of making HTTP requests to the ThingSpeak API are identical for both microcontrollers.

            Prev Post
            Next Post

            Leave a comment

            Please note, comments need to be approved before they are published.

            Thanks for subscribing!

            This email has been registered!

            Shop the look

            Choose Options

            Edit Option
            Back In Stock Notification
            Compare
            Product SKU Description Collection Availability Product Type Other Details

            Choose Options

            this is just a warning
            Login
            Shopping Cart
            0 items
            FREE SHIPPING!
            โ‚น100 OFF
            โ‚น200 OFF
            โ‚น999
            โ‚น2500
            โ‚น4900
            WhatsApp Chat Chat