Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MuShibo/Micro-Wheeled_leg-Robot/llms.txt
Use this file to discover all available pages before exploring further.
Several parameters in the firmware need to match your hardware and environment before you flash. The most important ones are the WiFi mode, the pitch balance zero-point, and the motor supply voltage. The sections below walk through each configurable area, explain what it does, and show the exact lines to edit in the source files.
Before making any permanent changes, read through all sections and note the values you intend to change. The three files you will touch are 3.Software/wl_pro_robot/wifi.cpp (WiFi credentials and mode) and 3.Software/wl_pro_robot/wl_pro_robot.ino (all other parameters).
WiFi Mode
The firmware supports two WiFi modes. AP mode (the default) turns the ESP32 into a wireless access point — the robot broadcasts its own hotspot network and you connect your phone or laptop directly to it. STA mode connects the robot as a client to an existing WiFi router, which can be convenient on a workbench where other devices are already on the same network.
The AP credentials are defined at the top of wifi.cpp:
// wifi.cpp — AP mode configuration
const char *AP_SSID = "WLROBOT";
const char *AP_PSW = "12345678";
IPAddress AP_IP(192, 168, 1, 11);
IPAddress AP_GATEWAY(192, 168, 1, 11);
IPAddress AP_SUBNET(255, 255, 255, 0);
In AP mode the robot is always reachable at 192.168.1.11. Open a browser on your phone or laptop (Chrome or Firefox recommended) and navigate to that address to access the control interface.
Switching to STA mode
To have the robot join your existing network instead, edit the STA credentials in wifi.cpp:
// wifi.cpp — STA mode credentials (edit these two lines)
char *sta_ssid = "YourNetworkName";
char *sta_password = "YourNetworkPassword";
Then, in wl_pro_robot.ino inside setup(), comment out the AP call and uncomment the STA call:
// wl_pro_robot.ino — setup(), WiFi initialisation block
// Default: AP mode (robot creates its own hotspot)
// WiFi_SetAP();
// Switch to STA mode: robot joins your existing network
set_sta_wifi();
In STA mode the robot’s IP address is assigned by your router’s DHCP server. The assigned address is printed to the Serial Monitor at 115200 baud during boot so you can find it.
Balance Zero-Point
angle_zeropoint defines the pitch angle (in degrees, from the MPU6050) at which the LQR balance controller treats the robot as perfectly upright. The default value is -2.25 degrees, which compensates for the physical tilt of the IMU board relative to the robot’s true vertical axis.
// wl_pro_robot.ino
float angle_zeropoint = -2.25;
If the robot consistently drifts or leans after standing, adjust this value:
- Leans forward at rest → decrease
angle_zeropoint (make it more negative, e.g. -3.0)
- Leans backward at rest → increase
angle_zeropoint (e.g. -1.5 or towards 0)
The firmware also includes an adaptive zero-point correction (pid_zeropoint) that trims angle_zeropoint automatically in small increments while the robot is stationary and balanced. A good initial calibration reduces how much work the adaptive system needs to do.
To find the best starting value for angle_zeropoint, place the robot on a flat surface, hold it perfectly balanced by hand, and read the raw mpu6050.getAngleY() value from the Serial Monitor. Set angle_zeropoint to that reading. The robot should then stand with minimal correction effort.
Motor Voltage
The motor driver voltage must match your actual battery output. The firmware is configured for a 2S LiPo battery:
// wl_pro_robot.ino — driver setup
driver1.voltage_power_supply = 8; // nominal ~50% charge voltage for 2S LiPo
driver2.voltage_power_supply = 8;
motor1.voltage_sensor_align = 6; // voltage used during FOC encoder alignment
motor2.voltage_sensor_align = 6;
voltage_power_supply tells SimpleFOC the maximum voltage available so it can scale PWM duty cycles correctly. Typical 2S LiPo voltages are:
| Battery State | Voltage | Suggested voltage_power_supply |
|---|
| Fully charged | 8.4 V | 8.4 |
| Nominal / 50% | 7.4–8.0 V | 8 (default) |
| Low (near cutoff) | ~7.0 V | 7 |
voltage_sensor_align (6 V) is the voltage applied to the motor phases during the one-time FOC encoder alignment that runs on every boot. Lowering this value reduces the audible click and motor jerk at startup; raising it ensures reliable alignment with high-resistance motors.
I2C Pin Assignments
The ESP32 manages two independent I2C buses to avoid address conflicts between the two AS5600 magnetic encoders (both share address 0x36).
| Bus | SDA GPIO | SCL GPIO | Speed | Connected Devices |
|---|
I2C 0 (I2Cone) | GPIO 19 | GPIO 18 | 400 kHz | Left wheel encoder (AS5600) |
I2C 1 (I2Ctwo) | GPIO 23 | GPIO 5 | 400 kHz | Right wheel encoder (AS5600) + IMU (MPU6050) |
These are initialised in setup() and should not need to be changed unless you are adapting the firmware for a different PCB layout:
// wl_pro_robot.ino — encoder I2C initialisation
I2Cone.begin(19, 18, 400000UL); // SDA=19, SCL=18 — left encoder
I2Ctwo.begin(23, 5, 400000UL); // SDA=23, SCL=5 — right encoder + IMU
Serial Ports
The firmware uses two UART ports for different purposes:
| Port | TX/RX GPIOs | Baud Rate | Purpose |
|---|
Serial (UART0) | GPIO 1 / 3 (USB) | 115,200 | Debug output + SimpleFOC Commander |
Serial2 (UART2) | GPIO 17 / 16 | 1,000,000 | FEETECH STS3032 servo bus |
Serial is used to print battery voltage, FOC motor initialisation status, and the WiFi IP address. It also carries the SimpleFOC Commander interface, which lets you tune LQR PID parameters in real time by sending single-character commands from the Serial Monitor (e.g. A maps to pid_angle, B to pid_gyro, and so on through L for lpf_roll).
Serial2 runs at 1 Mbaud to match the FEETECH STS3032 smart servo protocol. This port is dedicated to leg servo communication and is initialised early in setup():
// wl_pro_robot.ino — serial initialisation
Serial.begin(115200); // USB debug / Commander
Serial2.begin(1000000); // STS3032 servo bus