# Build: Raspberry Pi 4 Model B as a Muse gadget

## Goal
A working Muse Gadgets: Linux Device SDK (Linux) build on Raspberry Pi 4 Model B, paired to your Muse account and ready for first prompts.

## Hardware
- [Raspberry Pi 4 Model B](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/) x1 (required, board): Main board or device for this build.
- [USB-C power supply (5.1 V / 3 A)](https://www.raspberrypi.com/products/type-c-power-supply/) x1 (required, part): The official 15.3 W supply avoids undervoltage warnings.
- [microSD card, 16 GB or larger](https://www.amazon.com/s?k=microSD%2032GB%20A1) x1 (required, part): Flash Raspberry Pi OS with Raspberry Pi Imager.

## Shopping list (ask before buying)
- Raspberry Pi 4 Model B x1 (required, est. $35; buy: https://www.raspberrypi.com/products/raspberry-pi-4-model-b/)
- USB-C power supply (5.1 V / 3 A) x1 (required, est. $10; buy: https://www.raspberrypi.com/products/type-c-power-supply/)
- microSD card, 16 GB or larger x1 (required, est. $10; search: https://www.amazon.com/s?k=microSD%2032GB%20A1)
- Estimated total: $55
- Purchase policy: Show the human one list with links and the total, and get explicit approval for the exact items, sellers and total before buying anything. Amazon and eBay don't allow automated carts or checkout, so for those items give the human the links and let them check out. On other stores, once they approve and ask you to, you may add exactly those items to a cart and check out with a payment method they have already set up. Never buy anything they have not approved, and never type card numbers or passwords yourself.

## Constraints
- Ask the human before any purchase.
- Use `mgst_YOUR_TOKEN` as the placeholder; never commit a real token.
- ESP-IDF v6.0.1 only for ESP32 builds; do not substitute another ESP-IDF version.
- Find the serial port before flashing; only ask the human if the port check is empty or ambiguous.
- Terms: Same token terms as the ESP32 SDK: personal and non-commercial, at most 50 devices per token, no selling or public listing, revocable at any time. (https://gadgets.muse.ai/sdk-terms)

## Steps
1. Get the parts
You need the board and any build-specific accessories before flashing or pairing.
2. Put it together
The Linux gadget needs storage, power and Bluetooth ready before pairing.
   Put the board in its case, insert the flashed SD card if it uses one, connect the power supply and attach a USB Bluetooth LE adapter if the machine does not have Bluetooth built in.
3. Get your Muse SDK token
Muse gadgets pair with your account by using a private SDK token.
   Create a token at gadgets.muse.ai > Account > SDK tokens (https://gadgets.muse.ai/settings/sdk-tokens). It starts with `mgst_`. The Linux installer takes it as `--sdk-token mgst_YOUR_TOKEN`. Never commit the real token or paste it anywhere public.
4. Install the Linux SDK
The installer creates the Muse gadget service and gives Muse a bounded command surface on the machine.
   Download `install.sh`, read it, then run it with `mgst_YOUR_TOKEN`. Use `--run-as USER` with a dedicated low-privilege user unless you intentionally want Muse to have the install account's permissions.
   - `curl -fsSL https://raw.githubusercontent.com/facebookincubator/muse-gadget-sdk/main/linux/install.sh -o install.sh`
   - `less install.sh`
   - `bash install.sh --sdk-token mgst_YOUR_TOKEN`
5. Pair it with the Muse app
The Linux device needs to pair with your Muse account before it can receive commands.
   In the Muse app, turn on Settings > Devices > Developer mode, then Settings > Devices > Add Device (+). Pick `MuseGadget-XXXXXX` within 10 minutes of install. Green = connected. If you miss the window, run `sudo musegadget pair`, then add the device from the app again.
   - `sudo musegadget pair`
6. Try it
A first prompt proves the device is paired, reachable, and useful for the project.
   - Install Home Assistant on my Pi and tell me how to open it.
   - Check the Pi's temperature and uptime.

## Assemble
1. Insert the prepared SD card or boot storage into the board. Check: Storage is fully seated. Robot feasible: yes (Simple insertion if the slot is exposed and the card is oriented.)
2. Put the Linux board in its case or stable enclosure. Check: Board is supported, vents are clear and ports are accessible. Robot feasible: yes (Simple placement; fastening depends on the case.)
3. Connect power to the board. Check: Power LED is on and the board starts booting. Robot feasible: yes (Simple cable insertion if the connector is visible.)
4. Pair from the Muse app within 10 minutes, or run sudo musegadget pair and add the device again. Check: Muse app shows the gadget as connected. Robot feasible: no (Pairing requires app access and account confirmation.)
5. Ask Muse to check the device health or run a simple command. Check: The service responds and reports healthy status. Robot feasible: no (Requires software verification through Muse.)

## Verify
- The Linux service is paired and healthy.
- Try: Install Home Assistant on my Pi and tell me how to open it.
- Try: Check the Pi's temperature and uptime.

## References
- SDK repo: https://github.com/facebookincubator/muse-gadget-sdk
- AGENTS.md (read this first): https://github.com/facebookincubator/muse-gadget-sdk/blob/main/linux/AGENTS.md
- Platform docs: https://github.com/facebookincubator/muse-gadget-sdk/tree/main/linux
- Board docs or firmware: https://www.raspberrypi.com/documentation/
- Build page: https://www.hackshop.dev/build/raspberry-pi-4b
- Save it: tell the human to click Start a build on the build page so their progress is saved.