Skip to content

COD nationwide · Isb & Rwp delivery Rs 400

akCircuit
BeginnerGadgets 2 hours Arduino Nano

Desk clock with alarm and temperature

Build a desk clock with Arduino

An Arduino Nano clock with a precise DS3231 real-time clock, a crisp OLED face, room temperature from a DHT22 and a morning alarm. It keeps time even when unplugged, thanks to a coin cell.

Every required part

Rs 3,154

Parts list

13 items

  • Every required part in stock
  • Wiring and code included
  • Cash on delivery
Desk clock with alarm and temperature: Build a desk clock with Arduino
From our reel · 17 Jan 2027

Parts list

Everything you need for the desk clock with alarm and temperature

Every part below is in our catalogue at today's price, so the total is what you pay. Required parts are ticked; optional upgrades are not.

Required parts are ticked. Untick anything you already have; the total updates as you go.

Main parts

Wiring & mounting

You also need (most homes have these)

  • Phone charger (USB, 5 V)Powers the clock.

12 items

Rs 3,154

From our reel

Watch it come together in 12 steps

The reel of this build goes live on 17 Jan 2027, 7 pm. Follow us to watch it:

YouTube Instagram Facebook
  1. Step 1: The parts

    1The parts

  2. Step 2: Nano on the breadboard

    2Nano on the breadboard

  3. Step 3: DS3231 real-time clock

    3DS3231 real-time clock

  4. Step 4: 0.96" OLED

    40.96" OLED

  5. Step 5: DHT22 for temperature

    5DHT22 for temperature

  6. Step 6: Wire it up

    6Wire it up

  7. Step 7: Upload the code

    7Upload the code

  8. Step 8: Your own clock face

    8Your own clock face

  9. Step 9: Into a case

    9Into a case

  10. Step 10: Bedside glow

    10Bedside glow

  11. Step 11: Morning alarm

    11Morning alarm

  12. Step 12: Desk gadget done

    12Desk gadget done

How it works

What each part does

The DS3231 is a dedicated clock chip with its own temperature-compensated crystal, far more accurate than the Arduino's own timer. Its coin cell keeps it ticking when the power is off.

Every loop, the Nano asks the DS3231 for the time over I2C, reads the DHT22, and draws the time, temperature and alarm status on the OLED. The OLED shares the same two I2C wires.

When the clock reaches the alarm time, the buzzer beeps for 30 seconds; the alarm button turns it on or off.

Wiring

Connect it pin by pin

Switch the power off while you wire, and connect every GND together unless the table says otherwise.
FromToNote
DS3231 VCC→ Nano 3V33.3 V stops the module charging the CR2032
DS3231 GND→ Nano GND
DS3231 SDA / SCL→ Nano A4 / A5
OLED VCC / GND→ Nano 5V / GND
OLED SDA / SCL→ Nano A4 / A5Shared with the DS3231
DHT22 pin 1 / pin 4→ Nano 5V / GND
DHT22 pin 2 (DATA)→ Nano D510 kΩ from DATA to 5V
Buzzer +→ Nano D8
Buttons (hour, minute, alarm)→ Nano D2, D3, D4Other leg of each button to GND

The code

Ready-to-upload Arduino code

Copy it into the Arduino IDE, change the settings at the top if your build needs it, and upload.
Desk clockBoard: Arduino Nano (ATmega328P; try “Old Bootloader” if the upload fails)RTClib (Adafruit)Adafruit SSD1306Adafruit GFX LibraryDHT sensor library (Adafruit)Adafruit Unified Sensor
desk_clock.ino
#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>

RTC_DS3231 rtc;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
DHT dht(5, DHT22);

const int BTN_HOUR = 2, BTN_MIN = 3, BTN_ALARM = 4, BUZZER = 8;
const int ALARM_H = 6, ALARM_M = 30;  // alarm time, 24-hour clock
bool alarmOn = true;

bool pressed(int pin) {
  if (digitalRead(pin) == LOW) {
    delay(30);  // debounce
    while (digitalRead(pin) == LOW) delay(10);
    return true;
  }
  return false;
}

void setup() {
  pinMode(BTN_HOUR, INPUT_PULLUP);
  pinMode(BTN_MIN, INPUT_PULLUP);
  pinMode(BTN_ALARM, INPUT_PULLUP);
  pinMode(BUZZER, OUTPUT);
  rtc.begin();
  if (rtc.lostPower()) rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));  // time from your computer
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  dht.begin();
}

void loop() {
  DateTime now = rtc.now();
  if (pressed(BTN_HOUR)) rtc.adjust(now + TimeSpan(0, 1, 0, 0));
  if (pressed(BTN_MIN)) rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour(), (now.minute() + 1) % 60, 0));
  if (pressed(BTN_ALARM)) alarmOn = !alarmOn;
  now = rtc.now();

  bool ringing = alarmOn && now.hour() == ALARM_H && now.minute() == ALARM_M && now.second() < 30;
  digitalWrite(BUZZER, ringing && (millis() / 250) % 2);

  char line[16];
  oled.clearDisplay();
  oled.setTextColor(SSD1306_WHITE);
  oled.setTextSize(3);
  oled.setCursor(19, 8);
  snprintf(line, sizeof line, "%02d:%02d", now.hour(), now.minute());
  oled.print(line);

  oled.setTextSize(1);
  oled.setCursor(0, 50);
  float t = dht.readTemperature();
  if (!isnan(t)) {
    oled.print(t, 1);
    oled.print(" C   ");
  }
  if (alarmOn) {
    snprintf(line, sizeof line, "Alarm %02d:%02d", ALARM_H, ALARM_M);
    oled.print(line);
  } else {
    oled.print("Alarm off");
  }
  oled.display();
  delay(100);
}

Step by step

Build it

  1. 1

    Build it on the breadboard

    Put the Nano across the centre gap, then the three buttons and the buzzer. Connect the DS3231 and OLED with jumpers to A4 (SDA) and A5 (SCL).

  2. 2

    Fit the coin cell

    Put the CR2032 in the DS3231's holder, flat side up. Power the DS3231 from 3V3, not 5V.

  3. 3

    Install the libraries and upload

    Install the five libraries from the Library Manager and upload. On first start the clock takes the time from your computer.

  4. 4

    Set your alarm

    Change ALARM_H and ALARM_M to your wake-up time (24-hour) and upload again. Use the hour and minute buttons to fine-tune the clock any time.

  5. 5

    Put it in a case

    Cut a window for the OLED and holes for the buttons in the box, and run it from a phone charger.

Tips & troubleshooting

  • A blank OLED usually means a wrong address: most are 0x3C, a few are 0x3D.
  • If the time resets to the upload time after unplugging, the coin cell is flat or missing.
  • The temperature reads a little high if the DHT22 sits right next to the Nano: give it a few centimetres of space.

Stuck on wiring or code?

Send us a photo of your build on WhatsApp. We are makers too, and we will help you get it working.

Ask on WhatsApp

FAQ

Questions people ask

Why power the DS3231 from 3.3 V?+

Many DS3231 boards have a small charging circuit meant for rechargeable LIR2032 cells. At 3.3 V it cannot push current into an ordinary CR2032, so the coin cell stays safe.

Can it show the date too?+

Yes: now.day(), now.month() and now.year() are ready to print on the bottom line.

Can I use a bigger display?+

A 1.3" OLED works with small code changes (it often uses the SH1106 driver), or a 16×2 LCD for a retro look.

Read next

More projects to build

All projects