/ESP8266-WiFiClock

An ESP8266-powered WiFi clock that displays weather forecast data!

Primary LanguageCMIT LicenseMIT

ESP8266 WiFi Clock

WiFi Clock

Utilizing the ESP8266's capability to retrieve the current time in the form of a Unix timestamp (a long-type number of how many seconds elapsed since the last epoch, i.e. January 1, 1970) from an NTP server, we are able to process the timestamp and output it in a human-readable form on a display screen. As if that wasn't enough, why don't we add a feature where we can view the latest weather information? With custom weather icons, no less?

Background

The design of the WiFi clock is largely inspired by Ubuntu, a Linux distro. The startup screen resembles that of the Ubuntu terminal, with the colour scheme and font to match. A weather API called Dark Sky is used to obtain weather data in the JSON format. As the ESP8266 has limited memory, a streaming parser is used to collect necessary data, instead of storing the entire JSON tree in memory.

Hardware & Software Requirements

In terms of hardware, you will need:

  • An ESP8266 module with enough free pins to support a screen output (a NodeMCU Lua ESP-12E WiFi Development Board mounted on a breadboard is used here)
  • A display screen hooked up to the ESP8266 module (a 2.4" TFT LCD Touchscreen is used here)

As for software, you will need to install the Arduino IDE on your computer. Once that's done, you will need to install the addon for the ESP8266. A quick guide on installing the addon can be found here.

Libraries Used

The libraries used here are third-party libraries you can download from Github. They are:

Weather API

The documentation for the Dark Sky API used in this project can be found here. You will need to create an account and obtain a special API key. This key will be required when sending GET requests.

2023 Update: As of 31 March 2023, the Dark Sky API will be discontinued (thanks, Apple). You may find a drop-in replacement with Pirate Weather, which - despite its unfortunate name - is legal and compatible with the original Dark Sky API format. I will not update the code to use Pirate Weather, but it shouldn't be too hard to get it working with the WiFi clock. Please support Pirate Weather's creator if you can!

Usage

  1. Download or clone this repository into your desired directory. To clone using git, on the command line, type
git clone https://github.com/AugFJTan/ESP8266-WiFiClock
  1. Place the files in the repository's Fonts folder into the actual Fonts folder in the Adafruit_GFX library folder.
  2. Change the values in the ESP8266-WiFiClock.ino sketch where needed.
  3. Compile the sketch and upload it to your ESP8266 module.

Resources

Further Reading