๐Ÿšจ ShakeDetector

A Garmin watch watches for sudden rhythmic shaking of the wrist and tells your phone.

This is a personal, experimental project, not a medical device. The algorithm has not been clinically validated. Do not rely on it to detect a seizure, and do not treat it as a substitute for medical supervision.

How it works

The watch reads its accelerometer 25 times a second and counts how often the movement crosses an amplitude threshold. When enough crossings pile up inside a five-second window, it treats that as shaking: it vibrates, beeps and lights the screen, and posts a short signal to this server. The server then pushes a notification to every browser subscribed to that watch.

Detection happens entirely on the watch, so it keeps working with the phone off, out of range or out of signal โ€” the phone is only a louder speaker. To keep notifications useful rather than noisy, the watch tells the server at most once a minute even while it keeps buzzing on your wrist every few seconds.

Connecting a watch

  1. On the watch: Menu โ†’ Setup link. A six-character code appears.
  2. On your phone, open this-site/s/CODE to reach the setup page.
  3. Press Subscribe to notifications and allow them in the browser.

That is it. From then on the watch sends an alert whenever it triggers.

On iPhone and iPad โ€” add to the Home Screen first

Apple does not allow notifications for sites opened in a Safari tab, so at step 2 the page will ask you to install it as an app:

  1. In Safari, press Share (the square with an arrow).
  2. Choose Add to Home Screen and confirm.
  3. Close Safari and open ShakeDetector from the Home Screen.
  4. The Subscribe button now works โ€” allow notifications.

Requires iOS 16.4 or newer. Always open it from the Home Screen icon afterwards: in a Safari tab, subscribing is unavailable again.

Checking that it works

On the watch: Menu โ†’ Test fires a real alarm and reports whether the signal reached the server. The watch vibrates and a notification arrives on the phone.

Worth knowing

  1. The notification is an ordinary browser one: your phone's silent mode will mute it, and it cannot repeat until acknowledged.
  2. The watch works on its own. If the phone is unreachable, the vibration and tone on your wrist still happen.
  3. The subscription lives in the browser. A different browser, or cleared site data, means subscribing again.
  4. You can subscribe several devices โ€” the alert goes to all of them. Open the same link on another phone and press Subscribe. Turning notifications off on one device leaves the others alone.

Source

Everything is open source โ€” the Connect IQ watch app and this server live in one repository:

github.com/geminixandroid/garmin-shake-detector

Licensed under GPL-3.0-or-later.

If you need something clinically founded rather than a personal experiment, look at OpenSeizureDetector: a separate project that streams the watch's accelerometer to a phone and analyses it there with a proper frequency-domain algorithm.

Bug reports and pull requests are welcome. If you run your own instance, the watch app's server address is a build-time constant in ShakeDetectorPhone.mc.