«

»

Sep 25 2013

DIY Digital Wristwatch

Introduction

The main incentive behind this project was to see how much I could cram, in terms of both hardware and software, into a wristwatch-like device that is no larger than the display itself. An OLED display was chosen for being only 1.5mm thick and not requiring a backlight (each pixel produces its own light), but mostly because they look cool. The watch was originally going to have a 0.96″ display, but this proved too difficult to get all the things I wanted underneath it. Going up a size to 1.3″ was perfect.

DIGITAL CAMERA
DIGITAL CAMERA



Hardware

Wristwatch schematic

Wristwatch schematic


On the hardware side the watch contains an Atmel ATmega328P microcontroller, 2.5V regulator, Maxim DS3231M RTC, 1.3″ 128×64 monochrome OLED, 2 LEDs (red and green), a buzzer sounder, 3 way switch for navigation, powered by a 150mAh LiPo battery which can be charged via USB and 2 PCBs (though one PCB is just used as a raiser for the OLED).

The ATmega328P uses its internal 8MHz oscillator and runs on 2.5V from a linear regulator. Its current draw is around 1.5mA when active and 100nA in sleep mode.

The DS3231M RTC is an excellent chip, housed in a small 8 pin package which includes a built-in temperature compensated MEMS resonator with an accuracy of ±5ppm (± 2 minutes 40 seconds per year). Only a decoupling capacitor and a few extra pull-up resistors were required. The RTC is wired up so that instead of having power applied to the VCC pin, it’s applied to the Vbat pin which reduces its current draw from around 100uA down to 2.5uA.
Unfortunately this chip seems to be very hard to get hold of at a reasonable price if you’re not in the US. I had to get mine as samples.

The battery charging circuit uses a Microchip MCP73832 along with some additional components for load sharing, where the battery can charge without the rest of the watch interfering with it.

You might have noticed in the schematic that the LEDs are directly connected to the microcontroller without any resistors. The internal MOSFETs of the microcontroller have an on resistance of around 40Ω, so with a 2.5V supply voltage and LEDs with 2Vf, around 20mA ends up through the LEDs. I would have liked to have a blue LED, but the voltage drop for those are usually more than 3V which would have required some additional resistors and a MOSFET.

As the microcontroller is running on 2.5V the battery voltage needs to be brought down a bit to obtain an ADC reading. This is done by a simple voltage divider. However, with the voltage divider connected across the battery there would be a current of around 350uA constantly flowing through it, this is a huge waste of power. A P-MOSFET (and some voltage level conversion for it, which I forgot about in the first version so it was always stuck on) was added so the divider can be turned on only when needed.

The 2.5V regulator being used is a Torex XC6206, primarily chosen for its tiny quiescent current of just 1uA.
Why a linear regulator and not a switching regulator? The switching regulators I looked at had an efficiency of at least 80% with a 2mA load, but that efficiency quickly dropped off to less than 50% with loads of 100uA. Since the devices connected to the regulator draw 2-3uA in sleep mode, a switching regulator would have performed incredibly poor compared to a linear regulator. The 2.5V linear regulator efficiency is 60% with 4.2V input going up to 83% with 3V input.

Underside

Underside

Top side, under display

Top side, under display

Software

So we’ve got a nice OLED display and 32KB of program space at our disposal, surely we can have more than just the time and date?

Almost everything is animated

A lot of time was spent optimizing the rendering code which, in short, involves copying bitmap images from flash to the frame buffer in RAM and sending the frame buffer over SPI to the OLED. The end result was being able to maintain 100+ FPS in almost all areas of the watch with an 8MHz AVR. However, since the animations are frame based instead of time based and to save power, the frame rate is limited to 60FPS.

Some of the main animated things:

  • CRT animation when entering and exiting sleep mode (similar to Android CRT animation).
  • Main time numbers have a ticker effect.
  • Menus have a scroll left/right animation and selecting an option will cause the current menu to fall off the screen and the next thing to fall on.

Alarms

  • Set up to 10 alarm times.
    Number of alarm times is only limited by the amount of available EEPROM and RAM.
  • Each alarm has the hour, minute and which days of the week it should be active on.
Alarms menu

Alarms menu

Games

Breakout

Breakout

Car dodge

Car dodge

 
 

Apps

Flashlight

Flashlight
Turns on all OLED pixels and LEDs, also has seizure strobe mode

Stopwatch

Stopwatch

 
 

Plenty of options

  • 3 Channel volume control
    • UI
    • Alarms
    • Hour beeps
  • Sleep timeout
  • Display brightness
  • Animations
    You’re not going to turn them off, right?
Volume settings

Volume settings

Power saving

In ‘active’ mode the microcontroller tries to go into idle sleep as much a possible. In idle sleep the controller is woken each millisecond to see if anything needs to be updated, if not then it goes back to idle sleep, this usually takes less than 100us if the display doesn’t need to be updated. In this mode the current draw can be anywhere between 0.8mA and 2mA, depending on how long it takes to draw frames (fast frame draw time = more time in idle sleep).

In ‘sleep’ mode the microcontroller turns the OLED off and goes into power-down sleep mode where it is only woken by either a button press, an RTC alarm or USB being plugged in. In this state the microcontroller draws ~100nA.

Power consumption

In sleep mode the overall current draw of the watch is around 6uA. In active mode the current draw can vary from 2mA to over 70mA, though 10mA is the typical current draw.


Battery capacity: 150mAh

Minimum
(sleep mode)
Typical
(main time display)
High
(flashlight)
6uA
2.85 years
10mA
15 hours
64mA
2 hours, 20 minutes

If the watch is in active mode for an average of 1 minute per day (with a 5 second sleep timeout that would be checking the time 12 times a day) and all volume channels set to minimum the watch should last for around 30 days 1 year and 4 months on a single charge. (Oops, 30 days is if the watch is on for 1 minute per hour, not day).


Current draw breakdown (typical)

Part Current
ATmega328P (sleep / active) 100nA / 1.5mA
OLED (sleep / active) 500nA / 8.5mA
DS3231M RTC 2.5uA
Schottky diode (D1) (reverse leakage) 1uA
Regulator (quiescent current) 1uA
Other (MOSFET and capacitor leakage etc) 1uA
Total (sleep / active) 6.1uA / 10mA

v1 to v1.1 changes

The first version had a few problems:

  • Added level conversion for the ADC P-MOSFET.
    Without level conversion the P-MOSFET was always stuck on. To turn of the P-MOSFET off the gate voltage needs to be at around the same level as its source voltage (which is connected to the battery), but the microcontroller was only providing 2.5V.
  • Added a gate pull-down resistor for the MOSFET driving the sounder.
    The MOSFET gate was floating when the microcontroller was being programmed which was causing the MOSFET to turn on and allow non-pulsed current to flow through the sounder, which probably wasn’t good for it.
  • Larger solder pads for MicroUSB connector.
    Normally SMD MicroUSB connectors have solder tabs at the sides and should have extra solder pads underneath, but since this is soldered by hand the underneath is unreachable. With out the extra solder pads the USB connector was wobbly so some of the connector pins eventually broke their solder joints. To fix this issue I enlarged the side solder pads so that the connector can be soldered all along its side instead of just the tab. No more wobbly connectors.

DIGITAL CAMERA

Other problems

Out of 3 OLED displays, 2 died after a few minutes of being attached to the watch. One from Ebay and the other from AliExpress. I’m still not sure why they died, maybe just China quality? The one that worked was also from Ebay.

Future improvements

  • Programming via USB.
    At the moment 4 wires need to be poked into the board (SPI programming) and then hope they don’t fall out while programming.
  • Add a fuel gauge IC.
    At the moment the battery level is determined by its voltage, this isn’t a very accurate method of getting the remaining battery charge.
  • Different microcontroller.
    The current firmware is using ~28KB out of the 32KB of available program space in the ATmega328P, a different microcontroller with more program space and probably more RAM would be needed to add more things like a calculator (floating point stuff eats up a lot of program space). However, the ATmega328P has the most program space for an AVR in a 32 pin TQFP package, to have more program space I would have to use a 44 pin AVR. The ATmega1284 looks interesting.
  • Switching regulator, charge pump regulator or maybe a hybrid solution?
    The linear regulator in use at the moment isn’t particularly efficient and switching regulators don’t seem to be very good with low current draw. Perhaps a charge pump regulator or a hybrid solution to swap between a linear regulator for sleep mode and a switching regulator for active mode?
  • A case of some sort?

Sources available at GitHub

Parts list

Schematic Part/value Description Quantity
U1 Atmel ATmega328P Microcontroller 1
U3 MCP73832 Lithium battery charger IC 1
U4 XC6206P252MR 2.5V LDO Regulator 1
U2 DS3231MZ+ RTC 1
Q1, Q2 DMP1045U P-MOSFET 2
Q3, Q4 DMG6968U N-MOSFET 2
D1 ZLLS410 Schottky diode 1
D2 TS4148 High speed diode 1
C5 4.7nF Capacitor 1
C4, C6, C7 100nF Capacitor 3
C3, C8, C9, C10 1uF Capacitor 4
C12 2.2uF Capacitor 1
C1, C2, C11 4.7uF Capacitor 3
R4, R8, R10 100R Resistor 3
R6 2.7K Resistor 1
R5 7.5K Resistor 1
R7 10K Resistor 1
R1 22K Resistor 1
R2, R3, R11 47K Resistor 3
R9 390K Resistor 1
RN1 10K network Resistor network (4x resistors) 1
LED1 LED (green) LED 1
LED2 LED (red) LED 1
LS1 Sounder Magnetic sounder 1
SW1 3 Way navigation switch 1
MicroUSB connector (Ebay) 1
OLED1 OLED (Ebay / AliExpress) 1
Battery (Ebay) 1
Main PCB 1
Display raiser PCB 1
Watch strap G10 NATO 22mm 1


Featured at
Atmel, HackADay, Electronics Lab, adafruit

Water proof down to 0m!

232 comments

16 pings

Skip to comment form

  1. Hangman

    Hi Zak,

    I finally finished something like a case for your watch. It’s 3d printed in 2 parts and I tried to make it as minimalist as possible.
    If anyone is interested, on my website are some pictures and the .stl files (and everything in german).
    -> http://kekse23.de/2014.12.05/309/ein-gehaeuse-fuer-die-nwatch/

    1. Zak Kemble

      That looks really good, I like it! 😀

  2. marcello

    Could you send me a file of the pcb and code so i could make my own? At gravesmarcello@gmail.com if posable.

    1. Zak Kemble

      Everything is available at https://github.com/zkemble/NWatch

  3. Marcello

    I cant find the gerber files for the pcb.

    1. Zak Kemble

      Use EAGLE to open watch.brd/.sch (here) and use the CAM processor to create gerber files in the correct format for your PCB manufacturer.

      1. mark

        hi, how to open watch.brd using eagle? I can’t open it and all I get is just code and I can’t download the file too. what should I do?

        1. Zak Kemble

          Go to the main page of the N|Watch repo and click the “Download ZIP” button on the right side.

          1. mark

            okay got it, thanks mate..

  4. Alexander

    Hi Zak, I use display chip SH1106, runs a line from the top of the display, I can not fix the code that worked full Screen, please podskazhyte that must be corrected, thank you in advance.

    1. Zak Kemble

      Hi, I don’t have a SH1106 display so I can’t do much at the moment, but I do plan on buying one and getting it to work sometime.

  5. BitAbbas

    Hi.
    Pcb & hex email for me?

    1. Zak Kemble

      They can be found here – https://github.com/zkemble/NWatch

  6. Greg

    Hi
    You can also use flat/slim battery (1.5-2mm) which costs about 10$, (at the capacity 100-200mAh) :)

  7. Henry

    Your oled died because his VBAT = 3.3V to 4.2V, but you put the USB voltage and it is 5V (pin 6 of oled).

    1. Zak Kemble

      The absolute max for Vbat is 5V. There is also a schottky diode which drops the voltage by at least 0.2V.

  8. Tuur

    Dude this is amazing! The only question i have is:
    Does it receive notifications? And if it does with what Android version?
    And would it be compatible with Android 4.2.2

    1. Zak Kemble

      No, the watch doesn’t have any kind of connectivity.

  9. Jack Harwood

    i wish this would come back

  10. Lewis

    Awesome job! This is one of the best DIY projects I’ve seen. I’ve used a couple of these OLED displays for other projects and I was wondering if you ever had problems with horizontal bands of differing brightness?

    1. Zak Kemble

      Thanks :)
      I’ve only had issues like that from bad power, things like a bad connection or supply voltage being too low.

  11. Hare

    Hello Zak,I’m doing a watch like you.I want to know how to make it knows it is charging,and when in sleep, alarm clock does not work until I wake it up.What should I do?
    I use arduino,but I hope you can tell me something.
    Forgive me for my poor English.
    Thanks.

    1. Zak Kemble

      Battery charging can be detected by reading the STAT pin on the charging IC (or whatever pin has a charging state output). For alarm wakeup the RTC needs to have an alarm interrupt output connected to an interrupt input on the microcontroller (similar to how a button can wakeup the microcontroller).

      1. Hare

        alarm interrupt output isSQW PIN? Do I need to start the alarm interrupt in code? Thank

        1. Zak Kemble

          Yes (but check the datasheet for your RTC IC) and yes.

          1. Hare

            Do you create a Arduino project? I saw you writing TODO

          2. Zak Kemble

            The Arduino part is about making some kind of library for interacting with the rest of the hardware on the watch (RTC, detect USB, detect charging and battery voltage etc). I’ve not started working on it yet, though.

  12. Ben Hur

    Hi,

    I’m trying to make a watch like you but I want to add accelerometers and other sensors. However, you used the DS3231. On its datasheet it says it consumes 110uA standby plus a 575uA temperature conversion current. How is it possible to use it with just 2.5uA? Does its precision get compromised? Wasnt it suposed to waste a lot more power than that? Does it communicate correctly that way?

    Thanks in advance,
    Sorry for the bad english, I’m brazilian XD

    1. Zak Kemble

      The 2.5uA figure is when the RTC is being powered by Vbat instead of VCC. According to the datasheet the only difference between the two is that the temperature compensation conversion is done every 10 seconds instead of every 1 second when on Vbat. Having a lower sampling rate might effect accuracy if the temperature changes a lot in those 10 seconds, but other than that there are no issues.

  13. Surachai

    I compiled but it error.

    Build started.
    Project “optiboot.cproj” (default targets):
    Target “PreBuildEvent” skipped, due to false condition; (‘$(PreBuildEvent)’!=”) was evaluated as (”!=”).
    Target “CoreBuild” in file “C:\Program Files (x86)\Atmel\Atmel Studio 6.2\Vs\Compiler.targets” from project “C:\Users\tevada2010\Downloads\Compressed\NWatch-master\firmware\src\optiboot\optiboot.cproj” (target “Build” depends on it):
    Task “RunCompilerTask”
    Shell Utils Path C:\Program Files (x86)\Atmel\Atmel Studio 6.2\shellUtils
    C:\Program Files (x86)\Atmel\Atmel Studio 6.2\shellUtils\make.exe all
    Building file: .././optiboot.c
    Invoking: AVR/GNU C Compiler : 4.8.1
    “C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-gcc.exe” -x c -mcall-prologues -funsigned-char -funsigned-bitfields -DF_CPU=8000000L -DBAUD_RATE=57600 -DLED_START_FLASHES=3 -DDEBUG -DLED=D6 -DLED_DATA_FLASH=1 -Os -fno-inline-small-functions -fno-split-wide-types -fno-tree-scev-cprop -ffreestanding -fno-exceptions -maccumulate-args -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mshort-calls -mrelax -g2 -Wall -mmcu=atmega328p -c -std=gnu99 -Wstrict-prototypes -Wextra -MD -MP -MF “optiboot.d” -MT”optiboot.d” -MT”optiboot.o” -o “optiboot.o” “.././optiboot.c”
    avr-gcc.exe(0,0): error: unrecognized command line option ‘-mshort-calls’
    make: *** [optiboot.o] Error 1
    The command exited with code 2.
    Done executing task “RunCompilerTask” — FAILED.
    Done building target “CoreBuild” in project “optiboot.cproj” — FAILED.
    Done building project “optiboot.cproj” — FAILED.

    Build FAILED.
    ========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========

    1. Zak Kemble

      The compiler that comes with Atmel Studio doesn’t support ‘-mshort-calls’. I’ve been using AVR-GCC 4.7.2. Right click on optiboot in the top right side window > Properties > Toolchain tab > AVR/GNU C Compiler > Optimization > Untick ‘Use rjmp/rcall (limited range) on > 8K devices (-mshort-calls)’.

  14. John S

    Hi I really like your project. I’m thinking of doing something similar myself. Question: wouldn’t a two diode setup work for the load sharing instead of your switching mosfet? Sure you have a voltage drop, but you’re dropping the V from 3.7 or so down to 2.5 anyway. Just wondered if you thought about this or not. Your project seems very well thought out.

    1. Zak Kemble

      Thanks :) Yeah you could replace the MOSFET with a diode, though the OLED and buzzer run straight from the battery so they won’t be quite as bright or as loud. It’s personal preference I suppose, MOSFET method works better but adds a little more complexity.

  15. andrew

    good job. but for what did you need 2 nchannel mosfets? thx

    1. Zak Kemble

      Q3 N-MOSFET is for level shifting, 2.5V from the microcontroller isn’t enough to turn off the P-MOSFET (which controls the voltage divider for measuring the battery voltage) so Q3 shifts it up to the supply voltage.
      Q4 N-MOSFET is for driving the sounder.

      In the latest version (on GitHub, v1.4) the N-MOSFETs have been replaced with cheaper BC817-40 BJTs and Q2 P-MOSFET replaced with a BC807-40.

  16. Seb

    Good job and thanks for sharing.
    Just 2 questions :
    – Why it is the drain of Q1 connected to VBAT and not the source ?
    – Do you think it is possible to increase low power with a higher value for R4 ?

    Thanks

    1. Zak Kemble

      Hi, thanks.
      – Because the 5V from USB will then be connected to the battery via 2 diodes, D1 and the internal diode of the MOSFET. This will destroy the battery. More info here.
      – No, the gate of a MOSFET is similar to a small capacitor, once it’s charged or discharged then no more current will flow. A larger resistor will just make it turn on and off slower.

  17. Seb

    Thank you for your prompt and clear response.
    & long live Puppets and Open source !

  18. Hayri Uygur

    Hello Zak,

    This is really the nicest and most thought through OLED Watch I have seen. I signed up on your mailing list in the hopes to at least get a hold of the PCB’s. It would be a little overkill for me to have fabricated the minimum 5 pieces with a fabhouse.
    Anyway I would love to CNC machine a nice custom case for this watch, it really deserves it. I saw that someone created a 3D printed case but a case out of aluminum would be great I think.
    Oh I almost forgot to thank you for all your work and making it free for everybody.
    Wish you all the best.
    Hayri

    1. Zak Kemble

      Thanks 😀
      It’s very unlikely that I’ll be accepting orders anytime soon. I get PCBs from OSHPark.com, they come in sets of 3. The main PCB and raiser bit can be ordered for about $15 and free postage.

      1. Hayri Uygur

        Thanks for the reply Zak.

        I thought of OSHPark too since they do fewer PCB’s than Elecrow which I used till now, unless I want to make a bunch of watches. Now I have to make sure I can get all the components first before I order the PCB’s. Come to think I can just order the main PCB and cut the raiser bit on my CNC along with a case.
        Anyway thanks again for all your hard work.
        Take care,
        Hayri

  19. Damian

    Hi! Your smartwatch is really awesome! I’m trying to find out how this firmware works, but I have little problems with reading your code. Can you tell me how do you written animations? I will be so grateful :)
    Thank you in advance!

    1. Zak Kemble

      Here’s a quick run-though:
      The main rendering function is in draw.c, called draw_bitmap(). You’ll see at the top that it applies the animation by offsetting the Y location of each thing it renders. animation_offsetY() is in animation.c. Each time a new frame is drawn the animation_update() function is called from display_update() in display.c which updates the offset variable so that everything is rendered slightly further down the screen.

  20. Oriq

    Hi ! Your smartwatch is very cool ! I will make it one but in my city doesn’t have that components so can i make it use arduino mini? and what components that dont’ needed if i use arduino mini ?
    Thanks!

    1. Zak Kemble

      Using an Arduino Mini will remove the need for the 2.5V regulator and microcontroller. You’ll also need to add resistors (around 100R) between the LEDs and Mini output pin.

  1. I call it the Blue PIXie board…… (part 1) | bagaloozy

    […] A lot of the inspiration for this project came from the excellent work done by Zak Kemble at his blog. […]

  2. OLED WATCH | Christian Arnø

    […] couple of weeks ago i saw this project by Zak Kemble here:http://blog.zakkemble.co.uk/diy-digital-wristwatch/. I emediately wanted to build one myself using off-the-shelf […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Are you human? *