กลับไปหน้ารวมไฟล์
smart-weather-monitor-with-oled-screen-a795a7-en.md

This project shows how to use the ESP32/ESP8266 and an SSD1306 OLED display in order to display real-time weather condition from the OpenWeatherMap API. This system is able to present weather parameters, like temperature, humidity and wind velocity of Karachi, and cycle through these parameters with the push of a button.

Features:

  1. Wi-Fi Connectivity to obtain real-time weather data.
  2. Information on the Weather will be displayed on the OLED via 3 different modes: Temperature, Humidity, and Wind Speed.
  3. One Button shall be used to switch between modes.
  4. New information will be updated automatically every 10 minutes.

Components:

  1. ESP32/ESP8266 Based microcontroller.
  2. SSD1306 OLED Based Display.
  3. Switching for Button.
  4. OpenWeatherMap API for fetching the weather information.

Project Image

Project Image

IoT Weather Architecture Overview

The Smart Weather Monitor functions through a specialized Request-Parse-Display lifecycle. Operating on the ESP32 Dual-Core processor, the device initiates a secure WiFi handshake to access the OpenWeatherMap API. It transmits a location-specific GET request, receives a complex JSON payload, and utilizes high-speed parsing to extract precise telemetry for temperature (feels-like), humidity (absolute), and wind velocity. This data is then formatted for the high-contrast SSD1306 OLED interface.

Hardware Infrastructure & The Connectivity Tier

  • ESP32 NodeMCU / Nano ESP32: The "Connectivity Engine." Chosen for its integrated WiFi/Bluetooth stack and ample SRAM, which allows for large JSON buffers that would overwhelm a standard Arduino Uno.
  • SSD1306 OLED (128x64): The "Status Panel." It uses the I2C protocol (SDA/SCL) for a 2-wire setup. The monochrome display ensures that weather data is crisp and readable from any angle in any lighting condition.
  • Mode-Selection Button: A critical UX element. Instead of cluttering the small screen with all data at once, the physical button allows the user to cycle through three "High-Density Views":
    • Thermal View: Real-time temperature (°C/°F).
    • Atmospheric View: Relative humidity percentage.
    • Aerodynamic View: Wind speed (m/s) and gusts.
  • Dual-Bus Logic: The project demonstrates the importance of separating the Power Rail from the I2C Data Bus to ensure that WiFi signal spikes don't cause screen flickering or data corruption.

Technological Logic and The API Handshake

The system reaches high-latency reliability through several Software Protocol Strategies:

  1. JSON Stream Parsing: Because the OpenWeatherMap payload can be larger than 512 bytes, the code uses the ArduinoJson library to "Filter" the incoming stream, only keeping the specific weather keys required and discarding the rest to save memory.
  2. State-Cycling Interrupts: The button is tied to a "State Counter." Every press increments a variable (0, 1, 2) which the main loop uses to switch between visual dashboards.
  3. Automatic Refresh Protocol: To avoid hitting API rate limits while keeping data fresh, the system uses a non-blocking millis() timer. It refreshes the data every 600,000 milliseconds (10 minutes) without pausing the screen interaction.
  4. Weather Icons & Graphics: The project utilizes the Adafruit_GFX library to draw custom weather icons (clouds, sun, wind streaks), providing a premium look rather than just plain text.

WORKING

Get your API key from https://openweathermap.org and paste it in the code. Enter your wifi credentials. Upload the code.

MAKE SURE TO CHANGE THE LOCATION TO YOUR DESIRED LOCATION INSTEAD OF "KARACHI" AS IN THIS CODE.

Why This Project is Important

Mastering WiFi Serial Communication and API Integration is an essential skill for Full-Stack IoT Developers and Smart City Engineers. It teaches you how to bridge the physical world of microcontrollers with the digital world of global databases. Beyond weather monitors, these same principles are used in Industrial Stock-Ticker Displays, Real-Time Logistics Monitors, and Smart Grid Energy Dashboards. Building this project proves you can handle secure internet protocols and deliver high-value data to a compact, user-friendly interface.

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE 2.0"
  - "1x OpenWeatherMap One Call API (Pro/Free)"
  - "1x Arduino Cloud (Optional for Remote Access)"
author: "coding_boss"
category: "Sensors & Environment"
components:
  - "1x ESP32 NodeMCU or Nano ESP32"
  - "1x 0.96\" or 1.3\" SSD1306 OLED Display (I2C)"
  - "1x Tactile Push Button"
  - "1x 10k Ohm Resistor (Pull-down for Button)"
  - "1x Solderless Breadboard"
  - "1x 40-pin Male-Male Jumper Wire Pack"
  - "1x Micro-USB or USB-C Power Cable"
description: "Engineer a globally-connected environmental dashboard that fetches real-time climate telemetry from OpenWeatherMap APIs and displays high-density data on a 1.3\" I2C OLED display."
difficulty: "Intermediate"
documentationLinks:
  - "https://openweathermap.org/api"
downloadableFiles:
  - "https://projects.arduinocontent.cc/f80b0b5c-3928-4637-84f9-8767141358d9.ino"
encryptedPayload: "U2FsdGVkX19d/uYZeWxShfY3+Dn3j7V31M1+6Q8ktK/yEocccYdpHi9vZka4rgwy6OfCV9klbCthl8wfuRyHbCaeMmu25refwG21e4/UYuRnHBo0R7dd6E4KkkrBtae9shE3HowCChQluW83kmvYpQfWEcrKcZHUxEltPJQ4VL4="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/smart-weather-monitor-with-oled-screen-a795a7_cover.jpg"
lang: "en"
likes: 4
passwordHash: "4a5f5ed4d371b474741964567846905c77625b6524c7dfa8f2f4cdce95976dbe"
price: 299
seoDescription: "Build a compact IoT Smart Weather Monitor using ESP32. Learn to fetch real-time temperature, humidity, and wind speed from OpenWeatherMap and cycle through data with a physical button."
tags:
  - "Weather"
  - "Smart appliances"
  - "Environmental Sensing"
  - "Home Automation"
  - "Internet Of Things"
  - "Monitoring"
title: "Smart Weather Monitor with OLED Screen"
tools: []
videoLinks: []
views: 16523