-
Upload the updated code to ESP32
-
Open Serial Monitor (115200 baud)
-
Look for initialization message:
======================================== BUTTON INITIALIZATION ======================================== Button Pin: GPIO 0 Initial State: HIGH (RELEASED) ... ======================================== -
Press the button and watch Serial Monitor
Button PRESSED at [timestamp]
Button press detected - waiting for potential double press...
Button RELEASED
=== SINGLE PRESS CONFIRMED - Triggering SOS ===
SOS Triggered
✓ Button event sent to web app: SINGLE PRESS (SOS)
STATUS -> Battery: 87% GSM: OFF LED: ON BLE: ON
Button PRESSED at [timestamp]
Button press detected - waiting for potential double press...
Button RELEASED
Button PRESSED at [timestamp]
=== DOUBLE PRESS DETECTED - Cancelling SOS ===
SOS Cancelled
✓ Button event sent to web app: DOUBLE PRESS (CANCEL)
STATUS -> Battery: 87% GSM: OFF LED: OFF BLE: ON
Check Serial Monitor for:
[DEBUG] Button state: HIGH (not pressed)orLOW (pressed)- If state doesn't change when pressing, check wiring
Solutions:
- Verify button is connected to GPIO 0 (or your configured pin)
- Check button connects to GND when pressed
- Try using BOOT button (GPIO 0) directly
- Test with multimeter - button should show continuity when pressed
Check Serial Monitor for:
Button PRESSEDmessage appearsButton event sent to web appmessage[DEBUG] BLE Connected: YES[DEBUG] Data Char available: YES
If button is detected but SOS doesn't trigger:
- Check web app is connected (BLE Connected: YES)
- Check browser console for button event messages
- Verify Data characteristic notifications are enabled
- Try reconnecting from web app
Check Browser Console (F12):
- Look for "Button event received" messages
- Check for any errors
Solutions:
- Verify BLE connection is active
- Check Data characteristic supports notifications
- Try disconnecting and reconnecting
- Check browser console for errors
Add this to loop() to test button directly:
// Test button - remove after debugging
static int lastTestState = HIGH;
int currentTestState = digitalRead(BUTTON_PIN);
if (currentTestState != lastTestState) {
Serial.print("BUTTON STATE CHANGED: ");
Serial.println(currentTestState == HIGH ? "RELEASED" : "PRESSED");
lastTestState = currentTestState;
}- Cause: Button might be stuck or wiring issue
- Fix: Check button physically, verify wiring
- Cause: BLE notification not working
- Fix: Check Data characteristic has NOTIFY property, verify connection
- Cause: Pressing too slowly
- Fix: Press button twice within 500ms (adjust DOUBLE_PRESS_WINDOW_MS if needed)
- Cause: This is correct behavior - waits 500ms for potential double press
- Fix: This is by design - single press waits 500ms before triggering
- Button initialization message appears
- Button state changes when pressed (Serial Monitor)
- "Button PRESSED" message appears
- "Button event sent" message appears
- Web app shows SOS alert (single press)
- Web app cancels SOS (double press)
- Browser console shows button events
- Activity log shows button press messages