> ## Documentation Index
> Fetch the complete documentation index at: https://support.customtypeone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Reference: DIY USB Examples

You can create your own external triggers using Arduino, ESP32, Raspberry Pi, or other similar DIY hardware. The setup needs to be made per the below details:

Your DIY hardware must either:

1. Have its own power source separate from Sidekick so that it is powered on and running all the time to monitor the incoming power.
   1. The Sidekick USB A port must be connected to your hardware to be monitored for 5V power.
   2. When your DIY board detects power coming from the USB A port, you can perform any function of your choosing.
   3. When your DIY board detects that power from the USB A port has stopped (alert snoozed/stopped), you can perform another function.
2. Run on USB A, 5V, 1 Amp or less and automatically perform your dedicated functions when powered on.
   1. Plug your external hardware into Sidekick's USB A port.
   2. If your hardware connects to WiFi, bluetooth, or has other delayed startup functions, you should only use the first DIY option above to ensure the alert function you have programmed runs immediately.

<div className="cc card-bluebell">
  <Accordion title="Example: ESP32 3.3V Setup" icon="microchip" description="Voltage divider wiring and example code for ESP32 boards">
    ### <Icon icon="toolbox" /> What you need:

    * ESP32 board (like a DevKitC or NodeMCU-ESP32)
    * USB-A cable with exposed 5V (red) and GND (black) wires
    * Two resistors for voltage divider (e.g., 10kΩ + 20kΩ → drops 5V to \~3.3V)
    * Breadboard and jumper wires

    ### <Icon icon="plug" /> Wiring

    USB Wire | Connect to

    Red (5V) | Voltage divider → ESP32 GPIO (e.g., GPIO 18)

    Black (GND) | ESP32 GND

    ### Voltage divider setup:

    ```
    USB 5V → [20kΩ] → GPIO 18
               ↓
            [10kΩ] → GND
    ```

    This drops 5V down to \~3.3V safely.

    ### <Icon icon="circle-check" /> Example Code (ESP32, digital read)

    ```
    const int usbPowerPin = 18;  // GPIO18 gets the divided signal
    bool lastState = LOW;

    void setup() {
      pinMode(usbPowerPin, INPUT);
      Serial.begin(115200);
    }

    void loop() {
      bool currentState = digitalRead(usbPowerPin);
      if (currentState != lastState) {
        if (currentState == HIGH) {
          Serial.println("USB Power ON");
          // YOUR ALERT START CODE GOES HERE
        } else {
          Serial.println("USB Power OFF");
          // YOUR ALERT STOP CODE GOES HERE
        }
        lastState = currentState;
      }
      delay(100); // debounce / polling delay
    }
    ```

    <Icon icon="triangle-exclamation" /> **Important**:

    * **Do NOT** connect 5V directly to ESP32 pins — always drop it to ≤3.3V.
    * ESP32 pins are usually labeled **GPIO** on your board — you can pick most, but avoid strapping pins (like GPIO0, GPIO2, GPIO15).
    * Use `Serial.begin(115200)` — ESP32 typically uses higher serial baud rates than Arduino Uno.
  </Accordion>
</div>

<div className="cc card-lavender">
  <Accordion title="Example: Arduino 5V Setup" icon="microchip" description="Direct 5V input wiring and example code for Arduino boards">
    ### <Icon icon="toolbox" /> What you need:

    * Arduino Uno (or similar)
    * USB-A cable with the 5V (red) and GND (black) wires exposed
    * Connect the 5V wire to an Arduino digital pin (or analog for voltage measurement)
    * Optionally use a resistor divider if needed

    ### <Icon icon="circle-check" /> Simple Example Code

    This version monitors the 5V USB line connected to digital pin 2:

    ```
    const int usbPowerPin = 2;  // USB 5V line connected here
    bool lastState = LOW;

    void setup() {
      pinMode(usbPowerPin, INPUT);
      Serial.begin(9600);
    }

    void loop() {
      bool currentState = digitalRead(usbPowerPin);
      if (currentState != lastState) {
        if (currentState == HIGH) {
          Serial.println("USB Power ON");
          // YOUR ALERT START CODE GOES HERE
        } else {
          Serial.println("USB Power OFF");
          // YOUR ALERT STOP CODE GOES HERE
        }
        lastState = currentState;
      }
      delay(100); // debounce / polling delay
    }
    ```

    ### Wiring

    * **USB 5V (usually red)** → **Pin 2**
    * **USB GND (usually black)** → **GND on Arduino**

    <Icon icon="triangle-exclamation" /> **Important**: Ensure the USB power doesn't exceed 5V. If you're unsure, use a voltage divider (e.g., 10kΩ and 10kΩ) to cut voltage in half and measure with an analog pin.
  </Accordion>
</div>

## Example DIY Integrations

This is a list of examples found online for integrating various devices with Arduino, ESP32, etc. We have not tested any of these examples.

<Columns cols={1}>
  <Card title="Apple HomeKit Integration" icon="apple" color="#E11D48" href="/external-alert-devices/diy-integrations/homekit">
    Native HomeKit on ESP32 or ESP8266
  </Card>

  <Card title="Google Home Integration" icon="google" color="#EA580C" href="/external-alert-devices/diy-integrations/google-home">
    Bridge to Google Home with IFTTT, Firebase, or MQTT
  </Card>

  <Card title="Home Assistant Integration" icon="house-signal" color="#16A34A" href="/external-alert-devices/diy-integrations/home-assistant">
    Connect via MQTT, HTTP, or ESPHome
  </Card>

  <Card title="Relays" icon="toggle-on" color="#059669" href="/external-alert-devices/diy-integrations/relays">
    Trigger high-voltage devices like lamps, fans, or appliances
  </Card>

  <Card title="Motors" icon="gears" color="#0891B2" href="/external-alert-devices/diy-integrations/motors">
    DC, servo, and stepper motors for robotics and automation
  </Card>

  <Card title="Solenoids" icon="lock" color="#3B82F6" href="/external-alert-devices/diy-integrations/solenoids">
    Electromagnetic lock or push/pull mechanisms
  </Card>

  <Card title="Internet Services" icon="globe" color="#4F46E5" href="/external-alert-devices/diy-integrations/internet-services">
    Trigger a web request, IFTTT, or cloud automation
  </Card>

  <Card title="Servo-controlled Mechanisms" icon="robot" color="#9333EA" href="/external-alert-devices/diy-integrations/servo-mechanisms">
    Lockboxes, robotic arms, door locks
  </Card>

  <Card title="Home Automation (IR, RF)" icon="tower-broadcast" color="#C026D3" href="/external-alert-devices/diy-integrations/home-automation-ir-rf">
    Control TV, lights, or other RF/IR devices
  </Card>

  <Card title="LCD/OLED Displays" icon="display" color="#DB2777" href="/external-alert-devices/diy-integrations/lcd-oled-displays">
    Show text or graphics
  </Card>

  <Card title="Sirens" icon="siren-on" color="#E11D48" href="/external-alert-devices/diy-integrations/sirens">
    Trigger a siren for alerts or security systems
  </Card>

  <Card title="Cameras" icon="camera" color="#EA580C" href="/external-alert-devices/diy-integrations/cameras">
    Trigger capture or stream images
  </Card>

  <Card title="Phone Calls/Texts" icon="phone" color="#16A34A" href="/external-alert-devices/diy-integrations/phone-calls-texts">
    Send SMS alerts with ESP32 and Twilio
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.