The Coral Dev Board provides access to several peripheral interfaces through the 40-pin expansion header, including GPIO, I2C, UART, and SPI.
All I/O pins on the 40-pin header are powered by the 3.3V power rail, with a programmable impedance
of 40 - 255 ohms, and a max current of ~82 mA. You can interact with each pin using standard Linux
interfaces such as device files (
/dev) and sysfs files (
Table 1 shows the header pinout, including the sysfs paths for each port, which is often the name required when using the periphery library. For a pinout that includes the SoM pin names, instead see the Dev Board datasheet.
You can also see the header pinout from the command line by typing
pinout on the Dev Board.
|sysfs path||Pin function||Pin||Pin function||sysfs path|
|+3.3V Power||1||2||+5V Power|
|/dev/i2c-1||I2C 2 (SDA)||3||4||+5V Power|
|/dev/i2c-1||I2C 2 (SCL)||5||6||Ground|
|/dev/ttymxc2||UART 3 (TXD)||7||8||UART 1 (TXD)||/dev/ttymxc0|
|Ground||9||10||UART 1 (RXD)||/dev/ttymxc0|
|/dev/ttymxc2||UART 3 (RXD)||11||12||SAI 1 (TXC)|
|/sys/class/pwm/pwmchip2/pwm0||PWM 3||15||16||GPIO 73||/sys/class/gpio/gpio73|
|+3.3V Power||17||18||GPIO 138||/sys/class/gpio/gpio138|
|/dev/spidev32766||SPI 1 (MOSI)||19||20||Ground|
|/dev/spidev32766||SPI 1 (MISO)||21||22||GPIO 140||/sys/class/gpio/gpio140|
|/dev/spidev32766||SPI 1 (SCLK)||23||24||SPI 1 (SS0)||/dev/spidev32766.0|
|Ground||25||26||SPI 1 (SS1)||/dev/spidev32766.1|
|/dev/i2c-2||I2C 3 (SDA)||27||28||I2C 3 (SCL)||/dev/i2c-2|
|/sys/class/gpio/gpio8||GPIO 8||31||32||PWM 1||/sys/class/pwm/pwmchip0/pwm0|
|SAI 1 (TXFS)||35||36||GPIO 141||/sys/class/gpio/gpio141|
|/sys/class/gpio/gpio77||GPIO 77||37||38||SAI 1 (RXD)|
|Ground||39||40||SAI 1 (TXD)|
Using the Periphery library
To access the header pins on the Dev Board, you can use standard Linux sysfs interfaces. But if you'd like a Python API, we recommend you use the python-periphery library, which is built atop the sysfs interfaces.
You can install the library on your Dev Board as follows:
sudo apt-get install python3-pip sudo pip3 install python-periphery
- To access peripheral hardware resources on the Dev Board, you need to run your code with sudo privileges.
- You should install the Python 3 version of Periphery because that's the Python version required by the Edge TPU Python API.
The Periphery library allows you to select a GPIO or PWM pin with a pin number. Other interfaces, such as I2C and UART pins must be specified using the pin's device path. See the following examples.
The following code shows how to instantiate each of the GPIO pins with Periphery:
gpio6 = GPIO(6, "in") gpio7 = GPIO(7, "in") gpio8 = GPIO(8, "in") gpio138 = GPIO(138, "in") gpio140 = GPIO(140, "in") gpio141 = GPIO(141, "in") gpio73 = GPIO(73, "out") gpio77 = GPIO(77, "out")
For more examples, see the periphery GPIO documentation.
The following code shows how to instantiate each of the PWM pins with Periphery:
# PWM1 = pwmchip0, pwm0 pwm1 = PWM(0, 0) # PWM1 = pwmchip1, pwm0 pwm2 = PWM(1, 0) # PWM1 = pwmchip2, pwm0 pwm3 = PWM(2, 0)
For usage examples, see the periphery PWM documentation.
The following code shows how to instantiate each of the I2C ports with Periphery:
i2c2 = I2C("/dev/i2c-1") i2c3 = I2C("/dev/i2c-2")
For usage examples, see the periphery I2C documentation.
The following code shows how to instantiate each of the SPI ports with Periphery:
# SPI1, SS0, Mode 0, 10MHz spi1_0 = SPI("/dev/spidev32766.0", 0, 10000000) # SPI1, SS1, Mode 0, 10MHz spi1_1 = SPI("/dev/spidev32766.1", 0, 10000000)
For usage examples, see the periphery SPI documentation.
The following code shows how to instantiate each of the UART ports with Periphery:
# UART1, 115200 baud uart1 = Serial("/dev/ttymxc0", 115200) # UART3, 9600 baud uart3 = Serial("/dev/ttymxc2", 9600)
systemctl stop email@example.com
ls /dev | grep ttymxc
If you see
ttymxc2 listed, then you're all good. If not, then you need to update
sudo apt-get update sudo apt-get dist-upgrade sudo reboot now
For usage examples, see the periphery Serial documentation.
Is this content helpful?