Temperature monitoring using OpenWeatherMap & GLYPH
This guide will help you to set up a Temperature Monitoring system with a GLYPH-C3 that fetches Weather data and retrieve the Current Temperature data for a specified location using the OpenWeatherMap API and display it on the Arduino IDE Serial Monitor. We are doing this using the WiFiManager Library, which provides an easy way to connect the device to a WiFi network without hardcoding credentials or constantly re-uploading new firmware when WiFi settings change.Note that the WiFiManager Library, as stated in its GitHub Page, only supports certain ESP32 Devices. Currently it only supports GLYPH-C3. Hence, you cannot use other GLYPH boards for this project.
- API (Application Programming Interface): An API allows different software applications to communicate with each other. In the context of OpenWeatherMap, it lets developers access weather data programmatically.
- API Key: It is a unique identifier assigned to each user when they sign up for OpenWeatherMap’s services. It acts as a password to authenticate requests to the API, ensuring that the user has permission to access the data.
- Endpoint: An endpoint is a specific URL within the API that corresponds to a particular function or resource.
Step 1: Code Setup
- Open Arduino IDE
- Install the Necessary Libraries:
Sketch > Include Library > Manage Libraries. Search for and Install the following libraries:
- WiFiManager by tzapu - You can also install this Library via WiFiManager Library-tzapu-GitHub and then go to
Sketch > Include Library > Add .ZIP Library - ArduinoJson by Blanchon ArduinoJson-GitHub
- HTTPClient by McEwen HTTPClient-GitHub
- GetOpenWeatherMap API Key:
- Signup at OpenWeatherMap.
- After registering, go to the API section and get your API Key.
- You will use this key to make Authenticated requests to fetch weather data.
- Enter the following code into the Arduino IDE
Step 2: Upload the Code
- Connect the Board
- Connect your GLYPH board to your computer
-
Select the Board and Port
Do the following settings in your Arduino IDE,
Do the following settings in your Arduino IDE,
Tools > Board > esp32 > Pcbcupid GLYPH C3
Tools > Portand select the port connected to your GLYPH.Tools > USB CDC on Boot >Enabled
- Upload the Code
- Click the upload button (➡️ icon) or use the shortcut
CTRL + Uin Arduino IDE to upload the code to the board.
Step 3: Observe the Output on the Serial Monitor
The Serial Monitor should start displaying the Weather Description and Temperature of the Location which has been set in OpenWeatherMap.