ESP32 Wi-Fi tutorial: post sensor data to a web dashboard

Sharing is caring!

ESP32 Wi-Fi Tutorial: Post Sensor Data to a Web Dashboard

Free Daily Electronics Newsletter

Tutorials, news, and one component explained simply — every day.

Subscription Form

You’ve probably seen those expensive commercial IoT sensor systems that cost hundreds of dollars. Here’s the secret: you can build your own for under $20 using an ESP32 and a free web dashboard. By the end of this tutorial, you’ll have temperature data streaming from your workbench to a browser-based dashboard you can check from anywhere in the world.

Difficulty: Intermediate

This tutorial assumes you’re comfortable uploading code to an ESP32 and understand basic electronics. If you’ve successfully built a soil moisture sensor with Arduino, you’re ready for this project.

⚠️ EDITOR’S NOTE: This article requires technical diagrams to be complete. The following diagrams need to be created:

  • System overview showing ESP32, sensor, Wi-Fi transmission, cloud service, and display devices
  • Data flow diagram showing sensor → ESP32 → router → Internet → ThingSpeak → browser
  • Wiring diagram (Fritzing-style) showing ESP32, DHT22 sensor, and pull-up resistor connections with pin labels
  • ThingSpeak interface mockup showing channel creation and field configuration

Why the ESP32 Is Perfect for IoT Projects

The ESP32 isn’t just another microcontroller—it’s a game-changer for hobbyists building connected projects. Unlike traditional Arduino boards that require separate Wi-Fi shields costing $30-50, the ESP32 has Wi-Fi and Bluetooth built directly into the chip. You get a dual-core 240MHz processor, tons of GPIO pins, and wireless connectivity for around $6.

Compare this to the path many hobbyists take: buying an Arduino Uno ($25), then discovering they need a Wi-Fi shield ($35), then realizing the Uno doesn’t have enough memory for their web code. The ESP32 solves all three problems in one package.

The ESP32’s Wi-Fi capabilities mean you can post sensor readings to the cloud, control devices from your phone, or build entire home automation systems. If you’ve read about Wi-Fi drones built on PCBs, you know how powerful integrated wireless can be.

What We’re Building: Temperature Dashboard System

Our project reads temperature data from a DHT22 sensor every 30 seconds and posts it to ThingSpeak, a free IoT platform that provides instant data visualization. ThingSpeak gives you charts, gauges, and even MATLAB analysis tools—all without writing a single line of HTML or CSS.

Here’s what happens in our system:

  • ESP32 reads temperature from the DHT22 sensor
  • Data is packaged into an HTTP POST request
  • ESP32 connects to your Wi-Fi network and sends data to ThingSpeak
  • ThingSpeak stores the data and generates live graphs
  • You view your dashboard from any web browser

The beauty of this approach is scalability. Once you understand how to post one sensor reading, you can expand to multiple sensors, different data types, or even control outputs remotely.

Setting Up Your ThingSpeak Account

Before writing any code, we need to set up the cloud side of our system. ThingSpeak offers free accounts with enough capacity for most hobby projects (3 million messages per year, 8,200 data points per channel).

Step 1: Create Your Account

  1. Visit thingspeak.com and sign up for a free account
  2. Verify your email address
  3. Log in to your ThingSpeak dashboard

Step 2: Create a New Channel

  1. Click “Channels” → “My Channels” → “New Channel”
  2. Name your channel “ESP32 Temperature Monitor”
  3. Enable Field 1 and name it “Temperature (°C)”
  4. Optionally enable Field 2 for “Humidity (%)” if you want to track both readings
  5. Click “Save Channel”

Step 3: Get Your API Key

ThingSpeak uses API keys for authentication. Think of this as a password that identifies your device.

  1. On your channel page, click the “API Keys” tab
  2. Copy the “Write API Key”—you’ll need this in your code
  3. Never share this key publicly or commit it to GitHub

Wiring the DHT22 Sensor

The DHT22 is a digital temperature and humidity sensor that communicates using a one-wire protocol. It’s more accurate than the cheaper DHT11 (±0.5°C vs ±2°C) and handles a wider range (-40°C to 80°C).

Pin Connections:

  • DHT22 VCC → ESP32 3.3V (not 5V—the ESP32 is a 3.3V device)
  • DHT22 Data → ESP32 GPIO 4
  • DHT22 GND → ESP32 GND
  • 10kΩ pull-up resistor between Data and VCC

The pull-up resistor is crucial for reliable communication. Without it, you’ll get intermittent readings or complete communication failures. The resistor ensures the data line stays at a defined voltage level when not being actively driven.

If you’re wondering why we need pull-up resistors, it’s similar to how MOSFETs need gate resistors to operate reliably—components need defined voltage states to function correctly.

Installing Required Libraries

Open the Arduino IDE (make sure you have ESP32 board support installed). We need two libraries:

1. DHT Sensor Library by Adafruit

  1. Go to Sketch → Include Library → Manage Libraries
  2. Search for “DHT sensor library”
  3. Install the version by Adafru

Scroll to Top