DIoT 2023 Skills Dev II: Fall Detection

Made by Yujin Wu

a simple Fall Detection Sensor

Created: November 9th, 2023

0

Intention

I designed a fall detection mechanism—specifically, a system that sends out an alert if someone falls and is unable to get up. I attempted to implement this using a Force-Sensitive Resistor and a button.

0

Process

In the code, my logic is that when the user presses the "help" button, the system checks for a certain force from the Force-Sensitive Resistor. Imagine having multiple sensors on a person's back, buttocks, knees, etc. If there is sufficient force, the system will send out an SOS signal using Morse code. However, the force sensor should only be triggered if the button is pressed to prevent unintended triggers due to normal behaviors like sitting or lying down.

The code is shown below.

0
int ledPin = D2;
int buttonPin = D3;
int forcePin = A2;

int buttonState = 0;
int forceReading = 0;
int sos = 0;


void setup() {
    
    // Configure the pins to be outputs
    pinMode(ledPin, OUTPUT);

    pinMode(buttonPin, INPUT_PULLUP);
    
    Particle.variable("button", buttonState);
    Particle.variable("Force-Sensitive Resistor", forceReading);
    Particle.variable("sos", sos);

}

void flash(String s) {
    if (s ==  "S") {
        Particle.publish("S...");
        for (int i = 0; i < 3; i++) {
            // Particle.publish(char(i));
            digitalWrite( ledPin, HIGH);
            delay(1000);
            digitalWrite( ledPin, LOW);
            delay(1000);
        }
        
    }  
    
    if (s ==  "O") {
        Particle.publish("O...");
        for (int i = 0; i < 3; i++) {
            digitalWrite( ledPin, HIGH);
            delay(3000);
            digitalWrite( ledPin, LOW);
            delay(1000);
        }
    } 
}

void SOS() {
    flash("S");
    delay(3000);
    flash("O");
    delay(3000);
    flash("S");
}

void loop() {
    
    buttonState = digitalRead( buttonPin);
    forceReading = analogRead( forcePin);
    
    if (buttonState == LOW) {
        if (forceReading > 1000) {
            sos = 1;
            SOS();
            Particle.publish("SOS...");
        } else {
            sos = 0;
        }
            
    } 
    
    delay(500);
}
Click to Expand
1
0

Challenges and Improvement

The most challenging aspect during the process was connecting the Force-Sensitive Resistor. I was surprised to find that one end of the Force-Sensitive Resistor is connected to both the A2 pin and an additional resistor. Some possible improvements could include adding another button so that users can cancel the SOS signal if triggered accidentally. Alternatively, I could swap the button with a switch so that users do not have to press the button repeatedly (until they are noticed) but instead can turn the switch on/off.

x
Share this Project

Courses

48-675 Designing for the Internet of Things

· 11 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

a simple Fall Detection Sensor