Tiny Watch

 

TinyWatch


Objective: Make a digital watch from the ATTiny85 8-bit Microcontroller.

The ATTiny85 is a small and versatile microcontroller that I’ve been using for almost 2 years. In that time I have worked on many projects, from small quick inventions to complex builds like “The Lawn Mower”, a mini car that’s controlled via Bluetooth. The fun for me is being able to see what i can do with the small amount of memory that the ATTiny85 has available.

 

The ATTiny85 is a high-performance, very low-power, Atmel 8bit AVR microcontroller that 8KB ISP flash memory, 512Bytes of EEPROM, 512-Byte SRAM, as well as 6 I/O pins. In addition to that there are also 32 general purpose registers that the programmer can use for all kinds of tasks. There are internal and external interrups, a 4-channel 10-bit analog to digital converter, with operation at up to 20MHz between 2.5-5.5 volts.To sum that all up the ATTiny85 is a power house packed into a small profile about the size of a finger nail.


                                                                                * Image property of: https://www.sparkfun.com


My next project was a radical idea I had when I saw a class mate unveil his Arduino Mini based smart watch. It was a small and sleek smart watch that had a few neat functionalities like custom API, RTC, and a flash light. I liked the idea so much in fact that I decided to give it a go at making my own smart watch, but instead of using an Arduino I would use none other than the ATTiny85. So I got to brainstorming, I started asking what I wanted the watch to do, what kind of features it would have, and how to go about implementing those features such as

 

IMG_20150719_171431

  • Tell the time
  • Tell the temperature
  • Have Bluetooth Capabilities
  • Receive data from phone
  • Small enough to wear
  • Stylish

What I was able to come up with after about 2 months of research and development, and some odd hours sitting in front of a computer programming, was this ugly duckling here. Without much of the development going into the “Style” of the device I was able to focus mostly on the practical aspects of the build and was able to fit it with as many sensors as I could come up with.


The Hardware

People who are really serious about software should make their own hardware.” –  Alan Kay

This quote has been very inspirational for me over the past few years, it has guided me during rough patches of development and help me innovate some aspects of my builds. Sometimes existing hardware is not enough to make an idea come through. This is specially true for most of the consumer electronics market, which needs to be constantly adapting and changing to stay on top. For this build the tiny watch consists of the following components, all of these components were foreign to me before this build.

hardware-components1

 

The OLED

The 0.96” I2C OLED works great for this  of project, as it does not consume a lot of power; it is very bright and bright, crispy, and small enough to be used for a wearable. The awesome thing is that because it uses the I2C bus protocol I only have to use two of the 5 available pins on the ATTiny85. Also because with I2C you can have many devices connected over the same pins I was able to also connect the DS3231 RTC module alongside the OLED (More on this later on). The OLED consumes about 0.04W of power during normal operation and used a wide range of supply voltage from 3.3V-5V DC which made it ideal as I did not have to do add more components to regulate the voltage.

 

The RTC Module

RTC

The original plan with time keeping was to have the time be sent via Bluetooth from the host phone. I would then convert the data from a single string to individual letters and number that would then be stored for computing. To keep the current time I would have to keep a counter going on at all times, adding to the obtained time from the phone. While this idea wasn’t too far fetch I ended up buying three different RTC modules to test for the project.

The first one I tested was the DS1307 which is a bit less accurate than the DS3231 RTC but it also had a AT24C32 a memory chip with 32 Kilobytes of storage. This was great but I wanted something more accurate so I found the DS3231 RTC module that also had the same memory chip with 32 Kilobytes of storage. This was really exciting, I was thinking of all of the functionality I would be able to add to this device now that I had about 40 Kilobytes of total storage including the one from the ATTiny85.

IMG_20150807_150526.jpgIn the end I decided against the two modules with the added storage space, not because they weren’t good but because I felt like the final build would not be considered a legit ATTiny85 digital watch with all of that added storage. The defining reason why I chose the custom DS3231 module was because of its size, the custom DS3231 module is literally 4 times smaller than the DS1307 module.

This picture on the left shows a size comparison of the three modules. As you can see the custom module that made it onto the TinyWatch is significantly much smaller than the other two RTC modules on the right.

Navigation Switch

The three way switch I used for this build is really remarkable; it has one axis with left and right, and a middle click for selecting menu items. It was also thin enough to sit directly on the LIPO battery charger without causing any problems. Before I had this navigation switch however I was using three tactile switches, each had its own pin on the ATTiny85. This was not an issue as I was only testing the menu systems without any of the sensors attached. What I quickly realized was that I needed to decrease the amount of buttons I was using because I would not have enough pins to attach the Bluetooth, OLED, and RTC too.

After doing some research and banging my head against my desk for 2 days; I implemented a way to have as many buttons as I needed from only one pin on the microcontroller. While I was able to find ways of doing it online I needed a solution that would implement button denouncing in the mix as well, as I was getting way to many inputs from a single button click. The article I read online said that I could do this using different resistor values for each button, when a button is pressed the microcontroller reads the analog value of that resistor and decides what that value represents.

 

Navigation Switch Diagram

3-Way navigation button diagram.

Navigation switch

Navigation switch on ATTiny85

 

 

 

 

 

 

 

 

 

 

 

 

You can see how these inputs are configured on the left image above. Each output from the navigation switch has a different value resistor attached to it. Make sure that the difference in the values of the resistor is significant enough so that they ATTiny85 wont have problems detecting the right input. There is also a 100K pull up resistor attached to the three inputs coming from the navigation switch as well as 3.3V, this is so that we don’t get any false readings when we aren’t actually using the navigation switch.

 

LIPO battery and charger

The 3.7 V LIPO battery is soldered on to the output from the LIPO charger, the main power is also connected to both the battery and charger, so that if the battery is dead you can still use the watch when the power is connected to the charger. This charger has some neat features like automatic shut off once the battery is full, and LED notification for when the battery is fully charged.

LIPO battery and charger

LIPO battery Charging

 

 

 

 

 

 

 

 

The LIPO charger is hot glued onto the LIPO battery itself as well as the leads are soldered in place. When the battery is charging; the LED on the module glows Blue, once it reaches full capacity it changes to Red. Also notice that the display still works while the charging cable is connected. This device also has a long standby time as it does not draw a lot of power while it is being used, and because this is a 650mAh it can go a long time without charging.

 

Programming Pins

I wanted the TinyWatch to be re programmable so I added header pins to the side of the watch that are connected to gnd, vcc, pins 0, 1, 2, and 4 on the ATTiny85. There is a  power switch on the device which has two functions. Firstly it turns the device On/Off, and secondly while the device is off the connection from the battery is disconnected from the rest of the component, allowing power only to come from the header pins thus. This prevents any interruptions from the different modules while the device is being programmed.

IMG_20150719_171720.jpg These are the programming pins on the left side of the device, from left to right they are ground, pins 10, 13, 12, 11, and vcc. These pin numbers are coming from the Arduino uno board, as it is what I used to program the ATTiny85.

 

 

TinyWatch Circuit Diagram

Circuit Diagram.png

This is the circuit diagram and you can see all of the connections for all of the components. Notice how the Oled and the RTC module are both connected to the same pins. This is because they use the i2C bus to communicate.

 

What I learned

i2c is my friend.

The guys at DLNWare have a great explenation for the i2C bus, head over to their website here to read up on this protocol. I learned a lot from them. Basically in I2C you have a master and slave relationship between the microcontroller and the components. The microcontroller being the master, dishing out commands and receiving data, and the slaves being the components dishing out data. As they are all connected to the same lines you have to talk to them in the software through unique addresses that only the particular component you want to talk to can understand.

 

ADC are amazing

ADC (Analog to Digital Converter) are really cool to use in all kinds of projects specially in this one, as it allowed me to do something was would not have been possible without it. An analog to digital converter does exatly that converts an analog signal into a digital signal. In our case the analog signal was the voltage being produced when a button was pressed on the navigation switch. The voltage divider circuit made sure that we had a different voltage being read by the microcontroller, this allowed the internal ADC to distinguish between the signals and assign an individual action to each one. learn more about ADC’s here.

 

I know it’s a long post but I left many things out, if you have any questions don’t hesitate to ask me.