Close

Firmware/Software update

A project log for Custom Smartwatch

An ESP32 Based Open-Source Smartwatch

Matthew James BellafaireMatthew James Bellafaire 07/01/2020 at 03:290 Comments

In the last log the watch had only basic watch functionality and couldn’t do much outside of telling the time and reading its own battery state. In the last few weeks the functionality has grown to encompass more of what would be expected from a basic smart watch.

Most of the time I’ve spent on this project in the last two weeks has been focused on getting an android app to work with the watch. Until now I’ve never written an android app, although I have a lot of java experience, I found android to be much more of a beast than originally expected. Most of the code that’s used in this project comes from open-source projects or stack overflow posts. Data is communicated between the watch and my phone over a standard Bluetooth serial connection using a library by harry1453 (https://github.com/harry1453/android-bluetooth-serial) which massively simplifies the Bluetooth code. In order to actually get the notifications themselves I modified an example by kpbird which can be found at: https://github.com/kpbird/NotificationListenerService-Example/.

I ended up writing the app twice just to clean up the code once I had something that kind of worked. For all the effort the app in all its glory looks like:

The app attempts to send data to the ESP32 smartwatch about every 15 seconds over a standard bluetooth serial connection. When it connects it sends across the string that is shown in the middle of the app window. Using this approach is less than ideal but in practice it’s not too bad. Even though the app runs constantly in the background and is constantly trying to send data it appears to only have a negligable power useage according to my phone’s battery monitor. With all that said I’m still planning to rewrite the app to operate more efficently or switch to BLE. I’m open to suggestions on how to use the bluetooth functionality here, I’m new to android and there’s a lot that I still don’t know about.

With the app out of the way lets move onto the updates to the firmware that have been made recently. A major improvement to the watch was a software switch away from drawing individual pixels on the screen directly. I stumbled across the GFXcanvas16 class in the adafruit GFX library (this is the only real documentation I can find on it http://adafruit.github.io/Adafruit-GFX-Library/html/class_g_f_xcanvas16.html). Using the GFXcanvas16 the code can now buffer the image before displaying anything, this cleaned up some flickering that would occur from updating and allowed me to make the UI a bit more lively. Notifications received by the watch are partially displayed on the home screen (app name only) and in the notification menu accessible by the bell icon. The notification window allows all the received data to be viewed in one place for any notification. I put together another short video demonstration of the watch in operation, a picture’s worth a thousand words so here’s 30,000 words per second.

Under the hood the watch opens its Bluetooth serial port every 120 seconds of deep sleep and waits for a connection for a maximum of 10 seconds, when the notifications are received the string is stashed in the RTC ram and the esp32 goes back to sleep. So far this approach doesn’t seem to cause a significant power drain on the watch (maybe 15% every 8 hours?). I haven’t yet been able to give the battery a proper test since I’ve written code to the watch almost everyday giving it time to charge up.

With all that said the project is coming along nicely and I hope to see you in the next log!

Discussions