This project shows how to autoconnect to the internet and get time from an ntp-server pool and weather data from OpenWeatherMap. To get access to the weather data you have to register whereupon you receive a key.
Weather data, time and WiFi connection data are displayed in turn on the display of an ESP32-Shield with 0.96 inch OLED Display / 18650 Lithium Battery / WiFi / Bluetooth.
Thanks to the Arduino library AutoConnect there is no need to hardcode the WLAN credentials ssid/password in the program. To establish the first connection to your WiFi with AutoConnect you need only a mobile phone and the ip address of your ESP32.
The goal of this project is to display the connection data of the ESP32-Shield, the time and date received from an ntp-server and the actual weather imnformation for a configured location in a given time zone. Thes 3 information blocks are displayed in turn for 10 seconds each.
Power consumption : 5V / 50mA on USB or 4V / 70mA on battery (to be considered with caution).
The 3 screens and the according explanations are shown below.
- Screen 1 : Connection data
- IP address
- MAC address
- RSSI received signal strength indicator
- Screen 3 : Weather data
- Location and description of sky
- Sunrise and sunset UTC
- Temperature, relative humidity and barometric pressure
- Wind speed and direction
- Date and time MEST
- Screen 2 : Time and Date
- NTP-Clock as title
- MAC address
- 18650 Lithium Battery
4. WiringThe ESP32-Shield contains all parts therefor no wiring is needed.
5. Program Code
My programming environment is not the native Arduino™ IDE but PlatformIO™ on top of Microsoft's Visual Studio Code™. This combination offers many advantages and allows a much better structuring of the code into several modules especially when we adopt The Object Oriented way.
The main program uses the two classes NtpClock wich gets time and date from a time server and Owm which gets the weather data and parses the obtained strings into a data structure.
Interested? Please download the entire program code. The zip-file contains the complete PlatformIO project.