Seizure Safe

Safety System for High-Risk of Seizure Individuals

Devpost: https://devpost.com/software/seizuresafe Github: https://github.com/suchitahadimani/technica

Idea: Seizure Safe is a device for individuals who have epilepsy and have sensitivity to light. They are at high risk for seizures and might not always be around people during emergencies. Seizure Safe is a system which tries to predict if an at-risk individual fell due to conditions which may induce a seizure and then alert their family members/emergency contacts by sending out an SMS alert.

Timeline

Saturday

I arrived on campus at around 10 AM. Although I guess this wasn’t related to the hackathon, I’m really glad UMD was nearby and was just a weekend-long event. I had a lot more energy throughout the event knowing that I was spending 1.5 days as opposed to 4 days which had been the case for all the previous hackathons which were the Friday-Sunday hackathons which occurred far away. I would end up getting to the place Friday morning and then return Monday mornings to save money on flights.

Anyways, I got the UMD, and I really like the vibe there. I spent the first 2 hours of the hackathon mainly going around and talking to people. I got to the event and saw Kari from MLH which was pretty surprising. When I met her at HackHarvard, she was talking about how amazing Technica was and how sad she was that she couldn’t come this year. A twist of circumstances and a few last minute cancellations allowed her to come. So I was super happy about that!

She introduced me to two new friends who I randomly took pictures with. I bumped into some old high school friends who were organizing and mentoring at the event. I talked to the Capital One people, who were all recent graduates so they mainly just felt like friends, which was super fun. After enough dilly dallying, I figured it was time to hack.

While I originally was planning on doing the hackathon with a random team, I decided that I wanted to do something hardware-related, especially since Technica was going to be my last hackathon for this semester and potentially this school year. Hardware tracks are usually less popular, so I figured it would be cute to do it on my own anyways.

I asked kari for a hardware kit, and she gave me the Grove Beginner Arduino Kit which was pretty epic because everything was built into the board. While I do know basic breadboarding and circuitry, it did make my life a lot easier that I didn’t have to actually figure out how to wire things.

I wasn’t really sure what to build for the hackathon. I spent the next hour/lunch trying to come up with an idea. The moment I saw the light sensors, I knew I wanted to do something with flashing lights and the first thing that came to mind was epilepsy and seizures. Two weeks ago, I saw a person in the school library who had a seizure and I had no idea what to do. Luckily somebody called the police, and the person was fine, but since then seizures have been in my mind.

At first, the idea was to warn an epileptic person about flashing lights in their vicinity. That was a dumb idea because if the sensor detected flashing lights, so would the person… The device would be of no use. So, I kept trying to come up with other ideas like smart pillows, plant watering (oldest idea in the book), and other random stuff, but I found myself wandering back to the flashing lights idea.

After a few conversations with friends, I ended up refining the idea to something more usable. It would be an alert system which would reach out to emergency contacts of high-risk, epileptic individuals in situations where the probability of seizures are higher than average (aka lots of flashing lights) and if a fall motion was detected.

Here is the excerpt from the notes app in which I was drafting the idea.

After deciding on the idea, I decided to play around with the arduino. I followed all the tutorials on the grover tutorials and coded in the arduino ide. https://wiki.seeedstudio.com/Grove-Beginner-Kit-For-Arduino/

While I have worked with arduinos before, it has been over 7 years now. Following along with the tutorials still felt very new and fresh and was pretty fun (the 6th tutorial was my favorite with the LED blinking to sound intensities).

Then, the trauma starts (JK). Basically, I was able to read data from the sensors on the arduino ide through the serial port which was pretty cool, but I was ultimately supposed to develop an application either web or mobile based.

Since I primarily make websites in NextJS, my first instinct was to figure out how to stream arduino data from the device to the node js backend that I had. I tried following this tutorial: https://medium.com/@machadogj/arduino-and-node-js-via-serial-port-bcf9691fab6a

For some reason, I kept getting error after error in just trying to render the page. I followed a trail of stack overflows and arduino discussion forums to resolve it, but it ended up with me wasting a good many hours.

I took a much needed break and went to Taco Bell for dinner, talked to friends, and relaxed. After a few hours of chilling, I went back to work.

I had originally intended to go to a workshop or two on hardware, but had got so sucked into the rabbit hole of fixing the errors that I completely forgot. I randomly went back to the schedule and was reading through the list of workshops when I saw that there had been a workshop on “Using Python for Arduinos”. Thaaaat’s when it clicked that maybe I should use python as a language for my project instead of javascript.

Around 9pm, I created a new and followed this other tutorial for setting up an arduino project in python. https://www.instructables.com/Controlling-Arduino-with-python-based-web-API-No-p/

I got the program files to compile without error (Yay!) which felt really good. However, I was still having problems displaying accurate data from the sensors. Essentially, no matter how much I messed around with the sensor, the readings wouldn’t change.

At that point, I was just happy that something even showed up on the page without any sort of compile issues. I slept pretty early, considering it a day well spent. I got up at around 8, and the next three hours were the most productive hours (power of sleep!!! you don’t always need to pull all nighters!!)

Sunday

After waking up, I was able to make most of the major functions to display different types of data, as showed by these two function:

def read_sensors():
   try:
       ser.write(b'R') 
       time.sleep(0.1)
       line = ser.readline().decode('utf-8').strip()
       data = line.split(' ')
      
       accel_data = data[0].split(':')[1].split(',')
       light_data = data[1].split(':')[1]
       sound_data = data[2].split(':')[1]


       data = {
           "accel_x": accel_data[0],
           "accel_y": accel_data[1],
           "accel_z": accel_data[2],
           "light": light_data,
           "sound": sound_data
       }


       return jsonify(data)
      
   except Exception as e:
       print(f"Error reading sensors: {e}")
       data = {
           "accel_x": "Error",
           "accel_y": "Error",
           "accel_z": "Error",
           "light": "Error",
           "sound": "Error"
       }


       return jsonify(data)


@app.route('/', methods=['POST', 'GET'])
def hello_world():
   author = "Suchita"
  
   if request.method == 'POST':
       if request.form['submit'] == 'Turn On':
           ser.write(b'H')  # Send 'H' to turn on the LED
       elif request.form['submit'] == 'Turn Off':
           ser.write(b'L')  # Send 'L' to turn off the LED

Function for triggering an alert for sensitivity:

function checkForAlerts() {
           const minLight = Math.min(...lightValues);
           const maxLight = Math.max(...lightValues);


           const maxAccelXChange = Math.max(...accelXValues) - Math.min(...accelXValues);
           const maxAccelYChange = Math.max(...accelYValues) - Math.min(...accelYValues);
           const maxAccelZChange = Math.max(...accelZValues) - Math.min(...accelZValues);


           if ((maxAccelXChange > 0.5 || maxAccelYChange > 0.5 || maxAccelZChange > 0.5) && (maxLight - minLight > 100)) {
               sendAlertToArduino();
               document.getElementById('alert-message').innerText = "Warning!! High Probability of Seizure";


           }


           else{
               document.getElementById('alert-message').innerText = "Good";
           }
       }

This is how the UI looked like, very basic, but did the job!

I wanted to add a message notification system as well, so I tried to integrate Twilio for sending out the alert to the individual’s emergency contacts. I spent a solid hour trying to get Twilio to work, but it just wasn’t able to deliver messages. I decided to then use the OLED display on the arduino to “simulate” the messages being sent. (This was a very good move in hindsight because it looked very cute and the judges would love seeing it.) I also used the button on the arduino to simulate the individual sending out an “all good” message in case there wasn’t actually a seizure.

And then I was done with the project!

We got Subway for lunch. Judging went pretty well! It was super nice pitching solo and knowing my whole product inside and out.

I got an honorable mention for the “Real-World Impact” track sponsored by ICF.

Kari was super sweet and let me keep the grove arduino kit, which was an unexpected surprise!

Overall, very good last hackathon.