This project has two control modes:
- 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.
- 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
- remote/remote.ino
- remote/battlebot_config.h
- reciver/reciver.ino
- reciver/battlebot_config.h
- reciver_2/reciver_2.ino
- reciver_2/battlebot_config.h
In remote/remote.ino:
- Initialize serial logging if enabled.
- Configure joystick/button GPIO.
- Configure Wi-Fi station mode.
- Initialize ESP-NOW.
- Register send callback.
- Add receiver as peer using RECEIVER_MAC and ESPNOW channel.
Per loop:
- Read joystick raw ADC values (X and Y).
- Apply deadzone separately for throttle and steering.
- Map to normalized command range -1000 to 1000.
- Read arm input and weapon button.
- Generate weapon toggle event flag only on rising edge of weapon button.
The transmitter sends only when needed:
- Send immediately if control payload changed.
- Send keepalive at TX_INTERVAL_MS only while controls are active.
- Do not spam idle packets when controls are neutral.
This lowers traffic while maintaining responsiveness.
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.
In reciver/reciver.ino:
- Initialize serial logging if enabled.
- Configure status LED and weapon relay pin.
- Initialize left/right ESC outputs.
- Send neutral ESC signals and wait arm delay.
- Configure Wi-Fi station mode.
- Initialize ESP-NOW and register RX callback.
Per loop:
- Read latest packet atomically from callback-updated shared state.
- Apply failsafe timeout check.
- If timed out or disarmed, stop drive motors.
- If packet has WEAPON_TOGGLE and sequence is new, toggle relay ON/OFF once.
- Mix throttle and steering into differential left/right commands.
- Apply reverse-neutral-hold logic to avoid twitch on direction changes.
- Convert commands to ESC pulse widths.
- Apply ramp limiter and 17 ms ramp step window.
- Write pulses to left/right ESC outputs.
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.
Weapon is relay-based, not ESC pulse-based.
Behavior:
- Press weapon button on remote.
- Remote creates one toggle event in packet flags.
- Receiver checks event plus packet sequence.
- Receiver toggles relay state exactly once.
- Next press toggles it back.
This prevents repeated toggles while holding the button.
Implemented in both reciver and reciver_2:
- Neutral hold before reversing direction to reduce motor dribble/twitch.
- Full-range ramp control (1000 us to 2000 us) over configurable time.
- Ramp update window of 17 ms to control step timing.
Key effects:
- Smoother starts.
- Safer direction changes.
- Tunable response feel.
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)
reciver_2 is standalone and does not require ESP-NOW remote.
AP credentials:
- SSID: bottta
- Wi-Fi password: admin123
Panel login:
- username: admin
- password: admin123
Open in browser:
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.
Dashboard fields:
- Throttle Deadzone
- Steering Deadzone
- TX Interval (ms)
- Failsafe Timeout (ms)
- Ramp Full Sweep (ms)
In reciver_2/reciver_2.ino, settings are stored in ESP32 NVS flash using Preferences.
Flow:
- Boot loads saved values from flash.
- Save button writes new values to flash.
- Values persist across reboot/power cycle.
Use Arduino IDE or Arduino CLI:
- Install ESP32 board package.
- Select correct ESP32 board and port.
- For main pair:
- Upload remote/remote.ino to controller ESP32.
- Upload reciver/reciver.ino to receiver ESP32.
- 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)
Check:
- Correct GPIO in config headers.
- Correct receiver MAC in remote config.
- Same ESPNOW channel on both boards.
- Arm state active.
- ESCs are calibrated/armed and powered correctly.
Check:
- Relay pin mapping in receiver config.
- RelayConfig ACTIVE_HIGH value matches relay module.
- Weapon button wiring and pull-up behavior.
Check and tune:
- Reduce ramp full sweep time.
- Keep TX interval low (for example 10 ms).
- Confirm strong radio link and power supply stability.
Tune:
- Increase deadzones.
- Increase reverse neutral hold slightly.
- Verify ESC neutral pulse and calibration.
- Test on stand first with wheels/drive lifted.
- Keep weapon disconnected during initial control testing.
- Verify relay off/on behavior before weapon load.
- Confirm failsafe reaction by turning controller off.
- Keep an external kill switch when possible.
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.