Skip to content

About

ESP32 battle bot control system with two operating modes: a low-latency ESP-NOW remote/receiver pair and a standalone web-dashboard receiver mode. It includes differential drive control for dual ESC motors, relay-based weapon toggle logic, configurable failsafe behavior, command/ramp tuning, and persistent web settings saved to ESP32 flash.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battle Bot Control System - Full Documentation

1. Project Overview

This project has two control modes:

  1. Main ESP-NOW mode (controller + receiver)
  • Controller board reads joystick and weapon button.
  • Controller sends control packets over ESP-NOW.
  • Receiver board drives left/right ESC motors and toggles weapon relay.
  1. Web Panel mode (receiver-only variant)
  • ESP32 creates a Wi-Fi Access Point.
  • A browser dashboard sends WASD and E commands.
  • Settings are editable in the web panel and saved to ESP32 flash.

Current workspace folders:

  • remote
  • reciver
  • reciver_2

2. File Map

Main ESP-NOW mode

  • remote/remote.ino
  • remote/battlebot_config.h
  • reciver/reciver.ino
  • reciver/battlebot_config.h

Web panel mode

  • reciver_2/reciver_2.ino
  • reciver_2/battlebot_config.h

3. Main ESP-NOW Mode - Step by Step

3.1 Remote startup flow

In remote/remote.ino:

  1. Initialize serial logging if enabled.
  2. Configure joystick/button GPIO.
  3. Configure Wi-Fi station mode.
  4. Initialize ESP-NOW.
  5. Register send callback.
  6. Add receiver as peer using RECEIVER_MAC and ESPNOW channel.

3.2 Remote input processing

Per loop:

  1. Read joystick raw ADC values (X and Y).
  2. Apply deadzone separately for throttle and steering.
  3. Map to normalized command range -1000 to 1000.
  4. Read arm input and weapon button.
  5. Generate weapon toggle event flag only on rising edge of weapon button.

3.3 Remote send policy (optimized)

The transmitter sends only when needed:

  1. Send immediately if control payload changed.
  2. Send keepalive at TX_INTERVAL_MS only while controls are active.
  3. Do not spam idle packets when controls are neutral.

This lowers traffic while maintaining responsiveness.

3.4 Packet format

Shared packet struct:

  • sequence: Monotonic packet ID for duplicate/event handling.
  • throttle: -1000..1000
  • steering: -1000..1000
  • flags: bit flags (weapon toggle event)
  • armed: 0 or 1

Weapon event flag:

  • WEAPON_TOGGLE bit is a one-shot event.

3.5 Receiver startup flow

In reciver/reciver.ino:

  1. Initialize serial logging if enabled.
  2. Configure status LED and weapon relay pin.
  3. Initialize left/right ESC outputs.
  4. Send neutral ESC signals and wait arm delay.
  5. Configure Wi-Fi station mode.
  6. Initialize ESP-NOW and register RX callback.

3.6 Receiver runtime flow

Per loop:

  1. Read latest packet atomically from callback-updated shared state.
  2. Apply failsafe timeout check.
  3. If timed out or disarmed, stop drive motors.
  4. If packet has WEAPON_TOGGLE and sequence is new, toggle relay ON/OFF once.
  5. Mix throttle and steering into differential left/right commands.
  6. Apply reverse-neutral-hold logic to avoid twitch on direction changes.
  7. Convert commands to ESC pulse widths.
  8. Apply ramp limiter and 17 ms ramp step window.
  9. Write pulses to left/right ESC outputs.

3.7 Failsafe behavior

Current main failsafe is 50 ms.

  • If packet stream stops for longer than failsafe window, drive motors go neutral.
  • Weapon relay is event-toggle based and not repeatedly rewritten each loop.

4. Weapon Relay Logic (Main Receiver)

Weapon is relay-based, not ESC pulse-based.

Behavior:

  1. Press weapon button on remote.
  2. Remote creates one toggle event in packet flags.
  3. Receiver checks event plus packet sequence.
  4. Receiver toggles relay state exactly once.
  5. Next press toggles it back.

This prevents repeated toggles while holding the button.

5. ESC Drive Logic

Implemented in both reciver and reciver_2:

  1. Neutral hold before reversing direction to reduce motor dribble/twitch.
  2. Full-range ramp control (1000 us to 2000 us) over configurable time.
  3. Ramp update window of 17 ms to control step timing.

Key effects:

  • Smoother starts.
  • Safer direction changes.
  • Tunable response feel.

6. Main Tuning Parameters

In both main config files:

  • remote/battlebot_config.h
  • reciver/battlebot_config.h

Primary section:

  • UserTuning::THROTTLE_DEADZONE
  • UserTuning::STEERING_DEADZONE
  • UserTuning::TX_INTERVAL_MS
  • UserTuning::FAILSAFE_TIMEOUT_MS
  • UserTuning::RAMP_FULL_SWEEP_TIME_MS

Other important sections:

  • ReceiverPins (ESC and relay GPIO)
  • MotorConfig (invert left/right)
  • EscConfig (pulse limits, reverse hold, ramp window)

7. Web Panel Mode (reciver_2)

reciver_2 is standalone and does not require ESP-NOW remote.

7.1 Network and login

AP credentials:

  • SSID: bottta
  • Wi-Fi password: admin123

Panel login:

  • username: admin
  • password: admin123

Open in browser:

7.2 Control behavior

Keys:

  • W A S D for drive
  • E for weapon relay toggle

Transport optimization:

  • Commands send on key-state change.
  • Keepalive sends only while controls are active.

7.3 Settings editable in web panel

Dashboard fields:

  • Throttle Deadzone
  • Steering Deadzone
  • TX Interval (ms)
  • Failsafe Timeout (ms)
  • Ramp Full Sweep (ms)

7.4 Flash persistence

In reciver_2/reciver_2.ino, settings are stored in ESP32 NVS flash using Preferences.

Flow:

  1. Boot loads saved values from flash.
  2. Save button writes new values to flash.
  3. Values persist across reboot/power cycle.

8. Build and Upload

Use Arduino IDE or Arduino CLI:

  1. Install ESP32 board package.
  2. Select correct ESP32 board and port.
  3. For main pair:
  • Upload remote/remote.ino to controller ESP32.
  • Upload reciver/reciver.ino to receiver ESP32.
  1. For web mode:
  • Upload reciver_2/reciver_2.ino to receiver ESP32.

Required libraries:

  • WiFi
  • esp_now (from ESP32 core)
  • ESP32Servo
  • WebServer (for reciver_2)
  • Preferences (for reciver_2)

9. Typical Troubleshooting

9.1 No movement

Check:

  1. Correct GPIO in config headers.
  2. Correct receiver MAC in remote config.
  3. Same ESPNOW channel on both boards.
  4. Arm state active.
  5. ESCs are calibrated/armed and powered correctly.

9.2 Weapon relay does not toggle

Check:

  1. Relay pin mapping in receiver config.
  2. RelayConfig ACTIVE_HIGH value matches relay module.
  3. Weapon button wiring and pull-up behavior.

9.3 Too much latency

Check and tune:

  1. Reduce ramp full sweep time.
  2. Keep TX interval low (for example 10 ms).
  3. Confirm strong radio link and power supply stability.

9.4 Motors twitch near center

Tune:

  1. Increase deadzones.
  2. Increase reverse neutral hold slightly.
  3. Verify ESC neutral pulse and calibration.

10. Safety Notes

  1. Test on stand first with wheels/drive lifted.
  2. Keep weapon disconnected during initial control testing.
  3. Verify relay off/on behavior before weapon load.
  4. Confirm failsafe reaction by turning controller off.
  5. Keep an external kill switch when possible.

11. Current Defaults (Important)

Main mode defaults currently include:

  • TX interval: 10 ms
  • Failsafe timeout: 50 ms
  • Ramp full sweep: 1000 ms
  • Ramp step window: 17 ms

Web mode defaults can be changed live and persisted from panel settings.

About

ESP32 battle bot control system with two operating modes: a low-latency ESP-NOW remote/receiver pair and a standalone web-dashboard receiver mode. It includes differential drive control for dual ESC motors, relay-based weapon toggle logic, configurable failsafe behavior, command/ramp tuning, and persistent web settings saved to ESP32 flash.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages