Turn your M5Stack Stick Plus2 into a Bluetooth AirMouse that controls your iPhone, iPad, Mac, or PC via motion and buttons.
- Hardware:
- M5Stack Stick Plus2 (ESP32-based)
- Software:
- Arduino IDE
- ESP32 board core (v2.0.11 recommended)
- Libraries:
-
Install Board:
- Open Arduino IDE → File → Preferences
- Add this URL to Additional Board Manager URLs:
https://espressif.github.io/arduino-esp32/package_esp32_index.json - Go to Tools → Board → Boards Manager
- Search for esp32
- Install version 2.0.11
-
Install Libraries:
- Go to Sketch → Include Library → Manage Libraries
- Search and install:
- M5Unified
- ESP32 BLE Mouse
- (If errors appear, patch the BLE Mouse library as per issue #150)
-
Select Board:
- Tools → Board → M5Stack → M5Stick-C Plus2
-
Upload the Code
- Connect your M5Stick via USB-C
- Select correct port under Tools → Port
- Upload the provided
.inosketch
- The gyroscope inside the M5Stick senses motion.
- The ESP32 BLE acts as a Bluetooth mouse.
- Movement of the device moves the mouse pointer.
- Buttons:
- Button A → Left Click
- Button B → Right Click
- Open Settings → Bluetooth
- Turn on M5Stick — it will broadcast as M5 AirMouse
- Tap “M5 AirMouse” to pair
- Move the device to control the cursor
- On iPhone/iPad, go to Accessibility → Touch → AssistiveTouch → Devices → Pointing Devices to enable mouse control.
To invert or tune motion sensitivity, modify these lines:
int moveX = (int)(-gyroY / 6);
int moveY = (int)(gyroX / 6);Change the divisor (/6) to alter sensitivity.
- Developer: Sachin
- Core Libraries: M5Unified, ESP32 BLE Mouse