Skip to main content

Communication modules

This subpage contains additional description and manuals about Panther's communication modules don't include in Panther options.

SB03 - USB to I2C/SPI interface

SB03 is a hardware adapter for Panther that provides I2C and SPI interfaces for the external devices, like sensors. There are four connectors available for each interface, enabling you to use four I2C slave devices or four SPI slave devices. It is not possible to use both I2C and SPI interfaces together.

SB03 Software setup

This guide is based on manual CircuitPython Libraries on any Computer with FT232H by Adafruit.

SB03 is based on FT232H chip. It has a CircuitPython support, giving it a wide range of preexisting libraries.

SB03 Install dependencies

Install following dependency:

sudo apt-get install libusb-1.0

Later install Python 3 dependencies:

pip3 install pyftdi
pip3 install adafruit-blinka

SB03 Setup Udev rules

Create new Udev rule and edit it with your favorite text editor. We will use nano due to its simplicity.

sudo touch /etc/udev/rules.d/11-ftdi.rules
sudo nano /etc/udev/rules.d/11-ftdi.rules

While editing the file, paste:

SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6001", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6011", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6010", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6014", GROUP="plugdev", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6015", GROUP="plugdev", MODE="0666"

Save and exit file. If you are using nano press Ctrl+s and follow it by Ctrl+x and then y to confirm. Reload Udev with:

sudo udevadm control --reload-rules
sudo udevadm trigger

SB03 Environment variables

adafruit-blinka library relies on environment variables to select FT232H chip. It requires BLINKA_FT232H environment variable to be set to 1. You can do so by running

export BLINKA_FT232H=1

This will create a needed variable, but it will only exist in a given terminal session and will be destroyed once you close the window.

If you are sure the only blinka device you will use is FT232H you can modify .bashrc file. Now, every time you will launch Python script by given user, you will have the environment variable set. Run the following command to add create this variable every time you log into terminal as the given user.

echo "export BLINKA_FT232H=1" >> ~/.bashrc
source ~/.bashrc

A more secure way to do so is by creating the environment variable every time you run a Python script. You can achieve it by exporting the variable before the script will load blinka library.

import os
os.environ["BLINKA_FT232H"] = "1"
import board
import digitalio

Now you are ready to use SB03 board.

SB03 Example

This example covers using VL53L0X range sensor.

First install CircuitPython library:

pip3 install adafruit-circuitpython-vl53l0x

After successful installation, attach VL53L0X to the Groove connector on SB03. Remember to set BUS jumper to I2C and output voltage to 3.3V.

# Setup environment variable for FT232H
import os
os.environ['BLINKA_FT232H'] = '1'
# Import libraries
import adafruit_vl53l0x
import board
import busio
import time
# Setup I2C
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_vl53l0x.VL53L0X(i2c)
# Measure distance in a loop
while (True):
r = sensor.range
if r < 8000:
print(f'Range: {r}mm')
else:
print('Object is too far to measure.')
time.sleep(0.1)

SB03 Additional resources: