Internet Clock With ESP8266

by Arnov Sharma in Circuits > Clocks

2150 Views, 13 Favorites, 0 Comments

Internet Clock With ESP8266

16 (72).gif
15 (74).gif
17 (72).gif
IMG_20220911_192851.jpg

Hey Guys how you doing?

So this is the Internet Clock I made using an ESP12F Module and a custom PCB.

ESP8266 Gets the time from the internet and then displays those values on an SSD1306 Display. It Displays the current time, date, and day.

The goal here was to make a simple Digital Wall clock for my desk as the analog watch I have was super boring and dull so it was time for a DIGITAL UPGRADE.

This whole setup is made on a custom PCB that has a minimal ESP8266 Setup, but we can prepare this setup by using a NodeMCU with an OLED Display on a breadboard as well.

This Instructables is about the whole build process of this INTERNET CLOCK so let's get started.

Supplies

Following are the thing used in this built-

  • ESP8266 12F module
  • Custom PCB
  • 10K Resistors
  • AMS1117 Voltage Regulator 3.3V
  • 1uF Capacitor 1206
  • 10uF Capacitor 1206
  • Header Pin CON4
  • SSD1306 OLED Display
  • NodeMCU
  • Breadboard

Basic Setup With ESP8266 Board

11 (90).gif

We first start by preparing a Breadboard setup first, we place the ESP8266 Nodemcu board and OLED on a Breadboard and do the following wiring connections.

  • 5V of NodeMCU to VCC of OLED Display
  • GND to GND
  • D2 to SDA
  • D1 to SCL

After this, we add the main code into the NodeMCU and you'll see Time and Day displaying on the OLED Screen.

Working and Code

Here's the code for this project, It uses an NTP Server which is in short a Protocol for setting time through the internet.

#include "NTPClient.h"
#include "ESP8266WiFi.h"
#include "WiFiUdp.h"

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

#define OLED_WIDTH 128
#define OLED_HEIGHT 64

#define OLED_ADDR   0x3C

Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);

const char *ssid = "addyourSSID";
const char *password = "andYourPass";

const long utcOffsetInSeconds = 19800; //Change this according to your GTM

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};


WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);

void setup(){
  
  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.clearDisplay();
  Serial.begin(115200);
  WiFi.begin(ssid, password);

while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}

timeClient.begin();
}

void loop() {
timeClient.update();

display.clearDisplay();
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(13, 0);

display.println(daysOfTheWeek[timeClient.getDay()]);

display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(38, 28);
display.println(timeClient.getHours());

display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(60, 28);
display.println(":");

display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(70, 28);
display.println(timeClient.getMinutes());
//display.println(":");
//display.println(timeClient.getSeconds());


display.display();
delay(1000);
}


Before using this Sketch, you need to first install the NTPClient Library from the library manager and change the UTC Offset according to your timezone.

My UTC or GTM is +5:30 which is 5.5x60x60 so 19800, if your time is +2:00 then the equation will be 2x60x60 which should be 7200 UTC Offset.

Custom Board

Capture.JPG
Capture2.JPG

After Preparing the Simple Breadboard setup, we move on to LEVEL 2 of this project which is to make a custom board by using the ESP12F Module instead of using a whole NodeMCU Board.

Schematic

SCH_page-0001 (25).jpg

Here's the schematic that was used to prepare the circuit, It has an ESP12F Minimal Setup that is connected with the OLED Display.

As for power, a USB Port is used to take power from a Smartphone charger.

It supplies 5V to this board but ESP12F Module is 3.3V Tolerant so there's an AMS1117 Setup that steps down the 5V into 3.3V for the ESP12F to work properly.

As for Programming, there's a CON6 Breakout port that will be used to connect with an external programmer for uploading code into the ESP Board.

PCB Prototype From Seeed Fusion

02 (93).gif
IMG_20220909_201927.jpg
IMG_20220909_201935.jpg

After finalizing the PCB and generating its Gerber data, I send it to SEEED STUDIO for samples.

Ordered PCBs in RED Soldermask with white silkscreen.

I received PCBs in a week and their quality was super good considering the rate which was also pretty low.

Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly and as a result, they produce superior quality PCBs and Fast Turnkey PCBA within 7 working days.

PCB Quality of this ESP12F Board WAS SUPER!

Seeed Studio Fusion PCB Assembly Service takes care of the entire fabrication process from PCB manufacturing, parts sourcing, assembly, and testing services, so you can be sure that they are getting a quality product.

After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.

Next, is the PCB Assembly Process.

PCB Assembly Process

01 (93).gif
03 (88).gif
04 (93).gif
05 (93).gif
06 (89).gif
07 (92).gif
08 (88).gif
  • We first start the PCB Assembly Process by adding Solderpaste to each component Pad one by one with help of a Solder Paste Dispensing Needle
  • Next, we gather all the SMD Components and place them in their location by using an ESD Tweezer.
  • We then place the PCB on a Reflow Hotplate to melt the solder paste.
  • Next, we place the header Pin and USB Port in their place and solder them using a standard soldering Iron.
  • At last, we place the SSD1306 Display on the header pin connector, and the Board is now completed.

Flashing the ESP12F With an NodeMCU ESP8266 Board

13 (83).gif

For Programming the ESP12F module, we use a Nodemcu board. Let me show you how.

we start first by shorting the Enable pin and GND, this will turn off the esp12f of the Nodemcu and now we can hook an external esp12f setup with the Nodemcu according to the following wiring connections.

  • 3v to 3v
  • GND to GND
  • RST to RST
  • GPIO0 to GPIO0 //D3 is GPIO0 on Nodemcu
  • TX to TX
  • RX to RX

I made a Nodemcu Breakout board that has a CON6 Port connected with the Programming Pins, same pins are added to the ESP Watch PCB. The idea here is to connect them both and use the Nodemcu's UART IC to program the ESP8266 Board by disabling the Nodemcu's ESP8266 Board and using an External one.

Read this article for more brief details-

https://www.instructables.com/Program-ESP8266-With-NodeMCU/

Result

09 (83).gif
16 (72).gif
17 (72).gif

Here's the result of this built, a working Digital Clock that displays DAY and Time.

This device can now be added to any wall or we can make a 3D-printed enclosure for placing on a desk.

This is it for today folks.

All the Docs related to the project are attached, if you need any help regarding this project, DM me or comment.

Special thanks to Seeed Studio for providing PCBs for this project, do check them out if you need great PCB Service for less cost.

Peace out and I'll be back with a new project soon!