Skip to the content.

Armband Health Sensor

My project is a wearable armband that can sense when someone who is supposed to limit their mobility overextends their arm, as well as let them know about the safety of their specific temperature circumstance. Using a temperature sensor and accelerometer to detect the arms movement, a speaker and buzzer go off with different patterns to alert the wearer on what is happening. This project held many challenges and learning curves due to the many components, but it was also extremely entertaining to work on as well as fufilling because it made a device that was applicable for the health field and was effective.

Engineer School Area of Interest Grade
Sai C San Juan Hills High School Biomedical Engineering Incoming Senior

Headstone Image

Final Milestone

Since my previous milestone, I have adapted the breadboard to be more compact so that it fits on a smaller board in order for it to be easier for the armband wearer. Along with this, I began to use a 9 Volt battery to power my Arduino, rather than keeping it plugged into my computer, and I adjusted the coding and the sensor thresholds to work with the new configuration.

Some of the biggest challenges I faced during my time at BlueStamp Engineering were pushing through the basic hurdles of electrical engineering, as it was a new concept for me, and I found that working with all the components and making sure everything runs smoothly was a pretty daunting task. I overcame these struggles, however, through troubleshooting to address the root of the problem in each scenario, and I achieved many triumphs as a result, when I was able to piece together the whole board.

To summarize the key topics I learnt from this program, I learnt about basic breadboard engineering, as well as how Arduino sensors work, and how specific components work such as the accelerometer, and temperature sensor. Overall, all of this made me feel a lot more familiar with simple electrical engineering. In the future, I hope to use the skills I learnt at BlueStamp and apply them to work in the medical field, as I am interested in Biomedical Engineering. I am super grateful to this program and all it has provided for me, and I will take this knowledge with me in the future.

Here is what my board looked like at the end: Breadboard Image 2

First and Second Milestone

My project is an armband that is aimed to recognize when someone who is supposed to have limited mobility (due to surgery, broken bones, etc.) moves their arm past a certain threshold as well as when they are in unsafe temperature conditions. The components of my project include an Arduino Nano ESP32, a DS18B20 Temperature Sensor, an Accelerometer, a Piezo Speaker, and a Vibration buzzer.

Through both milestones, I was able to not only test the components individually (including a Force Resistive Sensor that I did not end up using at this stage), but I also connected each one and made the base of the device, in which both the temperature sensor and accelerometer set off the speaker and buzzer to alert the armband wearer if they are in too hot of a condition, are moving their arm too much, or both.

Some challenges I faced when making this project include the accelerometer not registering with the Arduino, and through many tests I was eventually able to figure out with the help of my instructors that the issue was stemming from the fact the A4 and A5 pins on my ESP32 were not working, and this was important because they are the only pins that work with the accelerometer. To fix this, we ordered a new ESP32 with working pins. The next issue I struggled with was the temperature sensor, as the DS18B20 was not working with the Nano, so for the time being I replaced the temperature sensor with a photoresister which measures ambient lighting for proof of concept, and in my video I demonstrate how I used the measurements taken to create a “Fake Temperature” which transfers the data found from the lighting into a readable temperature.

My second milestone was completing the board and combining all the components on my breadboard, and I displayed this in my video. Each of the sensors trigger a certain pattern in the buzzer and speaker based on if they pass the “dangerous” threshold for the armband wearer, and there is a pattern for if both are occurring.

Something that has been surprising about the project so far is that it has really taught me how to troubleshoot errors, because my project so heavily relies on multiple different components, and if one doesn’t work it sets off the rest of the project, so I did not expect for that to be such a large learning curve for me. To complete my final milestone, I am hoping to figure out my temperature sensor and add it back in, as well as attach my board to the armband apparatus, and figure out the logistics of that.

Here is what my board looked like at this stage: Breadboard Image 1

Schematic

Initial Schematic (To Test Device) Schematic 1

Final Schematic (Compressed and Simplified) Schematic 2

Code

#include <Wire.h>                 // For MPU6050 accelerometer communication

#include <OneWire.h>              // For DS18B20 temperature sensor

#include <DallasTemperature.h>    // Easier DS18B20 temperature readings
 // -------------------- PINS --------------------
const int motorPin = D9; // Vibration motor pin
const int buzzerPin = D8; // Piezo buzzer pin
const int buttonPin = D2; // Button pin
const int tempPin = D4; // DS18B20 data pin
// -------------------- MPU6050 --------------------
const int MPU_ADDR = 0x68; // MPU6050 default I2C address
bool accelFound = false; // Tracks if MPU6050 was detected
int16_t baseX, baseY, baseZ; // Starting/normal position
// -------------------- DS18B20 TEMP SENSOR --------------------
OneWire oneWire(tempPin); // OneWire connection on D4
DallasTemperature tempSensor( & oneWire); // Temperature sensor object
// -------------------- ALERT STATES --------------------
bool motionAlert = false; // True when motion alert is active
bool tempAlert = false; // True when temp alert is active
bool alertsMuted = false; // True after button press mutes alert
// -------------------- THRESHOLDS --------------------
// Same idea as raw threshold of 12000.
// 12000 / 16384 = about 0.73g
const float motionThresholdG = 0.73;
// Temperature range
const float lowTempC = 35.0;
const float highTempC = 38.0;
// -------------------- SETUP --------------------
void setup() {
    Serial.begin(115200); // Start Serial Monitor
    delay(2000); // Wait before starting
    pinMode(motorPin, OUTPUT); // Motor output
    pinMode(buzzerPin, OUTPUT); // Buzzer output
    pinMode(buttonPin, INPUT_PULLUP); // Button uses internal pull-up
    digitalWrite(motorPin, LOW); // Motor off
    noTone(buzzerPin); // Buzzer off
    Serial.println("Patient alert project starting...");
    // Start temperature sensor
    tempSensor.begin();
    Serial.print("DS18B20 sensors found: ");
    Serial.println(tempSensor.getDeviceCount());
    // Start accelerometer
    Wire.begin();
    // Check if MPU6050 is connected
    Wire.beginTransmission(MPU_ADDR);
    byte error = Wire.endTransmission();
    if (error == 0) {
        Serial.println("MPU6050 found!");
        accelFound = true;
        // Wake up MPU6050
        Wire.beginTransmission(MPU_ADDR);
        Wire.write(0x6B); // Power management register
        Wire.write(0); // Wake up sensor
        Wire.endTransmission();
        delay(500);
        // Save current position as normal
        readAccelerometer(baseX, baseY, baseZ);
    } else {
        Serial.println("MPU6050 not found. Motion alert disabled.");
        accelFound = false;
    }
}
// -------------------- MAIN LOOP --------------------
void loop() {
    // Button click stops/mutes the current alert
    if (buttonPressed()) {
        clearAlerts();
        alertsMuted = true;
        Serial.println("Alerts muted by button.");
        delay(500); // Simple debounce
        return;
    }
    checkMotion(); // Check motion
    checkTemperature(); // Check real DS18B20 temperature
    // If nothing is wrong anymore, allow future alerts again
    if (!motionAlert && !tempAlert) {
        alertsMuted = false;
    }
    // If alert was muted, keep outputs off
    if (alertsMuted) {
        stopOutputs();
        delay(100);
        return;
    }
    // Choose alert pattern
    if (motionAlert && tempAlert) {
        playBothAlert(); // Continuous beep
    } else if (motionAlert) {
        playMotionAlert(); // Long beep pattern
    } else if (tempAlert) {
        playTempAlert(); // Double beep pattern
    } else {
        stopOutputs(); // No alert
    }
    delay(100);
}
// -------------------- MOTION CHECK --------------------
void checkMotion() {
    if (!accelFound) return; // Skip if accelerometer missing
    int16_t x, y, z; // Current X/Y/Z values
    readAccelerometer(x, y, z); // Read accelerometer
    // Compare current position to starting position
    int rawMovement = abs(x - baseX) + abs(y - baseY) + abs(z - baseZ);
    // Convert raw MPU6050 movement to approximate g units
    float movementG = rawMovement / 16384.0;
    Serial.print("Movement G: ");
    Serial.println(movementG);
    // Trigger alert if movement is above threshold
    if (movementG > motionThresholdG) {
        motionAlert = true;
    }
}
// -------------------- TEMPERATURE CHECK --------------------
void checkTemperature() {
    tempSensor.requestTemperatures(); // Ask DS18B20 for temp
    float tempC = tempSensor.getTempCByIndex(0); // Read first sensor
    Serial.print("Temp C: ");
    Serial.println(tempC);
    // -127 means sensor is disconnected/not detected
    if (tempC == DEVICE_DISCONNECTED_C) {
        Serial.println("Temperature sensor not detected!");
        tempAlert = true;
        return;
    }
    // Trigger temp alert if outside range
    if (tempC < lowTempC || tempC > highTempC) {
        tempAlert = true;
    }
}
// -------------------- ALERT PATTERNS --------------------
void playMotionAlert() {
    // Pattern: beeeep ... beeeep ... beeeep
    digitalWrite(motorPin, HIGH);
    tone(buzzerPin, 1000);
    delay(600);
    digitalWrite(motorPin, LOW);
    noTone(buzzerPin);
    delay(400);
}
void playTempAlert() {
    // Pattern: beepbeep ... beepbeep ... beepbeep
    for (int i = 0; i < 2; i++) {
        digitalWrite(motorPin, HIGH);
        tone(buzzerPin, 1500);
        delay(150);
        digitalWrite(motorPin, LOW);
        noTone(buzzerPin);
        delay(150);
    }
    delay(500);
}
void playBothAlert() {
    // Pattern: continuous beeeeeeeeeep
    digitalWrite(motorPin, HIGH);
    tone(buzzerPin, 2000);
}
// -------------------- HELPER FUNCTIONS --------------------
void clearAlerts() {
    motionAlert = false; // Clear motion alert
    tempAlert = false; // Clear temp alert
    stopOutputs(); // Turn off motor/buzzer
}
void stopOutputs() {
    digitalWrite(motorPin, LOW); // Motor off
    noTone(buzzerPin); // Buzzer off
}
bool buttonPressed() {
    // INPUT_PULLUP means pressed = LOW
    return digitalRead(buttonPin) == LOW;
}
void readAccelerometer(int16_t & x, int16_t & y, int16_t & z) {
    // Tell MPU6050 we want accelerometer data
    Wire.beginTransmission(MPU_ADDR);
    Wire.write(0x3B); // First accelerometer register
    Wire.endTransmission(false);
    // Request 6 bytes: X, Y, Z
    Wire.requestFrom(MPU_ADDR, 6, true);
    // Combine high and low bytes for each axis
    x = Wire.read() << 8 | Wire.read();
    y = Wire.read() << 8 | Wire.read();
    z = Wire.read() << 8 | Wire.read();
}

Bill of Materials

Part Note Price Link
Arduino ESP32 Main computer for project that runs code $20.00 Link
Resistive Force Sensor To sense when arm compresses (Did not make it in Final Design) $11.99 Link
Vibrating Mini Motor Vibrates when sensors are triggered $5.99 Link
Accelerometer Detects motion when arm moves $11.25 Link
USBC Cable Connecting Arduino ESP32 to computer $3.88 Link
DS18B20 Temperature Sensor To detect the temperature through skin contact $9.99 Link
Armband To make device easily wearable $5.50 Link
Electronics Kit Contains miscellaneous items needed like breadboard, Piezo speaker, etc. $14.00 Link
9V Barrel Jack To connect battery to breadboard $6.00 Link
9V Batteries To power device $12.37 Link
Electrical Tape To attatch breadboard and battery to armband $5.99 Link
Digital Multimeter To detect electrical current in device $9.99 Link

Other Resources Used