ESP32 Weather Instrument with Real-Time Sensor Monitoring on ThingSpeak

This ESP32-based Weather Instrument collects temperature, humidity, light intensity, and atmospheric pressure from three onboard sensors and sends the data to ThingSpeak every two minutes. Ideal for beginners in IoT, this project demonstrates real-world sensor integration, data uploading via HTTP, and environmental monitoring using ESP32.

It’s a practical setup for home automation, remote monitoring, or a DIY weather dashboard.

PCBWay offers high-quality PCB prototyping and assembly at an affordable price, starting at just $5 for 5 PCBs. With fast turnaround, great customer support, and easy online ordering, it’s a top choice for hobbyists and professionals alike.

Hardware Components

You’ll need the following hardware components to get started:

ComponentModel / TypeQty
ESP32 BoardWith I2C-compatible GPIO1
DHT11 SensorTemperature + Humidity Sensor1
BMP180 SensorBarometric Pressure Sensor1
BH1750 SensorLight Intensity Sensor1
Jumper WiresMale-to-male1 set
Breadboard (optional)Half-size or full-size1
Micro USB CableFor programming/power1
Wi-Fi Access Point2.4GHz Network1

Steps-by-Step Guide

(1) Setting up Arduino IDE

Download Arduino IDE Software from its official site. Here is a step-by-step guide on “How to install Arduino IDE“.

(2) ESP32 in Arduino IDE

There’s an add-on that allows you to program the ESP32 using the Arduino IDE. Here is a step-by-step guide on “How to Install ESP32 on Arduino IDE“.

(3) Register ThingSpeak,set Channel,get API key

  1. Sign up ThingSpeak new account,then Sign in: https://thingspeak.com/
  2. Create a new Channel and receive the temperature , humidity , light and atmosphere data from “Weather Instrument” (Enable Field1 and name “Temperature” Enable Field2 and name “Humidity” Enable Field3 and name “Light”Enable Field4 and name “Atmosphere”) https://thingspeak.com/channels/new
  3. Set Channel to Public
  4. Get the Write API key of the channle for “Weather Instrument

(4) Download Code File and Update Wifi Credentials

Download the code files from the link given below. Locate “WeatherInstrument” Tab,
Replace the “********in the WiFi_Name with your WiFi Name Replace the “********” in the WiFi_Password with your WiFi Password

(5) Update ThingSpeak Write API Key

Locate “WeatherInstrument” Tab, Replace the “*******” in the thingspeak_API_key with your ThingSpeakChannel Write API Keys which you registered in the previous preparations

Wiring / Connections

SensorPin (ESP32)Description
DHT11GPIO 15 (D15)Digital data output
BMP180SDA → GPIO 18I2C Data line
BMP180SCL → GPIO 19I2C Clock line
BH1750SDA → GPIO 18Shares same I2C as BMP180
BH1750SCL → GPIO 19Shared clock line
All Sensors3.3V & GNDPower & ground

How the Code Works

Sensor Data Collection:

  • DHT11: Manually reads temperature and humidity via GPIO.
  • BH1750: Reads light intensity in lux.
  • BMP180: Measures atmospheric pressure in Pascals.

Timing:

  • Reads sensor data every 10 seconds.
  • Sends data to ThingSpeak every 120 seconds.

Upload Format:

GET /update?api_key=XXXXX&field1=temp&field2=hum&field3=light&field4=pressure

Key Code Behavior

WiFi.begin(WiFi_Name, WiFi_Password);
  • Connects ESP32 to your local Wi-Fi.
lightSensor.begin();
bmpSensor.begin();
  • Initializes light and pressure sensors via I2C.
readTemperatureHumidity();
readLightIntensity();
readAtmosphericPressure();
  • Reads all sensor data every 10 seconds.
uploadDatatoThinkspeak();
  • Builds a GET request and uploads data to ThingSpeak every 2 minutes.

Upload the code

Upload the code and see the result in serial monitor and Thingspeak

This project is a solid introduction to multi-sensor integration and cloud-based data logging. It bridges embedded systems with real-time monitoring services, perfect for weather enthusiasts, students, and IoT tinkerers alike.