กลับไปหน้ารวมไฟล์
aur4-clock-b26612-en.md
title: Arduino Uno R4 WiFi RTC NTP Clock
description: Building a high-precision clock using the internal RTC and synchronizing time via the NTP protocol on the Arduino Uno R4 WiFi board.
---

# Elevating the Arduino Uno R4 WiFi into a Smart Timepiece with NTP and RTC

In this project, we will harness the full potential of the **Arduino Uno R4 WiFi**, a new board packed with exciting features like the **Renesas RA4M1 (Arm® Cortex®-M4)** microcontroller and the **ESP32-S3** wireless connectivity chip. We will build a clock that automatically sets its time via the internet (NTP) and maintains time accuracy using the integrated RTC (Real-Time Clock) module within the chip.

This project builds upon the `RTC_NTPSync` example by **Sebastian Romero**, to create a clock that beautifully displays time on the onboard 12x8 LED Matrix.

---

## Diving Deeper into the Technology

### 1. Internal Real-Time Clock (RTC) System
Unlike the older Arduino Uno R3, which lacks an onboard timekeeping system and requires an external module like the DS3231 for clock projects, the **Arduino Uno R4 WiFi** comes with an integrated RTC within its RA4M1 chip. This allows us to precisely track time, date, and year at a hardware level.

### 2. Network Time Protocol (NTP)
To ensure our clock's time is always "spot on," we will use the **NTP** protocol to fetch the current time from global Time Servers via a WiFi connection. The system will retrieve the Unix Timestamp and then use it to synchronize (Sync) the internal RTC on the board.

### 3. LED Matrix Display (12x8)
A key feature of the R4 WiFi board is its onboard 12x8 red LED Matrix (96 individual LEDs). We will utilize this display to show the time digits, which supports orientation adjustment to suit vertical or horizontal board placement.

---

## Detailed Code Logic

The program's operation can be divided into the following key steps:

1.  **Initialization:** The program begins by enabling Serial Communication, checking the status of the WiFi module, and initializing the RTC system.
2.  **WiFi Connection:** It uses information from the `arduino_secrets.h` file to connect to the router. Upon successful connection, the status will be displayed via the Serial Monitor.
3.  **NTP Synchronization:** The program sends a request to an NTP Server to fetch the current time. Once the data is received, the `RTC.setTime()` command is used to update the time value for the RA4M1 chip.
4.  **Display Loop:** In the main loop (`void loop()`), the program continuously retrieves the current time from the RTC and displays it on the LED Matrix, checking the display orientation according to the `#define ORIENTATION` value we've set.

---

## Usage and Setup Steps

### 1. WiFi Network Configuration
You need to specify your WiFi connection details in the `arduino_secrets.h` file for the board to access the internet and fetch the time:

```cpp
#define SECRET_SSID "Your WiFi Name"
#define SECRET_PASS "Your WiFi Password"

2. Screen Orientation Setting

Since board placement may vary across projects, you can choose the display orientation of the digits on the LED Matrix by changing the numerical value:

#define ORIENTATION 0  // 0 for standard orientation or 1 for rotated display

3. Uploading the Code

Connect the Arduino Uno R4 WiFi to your computer. Select the correct board and Port in the Arduino IDE. Then, simply click Upload.


Components Used

  • Arduino Uno R4 WiFi: The core of the project (integrates MCU, WiFi, RTC, and LED Matrix all on one board).
  • USB-C Cable: For programming and power supply.
  • External Power Supply (Optional): If you wish to use it as a standalone display, a Power Bank or 5V-9V Adapter can be used.

Project Summary

Thanks to the powerful Renesas RA4M1, managing time is both easy and accurate. The integration of NTP with the RTC addresses the time drift issues commonly found in ordinary clocks. The onboard LED Matrix further makes this project a complete clock without the need for any additional external components.

[Download Code and Project Files Here] (Placeholder for download link/button)


Initial Developer Credit: Sebastian Romero (@sebromero) Information compiled by: [Your Name/Embedded Systems Engineer]


ข้อมูล Frontmatter ดั้งเดิม

title: "AUR4 Clock"
description: "A RTC NTP synced clock"
author: "eremefu"
category: "Screens & Displays"
tags:
  - "Clocks"
views: 440
likes: 0
price: 2450
difficulty: "Easy"
components:
  - "1x Arduino® UNO R4 WiFi"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles:
  - "https://github.com/eremef/aur4_clock"
  - "https://projects.arduinocontent.cc/33f126e9-fa02-4e30-92ed-9e746aca673b.ino"
  - "https://projects.arduinocontent.cc/98a269fc-e512-4416-8505-05fc76bdb15f.h"
documentationLinks: []
passwordHash: "fd096a74398ba2d04784ab8ff0ded00fb094f907b939c6bd15df5c2b02532065"
encryptedPayload: "U2FsdGVkX18IMXFGGDOfJkecPw0QlWppETq1monXBME2zxab0y8y4U25iVQRVH1/TVLbGn4Z+bUb3pUngoXE1Nlc0vjEx7bpUipMBZwWhOg="
seoDescription: "Build an AUR4 Clock synced via RTC and NTP for precise timekeeping in your Arduino projects."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/aur4-clock-b26612_cover.jpg"
lang: "en"