Mark Chin
Published

Type C USB Hub With Raspberry Pi And PiCHUB

USB Type C Hub Development Board for the Raspberry Pi.

IntermediateProtip15 minutes8,087
Type C USB Hub With Raspberry Pi And  PiCHUB

Things used in this project

Story

Read more

Schematics

PiCHUB to Raspberry Pi Zero Interface

Schematic Block Diagram of the Setup

Code

PiCHUB Code Instructions

Python
These are instructions on setting up the Raspberry Pi for i2c and SMBUS for PiCHUB operation. Software is included with the development kit.
Here are a couple good links on setting up the I2c:

http://www.raspberrypi-spy.co.uk/2014/11/enabling-the-i2c-interface-on-the-raspberry-pi/  
https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial 

Installing Python SMBUS

- sudo apt-get update (get the latest files and support)
- sudo apt-get install python-smbus python-dev i2c-tools (using Python 2.7)

Detecting the PiCHUB:
- Plug the PiCHUB onto the Pi Zero (or any other Raspberry Pi)
- Connect the Micro USB cable to "UP" upstream port on the PiCHUB and to the Pi Zero USB port
- Note: if using the Raspberry Pi Zero, it must NOT be in Gadget mode otherwise the USB jumper cable will not work
- At the command line, type:
sudo i2c-detect -y 1 (SDA - Pin 3, SCL - Pin 5, using i2c bus number 1)
- Two I2C addresses should appear, one for the USB Type C port controller IC and the other for the microcontroller onboard.  Address 0x60 is for the USB Type C port controller IC which the Python code will use to control.
Running the Python Script:
- This Python script should be put in the rc.local file on the Raspberry Pi so it is run upon bootup and the PiCHUB will work automatically. It can also be run from the command line if the PiCHUB is used occasionally. 
- Here is a link on adding the script to the rc.local file
https://www.raspberrypi.org/documentation/linux/usage/rc-local.md
- At the command line type (at the location of the i2c_comms.py file)
sudo python i2c_comms.py ( the python code will now run siliently in the background waiting for a connection on the USB Type C port)

Credits

Mark Chin

Mark Chin

5 projects • 10 followers
Entrepreneur and Innovator of embedded systems, RFID and IoT.

Comments