Emergency Button
A bright, unmissable button for safety-critical actions: emergency stop, panic alert, machine shutdown. Five geometric styles, three trigger modes, visual safety cues you can tune so a casual tap doesn’t fire it.
[image] Emergency Button on canvas, Round style, red, pulse glow visible
What it does
Emergency Button is a styled push button focused on one job: making a safety action obvious and hard to fire by accident. You pick a shape, a trigger filter (single press / long press / double press), and visual cues (pulse, warning stripes, border).
When the trigger condition is met, your sketch reacts in WHEN_PRESSED. The widget visually flips to a Triggered color, and (optionally) auto-resets after a delay.
When to use it
- Hardware emergency stop — Trigger mode Long, label HOLD TO STOP. Cut power to relays from
WHEN_PRESSEDand set a fault flag. - Panic alert — Trigger mode Double. Fire a notification or buzzer; reset is automatic.
Properties
The Inspector opens as a bottom sheet with a Widget ID field at the top, then these sections in order.
Widget ID
| Property | Type | What it controls |
|---|---|---|
| Widget ID | text | Identifier used by your sketch (IEmergencyButton("…")). |
1. Essential
| Property | Type | Default | What it controls |
|---|---|---|---|
| Enabled | toggle | on | Allow user interaction. |
| Target Devices | multi-select dropdown | — | Pick which device(s) this widget communicates with. Server Mode only. |
| Style | Round / Hex / Sq. / Oct. / Mush. | Round | Physical shape of the button. |
| Trigger mode | Press / Long / Double | Press | How strict the activation is. |
2. Header
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show header | toggle | off | Display a text label above the button. |
| Header text | text | empty (placeholder Label) | Header text. Only when Show header is on. |
| Alignment | Left / Center / Right | Center | Header text position. Only when Show header is on. |
3. Button label
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show label | toggle | on | Show text on the button itself. |
| Text | text | empty (placeholder EMERGENCY) | Button text. Only when Show label is on. |
4. Appearance
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show pulse | toggle | on | Slow attention-grabbing ring around the button. |
| Show warning stripes | toggle | off | Diagonal hatching for industrial look. |
| Show border | toggle | on | Outer border outline. |
| Border width | 1–10 px | 2 | Border stroke width. |
| Button size | 0.5–1.5 | 1.0 | Scale factor. |
5. Behavior
| Property | Type | Default | What it controls |
|---|---|---|---|
| Auto reset | toggle | on | Automatically return to Idle after a trigger. |
| Reset delay | 1–10 s | 3 s | Time before auto-reset fires. Only when Auto reset is on. |
6. Colors · States
| Property | Type | What it controls |
|---|---|---|
| Idle | color | Button color when armed. |
| Pressed | color | Color while held. |
| Triggered | color | Color after activation. |
7. Colors · Details
| Property | Type | What it controls |
|---|---|---|
| Border | color | Outer border color. |
| Label | color | Button text color. |
States and behavior
[image] Three states: Idle (red, pulsing) / Pressed (dark red) / Triggered (green)
- Idle — Armed, waiting. Idle color, with optional pulse and warning stripes.
- Pressed — During the touch. Pressed color.
- Triggered — The trigger condition was met. Triggered color, persists until Auto reset delay or user taps again.
The trigger filter prevents most accidental fires:
- Press — Fires on any single press. Fastest, easiest to fire by accident.
- Long — Must be held briefly before firing. Safer for serious actions.
- Double — Two quick presses. Filters most accidental taps.
In code
The button mirrors what the user does on the dashboard. To react to it in your sketch:
IEmergencyButton("estop") {
WHEN_PRESSED {
stopAllMotors();
}
};
That’s the minimum — one event block, the action fires when the trigger condition is met. See InstantIoT Library / Receive Command from App for details.
Working Arduino code example
A complete sketch you can flash. The Widget ID estop matches the one you set on your Emergency Button in the app.
[gif] Emergency Button on the dashboard cutting power to relays on the ESP32
Direct Mode
Your phone connects directly to the ESP32’s SoftAP — no router, no server. Best for prototyping and standalone setups.
#include <InstantIoTWiFiAP.hpp>
const char* AP_SSID = "InstantIoT-Greenhouse";
const char* AP_PASS = "12345678";
#define RELAY_PIN 5
#define ALARM_PIN 6
InstantIoTWiFiAP instant(AP_SSID, AP_PASS);
void stopAllMotors() {
digitalWrite(RELAY_PIN, LOW);
digitalWrite(ALARM_PIN, HIGH);
}
IEmergencyButton("estop") {
WHEN_PRESSED {
stopAllMotors();
}
};
void setup() {
pinMode(RELAY_PIN, OUTPUT);
pinMode(ALARM_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH);
digitalWrite(ALARM_PIN, LOW);
instant.begin();
}
void loop() {
instant.loop();
}
Server Mode
The ESP32 connects to your self-hosted InstantIoT Server over WiFi. Multiple devices, persistent state, history.
#include <InstantIoTWiFiServer.hpp>
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* SERVER_IP = "192.168.1.42";
const uint16_t SERVER_PORT = 9001;
const char* DEVICE_TOKEN = "YOUR_DEVICE_TOKEN";
#define RELAY_PIN 5
#define ALARM_PIN 6
InstantIoTWiFiServer instant(SERVER_IP, SERVER_PORT, DEVICE_TOKEN);
void stopAllMotors() {
digitalWrite(RELAY_PIN, LOW);
digitalWrite(ALARM_PIN, HIGH);
}
IEmergencyButton("estop") {
WHEN_PRESSED {
stopAllMotors();
}
};
void setup() {
pinMode(RELAY_PIN, OUTPUT);
pinMode(ALARM_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH);
digitalWrite(ALARM_PIN, LOW);
instant.begin(WIFI_SSID, WIFI_PASS);
}
void loop() {
instant.loop();
}
The widget code is identical — only the include and constructor change.
Notes
- Reset delay is hidden when Auto reset is off.
- Pulse and warning stripes are visual cues only — they don’t change the button’s behavior, just signal that this is a serious action.
Next
→ Simple Button — When you don’t need the safety filters.
→ Switch — For non-critical persistent on/off.