Python SDK Quick Start

This page covers Python control only. Before connecting hardware for the first time, identify your product in Choose Your Product and Manual and read its interface, power and safety instructions.

If you do not need to write code, use Control Pannel for direct graphical control.

1. Prepare

  • Python 3.9 or later.

  • Connect the hub’s command/control port to your computer with a USB cable.

  • To control downstream USB devices, connect the upstream data port, auxiliary power and downstream devices as described in the matching user manual.

After enumeration, the command port normally appears as:

System

Typical port name

Windows

COMx

Linux

/dev/ttyACM*

macOS

/dev/cu.usbmodem*

2. Install the Python SDK

Install the published package:

python3 -m pip install smartusbhub

Developers can install the current source tree instead:

git clone https://github.com/mixedsignal-labs/smartusbhub.git
cd smartusbhub
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .

3. Run your first control script

The example discovers a hub, reads its product and channel list, and then enables the first channel:

from smartusbhub import SmartUSBHub

hub = SmartUSBHub.scan_and_connect()
if hub is None:
    raise RuntimeError("SmartUSBHub not found; check the USB connection and serial-port permissions")

try:
    channels = list(hub.get_channels())
    print("Product:", hub.get_product_name())
    print("Channels:", channels)
    hub.set_channel_power(channels[0], state=1)
finally:
    hub.disconnect()

When working from the source repository, you can also run the included example:

python examples/power_control_example.py

4. Continue