Automatic pilot for motorboat with Arduino

1. A brief introduction

I’m actually developing an automatic pilot for my own motorboat. Just to avoid being at the wheel for hours in long travels. Commercial products are far away too expensive and this project gives me an opportunity to get hands on Arduino platform.

The goal of the solution is simple, make the motorboat follow a course or either a waypoint. There are a few ways to set up a course, either introducing the course by hand or navigating in a direction and pressing a button to lock the actual course. For those methods there is a keypad an LCD display that lets user see and introduce data navigating through a set of menus and functions. There is also possible to use a function in the Garmin GPS installed in my boat called “Navigation” where a waypoint is selected. The course is calculated by the GPS and data is passed to Arduino through an RS232 to TTL converter in the NMEA (National Marine Electronic Association) sentence protocol. This last option gives a more accurate navigation as course to destination waypoint is always recalculated despite of derivation caused by currents and winds.

Once course is setup the piece of logic calculates the difference between the actual course and the desired course and establishes a position for the helm to correct it. I have used a wiper motor driven by an H bridge acting over the wheel to move helm. There is a potentiometer in the axis of the helm to give feedback of its actual position so the motor acting over the wheel does not need to be accurate. Wiper motor turns and acts over the wheel until the desired helm position is acquired. Helm position is calculated every loop of the piece of software. This results in the boat turning towards the desired course until it is reached. The helm gradually returns to its centred position as the boat acquires the right course

2. Components

This is the list of components I used for my project. They are all very cheap and easy to find in Amazon or eBay.

Arduino starter Kit clone named Funduino: 51€


The kit contains the main board, plus a set of components, cabling, buttons, a breadboard to get started with the platform. Learning to use this platform is very easy. Adafruit has a full set of lessons that will guide you through that process form the very basics to more complex setups.

RS 232 to TTL converter: 4€


This interface will be used to convert RS 232 data signals coming from an external GPS into TTL signals so the Serial ports of the Arduino can handle it.

Double H Bridge: 5€


This component is a driver motor. It can control a stepper motor or a DC motor. In our case it will control the wiper motor turn direction.

Wiper motor: 12€


A Nissan Micra wiper motor. Second hand from scrapping.

LCD display with integrated buttons: 9€


The LCD display and buttons are the user interface. They are used to view and input data.

Triple axis magnetometer: 4€


The magnetometer measures the magnetic field of earth. It can be used to determine to where it is oriented an thus the course of the boat.

3. Software libraries

For each of the components I used there are libraries available from the Arduino community. They will make the use and integration of this components in the logic very straightforward. There is also a library to fetch and process sentences received from GPS in the NMEA protocol. Some of those libraries are delivered with the arduino developement platform as “IRremote.h”, to use Infrared remote controls, or Servo.h, to control a servo, and some others are found in the Arduino community. This is the full list of libraries I used:

IRRemote: to use a remote control provided in the Funduino Starter Kit or any other TV/HiFi standard remote control.

Servo: this one has been used in the developement phase to simulate the position of helm. In the final solution no servo is used but a wiper motor.

DCmotor: this library is used to control the double h bridge. It grants the ability to make the wiper motor move forward and backwards.

LiquidCrystal: this library is used to print data in the LCD screen.

TinyGPS++: This library is used to fetch data form the GPS.

EEPROM: this library will be used to store data in the Arduino persistent memory.


4. Wiring

The next schema shows how to connect Garmin GPS to an RS 232 connector. The RS 232 connector will be connected to the RS232 to TTL converter. The RS232 to TTL converter will be connected to one of the Serial ports of the Arduino board:


For testing pourposes, to emulate data sent by GarminGPS, as it can’t be unplugged from the boat, I used RealTerm and an USB to RS232 converter. With RealTerm is possible to send data to Serial port reading from a text file. The text file contains NMEA sentences. Here a photo with the connection of the USB to RS232 adapter and the RS232 to TTL converter:


This is an example of the text file emulating the data stream coming from the GPS:


Documentantion about NMEA protocol can be found on this web:

The last column of each NMEA sentence is a checksum so it has to be calculated as the TinyGPS++ library will discard wrong lines. In this website we can calculate the checksum:

5. Some photos

This are some photos illustrating the evolution of the project:


The developement process. 


Mechanical testing. This belt was a bad option. But with this mounting I could test position feedback.


This is the final mechanical instalation. A rocker arm with the wiper motor on top which rests on the rudder and makes pressure on it by its own weight. There is no reductive but wiper motor own. It has enough strenght to move the rudder. The wheel directly connected to wiper motor axis is coated with rubber to better the grip with the rudder.


The board mounted on a wooden board. In detail the input and output connections. The conection to the potentiomenter for feedback, the RS232 for GPS data and the connection to the double H bridge motor controller. Some leds indicating the state. A beep for alerts. The IR receiver for controlling the boat with an RC, yess an RC :)


Testing the whole thing in a real navigation situation. The solution responds quite well after 2 or 3 tests. But it still needs to be fine tuned.

Using Motor Driver BTS7960 43A on Arduino

This tutorial guides you through plugging and using the BTS7960 43A Motor Driver with an Arduino board. This is a very cheap motor driver with good specs that can handle a powerful motor. I’ve also writen a library that can be downloaded to ease up things.


1. BTS7960-43A Motor Driver

BTS7960 43A

I bought one of them on eBay for only 14 € but there was very little documentation on the internet about how to plug and use this Motor Driver with an Arduino board. So let’s see how to plug it to arduino first.

2. Pluggin the Motor Driver with Arduino

Motor Driver – Arduino

VCC - 5v output 
R_EN - Arduino Digital I/O (can also be connected to +5v)
L_EN - Arduino Digital I/O (can also be connected to +5v)
RPWM - Arduino analog output LPWM - Arduino analog output


3. Using the Motor Driver

Let’s say we used pins 2 and 3 for PWM and 44, 45 as digital I/O for R_EN and L_EN.

To turn Right we should put on HIGH both R_EN and L_EN and then set an analog value to RPWM between 0 and 255 being 0 stoped and 255 full throttle. So it would look like:

analogWrite(2,255); <- Turn
delay(2000); <-For a bit
analogWrite(2,0);  <- Stop turn (can also be used a digitalWrite(2,
                      LOW); to set a 0 to the output of the pin)

Turning Left would mean  set a value between 0 and 255 for LPWM pin always with the RPWM on 0 or LOW


To stop the motor we should set any PWM pin to 0 and R_EN and L_EN to LOW:



3. Library

To ease things up I wrote a library that can be downloaded from here: BTS7960MotorDriver

To use it you have to declare the object this way:

BTS7960MotorDriver objectname(R_EN,L_EN,RPWM,LPWM);

BTS7960MotorDriver mypowermotor(44,45,2,3);

To turn Right:


That’s it. Ready() is not needed if L_EN and R_EN pins are conected to +5v.

Ready() puts L_EN and R_EN on HIGH.

Stop() puts all pins to LOW.


And that’s all. Any comments are welcome.

TODO: define a brake function so motor can be in 2 states free wheeling and braked.