Digital Watch Using ATtiny85 & OLED Display

One of the greatest advances in electronic technology is the digital watch. These days, people are attracted to digital watches everywhere. The analogue watches are really outdated. Thus, day by day, the digital watch replaces it.

In this tutorial, I’ll walk you through building a tiny digital watch that runs for a long time without needing a new battery using an ATtiny85 processor. Additionally, all Arduino microcontrollers can be replaced with this readily accessible, inexpensive microcontroller chip. It’s also a small one.


Circuit Schematic



  • ATtiny85
  • 128×64 I2C OLED Display
  • Push Button (x2)
  • Connection Wires
  • Veroboard
  • 5V Power Supply

About Parts


The ATtiny85 microcontroller is the most affordable and potent microcontroller integrated circuit on the market. An 8-bit data bus, which can read 8 bits of data per instruction, powers this microcontroller. It can process data at a speed of 8MHz and store programmes in 8KB of flash memory. There are five input/output (I/O) pins on it that can be connected. The voltage range for operation is 1.8V to 5.5V.


  • It is possible to do digitalWrite() and digitalRead() operations on pins 2, 3, 5, 6, and 7.
  • Pins 5 and 6 have 8-bit resolution (0-255) PWM analogWrite() capabilities.
  • AnalogRead() can be used on Pins A1, A2, and A3 to measure analogue voltage using a 10-bit analogue digital converter (ADC).
  • The RESET pin, Pin 1, is used to restart a programme by connecting it to the ground.
  • Positive voltage (1.8V to 5.5V) is applied to pin 8 of the microcontroller.
  • Ground is indicated by pin 4.

OLED Display

Since our tiny Attiny85 processor has a restricted number of I/O pins, as we all know, I decided to use an I2C OLED display. With only four pins—VCC, GND, SDA, and SCL—it will meet our needs. Additionally, it works well to cut down on power usage. There are many different kinds of I2C OLED displays on the market, but I went with the SSD1306 (128×64) display as it is square and compact.

How to Upload Code to ATtiny85 Chip?

We must manually add the ATtiny85 board manager because the Arduino IDE does not support it by default.

  • Install ATtiny85 Board Manager
  • First Go to File > Preferences then scroll down to Additional Board Managers URLs > copy and paste the following URL

  • After that, go to Tools > Board >Boards Manager
  • A new tab will open and at the top of the tab type “ATtiny”
  • Select Install on the Attiny by David. A Mellis
  • Restart the Arduino IDE

Upload Code to ATtiny85

The ATtiny85 chip cannot be directly programmed with the code. We need an Arduino board to act as an ISP for that.

The Arduino Nano must first be configured as a Master ISP.

  • Go to Files > Examples > select ArduinoISP > open ArduinoISP code
  • Then select Tools menu > board type Arduino Nano
  • Select Processor to Atmega328 (Old Bootloader)
  • Select Port
  • Press the Upload button
  • Attach the Attiny85 and Arduino Nano in the manner shown in the circuit diagram below.
  • Go to Tools > Board > select ATtiny25/45/85
  • Under Tools > Clock > 8 MHz (Internal)
  • Under Tools > Processor > ATtiny85
  • Under Tools >Programmer >Arduino as ISP
  • Check that all wiring, capacitor, and board selections are correct
  • Finally, select Burn Bootloader

Working Principle of Digital Watch Using Attiny85

Required Battery By Current Calculation

The OLED display and microcontroller use roughly 6mA of current when the circuit is turned on.

To save power and enable the watch to function for more than a year, we must utilise the SLEEP_MODE_PWR_DOWN power-saving sleeping mode. It implies that the device will stay in sleep mode while not in use. The DC power metre indicates 0.1uA if all functions are deactivated. However, in order to maintain the continuous time, WDT (Watchdog Timer) must still be enabled. When WDT is enabled, 4uA is displayed.

Assume that the ATtiny85 and OLED display is set to turn off after five seconds and that the user wears his watch ten times every day.

{(0.004mA × 24 hours) + (6mA × (5 / 60 / 60) hours × 10)}

= 0.179

As a result, the watch will use roughly 0.2mAh every day. Thus, a 150mAh CR2025 battery has a 750-day battery life.

Proper Variables for Power Sleeping Mode

The real-time onscreen timer will, however, stop operating when the power sleeping mode is activated, and the millis() function will no longer function. In order to replace the millis() function, I need another variable. It raises a certain value for each WDT onscreen interruption. It is dependent upon the oscillator of the microcontroller and the WDT interval settings. The MCU calibrated the increment value to 998 (about 1000 milliseconds) using a one-second WDT interrupt.

In order to constantly check the battery’s condition, we also need to include the readVcc() function.

Proper Memory Management for Attiny85

Our little Attiny85 chip is experiencing a shortage of flash memory, which is a new issue. Too few characters in 8K flash memory to fit all the characters in regular or large font sizes.

Since the watch only needs 10 digital characters, as far as we know, we can create a special font type in binary form that will precisely fit in this constrained area.

I demonstrate how to convert custom font characters to a C header file using the ImageMagick command line tool.

For this specific program, we must translate 10 digits into two distinct font sizes: one that is 8 pixels tall to display “Date,” and another that is 24 pixels tall to represent “Time.”We can copy the font binary code to the “watchdigit.h” source file after exporting the.xbm file.

We can copy the font binary code to the “watchdigit.h” source file after exporting the.xbm file.

Leave a Comment