Skip to content

Project 2.1.1: Alert Bracelet Prototype


Overview

This project builds a wearable-style alert prototype that sends a BLE emergency message when a button is held long enough to confirm the action.

A buzzer provides local feedback and the phone receives the alert text over BLE.

The idea models how a simple wearable or wrist-mounted call-for-help device could work in a school, health, or care environment.

The final system should require a deliberate long press, send a clear alert message, and prevent repeated triggers during a short cooldown period.


Required Components

Push button
Push button
Phone with BLE app
Phone with BLE app
Raspberry Pi Pico 2 W
Raspberry Pi Pico 2 W
Active buzzer
Active buzzer
Breadboard and jumper wires
Breadboard and jumper wires
Optional strap or enclosure material
Optional strap or enclosure material

Project-Specific Setup Notes

  • This project uses the Pico's built-in wireless module plus two helper files: ble_uart.py and ble_advertising.py
  • Save ble_uart.py to the Pico root folder as ble_uart.py
  • Save ble_advertising.py to the Pico root folder as ble_advertising.py
  • In Thonny Shell, run import os; print(os.listdir()) and confirm both helper files are visible on the Pico
  • Communication Setup: install a BLE app such as nRF Connect, LightBlue, or another BLE UART terminal app on your phone
  • Scan for the device name AIDER_Bracelet after the Pico starts advertising
  • Do not pair from the normal phone Bluetooth settings menu. Open the terminal app, scan, connect to the UART-style service, then send text commands from inside the app
  • If the wireless connection does not work, restart the Pico and rescan from the terminal app before changing the wiring

Project-Specific Safety Note

This is a prototype learning device, not a certified medical or emergency product. Do not rely on the prototype for real emergency protection without professional redesign, battery management, enclosure design, and reliability testing.


Circuit Connections

Component terminal Connect to Pico physical pin Notes
Button leg 1 GPIO 4 GPIO 4 / physical pin 6 Use internal pull-up in code
Button opposite leg GND Physical pin 38 Active-low input
Buzzer positive (+) GPIO 16 GPIO 16 / physical pin 21 Local alert output
Buzzer negative (-) GND Physical pin 38 Common ground

Wiring Diagram

Circuit Diagram

Raspberry Pi Pico 2 W
┌─────────────────────┐
│                     │
│  GPIO 4 ────────────┤──── Button leg 1
│  GND ───────────────┤──── Button opposite leg
│  GPIO 16 ────────────┤──── Buzzer +
│  GND ───────────────┤──── Buzzer -
│                     │
└─────────────────────┘

Step-by-Step Assembly

Step 1: Place the Raspberry Pi Pico 2W

Place the Raspberry Pi Pico 2W on the breadboard so it sits across the center gap. Keep the USB port facing outward so you can easily connect it to your computer.

Step 2: Place the Push Button

Place the push button across the breadboard center gap. This keeps each side of the button on separate breadboard rows.

Step 3: Connect One Button Leg

Connect one button leg to GPIO 4.

Step 4: Connect the Opposite Button Leg

Connect the opposite button leg to GND.

The code uses the Pico internal pull-up, so the button reads LOW when pressed.

Step 5: Place the Buzzer

Place the buzzer on the breadboard and identify its positive (+) and negative (-) pins.

Step 6: Connect the Buzzer Positive Pin

Connect the buzzer positive (+) pin to GPIO 16.

Step 7: Connect the Buzzer Negative Pin

Connect the buzzer negative (-) pin to GND.

Step 8: Check the Button Position

Mount the button where it can be pressed deliberately during the test.


Wiring Check

  • [x] Pico 2W is placed correctly across the breadboard center gap
  • [x] Push button sits across the breadboard center gap
  • [x] One button leg connects to GPIO 4
  • [x] Opposite button leg connects to GND
  • [x] Buzzer positive pin connects to GPIO 16
  • [x] Buzzer negative pin connects to GND
  • [x] No loose jumper wires

Intermediate Note

This project uses wireless UART on the Raspberry Pi Pico 2W. Use a terminal app such as nRF Connect, LightBlue, or another UART terminal to connect to AIDER_Bracelet and send commands. The alert triggers only after the button is held long enough, and the cooldown prevents repeated alerts from one press.


Testing Individual Components

Before running the full project, test each part separately. This makes it easier to find wiring, library, or code problems.

Hardware setup

  • Build the button and buzzer circuit
  • Make sure the button is not physically stuck or held down by the prototype enclosure

Test the input sensor

  • Run a short button test script and confirm the input changes from 1 to 0 when pressed
  • Hold the button down briefly to understand how long a long press should feel to the user

Test the output device

  • Run a short buzzer beep test
  • Make sure the feedback is loud enough for the demo but not excessively long

Test communication

  • Connect to AIDER_Bracelet from the BLE app
  • Send status and test to confirm the system responds before trying the real alert flow

Run the full system

  • Press and hold the button for the required time
  • Confirm the buzzer sounds and the BLE app receives the alert message
  • Try a second immediate trigger and confirm the cooldown prevents repeated alerts

Save the project

  • Save the working code
  • Write down what changes would be needed before turning the breadboard prototype into a wearable device

Full Project Code

After completing and checking the circuit connections, open Thonny IDE. Copy and paste the code below into a new file, or upload the project file to the Raspberry Pi Pico 2 W, then run it from Thonny.

from machine import Pin
import bluetooth
import time
from ble_uart import BLEUART

DEVICE_NAME = "AIDER_Bracelet"
HOLD_MS = 1500
COOLDOWN_MS = 10000
button = Pin(4, Pin.IN, Pin.PULL_UP)
buzzer = Pin(16, Pin.OUT)
ble = bluetooth.BLE()
ble.active(True)
uart = BLEUART(ble, name=DEVICE_NAME)

press_start_ms = None
waiting_for_release = False
alarm_enabled = True
last_alert_ms = time.ticks_add(time.ticks_ms(), -COOLDOWN_MS)
command_queue = []


def send_line(message):
    print(message)
    uart.write((message + "\n").encode())


def on_rx(data):
    command = data.decode("utf-8").strip().lower()
    if command:
        command_queue.append(command)


def alert_beep():
    for _ in range(3):
        buzzer.on()
        time.sleep_ms(120)
        buzzer.off()
        time.sleep_ms(120)


def remaining_cooldown(now_ms):
    return max(0, time.ticks_diff(time.ticks_add(last_alert_ms, COOLDOWN_MS), now_ms) // 1000)


uart.on_rx(on_rx)
buzzer.off()
send_line("Bluetooth alert bracelet prototype ready")

while True:
    now = time.ticks_ms()

    if button.value() == 0:
        if press_start_ms is None:
            press_start_ms = now
        elif (
            alarm_enabled
            and not waiting_for_release
            and time.ticks_diff(now, press_start_ms) >= HOLD_MS
            and time.ticks_diff(now, last_alert_ms) >= COOLDOWN_MS
        ):
            alert_beep()
            send_line("EMERGENCY ALERT: Bracelet button held")
            last_alert_ms = now
            waiting_for_release = True
    else:
        press_start_ms = None
        waiting_for_release = False

    if command_queue:
        command = command_queue.pop(0)
        if command == "status":
            state = "ARMED" if alarm_enabled else "DISARMED"
            send_line("State:{} Cooldown:{}s".format(state, remaining_cooldown(now)))
        elif command == "test":
            alert_beep()
            send_line("Bracelet test complete")
        elif command == "arm":
            alarm_enabled = True
            send_line("Alert input armed")
        elif command == "disarm":
            alarm_enabled = False
            buzzer.off()
            send_line("Alert input disarmed")
        elif command == "help":
            send_line("Commands: status, test, arm, disarm, help")
        else:
            send_line("Unknown command. Send help.")

    time.sleep_ms(80)

How the Code Works

Code Section What It Does Why It Matters
Long-press timing Measures how long the button is held Helps avoid false emergency triggers from accidental taps
Cooldown logic Blocks repeated alerts for a short recovery period Prevents alert spam and improves reliability
waiting_for_release flag Requires the button to be released before the next alert can happen Prevents one long hold from causing multiple alerts
BLE status and test commands Let the phone check readiness without causing a real alert Supports safe validation of the prototype

Expected Result

A deliberate long press triggers the buzzer and sends an alert message over BLE. The system then waits through a cooldown period before another alert is allowed.


Troubleshooting

Problem Possible cause Solution
Short taps trigger the alert The hold time is too short or the button input is noisy Increase HOLD_MS and retest the button wiring.
Alert never triggers The button is wired incorrectly or the hold time is not being reached Check the active-low button wiring and hold the button longer during testing.
Alerts repeat during one button hold The release logic is not being reached because the button remains pressed Release the button fully between tests and verify the wiring is not stuck low.
Phone cannot find the BLE device The Pico is not advertising or the BLE helper files are missing Confirm ble_uart.py and ble_advertising.py are saved on the Pico, restart the board, and scan again from nRF Connect or LightBlue.
Commands do not change the system state The phone is connected to the wrong service or the command text is different from the expected command Reconnect to the BLE UART service and send the exact command shown in the test section.