I have always been into watches. Back before smart watches. I wanted to make a watch that worked more like the older digital watches but could also use all the features this device has to offer.
I am just a self taught hobyist and do this for fun and education. The code I am posting today is actually a third version. The first version set the time with the compile time and ran all the time. It lasted about an hour before the battery died. I also noticed that upon powering the device back up from a dead state the time reverted to the previously set time. The second version adderssed these two problems. I did a bit of reading and toying with code and found a sleep solution so as to conserve more battery. At this point it was only just a watch. The watch would sleep after about 10 seconds and to wake it you just push the home button. That helped the battery life greatly. I could wear it a full workday before it needed a charge. Next I decided to set the time using wifi and an ntp server. This way if I was in range of my wifi when it boots it will set the time if not it will use the current running system time.
Version 2 worked nice but I still wanted to use it for more than just a watch without having to flash new code on it each time. That and the sleep function needed reworked. Since the device had buttons I wanted to use those buttons the way you would on an old digital watch. In version 3 I had to completely rework things but it turned out well. Now I set it up as something of a state machine. It starts as a watch and runs until you either push the home (mode) button to switch its mode or push the reset (sleep) button and it goes to sleep. Right Now the only other mode is to use the ENV hat. If you press the mode button (might have to hold it for half a second, still working on timing) it will load a temp, humidity, and pressure screen. If it dosent find the sensor it will return to the time screen but if a sensor is found it will display the readings every second. I plan to add more modes and possibly a menu for choosing. Also I found that usin wifi to set the time has its drawbacks as well so I also plan on changing this to bluetooth as my phone is usually close by but my wifi connection isnt always. This would also enable notifications.
It is a work in progress but something I wanted to share.
*As a side note The arduino ide had a hard time finding the "DHT12.h" so i moved this file and "DHT12.cpp" to my project folder from the the example folder for the ENV hat.
Comments