Temperature is measured by Dallas DS18B20 temperature sensor. But the reading this kind of sensor takes about 700ms so this can cause time delay I already described here. But meahwhile I learned how easy is to change resolution of the temperature sensor to reduce reading time. Unfortunately this act to accuracy of the result. Find more details on page 3 and 8 in this document.
In my case we choose 10 bit resolution therefore reading increment is 0.25°C which is far enough according to my son's wish for showing temperature only in integer. The sensor reads temperature each 10 seconds by a counter which counts seconds but the result is printed on LCD each second to remain each time LCD is refreshed.

NTP clock (Network Time Protocol)


- updated 10.12.2019

I build this clock for my seven-year old son who wanted to have a precise clock. The best solution I thought was a clock which can be synchronized over the internet. But my main requirement was that it operates offline. So I build a simple counter on an ESP8266 chip which counts seconds and converts them into time. This is processed offline.  The system goes online only for a few seconds when a time synchronization with NTP server is needed and after that it returns back to offline.
The timer code is very simple because I wanted to demonstrate the principle of clock timer to my  son.

Project requirements:

Time synchronization over WiFi

Operate mostly offline


Dimming back light

One button

Components Required:


LCD library for I2C:  https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/
How to find address of I2C module for LCD:  http://playground.arduino.cc/Main/I2cScanner
NTP code and library: https://github.com/SensorsIot/NTPtimeESP/blob/master/NTPtimeESP.h
Find nearest NTP server: http://www.pool.ntp.org/zone/europe

Timer description:

This clock is basically a simple counter which uses millis() as a basic counting unit and converts them into seconds. To avoid time delay during operations no delay() function should be used in the code. Time synchronization is executed at every midnight in my case but it could be set at any desirable time or event.

Synchronization process:

When synchronization begins, the ESP will try to connect to your home AP over WiFi. After the ESP is successfully connected to home AP it will try to reach NTP server to get time data packet. This stage is indicated on LCD by changing previous icon with a new one. During this time, a special counter will count seconds instead of a time counter which is inactive at this moment.

If NTP packet is received successfully then time counter integrates the new time data.

In case of unsuccessful synchronization the ESP will try to synchronize twice more after a minute of delay. If synchronization still does not succeed, a second from special counter will be added to time counter so no time delay will be noted on the clock counter. This stage is indicated on LCD with a suitable icon.

After synchronization process is finished, ESP disconnects itself from AP so the system continues operating offline.

Button modes:

In case of unsuccessful synchronization or at any time user can manually synchronize time by holding down the button for at least 4 seconds.
The same button also serves to switch between three predefined backlight intensities if it is pressed for a short time. Backlight values are also saved in EEPROM so the last preset backlight value persist in case if mains drop down.

ESP8266 lcd ntp clock
Project gallery & downloads:
Project gallery & downloads:
ESP8266 lcd ntp clock
ESP8266 lcd ntp clock
ESP8266 lcd ntp clock thermometer
ESP8266 lcd ntp clock thermometer
ESP8266 lcd ntp clock
ESP8266 lcd ntp clock
ESP8266 lcd ntp clock thermometer
Any comments please leave on YouTube.


LCD 1602 with I2C module

resistors: 10k, 330, 560

voltage regulator LM317

5V AC-DC power supply

momentary push button

05.07.2018: temperature sensor added

After a year my son become interested in temperature measuring. So we tried together with some diy experiments but they wasn't giving precise results. After I mentioned something about digital sensors accuracy this project begin to grow.

This feature is handy if you want a low LCD backlight over the night and a brighter over the day. So a new piece of code added will automatically switch between "mid light" in the morning and "low light" in the evening so you won't have to do it manually. In the code you will find a morning and evening time triggers which will switch LCD backlight between two predefined values. The time triggers for changing backlight are adjustable by your needs also the predefined backlight values. Just follow the comments in the code thus you can disable this feature also.

Following download link you will find sketches of both versions of NTP clock also gallery still remains previous project version.
10.12.2019: Update - automatic backlight set by time
The code of the NTP clock with a thermometer is upgraded with a backlight switch which changes autoamtically by the time in the morning and in the evening