Step 1: Preparation
Today core subject, ATtiny85. Someone suggest me to use SOIC version to reduce the watch size and I found the coin cell mAh calculation method will count the battery voltage down to 2.0 V, so this watch require a low voltage version MCU to keep it stable. So I have ordered an ATTINY85V-10SU. (much expensive $_$)
Any ISP that can program ATtiny85, this time I am using a Digispark act as a littleWire. (http://digistump.com/board/index.php/topic,160.0.h...)
In order to meet the ring size, I choose CR1220, I expect it can last over half an year.
(Quote from previous project) 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 4 different sizes, 64x32 is the smallest one. (another sizes are 128x64, 128x32 and 64x48)
(Quote from previous project) It should be more stylish if make it by wood, but I am lazy one, so just print it out.
(Quote from previous project) A small piece of transparent PET plastic plate. It is transparent, provide enough support and very easy to get from many product packing.
- A SOIC ISP clip for program ATTINY85V-10SU
- 3 pieces of M2 screws
- 3 buttons
- 2 various resistors (more than 1k)
- coated copper wires
- thin mental plate for making a tailor-made battery holder
- a SOP8 to DIP8 board
- a little piece of multipurpose PC board for building button panel
Step 2: Setup Arduino With ATtiny85, EEPROM and TinyWireM Support
Download Arduino 1.6.5 (1.6.6/7 have known compatible issue - "contains deprecated recipe.ar.pattern")
Download ArduinoTiny (if you not familiar with GitHub, simply click Download ZIP button)
Run Windows installer / copy to Applications folder / simply unzip the file
Locate the Arduino path
If you install with Windows install, it should be:
If you are using OSX, it should be:
Or any path you unzipped to.
Add ArduinoTiny Support
- Unzip ArduinoTiny-master.zip
- Copy tiny folder to the hardware folder under Arduino path
Add EEPROM support
In Arduino path, copy hardware\arduino\avr\libraries\EEPROM\EEPROM.h to hardware\tiny\avr\cores\tiny folder.
Install TinyWireM Library
- Run Arduino
- Select Sketch Menu -> Include Library sub-menu -> Manage Libraries...
- Search TinyWireM
- Select TinyWireM and click Install button
- Close Library Manager and close Arduino
TinyWireM have an know issue but not yet fixed, you can fix it easily:
- Locate TinyWireM library path (Windows: "My Documents\Arduino\libraries\TinyWireM"; OSX: "~/Documents/Arduino/libraries/TinyWireM")
- Modify "TinyWireM.cpp" line 53, save and close the file
if (USI_BufIdx >= USI_BUF_SIZE) return 0; // dont blow out the buffer
if (USI_BufIdx >= USI_BUF_SIZE - 1) return 0; // dont blow out the buffer
Step 3: Download Latest Source Code
Download the latest source code here:
If you are not familiar with GitHub, simply press Download ZIP button.
You may find further details in the following materials:
- time function v1.4: https://github.com/PaulStoffregen/Time
- WDT and power related: http://www.re-innovation.co.uk/web12/index.php/en...
- DigisparkOLED: https://github.com/digistump/DigistumpArduino/tre...
- SSD1306 data sheet: https://www.adafruit.com/datasheets/SSD1306.pdf
Step 4: Create Watch Body
Say it again, it should be more stylish if make it by wood, but I am lazy one, so just print it out.
Attached the Sketchup and STL file for reference.
Step 5: Solder MCU
This step is not essential, but it can make further solder work and reprogram easily.
Solder SMD reference:
Step 6: Create Tailor-made Button Board
In previous project, I use 2 pins to handle 2 buttons input. It is too expensive for using an ATtiny85 IO pin for each input button. This time I try to use 1 IO pin to handle 3 buttons input.
Here is my setting:
set button - GND -> button -> PIN 2 (PB3, ADC3)
up button - GND -> 6.8k resistor -> button -> PIN 2
down button -> GND -> 68k resistor -> button -> PIN 2
Various resistors value should be ok, over 1k is recommended. 3 buttons have different resistor values, so it can use analogRead() function to distinguish which button pressed. I have measured some common resistor analog value for reference.
You may change the threshold value in ATtinyWatch.ino file if you use different resistor.
#define SET_UP_BUTTON_THRESHOLD 100
#define UP_DOWN_BUTTON_THRESHOLD 600
Step 7: Solder Circult
Since the ring watch have a curved surface, it cannot solder all component on a single PC board. MCU, OLED, button panel and battery holder all connected by coated copper wire. VCC and GND coated copper wire should around 6-8 cm and require remove the coating at the middle connect point by sand paper. Other wires are a little bit shorter.
Here is the connection summary:
Pin 2: Button Panel
Pin 4: OLED GND -> Button Panel ->Battery Holder
Pin 5: OLED SDA
Pin 7: OLED SCL
Pin 8: OLED VCC -> Battery Holder
Step 8: Create Tailor-made Battery Holder
The ring is small and it can not fit a normal CR1220 battery holder. So we need some thin mental plate to tailor-made a smaller one. My thin mental plate is re-cycling from Dupont line header wastage, you may find other near you.
Cut a short piece of mental plate and solder to a coated copper wire.
Bent it and slot it to the ring body, do it both at positive and negative terminal.
Slot in the battery and test the connective.
Step 9: Program MCU
- Plug your ISP to the computer
- Run Arduino
- Open ATtinyWatch.ino from unzipped ATtinyWatch folder
- Select Tools menu -> Board sub-menu -> select ATtiny85
- Select Tools menu -> Clock sub-menu -> select 1 MHz (internal oscillator; BOD disabled)
- Select Tools menu -> Programmer sub-menu -> your ISP
- Remove CR1220
- Connect the SOIC ISP clip to ATtiny85 and press Upload button
ISP -> ATtiny85
MISO -> Pin 6
VCC -> Pin 8
SCK -> Pin 7
MOSI -> Pin 5
RESET -> Pin 1
GND -> Pin 4
If you have SSD1306 screen other than 64x32 resolution, you can change resolution define in ssd1306.h
// custom screen resolution by define SCREEN128X64, SCREEN128X32, SCREEN64X48 or SCREED64X32 (default)
#define SCREEN_128X64 //#define SCREEN_128X32 //#define SCREEN_64X48 // not tested //#define SCREEN_64X32
Other program ATtiny85 reference:
Step 10: Debug Screen
Press up or down button while no any date time field selected will enter Debug Screen.
The value means:
Row 1 (I): Watch Dog Timer(WDT) interrupt count, this value will be reset for each set time operation that over 1 hour interval
Row 2 (M): Auto tuned value of micro-second per WDT interrupt, this value will be updated for each set time operation that over 1 hour interval
Row 3 (V): Calibrated value of battery level in millivolt
Row 4 (T): ATtiny85 internal temperature sensor raw value, this value is accumulated last 64 sample values
Step 11: Calibrate Time
Press set button will switch selected Date and time fields, selected field will be highlighted.
Press up and down buttons to change the selected field value. Press set button while highlighting SECOND fields will finished set time operation.
For each set time operation that over 1 hour interval, the micro-second per WDT interrupt value will be auto tuned.
In my experience, holding voltage and temperature condition stable, it should not drift over 1 minute each day after auto tune :P
Step 12: Calibrate Voltage Reference
- Comment the #define lines of DEBUG_SCREEN_V and MULTI_METER_VOLTAGE in WDT_time.h
- Program the watch
- Record the debug screen V reading and multimeter measured voltage
- Uncomment and fill the DEBUG_SCREEN_V and MULTI_METER_VOLTAGE reading value
- Re-program the watch
#define DEBUG_SCREEN_V 4979 // put your screen reading here
#define MULTI_METER_VOLTAGE 4740 // put your multimeter reading here (in millivolt)
Step 13: Calibrate Temperature Reference
- Record the debug screen T reading and real temperature value 2 times in different temperature condition
- Uncomment and fill the DEBUG_SCREEN_T_1, TEMPERATURE_1, DEBUG_SCREEN_T_2 and TEMPERATURE_2 values
- Re-program the watch
#define DEBUG_SCREEN_T_1 21823L #define TEMPERATURE_1 52000L #define DEBUG_SCREEN_T_2 18757L #define TEMPERATURE_2 12000L
Step 14: Assembly
Slot the OLED screen in the pit and place all the component at the right place.
Step 15: Screw Up
Assembly the ring and screw up the M2 screws to the ring body.
Step 16: Transparent Cover
- Cut a 16 mm width and 82 mm long PET transparent plastic plate
- Cut a little bit at 4 corners for easiler slot in
- Stick a 1.5 mm width double sided adhesive tape at 2 borders
- Slot in the transparent cover to the ring body at one side
- Stick the transparent cover to the ring body
- Slot in another side
Other transparent cover reference:
Step 17: Happy Time!
It's time to show what you have done to everyone!
- Slimmer ring body, as many one knows, SOP8 to DIP8 board is optional and the button panel can be smaller by replacing to SMD one
- Add other I2C modules
- Amber sensor to fine tune brighter screen under the sun
Research sync time method, GPS, WiFi + internet, BLE + mobile phone and more
Participated in the
Full Spectrum Laser Contest 2016
fmarkf made it!