Sensor Watch Pro

A more hackable ARM Cortex M0+ brain upgrade for Casio's iconic F-91W

Available for pre-order

View Purchasing Options
Oct 23, 2024

Project update 4 of 5

Sleep Tracking with Sensor Watch Pro and the Accelerometer Add-On

by Joey Castillo

The promise of Sensor Watch has always been the idea of tacking on different kinds of sensors via the nine-pin sensor board connector. Up to now, the only “official” sensor was the temperature sensor. It managed to enable some use cases I expected, like temperature logging, as well as some I didn’t, like the temperature-compensated “finetune” feature that’s pushing Sensor Watch to new levels of accuracy.

With this campaign, we’re shipping a new sensor board — an accelerometer — and I just spent all weekend working on a proof of concept for one use case I expect: sleep and activity tracking.

Still, before talking about what I implemented, let’s talk just a little bit about the accelerometer sensor itself and some of its features.

Accelerometer Sensor Background

The sensor itself is the LIS2DW12 accelerometer from STMicroelectronics and it’s an excellent fit for Sensor Watch. For one thing, it’s extremely versatile and configurable: it offers two interrupt pins that can signal a variety of different conditions, from free-fall and orientation change to motion detection (i.e., the device experiencing an acceleration over a certain threshold).

The other reason I picked it, though, was the big one: power consumption. In its lowest power mode, sampling at about once a second, the LIS2DW12 consumes power on the order of a fraction of a microampere. Since this is a sensor we’re going to want to run all the time, whether the watch itself is awake or asleep, this lowest-power mode is crucial to making the battery last as long as possible.

If you’ve ever used an accelerometer in an Arduino project, you’re probably used to reading in acceleration data and doing some processing on it in your sketch. You’ve probably even seen a plot like this one in the serial plotter:

Actually, this is the same sensor, but ramped up to a sampling rate of 12.5 Hz. In fact, we can dial it up to hundreds of samples per second if we want. Still, streaming this amount of raw data takes power and, in Sensor Watch, we don’t have a lot of that to burn.

Sensor Watch is all about doing more with less, so for this activity tracking proof-of-concept, we’re going to outsource all the data processing to the accelerometer itself. Once it’s done thinking about that raw data, we’re going to get its verdict in the form of two digital signals, producing data that looks more like this:

Two Signals

In the graph above, we’re plotting the state of two digital outputs coming from the sensor board. The blue line represents a pulse we receive when the orientation of the watch changes. The red line is a status signal: it’s high when the watch is still and goes low when motion is detected. Then, after some time without significant motion, it goes high again.

In the video below, I’ve written a watch face that shows three pieces of data:

To help me do a vibe check, I’ve also set the watch up to chirp once when the accelerometer detects motion — when the red line goes low — and to chirp twice when it senses that the motion has stopped.

I got this rudimentary activity tracking watch face done on Saturday, and I’ve been wearing it ever since. As configured, it adds 600 nanoamperes to the Sensor Watch power budget, which is well within range to maintain 1-2 year battery life on a single coin cell. Still, you might be wondering: how much can these two signals really tell us?

Well, immediately after finishing this proof of concept, I crashed, and hard. I fell asleep with Sensor Watch on my wrist and with an Oura sleep tracking ring on my finger. In the morning, I copied down the orientation and activity numbers into my notepad and checked them against the Oura app:

The Oura ring detected me going to sleep around 12:30 AM and waking up around 7:30. Sensor Watch detected five, one, and then zero active minutes in the hours after I crashed, continuing until I neared wakefulness around 7:00 AM.

The Oura also detected a couple of hours of deep sleep between 1:00 and 3:00 AM. Sensor Watch recorded eight orientation changes from 1:00 to 2:00 AM, and none at all between 2:00 and 3:00. It also detected some additional orientation changes throughout the night — tossing and turning — which seem to correspond to the lighter sleep from 3:00 to 7:00 AM.

In other words, with next to no fine tuning, Sensor Watch Pro seems to be able to catch something strongly resembling a sleep trend. Since I’m logging with pen and paper, I put the motion events into segments one hour wide for now, but I get the sense that by narrowing the data into windows of five minutes — or even one — we could start to pinpoint time in bed and time asleep.

More to come

As I mentioned above, this accelerometer is extremely configurable. We can change the angle required to register an orientation change, the acceleration threshold for activity detection, and even the duration of stillness that represents inactivity. I’m also very eager to try out this existing setup not just for sleep tracking, but for activity tracking: walking or jogging with the watch and checking how well my current settings are capturing robust exercise.

But back to the point at the beginning: the temperature sensor opened doors to possibilities for Sensor Watch I had never considered and an accelerometer is a much more powerful sensor than a temperature sensor. Mostly I’m stoked to see what cool uses YOU find for this exciting new addition to the Sensor Watch ecosystem.


Sign up to receive future updates for Sensor Watch Pro.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects