|
1 | | -# Shield Remote |
| 1 | +# Something Remote |
2 | 2 |
|
3 | | -BLE HID remote control for Nvidia Shield using M5Stack Atom Echo and MicroPython. |
| 3 | +BLE HID remote control for Nvidia Shield with Home Assistant integration, using the Everything Remote ESP32 board. |
4 | 4 |
|
5 | 5 | ## Hardware |
6 | 6 |
|
7 | | -- M5Stack Atom Echo (ESP32-PICO-D4) |
8 | | -- Button: GPIO39 (top button) |
9 | | -- LED: GPIO27 (SK6812 NeoPixel) |
| 7 | +- Everything Remote v1 board (ESP32 with 21 buttons) |
| 8 | +- MPU6050 accelerometer for motion wake (optional) |
| 9 | + - SDA: GPIO33, SCL: GPIO22, INT: GPIO36 (VP) |
10 | 10 |
|
11 | 11 | ## Features |
12 | 12 |
|
13 | | -- BLE HID Keyboard profile |
14 | | -- Press button to send Right Arrow key |
15 | | -- LED status: Blue=advertising, Green=connected, White=key pressed |
16 | | -- Bonding keys stored in ESP32 NVS |
| 13 | +- **BLE HID** - Keyboard and Consumer Control for Shield navigation |
| 14 | +- **Home Assistant** - MQTT integration with auto-discovery |
| 15 | +- **Power Management** - Light sleep and deep sleep with motion wake |
| 16 | +- **Captive Portal** - WiFi/MQTT setup via browser |
17 | 17 |
|
18 | | -## Prerequisites |
| 18 | +## Quick Start - Flashing Pre-built Firmware |
19 | 19 |
|
20 | | -- Docker |
| 20 | +### Download |
21 | 21 |
|
22 | | -## Build (Docker) |
| 22 | +Get `something-remote-firmware.bin` from [Releases](../../releases/latest). |
23 | 23 |
|
24 | | -### 1. Build Docker Image (first time only) |
| 24 | +### Flash |
25 | 25 |
|
26 | | -```bash |
27 | | -make docker-build |
28 | | -``` |
| 26 | +1. **Connect** board via USB and find the port: |
| 27 | + - Linux: `/dev/ttyUSB0` |
| 28 | + - Mac: `/dev/cu.usbserial-*` |
| 29 | + - Windows: `COM3` (check Device Manager) |
29 | 30 |
|
30 | | -### 2. Build Firmware |
| 31 | +2. **Erase and flash**: |
| 32 | + ```bash |
| 33 | + # Using uv (recommended - no install needed) |
| 34 | + uvx esptool --port /dev/ttyUSB0 erase_flash |
| 35 | + uvx esptool --port /dev/ttyUSB0 write_flash 0x0 something-remote-firmware.bin |
31 | 36 |
|
32 | | -```bash |
33 | | -make build |
34 | | -``` |
| 37 | + # Or using pip |
| 38 | + pip install esptool |
| 39 | + esptool.py --port /dev/ttyUSB0 erase_flash |
| 40 | + esptool.py --port /dev/ttyUSB0 write_flash 0x0 something-remote-firmware.bin |
| 41 | + ``` |
35 | 42 |
|
36 | | -### 3. Copy Firmware to Local Directory |
| 43 | +3. **Configure**: Connect to "SomethingRemote-Setup" WiFi (password: `12345678`), enter your WiFi and MQTT settings |
37 | 44 |
|
38 | | -```bash |
39 | | -make copy-firmware |
40 | | -``` |
| 45 | +4. **Pair**: See [Pairing with Shield](#pairing-with-shield) below |
41 | 46 |
|
42 | | -### 4. Flash to Device |
| 47 | +## LED Status |
43 | 48 |
|
44 | | -Connect Atom Echo via USB, then: |
| 49 | +| Color | State | |
| 50 | +|-------|-------| |
| 51 | +| Blue | Advertising (ready to pair) | |
| 52 | +| Green | Connected to Shield | |
| 53 | +| White | Button pressed | |
| 54 | +| Purple | Home Assistant activity | |
| 55 | +| Yellow | Setup portal active | |
| 56 | +| Red | Error or BLE forget | |
45 | 57 |
|
46 | | -```bash |
47 | | -make flash PORT=/dev/ttyUSB0 |
48 | | -``` |
| 58 | +## Button Combos |
49 | 59 |
|
50 | | -Or flash manually with esptool: |
| 60 | +| Combo | Hold Time | Action | |
| 61 | +|-------|-----------|--------| |
| 62 | +| **Power + Back** | 5 seconds | Clear BLE bonds, restart advertising (for pairing) | |
| 63 | +| **Shortcut1 + Shortcut3** | 5 seconds | Enter WiFi/MQTT setup portal | |
51 | 64 |
|
52 | | -```bash |
53 | | -pip install esptool |
54 | | -esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 build/firmware.bin |
55 | | -``` |
| 65 | +## Button Mapping |
56 | 66 |
|
57 | | -### Interactive Shell |
| 67 | +### BLE HID (Shield Control) |
| 68 | +- D-pad: Up/Down/Left/Right arrows |
| 69 | +- Select: Enter |
| 70 | +- Back: Consumer Control Back (AC Back) |
| 71 | +- Home: Consumer Control Home (AC Home) |
| 72 | +- Play/Pause, Vol+, Vol-, Mute: Consumer Control media keys |
| 73 | +- Ch+/Ch-: Page Up/Down |
58 | 74 |
|
59 | | -To debug or explore the build environment: |
| 75 | +### Home Assistant (MQTT) |
| 76 | +- Power: `power` action |
| 77 | +- Shortcuts 1-4: `shortcut_1` to `shortcut_4` actions |
| 78 | +- Brightness +/-: `brightness_up`/`brightness_down` actions |
60 | 79 |
|
61 | | -```bash |
62 | | -make shell |
63 | | -``` |
| 80 | +## Setup |
64 | 81 |
|
65 | | -## Usage |
| 82 | +### First Time Setup |
66 | 83 |
|
67 | | -1. After flashing, device starts advertising (blue LED) |
68 | | -2. On Nvidia Shield: Settings → Remote & Accessories → Add Accessory |
69 | | -3. Select "Shield Remote" |
70 | | -4. Once connected (green LED), press button to navigate right |
71 | | -5. LED flashes white on button press |
| 84 | +1. Flash firmware (see Build section) |
| 85 | +2. Device creates WiFi AP: "Something Remote Setup" |
| 86 | +3. Connect to AP, browser opens setup page |
| 87 | +4. Enter WiFi credentials and MQTT broker details |
| 88 | +5. Device restarts and connects |
72 | 89 |
|
73 | | -## Troubleshooting |
| 90 | +### Pairing with Shield |
| 91 | + |
| 92 | +1. Ensure LED is **blue** (advertising) |
| 93 | +2. If not blue, hold **Power + Back** for 5 seconds |
| 94 | +3. On Shield: Settings → Remote & Accessories → Add Accessory |
| 95 | +4. Select "Something Remote" |
| 96 | +5. LED turns **green** when connected |
| 97 | + |
| 98 | +### Re-entering Setup |
74 | 99 |
|
75 | | -- If Shield won't pair, ensure location services are enabled on Shield |
76 | | -- Use `screen /dev/ttyUSB0 115200` to view debug output |
77 | | -- Check BLE advertising with nRF Connect app on phone |
| 100 | +Hold **Shortcut1 + Shortcut3** for 5 seconds. LED turns yellow. |
| 101 | + |
| 102 | +## Power Management |
| 103 | + |
| 104 | +- **1 minute** idle → Light sleep (BLE stays active) |
| 105 | +- **5 minutes** of light sleep → Deep sleep |
| 106 | +- **Wake**: Any button press or motion (if MPU6050 installed) |
| 107 | + |
| 108 | +## Build |
| 109 | + |
| 110 | +### Prerequisites |
| 111 | + |
| 112 | +```bash |
| 113 | +# ESP-IDF v5.2.x |
| 114 | +cd ~ |
| 115 | +git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git |
| 116 | +cd esp-idf && ./install.sh esp32 && source export.sh |
| 117 | + |
| 118 | +# MicroPython |
| 119 | +cd ~ |
| 120 | +git clone https://github.com/micropython/micropython.git |
| 121 | +cd micropython && git checkout v1.24.1 && git submodule update --init |
| 122 | +make -C mpy-cross |
| 123 | +``` |
| 124 | + |
| 125 | +### Build & Flash |
| 126 | + |
| 127 | +```bash |
| 128 | +./build.sh |
| 129 | +./flash.sh /dev/ttyUSB0 |
| 130 | +``` |
78 | 131 |
|
79 | 132 | ## Project Structure |
80 | 133 |
|
81 | 134 | ``` |
82 | | -├── board/ATOM_ECHO/ # MicroPython board definition |
83 | | -├── modules/ # Python code (frozen into firmware) |
84 | | -│ ├── hid_services.py # BLE HID implementation |
85 | | -│ ├── shield_remote.py # Main application |
86 | | -│ └── main.py # Entry point |
87 | | -├── build.sh # Build script |
88 | | -└── flash.sh # Flash script |
| 135 | +├── board/ATOM_ECHO/ # MicroPython board definition |
| 136 | +├── modules/ # Python code (frozen into firmware) |
| 137 | +│ ├── shield_remote.py # Main application |
| 138 | +│ ├── hid_services.py # BLE HID implementation |
| 139 | +│ ├── hid_keystores.py # BLE bonding key storage |
| 140 | +│ ├── ha_client.py # Home Assistant MQTT client |
| 141 | +│ ├── wifi_setup.py # Captive portal for setup |
| 142 | +│ ├── config.py # Configuration storage |
| 143 | +│ ├── mpu6050_wake.py # Accelerometer motion wake |
| 144 | +│ ├── logger.py # File-based logging |
| 145 | +│ └── main.py # Entry point |
| 146 | +├── build.sh # Build script |
| 147 | +└── flash.sh # Flash script |
89 | 148 | ``` |
90 | 149 |
|
| 150 | +## Troubleshooting |
| 151 | + |
| 152 | +- **Can't pair**: Hold Power + Back 5 sec to clear bonds, then retry |
| 153 | +- **Can't see in Shield menu**: Check LED is blue, try nRF Connect app to verify advertising |
| 154 | +- **WiFi issues**: Hold Shortcut1 + Shortcut3 5 sec to re-enter setup |
| 155 | +- **Debug output**: `screen /dev/ttyUSB0 115200` |
| 156 | + |
91 | 157 | ## License |
92 | 158 |
|
93 | 159 | BLE HID library adapted from MicroPythonBLEHID (GPL-3.0). |
0 commit comments