Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

/ Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform/

Video

1. Introduction

I previously had a clock on my desk that used a OnePlus 5 with an OLED screen, powered by a Snapdragon 835 SoC, with a ROM derived from the Pixel Experience of Android 10. The clock app used a minimalist flip clock developed by KuAn developer @vulgur. However, the issues arising from the 24-hour always-on display became evident: screen burn-in, resulting in irreversible aging marks on the screen and an overall reddish tint; overheating, as the phone’s SoC continuously operated under constant display; and high power consumption, where the original OPPO VOOC charger showed a static current of 800mA at +5V, not accounting for the losses from the charger conversion.

After entering my sophomore year, I decided to take a general course on open-source hardware and makers, and suddenly thought about creating an electronic clock display with an always-on feature to replace it, primarily valuing the low power consumption and specificity of various open-source development boards.

To ensure real-time accuracy, the simplest method for time calibration is to connect to the internet and use NTP services, which led me to consider the ESP8266, a cost-effective microcontroller, along with its great companion – a 0.96-inch OLED display (which many people are familiar with). The ESP8266 I have here has been used for a long time (flashed with Deauther firmware), so the price might differ from current ones.

2. System Hardware Design

① Involved Hardware

5-12V to 3.3V DC-DC step-down board x1

ESP8266 (NodeMCU) x1

0.96 inch 4-pin OLED display x1

Dupont wires x several

Breadboard x1

Button x1

100Ω resistor x1

② Peripheral Power Supply Parts

Solution 1: DC 12V power adapter

Solution 2: USB to 6.5mm DC power line with USB output

Solution 3: Micro USB data cable connected +5V power directly to the NodeMCU

③ Features

1. Customizable time source (NTP server, default Alibaba);

2. Firmware customizable to select which city’s weather to retrieve;

3. Supports smart network configuration using open-source WiFiManager API;

4. Remote firmware flashing via OTA;

5. Uses a universal weather API, supporting replacement.

Additionally, later on, other sensors such as blood oxygen, light, air pressure, temperature, and humidity can be added via IIC bus to expand the functionality of the code, even though some Flash has already been occupied (about 900KB).

1. Overall Block Diagram

Powered by a power bank, the step-down circuit part uses a 5V to 3.3V DC-DC step-down board.

The connections between the main control and the screen are as follows:

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

2. Module Descriptions

① Power Supply

DC-DC step-down board, input 5V-12V (maximum 18V), output 5V/3.3V with free selection. The step-down circuit uses two forward low-dropout regulators AMS1117, with a fixed output voltage of 3.3V and 5.0V with 1% accuracy. Also, it integrates over-temperature protection and current limiting circuits, efficiently powering the backend while effectively protecting the circuit.

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

② Main Control

The renowned ESP8266 (NodeMCU)

Rich hardware interfaces supporting UART, IIC, PWM, GPIO, ADC, etc., suitable for various IoT applications.

③ 2.4GHz Wireless Transceiver Specifications

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

④ Display:

0.96 inch OLED Display

The screen controller uses SSD1306, with a resolution of 128*64.

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

The communication method between the screen and the development board can be selected as SPI or IIC (default address 0x78), with pins fully compatible with IIC (i.e., when set to IIC mode, only 4 wires can be connected), and the default is 4-Wire SPI communication mode, self-luminous with free viewing angles, low power consumption.

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

3. Software Design

1. Main Program: Weather.ino

(Located in the weather folder, with a compiled bin file that can be directly flashed) The code is extensive, and it is recommended to check the source file, with comments for each function.

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

2. Clear WiFi Settings

(Using the WiFiManager interface, compile and flash to clear the existing WiFi configuration on the board) Some code:

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform
Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

3. Demo App

(A small program that blinks an LED in a loop to free up memory, which can solve most issues of being unable to flash due to large bin size)

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform
Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

4. System Debugging and Testing

1. Platform

AMD R7-4800H, 16GB DDR4 3200

Windows 11 21H2 (November)

Microsoft Visual Studio Code 1.63.2

Arduino UWP Ver 1.8.51.0

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

Encountered a crash while compiling the main program using the win32 version of Arduino 1.8.16 on Windows 10 (20H2), with no errors or logs produced. Switching to Windows 11 (21H2) did not resolve the issue, and attempts to install older versions did not help either. Finally, using the UWP Arduino 1.8.51.0 from the Windows Store resolved the issue. It is suspected to be a compatibility issue between this AMD platform and the win32 version of Arduino.

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

The rest of the debugging process went smoothly.

2. Required Libraries for the Project

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

All related library files are packaged in the project directory under \Environment\libraries\

3. Related Open Source Code

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

4. Development Board Manager Involved

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

Text Editor: Wang Yaoyu 202013370005 Applied Chemistry

Images Provided by: Wang Yaoyu

Beautification Editor: Cheng Hongliu Wang Yingying

Editor: Chen Xueming

Building an Electronic Clock and Weather Display Based on the ESP8266 (NodeMCU) Platform

Leave a Comment