TrailGuard: the Band That Watches Over You

by ayushmaan45 in Circuits > Wearables

2759 Views, 29 Favorites, 0 Comments

TrailGuard: the Band That Watches Over You

InShot_20250917_185810415.gif
InShot_20250916_194808626.gif
IMG_20250916_115611820.jpg
IMG_20250916_115253265.jpg

Hey everyone!

I’m Ayushmaan, a B.Tech E.E.E. student who’s always been into building and creating cool stuff from scratch whether it’s tech, crafts, or something in between.

So, Every hiker knows the thrill of exploring new trails, but secretly in the back of your mind, there is this quiet fear: What if something happens? Slipping on wet rocks, a fainting fit from exhaustion, or just plain getting lost , these types of things occur more frequently than we like to admit.

That's why I created TrailGuard, a healthy wearable for individuals who love the great outdoors but don't want to sacrifice security. It's like having a hiking buddy who doesn't simply monitor your movements - it takes care of your health. With sensors to track your heart rate, identify threatening falls, and immediately alert your caregiver with your live GPS location, TrailGuard is my vision to bring peace of mind to adventurers, trekkers, and travelers on their own.

It is not about substituting risk with caution - it's about ensuring the individuals who venture out to explore can also safely return home.

Supplies

WhatsApp Image 2025-09-16 at 19.57.33_22932a7e.jpg

Here’s what I used to bring TrailGuard to life:

  1. ESP32 Development Board – the brain, with WiFi + Bluetooth
  2. OLED Display (SSD1306, I²C) – shows heart rate, modes, and alerts
  3. MPU6050 Gyroscope + Accelerometer – for fall detection
  4. MAX30102 Heart Rate & SpO₂ Sensor – to track vitals during a hike
  5. GPS Module (Neo-6M) – sends your live coordinates during emergencies
  6. 2 Push Buttons – one for switching modes, one dedicated SOS trigger
  7. Rocker Switch – acts as the main power control
  8. 800mAh Li-ion Battery – compact yet powerful enough for hours of use
  9. Type-C Charging Module (TP4056) – simple, safe recharging
  10. Perfboard – to solder and secure all the parts
  11. 3D-Printed Case – custom housing to turn electronics into a wearable
  12. Wires, connectors, and a wrist strap

How It Works

The concept of this project is relatively simple -- I needed a band that detects when you fall during hiking and sends an alert immediately. To implement this, I employed the use of a gyro sensor, which maintains a continuous check on orientation and jerks. If the band experiences an abnormal impact or fall, it sends a warning.

In addition to that, I included a MAX30102 heart rate sensor. That assists in monitoring vitals such as pulse and SpO₂, which can prove handy if one starts feeling ill while out hiking. The readings are displayed directly on the OLED screen, so you can easily glance at your status.

For emergencies, it has two buttons: one is a mode switch (normal/hiking modes), and the other an SOS button. Tapping on SOS triggers an alert to a guardian along with your coordinates. The GPS module does the coordinates, and currently I am testing with dummy/fake GPS values as I do not always have good satellite lock indoors.

If the person actually does fall, the band instantly sends their location coordinates to the guardian. Both the phone notification (via Blynk) and an email are sent to the guardian, so that the guardian is aware of the exact location of the hiker and can act fast.

All of this is managed by the ESP32, which connects the sensors and interfaces to Blynk for alerting. Power is from an 800 mAh Li-ion battery with a Type-C charging module and a rocker switch for convenient on/off. I mounted the entire circuit onto a perfboard and created a 3D-printed case to give it a proper wearable look and feel.

Design

band1.png
back.png
something v2 v5.png
band2.png
InShot_20250916_073615638.gif

The TrailGuard was designed with functionality and wearability in mind, although it ended up being somewhat bulky. Certain components, such as the ESP32 and the GPS module, are somewhat large, so the case had to be made to fit them in, which made it bulky.

I created the whole enclosure in Fusion 360, ensuring that there is sufficient space for the perfboard, battery, buttons, and sensors. The rocker switch and the buttons were placed with easy accessibility, and the OLED screen is situated so it's easily viewed while wearing the band.

The 3D-printed enclosure holds everything together and safe, even though the band itself is somewhat chunky. I attempted to make it as small as possible, but the main concern was ensuring that everything could fit safely and work properly. Even with the size, the band is wearable and completely functional for testing and use in the field.

Preparing the Perfboard

IMG_20250916_084559.jpg
InShot_20250916_074232329.gif
InShot_20250916_073852217.gif
IMG_20250916_084543.jpg

Before wiring everything, I started by tracing the outline of the 3D-printed case onto the perfboard and then cutting it to size. This ensured the board would fit neatly inside the enclosure without any unnecessary gaps.

For this design, the major components - ESP32, MPU6050 gyro, Type-C charging module, rocker switch, and the two push buttons - were directly soldered onto the perfboard. This keeps the wiring clean and sturdy, and reduces loose connections. Smaller components like the OLED and heart rate sensor can later be connected via short wires or headers.

By fixing the main modules directly onto the board, the structure became more compact and stable, making it easier to fit everything into the case and handle during testing.

Circuit Connections

IMG_20250916_105554267.jpg
InShot_20250916_160140721.gif
InShot_20250916_132432137.gif
IMG_20250916_101143706.jpg

Here’s how all the components are connected on the perfboard:

  1. ESP32 – acts as the main controller.
  2. OLED Display (SSD1306) → SDA: GPIO32, SCL: GPIO33
  3. MPU6050 Gyro + Accelerometer → SDA: GPIO32, SCL: GPIO33 (shared I²C bus)
  4. MAX30102 Heart Rate & SpO₂ Sensor → SDA: GPIO32, SCL: GPIO33 (shared I²C bus)
  5. GPS Module → TX: GPIO16, RX: GPIO17
  6. Mode Switch → GPIO25
  7. SOS Button → GPIO26
  8. Rocker Switch → inline with battery to control main power
  9. Battery + Type-C Charging Module → battery connects to ESP32 VIN & GND via charging module

Tips & Layout:

  1. I soldered the ESP32 facing downward and the push buttons flat on the board for easy access.
  2. The Type-C charging module sits on top of the board for convenient wiring and access to the charging port.
  3. The MPU6050 gyro is positioned on the bottom side to keep it stable and reduce vibrations.
  4. The OLED and MAX30102 are connected via wires, not soldered directly, and will be attached to the case with hot glue. This allows positioning on the wrist strap and keeps the display and sensor visible during use.
  5. Using this layout keeps the board compact and organized while making sure all components are accessible and functional.


Power Source

InShot_20250916_135018037.gif
InShot_20250916_135946588.gif
IMG_20250916_084902.jpg
IMG_20250916_103537045.jpg

Since I needed a thin battery to fit inside the band, I used a small Samsung phone battery. I soldered wires directly onto its connectors and hooked it up to a Type-C charging module. From there, the charging module is connected to the ground of the ESP32 and the rocker switch, which acts as the main power control.

This setup keeps everything compact and allows the band to be recharged easily while still providing stable power to all components.

Assembly

IMG_20250916_114106933.jpg
InShot_20250916_141430485.gif
InShot_20250916_155920495.gif
IMG_20250916_114112760.jpg

For the final assembly, I kept things straightforward:

  1. The OLED display was fixed on the top of the case for clear visibility.
  2. The PCB with the ESP32 and other components was placed in the middle section.
  3. The MAX30100 sensor was positioned at the bottom so it could make direct contact with the skin.
  4. Finally, the strap was attached to the sides, turning the body into a wearable band.

This arrangement kept the components organized and made the prototype easy to wear and test.

Code

Now comes the most important part – bringing everything to life with code. The ESP32 is programmed using Arduino IDE, and both the sensors and Blynk app are tied together in this step.

First, I included the required libraries for the MPU6050, GPS, OLED display, and Blynk:


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MPU6050.h>
#include <TinyGPS++.h>
#include <BlynkSimpleEsp32.h>

Then, I defined the I2C pins for the ESP32 (since I wanted to use GPIO 32 and 33 instead of the default):


#define I2C_SDA 32
#define I2C_SCL 33

Next, the Blynk Auth Token, Wi-Fi name, and password were added so the device could connect to the cloud:


char auth[] = "YourAuthToken";
char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";

Fall Detection Algorithm

The MPU6050 continuously sends acceleration and orientation data. The code checks for:

  1. A sudden spike in acceleration (impact).
  2. Followed by low activity/inactivity (person not moving).

If both are true, the system assumes the individual has fallen.

Here’s the simplified snippet:


if (abs(accelX) > threshold || abs(accelY) > threshold || abs(accelZ) > threshold) {
if (millis() - lastMotionTime > inactivityLimit) {
fallDetected = true;
}
}

When fallDetected becomes true, the code immediately grabs the GPS coordinates and sends them via Blynk.


if (fallDetected) {
String location = String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6);
Blynk.logEvent("fall_alert", "Fall Detected! Location: " + location);
}




Downloads

Blynk Setup

Screenshot 2025-09-17 162132.png
Screenshot_2025-09-17-17-06-09-64_12ffc8cefb1625d72bea53ca6feebda3.jpg

Blynk is the bridge between the hardware and the guardian’s phone. To make the alerts work, we need to configure both the Blynk Console (web dashboard on a PC/laptop) and the Blynk mobile app.

Step 1: Setting Up on Blynk Console (Windows/Web)

  1. Go to Blynk Console and log in.
  2. Create a New Template:
  3. Name: TrailGuard
  4. Device: ESP32
  5. Connection Type: Wi-Fi
  6. Inside the template, set up Datastreams:
  7. Virtual Pin V0 → For Fall Detection Alert (event trigger).
  8. Virtual Pin V1 → Latitude data from GPS.
  9. Virtual Pin V2 → Longitude data from GPS.
  10. Virtual Pin V3 → Heart Rate sensor value (MAX30100/30102).
  11. Go to Event Settings in the template, and create an event named fall_alert. This event will be triggered by the ESP32 whenever a fall is detected. You can configure it to send a push notification and email automatically.
  12. Save the template, then create a Device from it. Blynk will generate an Auth Token — copy this and paste it into your Arduino code.

Step 2: Setting Up the Blynk Mobile App

  1. Install the Blynk IoT App (iOS/Android).
  2. Log in with the same account you used for the console.
  3. You’ll see the device you created earlier (TrailGuard). Select it.
  4. Add Widgets:
  5. Notification Widget → shows real-time fall alerts.
  6. Email Widget → receives coordinates and health status.
  7. Map Widget → set its data source to V1 (Latitude) and V2 (Longitude) to track the hiker’s location in real time.
  8. Value Display Widget → set to V3 for showing live heart rate.
  9. Test the widgets: send dummy values from your ESP32 to the virtual pins (e.g., latitude/longitude values) and confirm they appear on the app.


Downloads

Testing

IMG-20250917-WA0013.jpg
InShot_20250917_190118398.gif
InShot_20250917_185948463.gif
InShot_20250917_185922422.gif

Once the hardware was assembled and the code uploaded, I moved on to testing the TrailGuard band. The process was carried out in multiple steps:

  1. Power Check: Verified that the ESP32, OLED, and sensors powered up correctly from the Li-ion battery through the charging module.
  2. Sensor Testing:
  3. Shook the band to simulate sudden movements — the MPU6050 values responded instantly on the serial monitor.
  4. Placed the MAX30100 sensor on my finger to confirm heart rate (BPM) and pulse/SpO₂ readings were being captured correctly.
  5. Blynk Communication:
  6. Tested Wi-Fi connection and checked if dummy values appeared correctly on Virtual Pins V1 (Latitude), V2 (Longitude), V3 (Heart Rate), and V4 (Pulse/SpO₂).
  7. Triggered a fall event (V0 = 1) manually from the code to verify that both phone notifications and emails were received.
  8. Full Simulation:
  9. Dropped the band gently to simulate a fall → Blynk notification “Fall Detected!” arrived on my phone.
  10. Email received with coordinates in the format Latitude, Longitude.
  11. Map widget updated the location marker.
  12. Checked live readings of heart rate and pulse on the Blynk dashboard, which matched the values shown on the OLED.

The test results showed that even with basic sensors, the prototype reliably detected falls, monitored vitals, and transmitted alerts in real time.

Conclusion

FA4O1UTMFFQ7CR1.gif
IMG_20250916_114935114.jpg
WhatsApp Image 2025-09-16 at 12.07.18_bdf10631.jpg
IMG_20250916_115559189.jpg

The TrailGuard project shows that, with low-cost electronics and a bit of fiddling around, you can create something that really is useful in real life. With fall detection, GPS location sharing, and health monitoring (heart rate and SpO₂), it behaves like an emergency buddy for hikers and explorers.


This initial build is a bit chunky due to the ESP32 and GPS module sizes, but it does what it's meant to — it proves that the idea works. For TrailGuard V2, the intention is to get it significantly more compact with a custom PCB, employ smaller sensors, and even include a SIM module so that it remains connected without relying on WiFi.


So while version 1 is a solid proof-of-concept, version 2 could be a sleeker, more reliable wearable — something you’d actually want to carry on every hike.