๐Ÿšจ ShakeDetector

A Garmin watch detects sustained, high-amplitude wrist shaking 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.

โŒš Install on your Garmin watch

How it works

The watch reads its accelerometer 25 times a second and counts how often the movement crosses an amplitude threshold. Two things then have to be true at once: enough of those crossings inside a five-second window, and at least three seconds of them running without a break. The second condition is what separates shaking from a single hard knock, which reaches the count on its own inside one second.

When both hold โ€” roughly three to three and a half seconds after the shaking starts โ€” the watch 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 the wrist every few seconds.

The alarm is aimed at whoever is nearby, not at the person wearing the watch. Someone in the middle of an event cannot act on their own watch buzzing. The sound and vibration are there for anyone within earshot; the notification reaches someone in another room.

Connecting a watch

  1. Install ShakeDetector from the Connect IQ Store and open it on the watch.
  2. On the watch: Menu โ†’ Setup link. A six-character code appears.
  3. On your phone, open this-site/s/CODE to reach the setup page.
  4. 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.