The inspiration for this project came from my aging 10 year old Boxer, Leah, who started experiencing seizures towards the end of her life. I hated not knowing if she had an episode while at home alone, and turned to remote monitoring as a solution. Unfortunately Leah passed before the project was completed, and so it got put aside. Recently however we’ve added a new member to the family, Muchacho, a Great Dane who suffers from epilepsy. While his seizures are mostly under control, they do occur and can occur when we’re not home. This seemed like a good time to revive the project.

While searching for other, similar projects, I came across this Github repo which seemed very inline with what I was trying to accomplish. Their project is a WiFi enabled accelerometer for general purpose use that reports data back to a Jupyter Notebook. Their wiring diagram was spot-on for my needs and I just needed to change the arduino code to report to an InfluxDB back-end instead. Many thanks to the students of the Texas Advanced Computing Center for their work.

The project components amount to about a $20 - $40 investment depending on the board you choose.

Wiring the controller

I’ve linked to the fritzing diagram on their Github page to show a quick overview of the wiring but for more detailed wiring instructions and diagrams please visit the AccelerometerLogger Github page.

wiring diagram

Here’s my completed prototype. Note that I went with the longer headers but recommend buying the short headers above. All that room in between is wasted space and when I do this again I’ll go for a more compact design with shorter headers. Actually I’ll probably use a Wemos D1 Mini and go even more compact. I may eventually add on a cellular transmitter and GPS so for a prototype this configuration has its advantages also.


And its eventual home.


Arduino Code

Source code to upload through the Arduino IDE can be found on this project’s Github page.

There’s not much to it. You’ll need WiFi credentials and the IP of the InfluxDB server. You can adjust the sensitivity of the accelerometer if you wish. I’m still experimenting with the settings.

Battery considerations

By necessity this collar takes frequent readings and makes frequent WiFi transmissions and those events drain the battery rapidly.
I haven’t yet taken an accurate measurement of the power draw but I’m assuming it’s somewhere in the 100-150 mA range with spikes up to 200 mA. This means that a small 500mAh LiPo battery should last somewhere in the 3-5 hour range and my new 2300 mAh battery should last from 15-20 hours.

The 2300mAh battery is a bit large, a 1000 mAh battery is probably a good trade-off in size and runtime.

Update: With the 2300mAh battery my runtime was approximately 32 hours, which tells me the actual power draw is closer to 72 mA. So a 1000 mAh battery should last approximately 13 hours.

Setup InfluxDB & Grafana

I still need to provide more detailed instructions on the server setup. The database (named accel in the Arduino code) must be created before the collar can write coordinates.

In Grafana I created a dashboard showing the x, y, and z axis. The red horizontal line is my alert threshold.

InfluxDB graph

May 2 update: Due to the way I’m now triggering alerts I’m only graphing positive values using the queries below.

InfluxDB graph

My alert query looks for an average value above 10,000 over the last 5 seconds. This allows for small spikes (sharp movements) of short duration. In the future I’ll probably have to increase my polling interval a few more seconds.

InfluxDB graph

Note that I also changed “If no data or all values are null” to “Ok” in order to avoid alerts when a coordinate was negative. If left at the default it will error on “No Data” since you’re filtering it out.

Alerting is through a threshold defined in Grafana with alerts being sent through Pushover, which is built into Grafana by default.

I currently alert on spikes from any axis above 22,000 or below -22,000 . This seems reasonable for now although I do get some false positives. To fix this however I don’t think I want to modify the threshold, rather I need to modify the threshold duration. Since the seizures are usually longer than 10 seconds in length (I think), a 5 second threshold should eliminate many false positives.

An alert received on my iPhone from Pushover.

Pushover Alert

Here’s the collar in action.

Collar in action

Once I’m happy with the setup, I either need to design and 3D print a case or more likely rebuild the system with a Wemos D1 mini so that I can print a more compact case.

I also need to modify the circuit to monitor the battery level.

I’ll note that since Muchacho has been with us he hasn’t yet experienced a seizure so I’m not completely sure what the pattern will look like, or if I have my alerting thresholds set correctly. He’ll have to wear the collar more often so that he’s hopefully wearing it when the next seizure occurs and I can collect meaningful data instead of just shaking the accelerometer back and forth.

If you’re looking to implement something similar please reach out. I’ll keep updating this page as the project progresses.