All paths

Clocks, RTCs and time

Keep real time: millis() rollover tested in seconds, the DS1307, DS3231 and DS1302 clocks, time zones and the US and EU daylight saving rules, NTP on an ESP32-C3, alarms and schedules, and a sunrise alarm clock.

Arduino Uno R3Free7 lessons6 h4 chapters2,024 XPEmbedded engineering · Intermediate+150 XP

0 of 7 done

What you will build

2 projects, built step by step

7 lessons in 4 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

The DS1302 on three wires

A DS1302 on its own three-wire bus: CE, a clock and one data line both ways, write-protect and halt bits, 31 bytes of battery-backed RAM, and setting the time.

Open it in the simulator
Chapter 2 project

NTP: time from the network

An ESP32-C3 asks an NTP server for the time: Unix time in UTC, an offset added by the sketch, a resync interval, and the seconds of the minute running around a strip.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Counting time

millis() and the clock chips that keep the calendar.

  1. Open218 XP

    millis() rollover

    millis() is a 32-bit count that wraps to 0 after 49.7 days: a clock that starts five seconds before the wrap, a blinker that survives it with subtraction, and one that goes haywire.

    0 of 6 steps

  2. Locked218 XP

    DS3231 vs DS1307

    Inside a DS1307: a 32.768 kHz crystal, seven BCD registers, the clock-halt bit and a coin cell, and why the DS3231 drifts ten times less.

    0 of 6 steps

  3. ProjectLocked436 XP

    The DS1302 on three wires

    A DS1302 on its own three-wire bus: CE, a clock and one data line both ways, write-protect and halt bits, 31 bytes of battery-backed RAM, and setting the time.

    0 of 6 steps

4 questions, graded as you go.
Chapter 2

Wall clock time

Time zones, daylight saving and the network.

  1. Locked218 XP

    Time zones and daylight saving

    Keep UTC on the RTC and show local time: a zone offset, the US and EU daylight saving rules worked out for any year, and the hour that is skipped in spring and repeated in the fall.

    0 of 6 steps

  2. ProjectLocked436 XP

    NTP: time from the network

    An ESP32-C3 asks an NTP server for the time: Unix time in UTC, an offset added by the sketch, a resync interval, and the seconds of the minute running around a strip.

    0 of 6 steps

4 questions, graded as you go.
Chapter 3

Alarms

Let the clock chip watch the time.

  1. Locked218 XP

    Alarms and schedules

    Two DS3231 hardware alarms, one at a set time and one every minute, flags that wait to be read, and a daily schedule table checked against the clock.

    0 of 6 steps

3 questions, graded as you go.
Chapter 4

Boss project

A sunrise alarm clock that wakes you with light.

  1. Locked280 XP

    Boss: a sunrise alarm clock

    Wake up to light: a DS3231 in UTC, New York time with daylight saving on a TM1637, a 16 LED ring that rises from deep red to warm white before the alarm, weekdays only, and a snooze.

    0 of 8 steps

3 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Counting time

  1. millis() rollovermillis() is a 32-bit count that wraps to 0 after 49.7 days: a clock that starts five seconds before the wrap, a blinker that survives it with subtraction, and one that goes haywire.
  2. DS3231 vs DS1307Inside a DS1307: a 32.768 kHz crystal, seven BCD registers, the clock-halt bit and a coin cell, and why the DS3231 drifts ten times less.
  3. The DS1302 on three wiresA DS1302 on its own three-wire bus: CE, a clock and one data line both ways, write-protect and halt bits, 31 bytes of battery-backed RAM, and setting the time.
Chapter 2

Wall clock time

  1. Time zones and daylight savingKeep UTC on the RTC and show local time: a zone offset, the US and EU daylight saving rules worked out for any year, and the hour that is skipped in spring and repeated in the fall.
  2. NTP: time from the networkAn ESP32-C3 asks an NTP server for the time: Unix time in UTC, an offset added by the sketch, a resync interval, and the seconds of the minute running around a strip.
Chapter 3

Alarms

  1. Alarms and schedulesTwo DS3231 hardware alarms, one at a set time and one every minute, flags that wait to be read, and a daily schedule table checked against the clock.
Chapter 4

Boss project

  1. Boss: a sunrise alarm clockWake up to light: a DS3231 in UTC, New York time with daylight saving on a TM1637, a 16 LED ring that rises from deep red to warm white before the alarm, weekdays only, and a snooze.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Clocks, RTCs and time

Is Clocks, RTCs and time free?

Yes. All 7 lessons of Clocks, RTCs and time are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Clocks, RTCs and time take?

About 6 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: The DS1302 on three wires and NTP: time from the network.

Where do I start?

With "millis() rollover", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.