Skip to content(if available)orjump to list(if available)

Building a T1D smartwatch for my son from scratch

coder543

Wow! This is some phenomenal engineering!

> Another area that stumped me is how to shut the power off 100% on the device, so that it can remain “off” for weeks or months.

This is actually a pretty solvable problem...

https://circuitcellar.com/resources/quickbits/soft-latching-...

Then the microcontroller can choose at any time to completely shut off the entire circuit (including itself), and extremely little power will be consumed until something (like a button) completes the power-on circuit again.

For ease of prototyping, there are off-the-shelf units you can play with: https://www.sparkfun.com/sparkfun-soft-power-switch-jst-2mm....

Some more advanced soft power switch circuits (like the SparkFun switch) also include the ability to forcibly power down a misbehaving device by holding down the button.

The design used in the SparkFun switch also allows your microcontroller to know if the button is pushed while the device is running, so you could imagine repurposing your existing button to also restore power to the device if the device is off, and still retain the existing functionality for cycling through watch faces. Then, either the device could automatically shut itself off after a period of inactivity or when the battery gets too low, or the user could click and hold the button for some number of seconds to turn the device off completely that way.

andrewchilds

This is exactly what I was looking for! I had a foggy idea of using a MOSFET and the button to close/open the circuit but I needed something like this to show how it all fits together. Thank you!

coder543

No problem. I haven’t had a chance to do anything hardware related for a long time, so it’s fun to think about hardware problems again.

On the topic of extending battery life mentioned in the article, one relatively straightforward thing to investigate is simply reducing the processor clock speed. Your application probably doesn’t need to run at full tilt. I think there is a function called setCpuFrequencyMhz — I think it only works with a few specific frequencies, but the lower the frequency you can pick (while still keeping up with your application’s needs), the less power the system should consume while awake.

Of course, you want to be putting the processor to sleep between updates anyways, and there is a trade off between sleeping more (which means running the processor faster so it can sleep sooner, “race to sleep”), versus the inefficiency caused by running a processor higher on the frequency/efficiency curve, so there might be an optimal frequency that isn’t the lowest or the highest possible option. It’s something that would need to be measured.

Just some thoughts! It might not make a big difference if the processor is already sleeping most of the time, but I figured I would mention it as something to try.

bbayer

Another alternative is to use ESP32's deep sleep mode. You can tell ESP to sleep until some event occurs. There are many options for waking up the microcontroller.

https://docs.espressif.com/projects/esp-idf/en/stable/esp32c...

It uses little power, so standard 18650 battery could last years with single charge.

https://www.programmingelectronics.com/esp32-deep-sleep-mode

andrewchilds

The ESP32-S3 spends most of its time in deep sleep, only waking up for about 5-10 seconds every 5 minutes. The problem I ran into was that not just the ESP32-S3, every component on the board (the accelerometer, the haptic motor driver, the LiPo battery charger, the 3v3 LDO) has a some constant, minimum (quiescent) current draw. And even how your resistors are configured (pullup or pulldown) and their resistance values contributes. To diagnose it, I would need a precision measurement tool like a ($1k) Joulescope https://www.joulescope.com/products/js220-joulescope-precisi... and probably a significant amount of time.

pipe01

I recommend the [nRF PPK II](https://www.nordicsemi.com/Products/Development-hardware/Pow...), it's (relatively) affordable and most likely would dl the job just fine for you

davidhyde

I have also recently been through the same steep learning curve you have and the following worked for me. Reading spec sheets is fine but nothing beats measurement if its feasible. I built a custom PCB with all the power pins for all the peripherals broken out so I could put an ammeter in series with each of them individually. Then I used Nordic's inexpensive power profiler kit 2 (search for Nordic PPK2 - its under $100). Really decent specs at 100kHz sampling rate and 100nA resolution - you connect it to a PC to see the charts. I also bought my own resin 3D printer. They are so cheap these days and it helped with iterating on designs and not having to wait days for things to arrive. PS, great post, loved it.

msandford

I had this problem on a low power design. We were making an industrial temperature sensor for something that moved and we needed to run on battery.

What I ended up doing was using a second voltage regulator with an enable pin for all the accessories. When the MCU wakes up it turns power on to the accessories and waits for things to stabilize, maybe 1ms or so. Then it does what it needs to do and before going back to sleep turns all the accessories back off.

Costs you a few extra parts and a second voltage bus and the hassle of programming but it turns "small quiescent draw" into essentially zero. Maybe the regulator has a bit of leak but it should be pico amps or less.

adrianlv512

Here's a nice write-up where power consumption is measured using a voltmeter: https://peppe8o.com/raspberry-pi-pico-w-power-consumption/

awjlogan

Wait until you look at the leakage current of capacitors..! Very poorly specified, if at all, and can actually swamp the consumption of active components in these low or sub-microamp situations. The dual voltage rail that msanford described is the way to go here, gate as much as you possibly can and really focus on reducing the duty cycle.

awjlogan

ESP's deep sleep is not great - the datasheet for the C3 says 5 uA. That's an order of magnitude above low power microcontrollers (e.g. ATSAML), and two orders of magnitude above an ultra low power timer. Not horrendous, but higher than I'd prefer for a tiny watch battery.

wanderingmoose

First of all -- awesome!

Second, if you aren't aware or in case others are interested, the main dev from the xdrip project released a custom watch as well: https://bluejay.website/ There are some posts on reddit from the dev. (for others -- the watch is available for purchase, and allows integration w/ xdrip).

Third --> we've come a long way in a short time. When I was diagnosed I had to collect urine samples and drop chemical tablets in them to see how much glucose was present. And now you are building an custom solution tailored to your and your son's needs...wow. I really applaud you.

Fourth --> I'm hoping the new discoveries in the synthetic signaling w/ insulin will finally give us a biological solution and the tech will no longer be necessary. Here's to hoping!

andrewchilds

Yes! The BlueJay watch project is amazing, very encouraging to see that he was able to connect directly to the sensor from the watch with the latest version. Totally agree with you - one of the biggest sources of hope for us in those first few weeks after he was diagnosed was knowing how far the tech had come, and how many huge advancements were in the pipeline.

mattboyle

This is really really awesome. I applaud you.

I had my own project trying to achieve a similar outcome to you, I wrote about it here: https://www.bytesizego.com/blog/keeping-alive-with-go. Your approach is much more hardcore. I hope you find a path to make them available to more folks.

If there is anything I can do to assist you please let me know!

andrewchilds

Thank you! I remember reading your article! Even though you have to maintain it, it’s actually way better than what’s commercially available since you actually have control over _how_ you’re alerted, not to mention when to escalate to friends or family. I’ve heard Type 1 kids going away to college is a huge source of stress for parents/caregivers for this reason - Sugarmate and the SugerPixel help with this but it still feels like a huge problem (a Type 1 sleeping through a low).

qq66

And to think, you could have done this in software if you had the right to push your own firmware to your Apple Watch.

summermusic

> I learned that One Does Not Simply put glass in front of a TFT display. It will look like a first-generation, low-budget Android phone if you do.

Do you happen to have any before-and-after photos of what this looked like, and more details on how your tortilla press DIY method works? I recently received a little hackable music player device with a TFT display that looks kind of bad and I wonder if this is something I can do to make the display look good.

andrewchilds

The process was applying steady pressure to the TFT display -> OCA film -> glass, sandwiched between soft rubber, for about a minute. However you need to do a decent job applying the OCA film in the first place - there are youtube videos that show how to do it.

I probably wouldn't recommend what I did in your case - it's easy to go too far and break the glass, and I'm not sure if what's wrong in your case is due to the OCA film in between the display and the glass.

antonok

FWIW, there is an alternative to OCA film that's slightly easier to apply in small quantities without specialized hardware - it's called LOCA glue (i.e. Liquid OCA).

I'd definitely recommend that if you're just assembling less than, say, 10 screens.

DoingIsLearning

Hi Andrew, amazing work and done for the best of reasons!

I see you are replying in the thread, in your closing notes you wrote:

> I would not have been able to get past the initial stages without ChatGPT.

One of the coolest uses of LLMs for me is indeed exploring a problem domain where I am not a subject matter expert.

The problem is if it leads you down a dead end or hallucinates a solution. Then, at the edge of your knowledge, you actually have a very small foothold with which to challenge these chat replies.

Did you also face this on the more HW 'heavy' part of your project? Any tips on how to navigate terra incognita with LLMs?

andrewchilds

Lots of trial and error! ChatGPT was sometimes helpful with hardware and electrical engineering questions, sometimes not. Since I would need to wait a while for the next version of the PCB to show up, it was important to check and verify things, but it did help me find my bearings and develop a general understanding of concepts. I learned a lot from open-source reference implementations from similar projects. I was able to get a lot of help while learning the software as well - in this case Fusion 360 and KiCad - though sometimes ChatGPT would invent a setting that should be there but isn't. As long as you have a rapid feedback loop where you're testing and verifying what it's telling you, I don't think you'll ever find yourself very far off course.

wnolens

> I didn’t have an OCA laminator, but you know what I did have? A cast-iron tortilla press.

Haha. Great read. And aesthetically it's sweet as well. I wish your son accurately tracked and lasting health. He has an amazing dad to lean on!

K0balt

Great project!

Idk if this might be useful or not, but there is a smartwatch platform (bangle.js 2) that uses the NRF52840 chip (extremely low power, solid BLE support, works with Espruino, micro python, arduino, and other IDEs) battery life is around a week, depending on what you run, of course.

The watch includes an always-on color transflective display, GPS, accelerometer , barometer, haptic motor, compass, sound, touchscreen, etc.

You could do firmware from scratch or you could use the onboard OS and write the program as an App.

The watch isn’t distracting, unless you install stuff on it to be distracting. I think your program might be able to be written as a “watch face” so that it would not have to be launched from the launcher, but you could also write firmware for the watch so that it just does what it does period.

It seems to me like this does everything you want, maybe?

I bought a couple of these (2?) years ago for my kids to program on, they have been great!

https://banglejs.com/

andrewchilds

Thank you! I did actually buy a Bangle 2 early on in the project; I was impressed by the Espruino project and by how small the watch is, but it seemed slow to wake, and the screen was tiny, dim and had a lot of light bleed. But you’re making me think I should take another look. Very cool that your kids are programming their own watches!

K0balt

Yeah, the transflective display is not great, but the power usage is nil when the backlight is off, which is nice. E-ink might be even nicer.. but the price is a major stumbling block for most form factors.

The pebble might be a good option though, not only is the os now open sourced but there is apparently someone trying to build new watches.

Once you get out of the hobby space, Hardware is a tough business, and there are a lot of people that would benefit from a solid solution that won’t be up for tinkering.

You might also find that there are Chinese manufacturers with white-box watches that might be running common chips like the nrf52840/832. I certainly see a lot of apparently identical smartwatches around 30 dollars that are marketed under different brands. Those might be a better direction if you are looking at a broad market.

OTOH, once you get away from the supportive and nurturing maker environment most of the fun will leak out, so depending on your motives, you might want to stick to your solution - which looks pretty great to me, even if it might not be as simple to scale production.

Best of luck with whatever direction you are looking at. By the way, you might try a resin printer if you are going to be doing any production in house. For larger multiples of small parts they are crazy fast and the finish is pretty great.

andrewchilds

Thanks! Yeah, it's odd to me that there are so many cheap Apple Watch clones on Aliexpress with nice AMOLED displays and sensors galore, but nothing hackable, nothing with an e-paper/MIP display. I feel like they would make way more $$ if they made one that was hackable? Lilygo.cc has done a lot of work on open hackable watches, but they're big and not water-resistant.

hommelix

Another interesting watch is zswatch. It uses a nrf mcu as well. https://github.com/jakkra/ZSWatch

https://www.youtube.com/watch?v=MmCzV0jV9hs

K0balt

This looks awesome!

bdcravens

This is great. I do watch my Dexcom on my Apple Watch, but there's times I just want the number, ASAP. I was hoping it'd talk about eliminating the need for the iOS app ("...where he shouldn’t have to run around with a phone strapped to him...") but it sounds like it's just not possible to avoid at least periodic polling.

Reading through the product development, I'm curious why you didn't use a dev kit like the Pine Time? (https://pine64.org/devices/pinetime/) I bought one a few years ago and it's just been sitting in the box, waiting for a project to build on it. I may take a stab at something similar.

nknealk

The G7 pairs directly with an Apple Watch and acts as the primary sync device. Unlike the G6, you don’t get null readings displaying on the watch until you open the app. I have the dexcom widget on my Apple Watch series 10 with a G7 paired with direct to watch and it always displays the current reading

andrewchilds

That's great to hear that direct-to-watch pairing leads to a reliable reading. That's a big improvement over where things were a year ago. I am surprised that the watch becomes the primary sync device instead of the phone, but maybe that's not actually a problem in most situations.

bdcravens

I wore the G7 briefly, but switched back to the G6 because the long-awaited iOS integration for my pump (Omnipod) only supports the G6 at this time. (otherwise I have to carry around a separate device, which is essentially a dumbed down Android phone)

andrewchilds

Thank you! It should be possible now with the G7 to have the watch pair directly with the sensor. We’re still on the G6. Agreed that would be much better than having to go through the iOS app and up to the cloud.

Honestly I don’t remember why I ruled out the PineTime. I purchased a Bangle.js and while it’s very small, it seemed very limited in what I could do with it. Of course with the Pebble announcement yesterday, that might change things.

roywashere

PineTime is nice and cheap and does a little BlueTooth. It's easy to flash your own firmware to it; I think it might have been an option.

That said, Pine64 does not do a whole lot of work on their platform and I guess a lot of people are wanting _more_. It's a simple watch and for what it does and costs it's great. If you think you'll get an open source Apple Watch, you're going to be disappointed.

martyz

Incredible work - so cool to see Dad being a tech and health champion for their kid. T1D is so tough and to have such incredible support is great to see.

bluesounddirect

Andrew : Amazing i always love to see the creative T1D projects. i home one day we have a biological cure . Back when the pebble watch was still a relatively new product. someone had an app for it to be a remote display for the dexcom. it required an external nodemcu based microcontroller to be a middleman, but what it did well was run for days off the battery. my wife used one for a long while; the take aways were black and white e-ink displays saved tons of power . pebbles os was good a power mgmt and it's limited features made devs stick yo core functionality not look for new cool extraneous add ons .

nonplus

This is a really cool project. Your post is the first time I am seeing the figures on how much others also hate CGM notifications.

I have been working on software for the G1 headset to display glucose data without any audible alarms, just a visual notification.

The issues I run into are:

* Dexcom sensors have limited Bluetooth connections (with pump support), so I need to pull data from a phone.

* Battery life (I can get 9 hours maybe with a not always on display, a far cry from 6 days).

* xDrip gets readings slower than directly from dexcom.

* General UI edge cases for missed readings.

Thank you for sharing your work, it's validation that others are experiencing this problem and maybe my visual solution will be useful to others (and a watch/audible/haptic device also might be a good complement to what I have now, my solution is not supposed to be the only way to get CGM data.) https://github.com/ltomes/rel-a/tree/feature/xDrip