Adaptive Trolling Autopilot for Small Boats
Powered by MicroPython, PID Control, and BNO055 Sensor Fusion
This project is a self-learning autopilot designed specifically for outboard trolling. Unlike traditional autopilots that require complex manual tuning, this system uses Passive System Identification to learn your boat's steering characteristics and automatically tunes its PID controller for optimal performance.
- ๐ง Adaptive PID Tuning: Automatically learns your boat's responsiveness (
deg/sper% power) and adjusts gains on the fly. - ๐ Continuous Control Loop: Runs a non-blocking 10Hz control loop for smooth, responsive steering in wind and waves.
- ๐งญ 9-Axis Sensor Fusion: Uses the BNO055 in NDOF mode (Quaternions) for tilt-compensated, stable heading data.
- ๐ Sea State Estimation: Monitors roll variance to detect rough water and adapt control behavior (future expansion).
- ๐พ Auto-Save: Automatically saves learned PID gains and settings to NVS memory.
- โก Non-Blocking: Fully asynchronous motor control and sensor reading.
| Component | ESP32 Pin | Notes |
|---|---|---|
| BNO055 SDA | GPIO 21 |
I2C Data |
| BNO055 SCL | GPIO 22 |
I2C Clock |
| Motor PWM | GPIO 27 |
Speed Control (0-100%) |
| Motor DIR | GPIO 26 |
Direction (High=Starboard, Low=Port) |
| Button | GPIO 33 |
Engage/Disengage (Pull-up) |
| LED | GPIO 19 |
Status Indicator |
- Controller: ESP32 DevKit V1
- Sensor: Adafruit BNO055 (or generic module)
- Motor Driver: BTS7960 (High Current) or L298N (Low Current)
- Pump: 12V Hydraulic Reversing Pump (e.g., Raymarine Type 1)
- Flash MicroPython: Install the latest MicroPython firmware on your ESP32.
- Upload Files: Upload the following files to the root directory:
main.py: Core logiclib/bno055.py: Sensor driverlib/bno055_base.py: Sensor base driverlib/motor.py: Motor controllerlib/pid.py: PID controllerlib/autotuner.py: Adaptive tuning logiclib/gps_stub.py: GPS placeholder
- Wiring: Connect hardware according to the table above.
The BNO055 needs calibration.
- Power on the system.
- Rotate the sensor/boat in figure-8 motions until the system status indicates calibration (LED behavior can be added for this).
- Note: The system saves calibration data automatically.
- Point the boat on your desired heading.
- Press the Button (GPIO 33).
- The LED will turn ON.
- The system will lock onto the current heading.
- Just drive! The system starts with "Safe" default gains.
- As it makes corrections, it measures how fast the boat turns.
- If the boat is sluggish, it increases aggressiveness.
- If the boat is twitchy, it decreases aggressiveness.
- Settings are saved every 60 seconds.
- Press the Button again.
- The LED turns OFF.
- Motor stops immediately.
โโโ main.py # Entry point & Control Loop
โโโ lib/
โ โโโ autotuner.py # Adaptive PID Logic
โ โโโ bno055.py # BNO055 Driver
โ โโโ bno055_base.py # BNO055 Base Class
โ โโโ motor.py # Non-blocking Motor Control
โ โโโ pid.py # PID Controller
โ โโโ gps_stub.py # Future GPS Integration
โโโ README.md # This file
- GPS Integration: Connect NMEA GPS for Course Over Ground (COG) hold.
- Pattern Steering: Zig-zag and Circle modes for fishing.
- WiFi UI: Web-based configuration and monitoring.