Raspberry Pi 4b Yacht Autopilot

I have a Pi4 that is the heart of our grandson’s yacht chart plotter. He is about to depart for his initial cruise from NZ to Tonga using the Pi as his principle source for navigation.

I’ve been thinking of making an autopilot for the yacht using the Pi4 and am hoping you can provide some advice on the required components. I plan on using a marine grade linear actuator to move the yacht tiller arm. My initial research indicated I’d need an Arduino and a motor controller to connect between the Pi4 and actuator. However I noticed Core stocks a Pi Relay HAT. Could I use this instead of the Arduino and motor controller? The linear actuator will be 12V and draw a maximum of 10 amps. I’ve also read the Pi Relay HAT relays may be damaged if used continuously and should be used to control solid state relays in this situation? Any suggestions would be welcomed.

4 Likes

Hi Tom
Welcome
As I think the RPi range is primarily a hobby and development platform would it not be a bit risky to use it in such an application. If there are any inspections involved before undertaking a journey of this nature I think he will be lucky to be allowed to leave his mooring. There are quite a few things going on with an Auto Pilot like a reference compass and rudder position feedback to name a couple. If you just want a means to drive the tiller instead of manpower then fine but I think an Auto Pilot is a bit more complex.

In summary, I personally would not be making that trip on that boat. I stress that this is my personal opinion. I know I might be a chicken but I would also like to grow up to be a big rooster.
Cheers and Good Luck. Bob

2 Likes

NZ Cat 1 safety rules do not require an auto pilot. It is an optional item that can vary from a simple length of line run from a sail with a piece of tyre tubing as the adjusting spring, to a Heath-Robinson version with vanes and strings and springs and gears and pulleys to a multi-thousand dollar electronic installation. It is used when conditions suit the capability of the device.

2 Likes

Hi Bob,
The yacht has two other navigation option including sextant and paper charts. If you search You Tube you will find many example of boats using RPi and OpenPlotter for navigation. However the autopilot would only be used to navigate entry and exit from ports as he has a self-steering windvane for the open ocean.
Cheers
Tom

2 Likes

Hi Jeff

I thought that. But I also thought that if such an item was fitted it would have to meet some minimum criteria. Apparently I am wrong but never mind. My personal thoughts still apply.
Cheers Bob

1 Like

Hi Tom

You can find lots on Tube. Some pretty good and some absolute garbage. Up to the individual to sort.
If you are just using the RPi for navigation and not actually controlling the boat then all good. But for me personally the Jury is still out when it comes to connecting it to actually control the boat.

Only my chicken thoughts.
Cheers Bob

Hey Tom,

This is a really interesting idea. To answer your Pi questions the Pi relay HAT I would recommend is this one:

For use with a linear actuator that runs at 12v at a max of 10 Amps this should work as it works up to 30VDC and 10 Amps which is within your spec.

As for reliability over a long ocean voyage I would be sceptical. As Bob has already said these sort of raspberry pi solutions or designed with hobbyist applications in mind and while this would probably work for you in the short term, I wouldn’t be betting anything as important as a NZ to Tonga trip on it without extensive testing first and some serious backup plans in the event of a failure.

Hope this helps!

Hi Samuel,
Thanks for the link.
The yacht already has a windvane self steering device for open ocean navigation. An autopilot would probably only be used when sailing in close proximity to harbours, moorings, reefs, etc.
Thanks

1 Like

There is BBN Marine OS for pi with pypilot software on it. PyPilot software has been used in ocean crossings.

Here is a link to one installation video

4 Likes

Problem: I am unable to upload a Sketch to a Pimoroni Arduino Nano V3.0 connected to a Raspberry Pi 5 using the usb cable that came with the Arduino.
The power LED is illuminated on the Arduino but the RX and TX LED’s are not.
From my limited understanding of the system the Rpi5 recognises the Nano but I am unable to communicate with it

carlin@sbcowrie:~ $ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
**Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC**
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
carlin@sbcowrie:~ $ ls /dev/tty*
/dev/tty    /dev/tty19  /dev/tty3   /dev/tty40  /dev/tty51  /dev/tty62
/dev/tty0   /dev/tty2   /dev/tty30  /dev/tty41  /dev/tty52  /dev/tty63
/dev/tty1   /dev/tty20  /dev/tty31  /dev/tty42  /dev/tty53  /dev/tty7
/dev/tty10  /dev/tty21  /dev/tty32  /dev/tty43  /dev/tty54  /dev/tty8
/dev/tty11  /dev/tty22  /dev/tty33  /dev/tty44  /dev/tty55  /dev/tty9
/dev/tty12  /dev/tty23  /dev/tty34  /dev/tty45  /dev/tty56  /dev/ttyAMA10
/dev/tty13  /dev/tty24  /dev/tty35  /dev/tty46  /dev/tty57  /dev/ttyOP_aduino
/dev/tty14  /dev/tty25  /dev/tty36  /dev/tty47  /dev/tty58  /dev/ttyOP_debug
/dev/tty15  /dev/tty26  /dev/tty37  /dev/tty48  /dev/tty59  /dev/ttyprintk
/dev/tty16  /dev/tty27  /dev/tty38  /dev/tty49  /dev/tty6   **strong text**/dev/ttyUSB0**
/dev/tty17  /dev/tty28  /dev/tty39  /dev/tty5   /dev/tty60
/dev/tty18  /dev/tty29  /dev/tty4   /dev/tty50  /dev/tty61

The program on the Rpi5 shows the following device details:

CURRENT_TAGS: :systemd:uaccess:seat:
DEVLINKS: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A5069RR4-if00-port0 /dev/ttyOP_aduino /dev/serial/by-path/platform-xhci-hcd.0-usb-0:2:1.0-port0
DEVNAME: /dev/ttyUSB0
DEVPATH: /devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-2/1-2:1.0/ttyUSB0/tty/ttyUSB0
ID_BUS: usb
ID_FOR_SEAT: tty-platform-xhci-hcd_0-usb-0_2_1_0
ID_MM_CANDIDATE: 1
ID_MODEL: FT232R_USB_UART
ID_MODEL_ENC: FT232R\x20USB\x20UART
ID_MODEL_FROM_DATABASE: FT232 Serial (UART) IC
ID_MODEL_ID: 6001

Looking in Arduino IDE running on the Rpi5 I see

Select ‘Get Board Info’ and the response is

BN: Unknown board
VID: 0403
PID: 6001
SN: Upload any sketch to obtain it


Attempt to upload a Sketch fails with response
Arduino: 1.8.19 (Linux), Board: "Arduino Nano, ATmega328P"
Sketch uses 8018 bytes (26%) of program storage space. Maximum is 30720 bytes.
Global variables use 309 bytes (15%) of dynamic memory, leaving 1739 bytes for local variables. Maximum is 2048 bytes.
avrdude error: unable to open programmer arduino on port /dev/ttyUSB0

My assumption is whilst the Rpi5 recognises the Arduino as connected via USB it isn’t communicating.

I don’t know why!

Can anyone provide some advice on what I should do to identify the issue and resolve it?

Thanks
Tom

I can’t replicate your exact error message, but it is possible that your Nano has the old bootloader installed. Try setting Tools\Processor to ATMega328P (Old Bootloader) and uploading again.

If that doesn’t fix it then the next likely solution is to re-load the bootloader.

Unfortunately that didn’t work

Error Message
Arduino: 1.8.19 (Linux), Board: “Arduino Nano, ATmega328P (Old Bootloader)”

Sketch uses 8018 bytes (26%) of program storage space. Maximum is 30720 bytes.
Global variables use 309 bytes (15%) of dynamic memory, leaving 1739 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch
avrdude OS error: cannot open port /dev/ttyUSB0: Device or resource busy
avrdude error: unable to open programmer arduino on port /dev/ttyUSB0

Hi Tom,

Programming an Arduino with a Raspberry Pi is something I had never considered doing before. Try @Jeff105671’s suggestion of changing the bootloader. Some of these not-name-brand boards use the old bootloader.

On your Pi could you try running dmesg | grep tty? This will tell you what port you have devices connected to.

Cannot open port…resource busy is a different problem. Firstly, if you are using REV 2 of the IDE, make sure console is closed - console does not release the port just because you start a download. If that doesn’t work then restart the IDE. Next, restart the Pi, and make sure nothing is running that could possibly be claiming a port. If that still doesn’t work then you need to check that the port actually works, and that’s starting to get complicated.

Hi Jack

I’ve made some slight progress. I ran an upgrade and immediately the rx & tx LEDs on the Arduino started blinking. However there is still no communication to the Arduino and I get an error message that the port is busy.

$ dmesg | grep tty
[    0.000000] Kernel command line: reboot=w coherent_pool=1M 8250.nr_uarts=1 pci=pcie_bus_safe  smsc95xx.macaddr=2C:CF:67:79:67:1F vc_mem.mem_base=0x3fc00000 vc_mem.mem_size=0x40000000  console=tty1 root=PARTUUID=3dc03fc6-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=AU
[    0.000161] printk: console [tty1] enabled
[    0.011100] 107d001000.serial: ttyAMA10 at MMIO 0x107d001000 (irq = 15, base_baud = 0) is a PL011 rev2
[    0.358414] 107d50c000.serial: ttyS0 at MMIO 0x107d50c000 (irq = 33, base_baud = 6000000) is a Broadcom BCM7271 UART
[    0.358465] serial serial0: tty port ttyS0 registered
[    1.818304] systemd[1]: Created slice system-getty.slice - Slice /system/getty.
[    2.411296] ftdi_sio ttyUSB0: Unable to read latency timer: -32
[    2.419599] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0

If the error is that the port is busy, it is in use somewhere. That command window being open could still have a line open with the Arduino. Rebooting the Pi is the easiest way I can think of that may close that for you.

Jack,

I think I may have uploaded the sketch. There was no error message. Instead I saw “018 bytes (26%) of program storage space. Maximum is 30720 bytes.
Global variables use 309 bytes (15%) of dynamic memory, leaving 1739 bytes for local variables. Maximum is 2048 bytes.”

In the RPi I noticed when I had made the connection in the Serial window of OpenPlotter I was required to add an Alias. This created a symbolic link which I assume led to two connections to the same port.

I subsequentially deleted all the connection data in OpenPlotter on the Rpi and then attempted to upload the Sketch.

The rx & tx LED’s no longer flash so I’m now going to reinstall all the connections in OpenPlotter and see if that works.

If it does; then obviously I needed to connect to the Arduino and upload the Sketch before making the USB connection in the RPi OpenPlotter.

1 Like

Another means of checking if it has uploaded is to blink the onboard LED on the Nano in your setup.

I guess you mean push the little button on the board. The LED flashed about 3 times

Hi @Tom270955,

I believe Jack was referring to adding the following code to the Setup part of your code:

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);  
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);  

This will blink the onboard LED on and then off when it goes through the Setup part of the code.

This is just a way to check that the code successfully uploaded and is running.