The Autonomous Sumobot Challenger is a compact robot designed to compete in sumo ring competitions using an ESP32 microcontroller as its brain. Powered by a protected 2S 18650 battery pack and equipped with dual TT motors, ultrasonic distance sensing, and infrared line tracking, this bot autonomously detects opponents and ring edges while executing strategic movement patterns.
This guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions for building a fully functional sumobot. You'll learn how to set up protected power distribution with dual voltage regulators, configure the TB6612FNG motor driver with I2C port expansion, integrate sensor feedback, and upload the autonomous control firmware that handles obstacle detection, edge avoidance, and combat logic.
Wiring diagram

Gather all the parts
Assemble it in 7 steps
1. Lay out the robot electronics
Put the protected battery, fuse, switch, Mini360, motor buck and diode on the left; XIAO and MCP23017 in the center; sonar at the front/top, IR sensors at the front corners/bottom, and TB6612 plus motors on the right. Labels in the circuit identify 2S BAT (7.4V nominal, 8.4V maximum), +5V, +4.5V_VM, 3V3 and GND.
2. Build protected power distribution
With the pack unplugged, connect P+ through the 3A fuse and SPST toggle to both regulator inputs. Connect P- to the shared GND. Use insulated soldered connections and short power wires rated at least 5A; do not route motor current through a breadboard or XIAO. Return driver and regulators directly to P-; run a separate logic ground branch.
- Buy a factory-built protected and balanced 2S 18650 pack rated at least 5A. Do not solder directly onto loose cells. Never connect 8.4V to the XIAO BAT pads.
- Disconnect the pack from the robot to charge with a compatible 8.4V CC/CV lithium-ion charger. BMS protection is not a charger.
3. Adjust and check both regulators
Before attaching electronics, use a meter to adjust Mini360 to 5.00V and the LM2596 motor module to 4.50V. Use a motor regulator module verified for 2A continuous operation with suitable cooling. Stop using the robot when either regulated rail drops out; the BMS cutoff is emergency protection, not a normal stopping point. Connect the diode banded end to XIAO 5V and its other end to Mini360 OUT+.
- Verify voltages under load and at low battery voltage. Mini360 performance varies between clones.
- Switch off and unplug the battery before USB deployment. Never use the 5V logic regulator to power motors.
4. Wire motor protection and standby
Connect driver VM to regulated 4.5V, VCC to XIAO 3V3 and GND to shared GND. Place the 100µF capacitor close to VM/GND, positive to VM. Place 100nF at driver VCC/GND and one 100nF across each motor's terminals. Connect STBY to D10 and a 10kΩ resistor to GND so motors remain disabled during reset. Connect motor terminals to AO1/AO2 and BO1/BO2.
- Selected 1:90 bi-metal TT motors measure about 0.8A stalled at 4.5V. Measure your samples; reject motors exceeding the driver continuous rating. Avoid sustained stalls and validate temperatures before competition.
5. Connect extra control pins
Use MCP23017 DIP pins 9=3V3, 10=GND, 12=SCL to D5, 13=SDA to D4, 15/16/17=GND for address 0x20, 18=RESET through 10kΩ to 3V3. Put a 4.7kΩ resistor from each I2C line to 3V3. GPA0..3 (pins 21..24) connect AIN1, AIN2, BIN1, BIN2. GPA4/5 (pins 25/26) read left/right IR OUT. GPA6 (pin 27) reads the start button; its other leg goes to GND. Leave unused GPIO and interrupt pins open. Place 100nF at VDD/VSS and another at XIAO 3V3/GND. D1 and D2 drive PWMA and PWMB. D0, D8, D9, D6 and D7 are unused.
6. Connect the sensors
Power both IR modules at 3.3V; OUT is called DO on the diagram. Power HC-SR04 at 5V and connect TRIG to MCP23017 GPA7 (DIP pin 28, 3.3V TTL trigger). ECHO goes through 1kΩ to the junction connected to D3; 2kΩ goes from that junction to GND. This reduces a 5V echo to about 3.33V. Mount the IR sensors a few millimeters above the floor, ahead of the wheels.
7. Test before entering the ring
Lift the wheels. Check that both wheels drive forward; swap a motor's two leads with power removed if reversed. With robot stopped, inspect serial edge readings over the actual black ring and white border. Adjust both sensor pots: readings must report 0 on black and 1 on white. If necessary change EDGE_LEVEL in firmware. Press start for a five-second countdown; pressing again stops. Confirm border retreat, obstacle pursuit, and switch shutdown. Check total assembled mass is below 1kg and follow your competition's start rules.
- This is a buildable reference design, not a certified production product. Validate stall current, battery protection, regulator loading, sensor response and thermal behavior on the assembled robot before arena use.
Review all connections
1. Connections between "battery" and "ESP32"
2. Connections between "fuse" and "ESP32"
3. Connections between "switch" and "ESP32"
4. Connections between "logicbuck" and "ESP32"
5. Connections between "motorbuck" and "ESP32"
6. Connections between "diode" and "ESP32"
7. Connections between "bulk" and "ESP32"
8. Connections between "driver" and "ESP32"
9. Connections between "sonar" and "ESP32"
10. Connections between "leftir" and "ESP32"
11. Connections between "rightir" and "ESP32"
12. Connections between "io" and "ESP32"
13. Connections between "start" and "ESP32"
14. Connections between "echoBottom" and "ESP32"
15. Connections between "standbyPull" and "ESP32"
16. Connections between "sdaPull" and "ESP32"
17. Connections between "sclPull" and "ESP32"
18. Connections between "resetPull" and "ESP32"
19. Connections between "echoTop" and "ESP32"
20. Connections between "logicCap" and "ESP32"
21. Connections between "ioCap" and "ESP32"
22. Connections between "driverCap" and "ESP32"
23. Connections between "leftmotorCap" and "ESP32"
24. Connections between "rightmotorCap" and "ESP32"
Deploy the firmware
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_MCP23X17.h>
Adafruit_MCP23X17 io;
constexpr int PWM_L=3,PWM_R=4,ENABLE=10,ECHO=5;
// Verify white-border polarity on your actual modules before arena operation.
constexpr int EDGE_LEVEL=HIGH;
bool ready=false,active=false,lastButton=false;
uint32_t startAt=0,phaseAt=0,lastPing=0,lastPress=0;
int phase=0,turn=1,distanceCm=0;
void stop(){digitalWrite(ENABLE,LOW);analogWrite(PWM_L,0);analogWrite(PWM_R,0);}
void drive(int l,int r){
digitalWrite(ENABLE,LOW);analogWrite(PWM_L,0);analogWrite(PWM_R,0);
uint8_t bits=(l>0?1:l<0?2:0)|(r>0?4:r<0?8:0);
io.writeGPIOA(bits); // Input pins GPA4..6 retain pull-ups configured below.
analogWrite(PWM_L,abs(l));analogWrite(PWM_R,abs(r));digitalWrite(ENABLE,HIGH);
}
void setup(){
pinMode(ENABLE,OUTPUT);stop();pinMode(PWM_L,OUTPUT);pinMode(PWM_R,OUTPUT);
pinMode(ECHO,INPUT);
Serial.begin(115200);Wire.begin(6,7);Wire.setClock(400000);Wire.setTimeOut(10);
if(!io.begin_I2C(0x20,&Wire)){Serial.println("STOP: expander missing");return;}
for(int i=0;i<4;i++){io.digitalWrite(i,LOW);io.pinMode(i,OUTPUT);}
for(int i=4;i<=6;i++)io.pinMode(i,INPUT_PULLUP);
io.digitalWrite(7,LOW);io.pinMode(7,OUTPUT);ready=true;Serial.println("Stopped. Verify edges, then press start. Five second delay.");
}
void loop(){
if(!ready){stop();delay(20);return;}
Wire.beginTransmission(0x20);if(Wire.endTransmission()!=0){stop();active=false;delay(20);return;}
uint8_t inputs=io.readGPIOA();
bool left=((inputs>>4)&1)==EDGE_LEVEL,right=((inputs>>5)&1)==EDGE_LEVEL;
bool button=!(inputs&(1<<6));uint32_t now=millis();
if(button&&!lastButton&&now-lastPress>250){lastPress=now;active=!active;startAt=now;phase=0;stop();}
lastButton=button;
if(!active){stop();static uint32_t printed=0;if(now-printed>500){printed=now;Serial.printf("Edge L=%d R=%d (must be 0 on black, 1 on white)\n",left,right);}delay(3);return;}
if(now-startAt<5000){stop();delay(3);return;}
if(phase==0&&(left||right)){turn=left?1:-1;phase=1;phaseAt=now;drive(-170,-170);}
if(phase==1){if(now-phaseAt<220){delay(2);return;}phase=2;phaseAt=now;drive(170*turn,-170*turn);}
if(phase==2){if(now-phaseAt<250){delay(2);return;}phase=0;}
if(left||right){drive(-170,-170);return;}
if(now-lastPing>=60){lastPing=now;io.digitalWrite(7,HIGH);delayMicroseconds(10);io.digitalWrite(7,LOW);unsigned long us=pulseIn(ECHO,HIGH,6000);distanceCm=us?us/58:0;}
if(distanceCm>=2&&distanceCm<60)drive(220,220);else drive(130,-130);
delay(2);
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




