Connecting Your Device with Navigator and BlueOS

Introduction

Many payloads, such as CTD Sondes and Sonars, use a serial protocol for communication. Common types include RS232, RS485, and RS422. Other payloads use different interfaces, such as USB or Ethernet, to allow for more data bandwidth. Many small sensors intended to interface directly with a microcontroller use the I2C communication protocol.

These protocols transmit data streams in different formats, like NMEA or the Ping Protocol. In this guide, we detail methods to receive these data streams and connect them to computers using the Blue Robotics BlueROV2, BlueBoat, or any Navigator / BlueOS-based vehicle. Let’s dive in!

You will need

To complete the setup for your system, you will need the following components:

  • Your vehicle with Navigator installed
  • Connection to vehicle (via FXTI, BaseStation, or any TCP/IP link)
  • Your computer
  • Appropriate hardware for your device (see table)

Common ways things talk:

Device Communication MethodRequirementPin Names Typical Data ratesTypical / Max cable length
Serial RS232MAX IC or USB AdapterTX, RX, GND, V9.6/115.2/576 Kbit/s (dependent on cable length)9.1 m or 30 dt / 15.25 m or 50 ft
Serial RS485 / RS422MAX IC or 422 / 485 USB adapterA, B, GND, V0.1 / 10 Mbit/s100 m / 1200 m or 4000 ft
I2CNo device address conflicts, sometimes level shifterSCL, SDA, GND, V0.1/0.4/1 Mbit/s (very dependent on cable length)0.3 m or 1 ft/ 10-50 m or 30-165 ft with additional hardware
EthernetEthernet Switch or USB AdapterRX +, RX-, TX+, TX-10/100 Mbit/s
1 Gbit/s (compatible tether adapter and devices only)
50 m or 165 ft / 100 m or 328 ft
USBNone (Hub if more ports required.)D+, D-, 5V, GND480 Mbit/s USB2.0
5 Gbit/s USB3.0
2 m or 6.5 ft / 5 m or 16 ft USB 2.0
1 m or 3.3 ft / 3 m or 9.8' USB 3.0

Serial devices

This guide focuses on how to connect payloads, but if you want to learn everything about serial signals, check out this great resource. Understanding the differences between all the recommended standards, is quite complex!

USB serial adapter

A USB adapter often provides the easiest connection for RS422 signals. For RS485 and RS232, you could use the BLUART, but it does not support the higher voltages used in many serial payloads, so you’ll still need to convert the signal as detailed in the section below. The labels TX (transmission), RX (receive), and GND (ground) represent the signals. You’ll need to connect your payload device’s TX signal line to the appropriate RX signal line of the USB adapter, and similarly the device RX to the adapter TX. When troubleshooting a connection, swapping these two wires is often the best first step! You’ll also need to connect the GND of the adapter and the payload, so the signals are referenced to a common level. You must make your payload power (and ground) connections separate from this referencing link.

A great way to test your wiring before installation in the vehicle is to connect the adapter to your computer and verify any vendor software functions as expected, such as receiving the data in a serial terminal program. With that verified, you can move on to BlueOS Configuration!

The Navigator has labeled ports of Serial 1, 3, 4 & 5. Ports 3 & 4 are generally the best to use when connecting your payload, to keep Serial 1 free for potential RC Radio use. Serial 5 is commonly used by a vehicle’s GPS, as with the BlueBoat.

If connecting an RC Radio receiver to the system via SBUS protocol, only Serial 1 can be used, and the Parameter SERIAL1_PROTOCOL should be set to RCIN. This type of Radio is only supported by BlueBoat / ArduRover systems.

Converting serial protocol to TTL levels with MAX

The signal protocols typically used for standard serial connections are designed to travel long distances along cables. The standard for RS232 shows that signals sent with the protocol are ±15V – yes that’s negative 15 volts! Connecting this signal directly to either USB or serial ports of the Navigator/Raspberry Pi combo would damage the system.

To convert the signals from higher & negative voltages to TTL levels, a MAX series chip is typically used. These will convert the signals to the TTL voltage level they are powered with. You will need to connect the TX and RX from the Navigator to the converter circuit, along with the GND and 3.3V. The diagram below details a typical arrangement for RS232, and the adapter to Navigator connection is identical for RS422 and RS485.

In cases where you might be connecting two 3.3V logic serial ports together, with no converter, a 2.2 kΩ resistors in series with RX and TX lines can prevent potential damage with an incorrect connection. The Navigator serial ports are also tolerant of 5V logic input signals!
Navigator to MAX series Serial Connection

Navigator to MAX series Serial Connection

BlueOS configuration: serial bridges

With the device wired up, it’s time to configure BlueOS! In these instructions, we explain how to use the BlueOS Serial Bridges menu to set up a bidirectional serial to UDP link powered by Bridget. This means your receiving computer will need to access the data at the specified port, via UDP packets. If you are using a USB adapter, you can skip to step 1 & 2 below.

  1. We’ll first need to make sure the Autopilot is not trying to use the serial port. Select Autopilot Firmware from the top of the menu, and then Select Serial Port Configuration. Click the small X next to the serial Port you intend to bridge. In the screenshot, we’ve removed the configuration for Serial Port 4.
  2. Click SAVE AND RESTART.
  3. Next, select Serial Bridges from the menu- you’ll need to be in Pirate mode for this option to appear. Click the “+” button in the lower right to create a new connection.
  4. Select the Serial Port, which is helpfully illustrated in the drop-down. If you are using a USB Adapter, this will likely appear as /dev/tty/USB0 or similar.
  5. Now, input the appropriate serial baud rate for the device you’ll be connecting to. Common values are 9600 and 115200, but it is device specific.
  6. If you intend to access the serial data stream via UDP Client, leave the IP Address at 0.0.0.0. If you intend for the software on your computer to run as a UDP server when receiving the datastream, input its IP address instead. The advantage to running the bridge as a server is that multiple clients will be able to connect to the serial port simultaneously.
  7. Finally, select the UDP port you would like to use for the connection. Click Create and your Serial Bridge will be configured!

If you are receiving scrambled data with crazy characters, or having issues with your client software connecting, using the wrong baud-rate for the device is likely the cause!

Testing the serial connection

You can use the NetCat tool to check if data is available on a configured port. It’s installed by default on MacOS and most Linux distributions, as well as Windows via WSL. From your connected computer, run the following command in the terminal application to see the data in real-time.

nc -u blueos.local 15000

You could replace the blueos.local with your system IP if different, and the port # should match what you configured your bridge to use.

If you connect the TX to the RX wire on a serial port, any text you type will be repeated back to you when you press enter, verifying the bidirectional connection (loopback).

Accessing serial stream via UDP with Python

To convert a python script that accesses local serial ports to one that can receive serial data via UDP, check out the socket library. Once you’ve opened the connection, you need to send data to it periodically, every 10 seconds minimum, so the connection is not automatically closed. Here’s an example of how you might modify your script from using a serial device to using a remote serial device accessed via UDP thanks to BlueOS:

import socket

# Set up UDP connection
udp_ip = "192.168.2.2"  # Replace with your UDP server IP
udp_port = 15000       # Replace with your UDP server port

# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((udp_ip, udp_port))

while True:
    # Receive data from UDP
    data, addr = sock.recvfrom(1024)  # buffer size is 1024 bytes

    # Process data
    # ... Your data processing logic here ...

    # Optionally send data back
    # sock.sendto(bytes_to_send, (udp_ip, udp_port))

I2C devices

The I2C or “I squared C” communications bus functions on circuit boards, transmitting data to and from multiple devices. Long wires, especially in electrically noisy environments, can greatly affect the performance of I2C due to its sensitivity to wire capacitance. When connecting multiple devices of the same type to an I2C communications bus, you must follow instructions to change each device’s default address. A multiplexer can assist if you are connecting multiple devices without configurable addresses. You can learn more about I2C here.

If you’re having problems with I2C communications, one or two ferrite cores placed with the wires going through them, at one or both ends of your cable in the noisy environment, can significantly help!

Supported devices

ArduSub, which the BlueROV2 uses, supports the Bar30 or Bar100 pressure sensors, as well as the Celsius temperature sensor. More sensors could be added, with updates to the Ardusub code. By default, ArduRover, which the BlueBoat uses, does not support any I2C devices. You can access I2C devices using your own Python code with existing libraries. The Linux kernel in BlueOS manages the I2C bus access, ensuring no interference with existing sensor communications.

Extending I2C connection distance

You can use various methods to extend I2C communication range for long wires, sometimes reducing connection bandwidth. The differential signaling and the active terminator method can both extend I2C communication range.

Connecting an I2C device

You need to attach Ground, 3.3 Volts, SCL (clock), and SDA (data) lines to any I2C device. The Navigator provides this connection with 2x 4 pin jst-gh connectors and also includes it on the Serial 5 connector. After plugging in, navigate to the BlueOS terminal (in Pirate Mode) and take the red-pill. Then you can run:

apt update && apt install -y i2c-tools
Running apt upgrade can cause issues compatibility with BlueOS installations, please avoid!
To list devices connected to the bus, by address, run:
 i2cdetect -y 1 
If you consult your sensor’s documentation, you should find its default address listed. For example, 4 discrete devices are connected in this output:
4xI2C_devices
With your device ID shown, you can now develop code to access it at its address, perhaps in the form of a BlueOS extension.

Ethernet devices

BlueOS allows access and use via a TCP/IP Ethernet connection. Using an ethernet switch with BlueOS enables multiple devices to communicate at high data rates. Our Blue Robotics Ethernet switch, which is easy to integrate in the BlueROV2, has a small form factor. However, any ethernet switch will allow communication between connected peripherals. This switch, and most low-cost network switches are “unmanaged” meaning the device is transparent to the user and any devices connected to it. It does not have an IP address, and is simply shuttling packets between plugged in devices.

It is important that systems trying to communicate with each other are using IP addresses of the same subnet – 192.168.2.X, with 255.255.255.0 as the subnet mask is the default configuration for Blue Robotics systems. The control station, or “topside” computer uses an address of 192.168.2.1 in the default Blue Robotics software configuration. As the standard configuration of BlueOS does not include a DHCP server, devices must use a self-/manually-assigned static IP address to communicate.

USB devices

USB/IP extension

This extension is another application of the USBIP project. It supports client machines running Linux or Windows OS. Instructions are available from the Extension installation page. To use this extension, you’ll need to use the terminal on your computer to list remote devices and virtually attach it to your local machine. Install the extension and check the description for more information.

VirtualHere extension

VirtualHere, a commercial program offering a free client with some restrictions, uses the USBIP project. It is compatible with MacOS, Windows, and Linux, and provides a nice GUI tool for configuration. Once the extension is installed, you use the client software on your computer so any USB device plugged into the vehicle Raspberry Pi can be selected for virtual attachment to your computer.

virtualherewindows_client_screen

USB cameras

BlueOS supports USB cameras capable of streaming H264 containerized video and adhering to the USB Video Class (UVC) standard. This standard allows for these cameras to be compatible with a wide range of operating systems and software without the need for proprietary drivers or software. You can dip your toes into all things camera gently, or dive in and level up with the advanced usage documentation!

Get help

If you’re stuck trying to get a device to communicate, please reach out to our forums! Your experience can benefit others, and we’re eager to help with your application.

What did you think of this guide? Can we improve it? Let us know here!