top of page
No tags yet.

SEARCH BY TAGS: 

RECENT POSTS: 

FOLLOW ME:

  • LinkedIn - Grey Circle
  • Twitter - Grey Circle

Arduino Seizure Alarm


Back in early 2014, my son Daniel was diagnosed with Benign Rolandic Epilepsy, a type of Epilepsy the Epilepsy Foundation says accounts for about 15 percent of all Epilepsies in children. The good news is that most children grow out of it.

The bad news is that he's most affected by his condition at night while he sleeps. The three seizures he's had in the past year-plus have been either in the middle of the night or early in the morning. Because of this, we invested in a sleep monitor/alarm for his bed that detects when he's having a full tonic-clonic seizure.

While shopping around for the exact type of monitor/alarm my wife and I wanted, I found out a few things:

  1. They are hard to find. I believe the one we ended up with was manufactured by a company in Great Britain.

  2. They are expensive. The one we ended up getting cost in the $400-$500 range.

  3. The one we have isn't totally cumbersome, but it's not easy to pack up and take with you somewhere.

Figuring these things out, I decided to search for a way to build a simple seizure alam that's both relatively inexpensive and easy to transport. I'm sure there are people out there who have children that suffer from seizures that simply cannot afford equipment such as this even though they truly need it. Thanks to the folks in the Arduino community, I was able to accomplish both things I was setting out to do.

Disclaimer: I cannot guarantee how well this alarm will work in your individual situation, or if will even work at all. I tested it on a twin-sized inner-spring mattress. I'm not sure it will work on a memory foam mattress since they are designed to insulate vibration.

The inspiration for this project came from Arduino's "Knock" example project. The sketch code was originally created in 2007 by David Cuartielles and modified by Tom Igoe in 2011. I took the modified code, which was written for an Arduino Uno microcontroller board and modified it again to work on an Arduino Micro board. Using the Micro instead of the Uno allowed me to mount the microcontroller board, wires, and buzzer to a small breadboard and minimized the amount of soldering I had to do.

What you'll need:

  • an Arduino Micro microcontroller board (If the Arduino store is sold out, you can also find them on Amazon.)

  • a small breadboard

  • an electric buzzer

  • a piezo sensor (This is the one I used. I chose the one with the mass attached because of the enhanced sensitivity. If you're looking at it print-side up, the positive lead is the one on the right.)

  • a 1 megohm resistor

  • an enclosure for the main components (This is the one I used. In order for the breadboard to fit inside it, I had to shave off the tabs that allow you to mount multiple boards together. Fun tip: If you don't have a pair of pliers that can get close enough to the tabs to shave them off handy, a pair of good ol' toenail clippers actually works well.) This was wierd: The screws for the cover are correct for the holes in the cover but too small for the holes in the actual enclosure. To make it work, I pumped hot glue into the larger holes then screwed down the cover before the glue completely cooled.

  • a smaller enclosure for the sensor (This is the one I used. Make sure whatever enclosure you choose for the sensor is sturdy since it'll be under the mattress while someone is sleeping on top of it.)

  • 12 feet of small-gauge wire, cut into two 6-foot pieces (Tip: Use two different-clored wires so it's easier to follow them through the shrink tubing.) I used 22-gauge wire for mine.

  • 6 feet of shrink tubing

  • a 5-volt power supply with a micro USB connector.

  • This file, which has the sketch I modified to work with the Micro (NOTE 8/12/15: Wix won't let me upload a file with the .ino extension, so this sketch file is saved as text. All you have to do is copy and paste the text into a blank sketch in the Arduino software.). Don't worry that the code refers to an LED. It will still allow the buzzer to work instead, because all the code is doing is assigning a state to that port. (If you use a different buzzer than the one I used, the positive side may end up in a different digital port. In that case, you'll just have to update the line "const int ledPin = 4; // led connected to digital pin 4" to whatever pin it actually falls in.)

The cost for the Micro, enclosures, and piezo sensor totaled together less than $40 before any taxes and/or shipping. I already had a power supply from an old Bluetooth earbud lying around, as well as a breadboard and buzzer. Other items, such as the resistor, wire, and shrink tubing, typically come in bulk. I now have somewhere in the neighborhood of 99 1 megohm resistors handy.

You'll also need a soldering iron and solder, a wire cutter and stripper, a Phillips screwdriver (for the enclosure lids), electrical tape, and either a hair dryer or heat gun.

The Circuit

Steps:

  1. Mount the Micro onto the breadboard, making sure the micro USB port sits on the edge of it.

  2. Mount the buzzer onto the breadboard on the matching numbered rows as the ports of the microcontroller. The post opposte the positive side must be connected to the ground. Like I mentioned above, that may cause the port the positive side falls on to change. The drawing above reflects where it falls using the buzzer I had.

  3. Set the breadboard and mounted components into the main enclosure and mark the holes for the micro USB, buzzer, and sensor wires. If you're not using a clear enclosure, you may want to also drill out one or more small holes near the micro USB port to see the power LED. Do not take the backing off the breadboard yet! Also don't forget you may have to shave the tabs off the sides of the breadboard to get it to sit on the bottom of the enclosure.

  4. Remove the breadboard and components and drill or cut out all the necessary holes. If you use the same enclosure I used, you'll have to make a hole large enough for the collar of your micro USB cable to fit through.

  5. Once all of your holes are drilled (and you're sure everything lines up), you can remove the backing from the breadboard and mount it to the bottom of the enclosure.

Next, drill a hole in the side of the enclosure for the sensor.

  1. Strip a small amount of insulation (only about a quarter-inch should suffice) off one end of each of your wires. Solder the wires to the leads on the piezo sensor. Remember which wire is the positive side and which wire goes to the ground.​​

  2. Feed the wires through the sensor enclosure and pull until the sensor sits in the middle and isn't touching any of the side walls. I (rather sloppily) wrapped some electrical tape around the wire inside the enclosure so the wire can't get ripped out. Just be sure to not make the wire inside the enclosure stiff. Once done, it should look like the photo at right. You're now done with this part, so you can fasten the cover down to it.

  3. Shrink tube the wires together, leaving a few inches exposed so you can feed it through the hole in the main enclosure.

  4. Feed the wires through the hole you drilled for them, strip about one-third of an inch of insulation off the ends, and feed into the breadboard so they are in line with their correct Micro ports.

  5. Insert the resistor into the same rows of the breadboard as the wires. It should look like this:

Once completed, your alarm and sensor should look like this:

Now, all you need to do is load the sketch onto your Arduino! Just connect the alarm to your computer, load up the sketch, and place the sensor between the mattress and foundation (boxspring) in the middle of the bed you'll be using it on (which is why I made the leads so long). Or, if it's going under the mattress of a larger bed the person will only sleep on one specific side of, place it directly under where they typically sleep.

If when you first test it the sensor isn't sensitive enough to set the buzzer off, or if it's too sensitive and the buzzer won't stop, just adjust the threshold in the sketch. It's the number in this line:

"const int threshold = 30"

FYI: The lower the number, the more sensitive the sensor will be.

You can probably figure out a way to adjust the sensitivity by connecting a potentiometer, but I didn't get that complicated with this.

Once you get the sensitivity to where you're confortable with it, just replace the micro USB connector with your power supply, and you're ready to go!

I hope this project helps bring a little ease to your mind!

bottom of page