1. Introduction
Building a real IoT product usually involves several protocols working together — from the sensor to the microcontroller, and finally from the microcontroller to the cloud. To keep things simple, this guide assumes you already have a network-connected device (an ESP32) with a valid IP address obtained through a Wi-Fi router, and it already has internet connectivity.
The focus here is purely on the last leg of the journey: how the ESP32 talks to a cloud platform once it is online.
2. The Three Popular IoT Protocols
When an ESP32 needs to push sensor data to a cloud service, it almost always uses one of three well-known application-layer protocols:
HTTP / HTTPS
The classic web protocol. Uses simple GET and POST requests. Very easy to implement, but has a larger message overhead and is the slowest of the three.
MQTT
Message Queuing Telemetry Transport. A lightweight publish/subscribe protocol, the most widely used general-purpose protocol for IoT devices.
CoAP
Constrained Application Protocol. A specialized, very low-latency protocol used in constrained networks where speed and small packet size matter most.
HTTP / HTTPS in Detail
HTTP (HyperText Transfer Protocol) and its secure version HTTPS are by far the simplest protocols to work with. Data is exchanged using standard request types such as GET and POST. The main drawback is that the header/message size for each request-response cycle is larger than the other two protocols, which also makes HTTP the slowest option for frequent, real-time data transfer.
MQTT in Detail
MQTT is a lightweight, broker-based messaging protocol built around a publish/subscribe model. Devices "publish" data to a topic, and any number of subscribers (dashboards, other devices, cloud services) can "listen" to that topic. Because the header overhead is tiny compared to HTTP, MQTT is considered the most popular and general-purpose protocol for IoT applications.
CoAP in Detail
CoAP is designed for constrained devices and constrained networks, targeting scenarios where very low latency is critical. It is less commonly used than MQTT for general purpose projects but shines in specialized, real-time control systems.
3. Quick Comparison
| Protocol | Model | Overhead | Speed | Best For |
|---|---|---|---|---|
| HTTP / HTTPS | Request / Response | High | Slow | Simple, low-frequency data logging |
| MQTT | Publish / Subscribe | Low | Fast | General-purpose IoT, real-time dashboards |
| CoAP | Request / Response (UDP-based) | Very Low | Very Fast | Ultra-low-latency, constrained networks |
4. Meet ThingSpeak
ThingSpeak is a cloud platform built specifically for IoT projects. Its free tier supports data transfer over HTTP, and paid tiers add MQTT support as well.
Each ThingSpeak channel gives you up to 8 data fields, so a single channel could, for example, log temperature, humidity, pressure, and several other readings for a home-automation or industrial-automation project simultaneously.
5. Creating Your First ThingSpeak Channel
- Go to the ThingSpeak website and click Sign In.
- If you don't have an account, click Create One and provide your email, location, first name, and last name.
- Check your email and click the verification link, then set a password.
- Log in with your new credentials.
- From the dashboard, click New Channel.
- Give your channel a name, e.g. "IoT Project 1".
- Add a short description such as "Temperature and humidity monitoring" (optional).
- Enable Field 1 and name it Temperature.
- Enable Field 2 and name it Humidity.
- Leave the remaining settings at their defaults.
- Click Save Channel.
6. Sending Data to ThingSpeak with a Simple HTTP Request
Every channel has a unique Write API Key, found under the API Keys tab of the channel. This key lets any device — even a web browser — push data into your channel fields using a plain HTTP GET request.
Basic URL Structure
Step-by-Step Test (from a browser)
- Open the API Keys tab of your channel.
- Copy your Write API Key.
- Open any web browser.
- Paste the update URL and replace the key with your own.
- Set field1 to a sample temperature value.
- Press Enter to send the request.
- Check the response — a returned number greater than 0 means success.
- Go back to your channel dashboard to see the new data point plotted.
Example Requests
Sending a single temperature reading of 11.5°C:
Sending both temperature and humidity together:
Updating both values again a little later:
7. What's Next?
What you have built so far is a "bare-bones" IoT project — no hardware, no sensors, just a channel that accepts numbers. The next step is to replace the manually-typed browser URL with real code running on the ESP32, reading live values from sensors (such as a DHT11/DHT22 for temperature and humidity) and automatically sending them to ThingSpeak over Wi-Fi using HTTP, and later, MQTT.
Coming Up
- Wiring a temperature/humidity sensor to the ESP32
- Writing Arduino/ESP-IDF code to connect to Wi-Fi
- Sending sensor readings automatically via HTTP GET
- Switching to MQTT for faster, lighter updates
- Visualizing data with ThingSpeak widgets and apps