An ESP32 is a powerful microcontroller which includes WiFi networking. Below are a couple of Sketches that can be built and installed using Arduino IDE.
You may first need to do more setup. Add the URL below to Boards Manager in Arduino IDE.
https://dl.espressif.com/dl/package_esp32_index.json
For your current Sketch, change board selection to ESP32 Dev Board and the USB Port. You will need to install ArduinoJson library to use the code below.
You will also create 2 local libraries to hold into values which are unique to your environment. On a Mac libraries are located in ~/Documents/Arduino/libaries
. Create WiFiNetwork
and OpenWeatherMapKey
in this directory. Then create the simple source files below in these directories, respectively.
- WiFiNetwork.h
- WiFiNetwork.cpp
- OpenWeatherMapKey.h
- OpenWeatherMapKey.cpp
The purpose of these libraries is so you can set up your unique values for WiFi and the API key for OpenWeatherMap.
Then see the Time and Weather Sketches below. Both will start up WiFi in setup and then make a request periodically. While the request is active the LED light will be turned on so you can see that activity.