Project tutorial
LED Matrix NTP Clock with DS3231, BME280, BH1750 & ESP01

LED Matrix NTP Clock with DS3231, BME280, BH1750 & ESP01 © GPL3+

Modified exisiting project to include some sensors and extra buttons. Can use ESP01 to set time via NTP.

  • 31 respects

Components and supplies

Ard nano
Arduino Nano R3
Ds3231mpmb1 en4txppxku
Maxim Integrated DS3231MPMB1 Peripheral Module
The cheap one on Ebay, with the resistor removed to stop battery from exploding
13676 01
SparkFun Atmospheric Sensor Breakout - BME280
The cheap one from Ebay
BH1750 Light Sensor
From Ebay
Max7219 32x8 LED Matrix
Panasonic eca1hm2r2
Capacitor 10 µF
Espressif ESP8266 ESP-01
Optional if you want time set via NTP
3.3v LDO Regulator for ESP01
12009 06
SparkFun Level Shifter Board
Needed by ESP01

About this project

This is what got me into Arduino's. I came accross Nick's LED Word Clock, and thought I want to make that.

Since downloading his code, I've modified it to include extra sensors and buttons as well as adding an ESP01.

The BH1750 is used to auto dim the display, depending on light conditions, and it can turn the display off at night. The BME280 shows the temperature, humidity and pressure. The ESP01 is used to get the time from

The extra buttons are there to make it easy to adjust settings. You can adjust light sensor settings using the buttons, as well as change fonts and NTP/DST/UTC settings.

Six new fonts have been added, I made the fonts using:

I've made quite a bit of change to the word clock, it has more words now and have moved quite a bit to PROGMEM to save RAM.

Nick's project page:

My code:

The code is now complete, apart from uknown bugs and a tweak here and there, I will make a case for it.

You will need to adjust the light sensor code to match your light conditions, I coded this during bright sunlight sitting next to a window.

An ESP01 is used to get time via NTP, the ESP01 is coded to sleep (wifi off) when not needed, and is woken up via serial to get the time in UNIX format. The SSID name and password is passed via the Arduino code for convinience.

This version also has DST/UTC and BST calculations. These settings can be adjusted or disabled via the menu.

Settings are saved to EEPROM, this means if you power off and back on your changes made via the menu are saved.

These are the code files on Github:

Code on Github []:

When the ESP01 is running the Arduino Serial will show this:

Arduino : Sent NTP request to ESP01
ESP01 : NTP request received from Arduino
[attempt 1 of 3]
Connecting to SSID: TheInternets....connected
SSID: TheInternets, IP Address:
Signal Strength (RSSI): -42 dBm
Sending NTP packet to: [attempt 1]
Sending NTP packet to: [attempt 2]
Disabling WiFi....ok

More pictures and instructions to come...

Completed Project

Putting it all together:


DS3231, BH1750 and BME280:
 VCC = 3.3v
LED Matrix:
 CLK = D11
 CS  = D10
 DIN = D12
 VCC = 5v
 D2 - Menu
 D3 - Date / +
 D4 - Temp / -
 D5 - Display options
ESP01 - Optional
 D7 - TX pin of ESP01
 D6 - RX pin of ESP01

These are the global variables you can change:

// Global variables (changeable defaults), numbers in [] brackets are the EEPROM storage location for that value
// Clock settings
// [200] Default intensity/brightness (0-15), can be set via menu
byte intensity = 2;
// [201] Default clock mode. Default = 0 (basic_mode)
byte clock_mode = 0; 
// [206] Define random mode - changes the display type every few hours. Default = 0 (off)
bool random_mode = 0; 
// [207] Define font random mode - changes the font every few hours. 1 = random font on
bool random_font_mode = 0; 
// [208] Define 12 or 24 hour time. 0 = 24 hour. 1 = 12 hour
bool ampm = 0; 
// Light settings
// [202] Default display on/off mode, used by light sensor. 0 = normal, 1 = always on, 2 - always off, 3 - 5 = defined by hour_off_1,2,3
byte display_mode = 5; 
// [209] Default auto light intensity setting
bool auto_intensity = 1; 
// These three define the hour light sensor can turn off display if dark enough, format is 24 hours, the routine for
// this checks between 8.00 and one of these values
byte hour_off_1 = 21; 
byte hour_off_2 = 22; 
byte hour_off_3 = 23;
// Font settings - these are set via the setup Font menu, see set_font_case() routine for all default values:
// [203] Default clock large font style
byte font_style = 2; 
// [204] Default clock large font offset adjustment
byte font_offset = 1; 
// [205] Default clock large font columns adjustment
byte font_cols = 6; 
// DST NTP and UTC settings
// [210] Enable DST function, 1 = enable, 0 = disable
bool dst_mode = 1; 
// [211] Enable NTP function, 1 = enable, 0 = disable
bool ntp_mode = 1; 
// Number of seconds to adjust NTP value before applying to DS3231, takes a few hundred milliseconds to process the ESP01 data
byte ntp_adjust = 1; 
// [213] UTC offset adjustment, hours
int8_t utc_offset = 0; 
// The hour daily NTP/DST sync happens, should be left at 2am if using DST mode
byte ntp_dst_hour = 2; 
// Number of time to retry NTP request 1 = 35 seconds(ish) in total, values 1 - 9
byte ntp_max_retry = 3; 
// Used to calculate when to quit ntp() when it's not receiving data, value in seconds, it is multiplied by ntp_max_retry
byte ntp_timeout = 45; 
// Global constants - SSID and password for WiFi, passed to ESP01 via SoftwareSerial
// The combined SSID and password length cannot exceed 72 characters
// The length of your SSID name, e.g SSID = MyWifi, ssid_len = 6
const byte ssid_len = 8; 
// Your SSID name, e.g MyWifi
const char ssid[] = "YourSSID"; 
// The length of your SSID password, e.g password = password, pass_len = 8
const byte pass_len = 12; 
// Your SSID password, e.g password
const char pass[] = "YourPassword"; 



There was no BH1750, it connects the same way as BME280
Matrixclock bb 6xloafehqs


Similar projects you might like

Mini LED Matrix Clock

Project tutorial by Mirko Pavleski

  • 100 respects

Arduino Nano Clock with 4x64 LED Matrix (new version)

Project tutorial by M.V.P.

  • 82 respects

Analog Clock with LED Matrix and Arduino

Project showcase by LAGSILVA

  • 84 respects

Single LED Matrix Arduino Flip Clock

Project tutorial by Mirko Pavleski

  • 25 respects

Arduino Word Clock on 8x8 RGB LED Matrix

Project tutorial by Mirko Pavleski

  • 35 respects

Epoxy Resin LED Clock

Project tutorial by TheTNR

  • 16 respects
Add projectSign up / Login