SP32 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.
Materials for the Project
- 1X ESP32 Board With I2C-compatible GPIO
- 1X DHT11 Sensor Temperature + Humidity Sensor
- 1X BMP180 Sensor Barometric Pressure Sensor
- 1X BH1750 Sensor Light Intensity Sensor
- Jumper Wires Male-to-male
- 1X Breadboard (optional) Half-size or full-size
- 1X Micro USB Cable For programming/power
- 1X Wi-Fi Access Point 2.4GHz Network
Step-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, and get API key
- Sign up for a Thing Speak new account, then Sign in: https://thingspeak.com/
- Create a new channel and receive the temperature, humidity, light, and atmosphere data from the “Weather Instrument” (enable Field1 and name it “Temperature”). Enable Field2 and name it “Humidity.” Enable Field3 and name it “Light. Enable Field4 and name it “Atmosphere.” https://thingspeak.com/channels/new
3. Set Channel to Public
4. Get the Write API key of the channel for “Weather Instrument.”
(4) Download Code File and Update Wifi Credentials
Download the code files from the link given below. Locate the “WeatherInstrument” tab.
Replace the “********” in the WiFi_Name with your WiFi name. Replace the “********” in the WiFi_Password with your WiFi password.
Download code
(5) Update ThingSpeak Write API Key
Locate the “WeatherInstrument” tab, and replace the “*******” in the thingspeak_API_key with your ThingSpeakChannel. Write the API that you you registered in the previous preparations
Wiring/Connections
Sensor | Pin (ESP32) | Description |
---|---|---|
DHT11 | GPIO 15 (D15) | Digital data output |
BMP180 | SDA → GPIO 18 | I2C Data line |
BMP180 | SCL → GPIO 19 | I2C Clock line |
BH1750 | SDA → GPIO 18 | Shares same I2C as BMP180 |
BH1750 | SCL → GPIO 19 | Shared clock line |
All Sensors | 3.3V & GND | Power & 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 the 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.