Potential Custom Seizure Detector Hardware?

With Pebble watches not being available any more, and Android Wear devices being very expensive, I am still wondering about an alternative seizure detector hardware platform.

I have heard about ESP8266 modules – they are small microcontrollers with built in wifi capability.    Although most people connect them to another microcontroller, it is possible to write your own software to run directly on it so I am wondering if it may be possible to make a seizure detector watch with them – It would need an ESP8266 module, an accelerometer chip and a LiPo battery, and put it in a 3D printed case.

I have just got an ESP8266 module with a built in USB interface.  This is a bit on the big side, but about the same size as a Pebble Time, so not out of the question (top image on right)

I have also got a few smaller modules that do not have a USB interface, so will take a bit more programming, but they are a lot smaller (bottom image on right)

The most surprising thing is the cost – the big one with extra hardware was just over £5, but the small ones are less than £2 each – it is hard to believe anyone can manufacture things and ship them from China for that price….

I have set up the compiler toolchain from https://github.com/pfalcon/esp-open-sdk, and obtained the tools to interact with the boards from https://github.com/espressif/esptool, and finally obtained some example programmes from https://github.com/esp8266/source-code-examples.git, which includes a ‘blink’ example.

After a bit of faffing to get the Makefile to work with my new cross compiler, ‘make’ will compile the programme, and ‘make flash’ will write it to the board.

After which – the on-board LED flashes on and off every second – success – the Microcontroller equivalent of ‘Hello World!’.

Next steps are:

  • Connect an accelerometer chip  to the board, using the SPI or I2C interface and try to read data from it (like I did using an Arduino back in 2013 – Soldering onto Surface Mount ICs).
  • Port the Pebble_SD seizure detector algorithm to the board to see if it will fit.
  • Get it to act as an OpenSeizureDetector network data source so that other devices can connect to it to detect alarms etc.
  • See if we can get the power consumption down enough that running it off a watch battery is feasible.
  • If it seems feasible, re-commission my 3D printer and try to make a case.
  • Think about adding an optical heart rate and blood saturation measurement to it.

The video below is not exciting, but it proves we can at least run a programme on one of these tiny (and very cheap) boards.


Beta Release of OpenSeizureDetector V2.5.1

I have just released a new Beta test release of OpenSeizureDetector on Google Play Store (V2.5.1).

The only change is an improvement to handling alarms from short duration seizures.   If a seizure is only detected for a short period, the previous version may only give a single set of Alarm beeps, which may be insufficient to alert a carer.

With the new version, if you enable “Latch Alarms” in the Alarms settings then when an alarm initiates, the alarm beeps will sound for the period specified in the “Latch Alarm Timer Duration” setting, even if the alarm resets quicker.

You can stop the alarm to silence the beeps earlier by pressing the Accept Alarm button.  This works both on the main OpenSeizureDetector app screen, and also if you are running it on another device using Network Datasource to provide alarm annunciation in a different part of the house.

This is as a result of the seizure Benjamin had last week, when we only got a single sent of alarm beeps.   This is fine if you are awake and alert, but if you are asleep it may not be enough to rouse you.   More details of this event on the Real Test of OpenSeizureDetector page.    A further update will follow fairly soon with an improved algorithm to detect seizures with lower frequency movement.

Real Test of OpenSeizureDetector


Benjamin had a seizure yesterday morning (03/05/2017).  It was not a ‘classic’ tonic clonic seizure (with rapid shaking of the arms).  Instead he was lying on his back with arms stiff in the air and ‘waving’.  This movement was on the borderline of detectability by OpenSeizureDetector.  It gave one WARNING and one ALARM.   On the positive side, it did detect the seizure.   On the negative, it only gave a single ALARM initiation, which might not be enough to wake you up if asleep.   Reducing the AlarmRatioThresh setting will increase sensitivity to improve detection reliability in the future.


The seizure was not a ‘classic’ tonic clonic seizure (quite rapid shaking of the arms).  Instead Benjamin was lying on his back with arms stiff in the air and ‘waving’.

OpenSeizureDetector gave one WARNING notification at 06:24:24 on 03/05/2017 followed by a single ALARM initiation at 06:20:30, then it re-set.

The movement was right on the limit of detection using default settings which look at a frequency range of 3bHz to 8bHz as the Region of Interest.   The movement peak was at 4bHz, but there was quite a lot of power in the 1-3bHz range too and not much above.  This meant that the region of interest average power was quite low – see graph below showing the frequency spectrum of the movement during the alarm (the grey shaded area is the 3-8 Hz region of interest).

The calculated spectrum ratio (=10x[Region of Interest Power]/Spectrum Power) was 59, against a threshold of 56 (the threshold had been set higher than the default 50 to reduce false alarm rate).

We use a second android device running OpenSeizureDetector in ‘Network’ mode to relay the alarm notifications to other parts of the house over wifi.   The second device gave a WARNING but did not go into alarm.   I think this is because of a timing issue with the ALARM being raised for only a short period, so this is something to look at as we would have expected the alarm to sound on both devices.

Changes to Settings

Detection of this particular type of seizure could be improved by reducing the Region of Interest to be 3-6 Hz rather than 3-8 Hz, but this would reduce the sensitivity to seizures resulting in higher frequency movement.   Benjamin’s worst fits have been the higher frequency type, so I am minded to retain detection in that region so have retained 3-8 Hz region of interest for now.

I have reduce the AlarmRatioThreshold back to 50 rather than the 56 that we were using to increase sensitivity.

So the main settings we will be using for now are:

  • alarmFreqMin = 3 Hz
  • alarmFreqMax = 8 Hz
  • alarmRatioThresh = 50

Software Changes

I will update the phone app to give multiple alarm sounds rather than just 3 beeps in the near future to improve the chances of you noticing a single alarm annunciation.

In the meantime, users could consider switching on the Latch Alarms option in the Alarms settings – this will make the system alarm continuously until you press the ‘Accept Alarm’ button on the phone app.


OpenSeizureDetector did detect this slightly unusual seizure, but it was right on the limit of detection, so just gave a single WARNING and a single ALARM notification.

Increasing the sensitivity by reducing the AlarmRatioThresh setting should improve detection in the future.  Other changes would improve detection of this seizure type to the detriment of detection of higher frequency movement seizures, which is probably not a good idea.

Android Wear Version – Update 1

We have made some progress with an Android Wear version of OpenSeizureDetector (long train journeys for work have their uses!).  It is not ready for testing yet, but it is starting to take shape.   What we have got is:

  • A very simple Android Wear app that does the basic seizure detection calculations – collects acceleration data and does Fourier Analysis to get us a frequency spectrum.
  • Packages the analysis results into a message that is sent to the OpenSeizureDetector app on the phone.
  • The development version of the OpenSeizureDetector phone app (V3.0.0) has an ‘Android Wear’ data source that works in a similar way to the Pebble data source – it waits for the watch to send it data, and displays the data on the screen, raising alarms when necessary.
  • You can see it running on the phone and my Android Wear watch below






For those who are interested, the source code for the watch app is at https://github.com/openseizuredetector/AndroidWear_SD

and the updated phone app is the V3.0.x branch at https://github.com/OpenSeizureDetector/Android_Pebble_SD/tree/V3.0.x

Any offers of help would be gratefully received!!

What is left to do?


  • Check the seizure detection calculations on Android Wear – I think the values are higher than the equivalent Pebble one, so we must have units wrong somewhere.
  • Provide a way of editing the seizure detection settings for the Android Wear seizure detector (They are hard coded at present – need to provide a user interface on the phone to edit settings, and ability to send settings to the watch), and maybe allow on-watch editing too?
  • Add ability to start the seizure detector watch app from the phone, so it starts when the OpenSeizureDetector phone app starts.
  • Add a user-interface to the watch like we have on pebble – ability to raise alarms manually, and mute alarms if you are doing something that is liable to trigger a false alarm.
  • Find out why it does odd things when I disconnect the debugger from the watch – it was working fine for half an hour with the USB debugger connected, and is showing FAULT now I have disconnected it….. (seemed to need a manual re-start…).    I think it may be going to sleep after a while….
  • Some Android Wear devices have heart rate monitors – maybe use that to look at heart rate and blood oxygen saturation too? (I’ll need to get a watch with these sensors to try that though – my Sony SmartWatch 3 does not have them).