Project files
11 KB
Machine-translated by Robotheca from the original in Japanese (opens in a new tab). License: MIT (opens in a new tab).
Examples
This folder contains Arduino sketches for controlling the M5Stack Q-Spider quadruped robot.
Folder Structure
| Folder | Description |
|---|---|
M5_Spider_Webserver | Control the robot from a web browser via WiFi. |
M5_Spider_esp-now | Control the robot with a game controller using ESP-NOW communication. |
ESP32_ChipInfo | Utility sketch to check the ESP32 chip info and MAC address. |
Common Requirements
- M5Stack Basic (ESP32 based)
- SG-90 or compatible 9g servos × 9
- PCA9685 servo driver module (I2C address:
0x72) - Arduino IDE with the following libraries:
M5Stack/M5UnifiedAdafruit PWM Servo Driver Library(for PCA9685)M5StackUpdater
An Arduino IDE with the following libraries installed is required.
M5Stack/M5UnifiedAdafruit PWM Servo Driver Library(for PCA9685)M5StackUpdater
The servo channel assignment is common across all sketches.
The servo channel assignment is common across all sketches.
| Channel | Function | Function |
|---|---|---|
| 0 | FR0 | Front Right knee / Front right leg knee joint |
| 1 | FR1 | Front Right leg swing / Front right leg swing |
| 2 | FL0 | Front Left knee / Front left leg knee joint |
| 3 | FL1 | Front Left leg swing / Front left leg swing |
| 4 | TILT | Head tilt / Head tilt |
| 6 | RR0 | Rear Right knee / Rear right leg knee joint |
| 7 | RR1 | Rear Right leg swing / Rear right leg swing |
| 8 | RL0 | Rear Left knee / Rear left leg knee joint |
| 9 | RL1 | Rear Left leg swing / Rear left leg swing |
M5_Spider_Webserver
By default, this sketch starts the M5Stack as a standalone WiFi access point and serves a simple web controller on port 80.
By default, this sketch starts the M5Stack as a standalone WiFi access point and serves a simple web controller on port 80.
Features / 機能
-
Standalone WiFi access point mode by default
-
Optional WiFi setup via
WiFiManager(captive portal) -
OTA (Over The Air) firmware updates in WiFiManager mode
-
Web UI with buttons for forward, backward, left/right shift, spin, and stop
-
Face animation (eye blink, mouth open) on the M5Stack LCD
-
Calibration mode (
adjMode) triggered when powered on while charging -
Operates as a standalone WiFi access point by default
-
WiFi configuration is also available via
WiFiManager(captive portal) -
Supports firmware updates via OTA in WiFiManager mode
-
Web UI for forward, backward, left/right shift, spin, and stop operations
-
Displays face animations (eye blinks, mouth movements) on the M5Stack LCD
-
Entering calibration mode (
adjMode) by turning on the power while charging
WiFi Mode / WiFi Mode
usesoftAP is defined by default near the top of M5_Spider_Webserver.ino. In this mode, the M5Stack creates an access point named ESP32-xxxx with the password esp32. Connect directly to it and open http://192.168.4.1/.
In M5_Spider_Webserver.ino, usesoftAP is defined by default near the top. In this mode, the M5Stack creates an access point named ESP32-xxxx with the password esp32. Connect directly to it and open http://192.168.4.1/.
To connect the M5Stack to an existing WiFi access point instead, comment out #define usesoftAP. The sketch then uses the WiFiManager portal for network configuration and enables OTA updates.
To connect the M5Stack to an existing WiFi access point instead, comment out #define usesoftAP. In that case the WiFiManager configuration portal is used, and OTA updates are also enabled.
How to Use / How to Use
-
Open
M5_Spider_Webserver.inoin Arduino IDE. -
Select the
M5Stack-Core-ESP32board. -
Keep
#define usesoftAPenabled for standalone AP mode, or comment it out for WiFiManager mode. -
Upload the sketch to M5Stack.
-
Connect to the AP name displayed on the LCD.
-
Open the IP address shown on the LCD with a browser.
-
Open
M5_Spider_Webserver.inoin Arduino IDE. -
Select the
M5Stack-Core-ESP32board. -
In standalone AP mode, keep
#define usesoftAPenabled; in WiFiManager mode, comment it out. -
Upload the sketch to M5Stack.
-
Connect to the access point name shown on the LCD.
-
Open the IP address shown on the LCD in a browser.
Main Files / 主なファイル
-
M5_Spider_Webserver.ino: Main sketch -
WebPage.h: HTML for the web controller -
wifi_setup.cpp/h: WiFi connection helper and OTA setup -
avatar.cpp/h: Face animation class -
M5_Spider_Webserver.ino: Main sketch -
WebPage.h: HTML for the web controller -
wifi_setup.cpp/h: WiFi connection helper and OTA setup -
avatar.cpp/h: Face animation class
M5_Spider_esp-now
This sketch receives control commands wirelessly from a custom ESP-NOW controller (such as M5AtomPad) and drives the robot.
This sketch receives control commands wirelessly from a custom ESP-NOW controller (such as M5AtomPad) and drives the robot.
Features
-
ESP-NOW peer-to-peer communication
-
NES (Famicom) style gamepad input support
-
Continuous walking/spinning controlled by flags
-
FreeRTOS face animation task on Core 0
-
Two machine presets (
modeNES = 1for SpiderW,modeNES = 2for SpiderB) for per-unit calibration -
Calibration mode triggered by charging detection (define
chgDETto enable) -
ESP-NOW peer-to-peer communication
-
NES (Famicom) style gamepad input support
-
Continuous walking/spinning controlled by flags
-
FreeRTOS face animation task on Core 0
-
Two machine presets (
modeNES = 1for SpiderW,modeNES = 2for SpiderB) for per-unit calibration -
Calibration mode triggered by charging detection (enabled by defining
chgDET)
Controller Button Mapping / コントローラのボタン割り当て
| NES Button | Command | Action / 動作 |
|---|---|---|
| UP | rNES_UP | Walk forward / 前進 |
| DOWN | rNES_DOWN | Walk backward / 後退 |
| LEFT | rNES_LEFT | Shift left / 左移動 |
| RIGHT | rNES_RIGHT | Shift right / 右移動 |
| A | rNES_A | Spin right / 右旋回 |
| B | rNES_B | Spin left / 左旋回 |
| START/SELECT | - | Reserved / 予約 |
| (no input) | rNES_STOP | Stop / 停止 |
How to Use / How to Use
-
Open
M5_Spider_esp-now.inoin Arduino IDE. -
Set
modeNESto match your robot unit (1 or 2). -
Make sure the controller MAC address is registered in the
OnDataRecvfilter. -
Upload the sketch to M5Stack.
-
Power on the ESP-NOW controller and gamepad.
-
Open
M5_Spider_esp-now.inoin Arduino IDE. -
Set
modeNESto 1 or 2 to match your robot unit. -
Make sure the controller MAC address is registered in the
OnDataRecvfilter. -
Upload the sketch to M5Stack.
-
Power on the ESP-NOW controller and gamepad.
Main Files
-
M5_Spider_esp-now.ino: Main sketch -
avatar.cpp/h: Face animation class -
M5_Spider_esp-now.ino: Main sketch -
avatar.cpp/h: Face animation class
For the transmitter side, see the M5AtomPad repository.
For the transmitter side, see the M5AtomPad repository.
https://github.com/tomorrow56/M5AtomPad (opens in a new tab)
When registering a controller in the OnDataRecv MAC filter, you can use ESP32_ChipInfo on each M5Stack to check its MAC address.
When registering a controller in the OnDataRecv MAC address filter, you can run ESP32_ChipInfo on each M5Stack to check its MAC address.
ESP32_ChipInfo
A simple utility sketch that prints ESP32 chip information (model, features, core count, revision, flash size, and most importantly the MAC address) to the Serial Monitor.
A simple utility sketch that prints ESP32 chip information (model, features, core count, revision, flash size, and most importantly the MAC address) to the Serial Monitor.
Use Case / 用途
Useful for checking the MAC address of an M5Stack unit before registering it as an ESP-NOW peer (see M5_Spider_esp-now) or before hardcoding a peer's MAC address in a controller sketch.
Useful for checking the MAC address of an M5Stack unit before registering it as an ESP-NOW peer (see M5_Spider_esp-now) or before hardcoding a peer's MAC address in a controller sketch.
How to Use / 使い方
-
Open
ESP32_ChipInfo.inoin Arduino IDE. -
Upload the sketch to the M5Stack.
-
Open the Serial Monitor at 115200 baud.
-
The chip model, features, core count, revision, MAC address, flash size, and chip ID are printed once at startup.
-
Open
ESP32_ChipInfo.inoin Arduino IDE. -
Upload the sketch to the M5Stack.
-
Open the Serial Monitor at 115200 baud.
-
The chip model, features, core count, revision, MAC address, flash size, and chip ID are printed once at startup.
Main Files / 主なファイル
-
ESP32_ChipInfo.ino: Main sketch -
ESP32_ChipInfo.ino: Main sketch
Calibration
All sketches provide a calibration mode that moves every servo to its center position. This is useful during mechanical assembly.
いずれのスケッチでも、すべてのサーボをセンター位置に移動するキャリブレーションモードがあります。機械的な組み立て時に便利です。
-
Web versions: Enter calibration mode automatically when powered on while M5Stack is charging.
-
ESP-NOW version: Define
chgDETat the top of the sketch to enable the same behavior. -
Web版:M5Stackの充電中に電源を入れると、自動的にキャリブレーションモードへ移行します。
-
ESP-NOW版:スケッチ先頭で
chgDETを定義すると、同じ動作が有効になります。
| Sketch | Calibration Trigger / トリガ |
|---|---|
M5_Spider_Webserver | Power on while charging / 充電中に電源ON |
M5_Spider_Webserver_task | Power on while charging / 充電中に電源ON |
M5_Spider_esp-now | Enable chgDET then power on while charging / chgDETを有効にして充電中に電源ON |
Press the B button to exit calibration mode.
Bボタンでキャリブレーションモードを終了します。
Files by @tomorrow56, at commit 07778c2, read from GitHub in your browser. Hardware license: MIT; software license: MIT. Robotheca doesn't review code: read it before running it.