ATtiny-Watch-Core
ATtiny-Watch-Core
Table of Contents
Step 1: Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
ISP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Battery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Other Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Step 2: Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Step 6: Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Step 8: Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
http://www.instructables.com/id/ATtiny-Watch-Core/
Intro: ATtiny Watch Core
This instructable show how to use an ATtiny85 to create a tiny watch core that can run over 1 year before recharge or replace battery.
I have made a few Arduino watch before, but I found the watch using ATmega boards or ATmega chips are a little bit too big to wear. So I would like to make it with a
smaller chips.
Step 1: Preparation
MCU
ISP
Battery
In general expectation, a watch should run over 1 year without charging or replace battery. For my simple measurement of power usage and the battery specification,
CR1220 can only run about half an year, CR2016, CR2025 and CR2032 can run over 1 to 2 years representatively.
Display
Since the number of IO pins of ATtiny85 is very limited, I design display and further modules should all run in I2C. Power consumption and source availability are also
important factors. I choose an OLED screen drive with SSD1306. It can find in 3 different sizes, 64x32 is the smallest one. (another sizes are 128x64 and 128x32)
Other Parts
A battery holder, a small bread board, some bread board wires, two buttons and a power switch (optional).
http://www.instructables.com/id/ATtiny-Watch-Core/
Step 2: Assembly
connect all the parts on the bread board:
ATtiny85
pin 8: VCC
http://www.instructables.com/id/ATtiny-Watch-Core/
Step 3: Power Down, WDT and Time
When MCU and OLED turned on, it consume about 6 mA.
In order to make the watch can run over 1 year, I will use the most power saving sleep mode, SLEEP_MODE_PWR_DOWN, when user not in use. According to my
cheap power meter, it show 0.1 uA if disable all the function. But It still need to enable WDT for time keeping, after enable WDT, it show 4 uA. Assume MCU and OLED
auto sleep after 5 seconds and user view the watch 12 times, the watch will consume about 0.2 mAh. ((0.004 mA * 24 hours) + (6 mA * (5 / 60 / 60) hours * 12)) So a 150
mAh CR2025 battery can run 750 days.
The time source code mainly come from PaulStoffregen. However, the power down sleep mode will stop the normal timer, use mills() function for time keeping is not
valid. So I keep another variable to replace mills() function. For each WDT interrupt, it increase the variable value. The increment value depends on the WDT interval
settings and the chip's oscillator. When using 1 second WDT interrupt, my chip's calibrated increment value is 998 (around 1000 milliseconds).
And also I have added the readVcc() function for monitoring the battery status.
Ref.:
readVcc: http://www.re-innovation.co.uk/web12/index.php/en...
http://www.instructables.com/id/ATtiny-Watch-Core/
File Downloads
WDT_Time.cpp (9 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'WDT_Time.cpp']
WDT_Time.h (7 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'WDT_Time.h']
Step 4: I2C Display
The code is reference from DigisparkOLED, but since its example code complied size is over 6K, the complete example cannot put on their ATtiny85 product, Digispark.
(it require to comment out the bitmap code) The complete example can only run on their another product, Digispark Pro.
Ref.:
DigisparkOLED: https://github.com/digistump/DigistumpArduino/tre...
File Downloads
ssd1306.cpp (5 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'ssd1306.cpp']
ssd1306.h (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'ssd1306.h']
http://www.instructables.com/id/ATtiny-Watch-Core/
Step 5: Custom Font
8K flash has no enough room to store all characters in large font size. (such as 24 pixels font height)
As watch only require 10 digital characters, we only need to tailor-make a selected font type binary to make it.
http://www.imagemagick.org/script/index.php
I need 2 font sizes, one with font height 8 pixels to show date digits and one with font height 24 pixels to show time digits:
convert -depth 1 -font Lucida-Sans-Unicode -pointsize 11 label:00123456789 -crop 70x8+7+4 -flip -rotate 90 watch_digit.xbm
convert -depth 1 -font Cooper-Black -pointsize 25 label:00123456789 -crop 150x24+14+4 -flip -rotate 90 watch_3x_digit.xbm
Lucida-Sans-Unicode and Cooper-Black are the font type in Windows 7, you may use your selected font type in your OS.
The corp, flip and rotate option help to adjust the binary data in correct position and direction.
#define FONTWIDTH 7
#define FONT3XWIDTH 15
File Downloads
watchdigit.h (3 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'watchdigit.h']
Step 6: Program
I am using littlewire something like that:
https://digistump.com/wiki/digispark/tutorials/pro...
File Downloads
attiny85watch.ino (3 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'attiny85watch.ino']
http://www.instructables.com/id/ATtiny-Watch-Core/
Step 7: User Input
Set button: select adjust field, the field will highlighted
Step 8: Calibration
Press Up button when not select any field will enter debug screen.
The first number is WDT interrupt count, this value can be used to calculate the value of millis per interrupt.
The second number is current battery voltage in millivolt. It also require calibrate with multimeter.
http://www.instructables.com/id/ATtiny-Watch-Core/
Step 9: What's Next?
Related Instructables
Advertisements
Comments
2 comments Add Comment
http://www.instructables.com/id/ATtiny-Watch-Core/