A picture of me.

Tom Hodson

Maker, Baker Programmer Reformed Physicist RSE@ECMWF


Sensor Watch

A while ago I backed a crowdsupply project called Sensor Watch. It’s a replacement logic board for those classic Casio watches that you probably don’t know the name of but have certainly seen around. This post goes through the process of getting the board swapped out and programming custom firmware on it. I also went opted for the temperature sensor addon board.

A photo of a slightly scratched Casio A164W stainless steel wristwatch
I got this Casio A164W off ebay, it's not quite the classic F-91W model but they all use the same 593 module internally and the sensor watch board replaces that module.

The watch firmware

There is a firmware called Movement that already supports most of the things you probably want a watch to do, uses very little power and exposes a nice interface for writing extensions.

To compile it you need the the ARMmbed toolchain and if you want to test the firmware in a javascript simulator (you do!) then you also need emscriptem:

 1# first make sure you've activated emscripten
 2# in the current shell, see emscripten docs
 3# for me this means running
 4source ~/git/emsdk/emsdk_env.sh
 5cd ~/git/Sensor-Watch/movement/make
 6
 7# emmake takes a normal makefile for a C project
 8# and compiles it to JS instead
 9emmake make 
10
11# Serve watch.html locally
12python3 -m http.server 8000 -d build

The simulator itself is an adapted version of this lovely simulation of the original watch firmware for the sensorwatch project. The contents of watch.html is basically an svg of the watchface, some glue code and the watch firmware in watch.wasm. I factored out the inline svg and glue code to end up with a snippet that I could embed in this page:

 1<figure>
 2{% include watch.svg %}
 3<!-- change display from none to inline to see the debug output -->
 4<textarea id="output" rows="8" style="width: 100%; display: none;"></textarea>
 5<figcaption>
 6Click the buttons to interact with my watch firmware!
 7</figcaption>
 8</figure>
 9<script async type="text/javascript" src="/assets/blog/SensorWatch/emulator.js"></script>
10<script async type="text/javascript" src="/assets/blog/SensorWatch/watch.js"></script>

Which I can update by re-running emmake and copying over watch.js and watch.wasm:

1 emmake make && \
2 cp ./build/watch.wasm ./build/watch.js  ~/git/tomhodson.github.com/assets/blog/SensorWatch
Click the buttons to interact with my custom watch firmware! The mode button (bottom left) cycles though different watch faces, the right button is the primary mode of interaction but the light button can also provide additional options.

Customising the firmware

I noticed that there wasn’t support for simulating the bicolor red/green led on the sensorwatch board so I made a quick PR to fix that. Next I want to try adding my own new watch face.

Doing the board swap

I have yet to do this!