Project in progress

Alexa Skill for Seizure-Risk Users (Requires Wristband) © GPL3+

A wristband that works in conjunction with alexa to detect if the user is having a seizure, The wristband monitors pulse and gyroscope data.

  • 1,017 views
  • 0 comments
  • 4 respects

Components and supplies

About this project

Welcome To The Alexa Wristband Project

Hi my name is Kris, i've always been a strange but interesting individual. Hacking away in my in-home lab with the tools the internet has provided, expanding my knowledge by application and approach rather then studying and testing. I'd like to explain what it is im doing here quickly and straight to the point. So we can use our resources to benefit our outcome here on earth.

-Kris

What Is It

A wristband that detects seizures, comes equipped with a pulse, gyro sensor and connects to wifi to report events.

What Is The Device Used For

  • Fall Risk
  • Seizure Detection
  • Irregular Arrhythmia Events
  • Autonomic Events Reporting

What It Can Do

When the device detects a seizure,heart event,fall. Alexa will ask the user to respond. If there is no response the device will seek Medical help

We have a layout and a test system in the works, the wristband sketch is in the development folder - Listed on GIT

Where We've Come So Far

Coding The Real - Time Notification Platform

The Alexa / ECHO API, If used for what we are developing. The Alexa API will need to develop a NEW function for notifications to pass through without using context like "Im Reminding You" or require the user to ask what the notification is. so if there is a function integrated that can take text to speech and send it to alexa/ECHO without needing to be called on by a function - intent.

We Need More Options !

More info about the problem found here...

https://community.smartthings.com/t/play-a-message-remotely-on-sensor-trigger-through-alexa-voice/56946

and here

https://stackoverflow.com/questions/33409530/amazon-echo-push-a-message-to-the-device

The Code

There is nothing special here just a API that makes a call to a home server to send the request to Alexa, store's the user's data...

Requirements - Library's

IP

Arduino .INO File Property

http://www.instructables.com/id/Wearable-heart-beat-sensor-ESP8266Pulse-sensor/

ARDUINO

  • GYRO - mpu6050
  • WIFI - esp

Direct Links

EDA - https://easyeda.com/kris193/Bionic_Controller-fa710b2fb0de45e5890d60f8d222c095

DRIVE - http://docs.google.com/document/d/1Pn-qL3KPpfgW_2eByCOJL4VaNJWr2PjLrmeETrg6gzk/edit?usp=sharing

GIT- https://github.com/givemesite/ALEXA-APP

The PHP & Arduino CODE

PHP

<?PHP
//////////////////////
//    ALEXA 
//
// This is used to import all the lib's
// V0.0.2
//     GMS INC 2018
//////////////////////
 include ("./ALEXA.php");
//Fall Risk 
//Seizure Detection
//Irregular Arrhythmia Events   
//Autonomic Events Reporting
//
//
//
?>

ARDUINO

//////////////////////
// This is used to import all the lib's
// V0.0.2
//     GMS INC 2018
//////////////////////
void setup() { 
//Fall Risk 
//Seizure Detection
//Irregular Arrhythmia Events   
//Autonomic Events Reporting
#include <ESP8266WiFi.h> 
#include <Ticker.h> 
Ticker flipper; 
const int httpPort = 80; 
Ticker sender; 
const int maxAvgSample = 20; 
volatile int rate[maxAvgSample];                    
// used to hold last ten IBI values 
boolean sendok = false; 
volatile unsigned long sampleCounter = 0;          
// used to determine pulse timing 
volatile unsigned long lastBeatTime = 0;          
// used to find the inter beat interval 
volatile int P =512;                      
// used to find peak in pulse wave 
volatile int T = 512;                     
// used to find trough in pulse wave 
volatile int thresh = 512;                
// used to find instant moment of heart beat 
volatile int amp = 100;                   
// used to hold amplitude of pulse waveform 
volatile boolean firstBeat = true;        
// used to seed rate array so we startup with reasonable BPM 
volatile boolean secondBeat = true;       
// used to seed rate array so we startup with reasonable BPM 
volatile int BPM;                   
// used to hold the pulse rate 
volatile int Signal;                
// holds the incoming raw data 
volatile int IBI = 600;             
// holds the time between beats, the Inter-Beat Interval 
volatile boolean Pulse = false;     
// true when pulse wave is high, false when it's low 
volatile boolean QS = false;   
const char* ssid = "ssid"; 
const char* password = "password"; 
WiFiClient client; 
const char* host = "192.168.1.80";//you pc IP 
void setup() { 
 Serial.begin(115200); 
 delay(10); 
 Serial.print("Connecting to "); 
 Serial.println(ssid); 
 WiFi.begin(ssid, password);  
 while (WiFi.status() != WL_CONNECTED) { 
   delay(500); 
   Serial.print("."); 
 } 
 Serial.println(""); 
 Serial.println("WiFi connected");   
 Serial.println("IP address: "); 
 Serial.println(WiFi.localIP()); 
 Serial.print("connecting to "); 
 Serial.println(host); 
 if (!client.connect(host, httpPort)) { 
   Serial.println("connection failed"); 
   return; 
 } 
 //client.print("255"); 
 delay(10); 
 Serial.println(); 
 Serial.println("end Setup"); 
 flipper.attach_ms(2, Test); 
 sender.attach(2, senderfunc); 
} 
void senderfunc() 
{ 
 sendok=true; 
} 
void loop() {   
    if(sendok) 
    { 
       delay(100); 
           WiFiClient client; 
             const int httpPort = 80;
// to port to send the data 
             if (!client.connect("YOURPCIP", httpPort)) { 
               Serial.println("connection failed"); 
               return; 
             } 
             //Serial.print("Requesting URL: "); 
             // This will send the request to the server 
             client.print(BPM); 
             Serial.println(BPM); 
             delay(10); 
             sendok =false; 
             flipper.attach_ms(2, Test); 
    } 
} 
void sendtcp() 
{ 
} 
int count = 0; 
void Test() 
{ 
 count++; 
 if(count ==1000) 
 { 
   flipper.detach(); 
   count =0; 
   //sendtcp(); 
   sendok=true; 
 } 
     Signal = analogRead(A0);              
// read the Pulse Sensor  
       sampleCounter += 2;                         
// keep track of the time in mS with this variable 
   int N = sampleCounter - lastBeatTime;       
// monitor the time since the last beat to avoid noise 
     if(Signal < thresh && N > (IBI/5)*3){       
// avoid dichrotic noise by waiting 3/5 of last IBI 
       if (Signal < T){                        
// T is the trough 
           T = Signal;                         
// keep track of lowest point in pulse wave  
        } 
      } 
   if(Signal > thresh && Signal > P){          
// thresh condition helps avoid noise 
       P = Signal;                             
// P is the peak 
      }                                        
// keep track of highest point in pulse wave 
 //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT 
 // signal surges up in value every time there is a pulse 
if (N > 250){                                   
// avoid high frequency noise 
 if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){         
   Pulse = true;                               
// set the Pulse flag when we think there is a pulse 
   //digitalWrite(blinkPin,HIGH);                
// turn on pin 13 LED 
   IBI = sampleCounter - lastBeatTime;         
// measure time between beats in mS 
   lastBeatTime = sampleCounter;               
// keep track of time for next pulse 
        if(firstBeat){                         
// if it's the first time we found a beat, if firstBeat == TRUE 
            firstBeat = false;                 
// clear firstBeat flag 
            return;                            
// IBI value is unreliable so discard it 
           }    
        if(secondBeat){                        
// if this is the second beat, if secondBeat == TRUE 
           secondBeat = false;                 
// clear secondBeat flag 
              for(int i=0; i<=maxAvgSample-1; i++){         
// seed the running total to get a realisitic BPM at startup 
                   rate[i] = IBI;                       
                   } 
           } 
   // keep a running total of the last 10 IBI values 
   word runningTotal = 0;                  
 // clear the runningTotal variable     
   for(int i=0; i<=(maxAvgSample-2); i++){               
 // shift data in the rate array 
         rate[i] = rate[i+1];             
 // and drop the oldest IBI value  
         runningTotal += rate[i];          
// add up the 9 oldest IBI values 
       } 
   rate[maxAvgSample-1] = IBI;                         
 // add the latest IBI to the rate array 
   runningTotal += rate[maxAvgSample-1];               
 // add the latest IBI to runningTotal 
   runningTotal /= maxAvgSample;                    
 // average the last 10 IBI values  
   BPM = 60000/runningTotal;              
 // how many beats can fit into a minute? that's BPM! 
   QS = true;                             
 // set Quantified Self flag  
   // QS FLAG IS NOT CLEARED INSIDE THIS ISR 
   }                        
} 
 if (Signal < thresh && Pulse == true){     
// when the values are going down, the beat is over 
     //digitalWrite(blinkPin,LOW);            
// turn off pin 13 LED 
     Pulse = false;                         
// reset the Pulse flag so we can do it again 
     amp = P - T;                           
// get amplitude of the pulse wave 
     thresh = amp/2 + T;                    
// set thresh at 50% of the amplitude 
     P = thresh;                            
// reset these for next time 
     T = thresh; 
    } 
 if (N > 2500){                             
// if 2.5 seconds go by without a beat 
     thresh = 512;                         
 // set thresh default 
     P = 512;                             
  // set P default 
     T = 512;                               
// set T default 
     lastBeatTime = sampleCounter;        
  // bring the lastBeatTime up to date         
     firstBeat = true;                     
 // set these to avoid noise 
     secondBeat = true;                   
  // when we get the heartbeat back 
    } 
 //sei();                                    
 // enable interrupts when youre done! 

Code

GIT - Alexa Soft DEV Folder
Contents all the Development files and 3d art work

Custom parts and enclosures

EDA Links
Links to our EDA https://easyeda.com/kris193/Bionic_Controller-fa710b2fb0de45e5890d60f8d222c095

Schematics

Links To Alpha Phase (Schematics & Drawings) Soft Dev
Link To Public Google Drive Document With Alexa OPEN SOURCE DOCS GITHUB LINKS in DEV FILES http://docs.google.com/document/d/1Pn-qL3KPpfgW_2eByCOJL4VaNJWr2PjLrmeETrg6gzk/edit?usp=sharing

Comments

Team GMS Bionics

Kris193
kris193
  • 1 project
  • 0 followers
Default
Anton
  • 2 projects
  • 0 followers

Additional contributors

  • Motivated by miguel mota https://miguelmota.com/blog/alexa-voice-service-with-curl by miguel
  • Alexa curl by https://github.com/gravesjohnr

Published on

February 23, 2018

Members who respect this project

Img 20151017 124922 stwwfrkyprDefaultProfilepic

and 1 other

See similar projects
you might like

Similar projects you might like

Alexa Skill for Seizure-Risk Users (Requires Wristband)

Project in progress by GMS Bionics

  • 966 views
  • 0 comments
  • 3 respects

Wise Shower Driven by Alexa Skill

Project in progress by Virgilio Enrique Aray Arteaga

  • 2,043 views
  • 0 comments
  • 3 respects

Smart Switch Using Arduino and Alexa

Project tutorial by Ruchir Sharma

  • 11,317 views
  • 22 comments
  • 56 respects

Safe City: A Device to Keep You Safe

Project tutorial by Patel Darshil

  • 6,169 views
  • 0 comments
  • 24 respects

Voice Activated Media Appliances Using Arduino and Alexa

Project tutorial by Patel Darshil

  • 3,941 views
  • 2 comments
  • 18 respects
Add projectSign up / Login