'ODROID-N2' on this page refers to the ODROID-N2 series (N2, N2+, N2L).
WiringPi and Python Wrapper
- Legacy master branch has renamed to master-old branch. If you face a problem with new master branch, please try again with old one.
WiringPi
The original WiringPi is a PIN based GPIO access library written in C for the BCM2835 used in the Raspberry Pi. It’s released under the GNU LGPLv3 license and is usable from C, C++ and RTB (BASIC) as well as many other languages with suitable wrappers (See below) It’s designed to be familiar to people who have used the Arduino “wiring” system[1]. Hardkernel provides WiringPi library for ODROID boards forked from original WiringPi.
You can install our WiringPi using our Ubuntu PPA (except for M1 and M1S). This comes with you to keep it the latest version using apt command. Or, clone our Github repository and build it yourself.
Github repository
- target
sudo apt install git git clone https://github.com/hardkernel/wiringPi cd wiringPi sh autogen.sh ./configure make sudo make install
ODROID-XU4/N2/C4
- Please be aware that our package names odroid-wiringpi, not just wiringpi. Canonical provides the wiringpi package designed for RaspberryPi by default, but that version is not compatible with ours.
- target
sudo apt install software-properties-common sudo add-apt-repository ppa:hardkernel/ppa sudo apt update sudo apt install odroid-wiringpi
If you want to development libraries, install the extra packages.
- target
sudo apt install libwiringpi-dev
Run gpio readall to check all of the expansion GPIO pins.
ODROID-N2
root@odroid:~# gpio readall +-----+-----+---------+------+---+--- N2 ---+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3V | | | 1 || 2 | | | 5V | | | | 493 | 8 | SDA.2 | ALT1 | 1 | 3 || 4 | | | 5V | | | | 494 | 9 | SCL.2 | ALT1 | 1 | 5 || 6 | | | 0V | | | | 473 | 7 | IO.473 | ALT1 | 0 | 7 || 8 | 1 | ALT1 | TxD1 | 15 | 488 | | | | 0V | | | 9 || 10 | 1 | ALT1 | RxD1 | 16 | 489 | | 479 | 0 | IO.479 | IN | 1 | 11 || 12 | 1 | IN | IO.492 | 1 | 492 | | 480 | 2 | IO.480 | IN | 1 | 13 || 14 | | | 0V | | | | 483 | 3 | IO.483 | ALT2 | 1 | 15 || 16 | 1 | IN | IO.476 | 4 | 476 | | | | 3.3V | | | 17 || 18 | 1 | IN | IO.477 | 5 | 477 | | 484 | 12 | MOSI | IN | 1 | 19 || 20 | | | 0V | | | | 485 | 13 | MISO | IN | 1 | 21 || 22 | 1 | IN | IO.478 | 6 | 478 | | 487 | 14 | SCLK | IN | 1 | 23 || 24 | 1 | IN | CE0 | 10 | 486 | | | | 0V | | | 25 || 26 | 0 | IN | IO.464 | 11 | 464 | | 474 | 30 | SDA.3 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.3 | 31 | 475 | | 490 | 21 | IO.490 | ALT1 | 1 | 29 || 30 | | | 0V | | | | 491 | 22 | IO.491 | ALT1 | 1 | 31 || 32 | 0 | IN | IO.472 | 26 | 472 | | 481 | 23 | IO.481 | IN | 1 | 33 || 34 | | | 0V | | | | 482 | 24 | IO.482 | ALT2 | 1 | 35 || 36 | 0 | IN | IO.495 | 27 | 495 | | | 25 | AIN.3 | | | 37 || 38 | | | 1V8 | 28 | | | | | 0V | | | 39 || 40 | | | AIN.2 | 29 | | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+--- N2 ---+---+------+---------+-----+-----+
root@odroid:~# gpio readall -a +------+-----+----------+------+---+----+---- Model ODROID-N2 ----+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | | | 3.3V | | | | | 1 || 2 | | | | | 5V | | | | 493 | 8 | SDA.2 | ALT1 | 1 | 2 | P/U | 3 || 4 | | | | | 5V | | | | 494 | 9 | SCL.2 | ALT1 | 1 | 2 | P/U | 5 || 6 | | | | | GND(0V) | | | | 473 | 7 | GPIO.473 | ALT1 | 0 | 1 | P/D | 7 || 8 | P/U | 1 | 1 | ALT1 | TxD1 | 15 | 488 | | | | GND(0V) | | | | | 9 || 10 | P/U | 1 | 1 | ALT1 | RxD1 | 16 | 489 | | 479 | 0 | GPIO.479 | IN | 1 | 2 | P/U | 11 || 12 | P/U | 1 | 1 | IN | GPIO.492 | 1 | 492 | | 480 | 2 | GPIO.480 | IN | 1 | 2 | P/U | 13 || 14 | | | | | GND(0V) | | | | 483 | 3 | GPIO.483 | ALT2 | 1 | 1 | P/U | 15 || 16 | P/U | 2 | 1 | IN | GPIO.476 | 4 | 476 | | | | 3.3V | | | | | 17 || 18 | P/U | 2 | 1 | IN | GPIO.477 | 5 | 477 | | 484 | 12 | MOSI | IN | 1 | 1 | P/U | 19 || 20 | | | | | GND(0V) | | | | 485 | 13 | MISO | IN | 1 | 1 | P/U | 21 || 22 | P/U | 2 | 1 | IN | GPIO.478 | 6 | 478 | | 487 | 14 | SCLK | IN | 1 | 2 | P/U | 23 || 24 | P/U | 1 | 1 | IN | CE0 | 10 | 486 | | | | GND(0V) | | | | | 25 || 26 | P/D | 1 | 0 | IN | GPIO.464 | 11 | 464 | | 474 | 30 | SDA.3 | ALT2 | 1 | 3 | P/U | 27 || 28 | P/U | 3 | 1 | ALT2 | SCL.3 | 31 | 475 | | 490 | 21 | GPIO.490 | ALT1 | 1 | 1 | P/U | 29 || 30 | | | | | GND(0V) | | | | 491 | 22 | GPIO.491 | ALT1 | 1 | 1 | P/U | 31 || 32 | P/D | 2 | 0 | IN | GPIO.472 | 26 | 472 | | 481 | 23 | GPIO.481 | IN | 1 | 2 | P/U | 33 || 34 | | | | | GND(0V) | | | | 482 | 24 | GPIO.482 | ALT2 | 1 | 1 | P/D | 35 || 36 | DSBLD | 1 | 0 | IN | GPIO.495 | 27 | 495 | | | 25 | AIN.3 | | | | | 37 || 38 | | | | | 1V8 | 28 | | | | | GND(0V) | | | | | 39 || 40 | | | | | AIN.2 | 29 | | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+---- Model ODROID-N2 ----+----+---+------+----------+-----+------+
ODROID-C4
root@odroid:~# gpio readall +-----+-----+---------+------+---+--- C4 ---+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3V | | | 1 || 2 | | | 5V | | | | 493 | 8 | SDA.2 | ALT1 | 1 | 3 || 4 | | | 5V | | | | 494 | 9 | SCL.2 | ALT1 | 1 | 5 || 6 | | | 0V | | | | 481 | 7 | IO.481 | IN | 1 | 7 || 8 | 1 | ALT1 | TxD1 | 15 | 488 | | | | 0V | | | 9 || 10 | 1 | ALT1 | RxD1 | 16 | 489 | | 479 | 0 | IO.479 | IN | 1 | 11 || 12 | 1 | IN | IO.492 | 1 | 492 | | 480 | 2 | IO.480 | IN | 1 | 13 || 14 | | | 0V | | | | 483 | 3 | IO.483 | IN | 1 | 15 || 16 | 1 | IN | IO.476 | 4 | 476 | | | | 3.3V | | | 17 || 18 | 1 | IN | IO.477 | 5 | 477 | | 484 | 12 | MOSI | ALT4 | 1 | 19 || 20 | | | 0V | | | | 485 | 13 | MISO | ALT4 | 1 | 21 || 22 | 1 | IN | IO.478 | 6 | 478 | | 487 | 14 | SLCK | ALT4 | 1 | 23 || 24 | 1 | OUT | SS | 10 | 486 | | | | 0V | | | 25 || 26 | 0 | IN | IO. 23 | 11 | 433 | | 474 | 30 | SDA.3 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.3 | 31 | 475 | | 490 | 21 | IO.490 | IN | 1 | 29 || 30 | | | 0V | | | | 491 | 22 | IO.491 | IN | 1 | 31 || 32 | 0 | IN | IO. 24 | 26 | 434 | | 482 | 23 | IO.482 | IN | 0 | 33 || 34 | | | 0V | | | | 495 | 24 | IO.495 | IN | 0 | 35 || 36 | 1 | OUT | IO. 22 | 27 | 432 | | | 25 | AIN.2 | | | 37 || 38 | | | 1V8 | 28 | | | | | 0V | | | 39 || 40 | | | AIN.0 | 29 | | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+--- C4 ---+---+------+---------+-----+-----+
root@odroid:~# gpio readall -a +------+-----+----------+------+---+----+---- Model ODROID-C4 ----+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | | | 3.3V | | | | | 1 || 2 | | | | | 5V | | | | 493 | 8 | SDA.2 | ALT1 | 1 | 3 | P/D | 3 || 4 | | | | | 5V | | | | 494 | 9 | SCL.2 | ALT1 | 1 | 3 | P/U | 5 || 6 | | | | | GND(0V) | | | | 481 | 7 | GPIO.481 | IN | 1 | 0 | P/U | 7 || 8 | P/U | 0 | 1 | ALT1 | TxD1 | 15 | 488 | | | | GND(0V) | | | | | 9 || 10 | P/U | 0 | 1 | ALT1 | RxD1 | 16 | 489 | | 479 | 0 | GPIO.479 | IN | 1 | 0 | P/U | 11 || 12 | P/U | 0 | 1 | IN | GPIO.492 | 1 | 492 | | 480 | 2 | GPIO.480 | IN | 1 | 0 | P/U | 13 || 14 | | | | | GND(0V) | | | | 483 | 3 | GPIO.483 | IN | 1 | 0 | P/U | 15 || 16 | P/U | 0 | 1 | IN | GPIO.476 | 4 | 476 | | | | 3.3V | | | | | 17 || 18 | P/U | 0 | 1 | IN | GPIO.477 | 5 | 477 | | 484 | 12 | MOSI | ALT4 | 1 | 3 | P/U | 19 || 20 | | | | | GND(0V) | | | | 485 | 13 | MISO | ALT4 | 1 | 3 | P/U | 21 || 22 | P/U | 0 | 1 | IN | GPIO.478 | 6 | 478 | | 487 | 14 | SLCK | ALT4 | 1 | 3 | P/U | 23 || 24 | P/U | 0 | 1 | OUT | SS | 10 | 486 | | | | GND(0V) | | | | | 25 || 26 | P/D | 0 | 0 | IN | GPIO. 23 | 11 | 433 | | 474 | 30 | SDA.3 | ALT2 | 1 | 3 | P/U | 27 || 28 | P/U | 3 | 1 | ALT2 | SCL.3 | 31 | 475 | | 490 | 21 | GPIO.490 | IN | 1 | 0 | P/U | 29 || 30 | | | | | GND(0V) | | | | 491 | 22 | GPIO.491 | IN | 1 | 0 | P/U | 31 || 32 | P/D | 0 | 0 | IN | GPIO. 24 | 26 | 434 | | 482 | 23 | GPIO.482 | IN | 0 | 0 | P/D | 33 || 34 | | | | | GND(0V) | | | | 495 | 24 | GPIO.495 | IN | 0 | 0 | DSBLD | 35 || 36 | P/D | 0 | 1 | OUT | GPIO. 22 | 27 | 432 | | | 25 | AIN.2 | | | | | 37 || 38 | | | | | 1V8 | 28 | | | | | GND(0V) | | | | | 39 || 40 | | | | | AIN.0 | 29 | | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+---- Model ODROID-C4 ----+----+---+------+----------+-----+------+
ODROID-M1
root@odroid:~# gpio readall +-----+-----+---------+------+---+--- M1 ---+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3V | | | 1 || 2 | | | 5V | | | | 110 | 8 | SDA0 | IN | 1 | 3 || 4 | | | 5V | | | | 109 | 9 | SCL0 | IN | 1 | 5 || 6 | | | 0V | | | | 14 | 7 | IO0_B6 | IN | 1 | 7 || 8 | 0 | IN | UART.TX | 15 | 126 | | | | 0V | | | 9 || 10 | 0 | IN | UART.RX | 16 | 127 | | 16 | 0 | IO0_C0 | IN | 0 | 11 || 12 | 0 | IN | IO3_D0 | 1 | 120 | | 17 | 2 | IO0_C1 | IN | 0 | 13 || 14 | | | 0V | | | | 106 | 3 | IO3_B2 | IN | 0 | 15 || 16 | 0 | IN | IO3_C6 | 4 | 118 | | | | 3.3V | | | 17 || 18 | 0 | IN | IO3_C7 | 5 | 119 | | 89 | 12 | SPI.TXD | IN | 0 | 19 || 20 | | | 0V | | | | 88 | 13 | SPI.RXD | IN | 0 | 21 || 22 | 0 | IN | IO3_D1 | 6 | 121 | | 91 | 14 | SPI.CLK | IN | 0 | 23 || 24 | 0 | IN | SPI.CS0 | 10 | 90 | | | | 0V | | | 25 || 26 | 0 | IN | IO3_D2 | 11 | 122 | | 12 | 30 | SDA1 | ALT3 | 1 | 27 || 28 | 1 | ALT3 | SCL1 | 31 | 11 | | 145 | 21 | IO4_C1 | IN | 0 | 29 || 30 | | | 0V | | | | 142 | 22 | IO4_B6 | IN | 0 | 31 || 32 | 0 | IN | IO3_D3 | 26 | 123 | | 13 | 23 | IO0_B5 | IN | 1 | 33 || 34 | | | 0V | | | | 125 | 24 | IO3_D5 | IN | 0 | 35 || 36 | 0 | IN | IO3_D4 | 27 | 124 | | | 25 | AIN1 | | | 37 || 38 | | | 1V8 | 28 | | | | | 0V | | | 39 || 40 | | | AIN0 | 29 | | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+--- M1 ---+---+------+---------+-----+-----+
root@odroid:~# gpio readall -a +------+-----+----------+------+---+----+---- Model ODROID-M1 ----+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | | | 3.3V | | | | | 1 || 2 | | | | | 5V | | | | 110 | 8 | I2C0_SDA | IN | 1 | 1 | P/D | 3 || 4 | | | | | 5V | | | | 109 | 9 | I2C0_SCL | IN | 1 | 1 | P/D | 5 || 6 | | | | | GND(0V) | | | | 14 | 7 | GPIO0_B6 | IN | 1 | 0 | P/U | 7 || 8 | P/D | 1 | 0 | IN | UART1_TX | 15 | 126 | | | | GND(0V) | | | | | 9 || 10 | P/D | 1 | 0 | IN | UART1_RX | 16 | 127 | | 16 | 0 | GPIO0_C0 | IN | 0 | 0 | P/D | 11 || 12 | P/D | 1 | 0 | IN | GPIO3_D0 | 1 | 120 | | 17 | 2 | GPIO0_C1 | IN | 0 | 0 | P/D | 13 || 14 | | | | | GND(0V) | | | | 106 | 3 | GPIO3_B2 | IN | 0 | 1 | P/D | 15 || 16 | P/D | 1 | 0 | IN | GPIO3_C6 | 4 | 118 | | | | 3.3V | | | | | 17 || 18 | P/D | 1 | 0 | IN | GPIO3_C7 | 5 | 119 | | 89 | 12 | SPI_MOSI | IN | 0 | 1 | P/D | 19 || 20 | | | | | GND(0V) | | | | 88 | 13 | SPI_MISO | IN | 0 | 1 | P/D | 21 || 22 | P/D | 1 | 0 | IN | GPIO3_D1 | 6 | 121 | | 91 | 14 | SPI_CLK | IN | 0 | 1 | P/D | 23 || 24 | P/D | 1 | 0 | IN | SPI_CS0 | 10 | 90 | | | | GND(0V) | | | | | 25 || 26 | P/D | 1 | 0 | IN | GPIO3_D2 | 11 | 122 | | 12 | 30 | I2C1_SDA | ALT3 | 1 | 0 | DSBLD | 27 || 28 | DSBLD | 0 | 1 | ALT3 | I2C1_SCL | 31 | 11 | | 145 | 21 | GPIO4_C1 | IN | 0 | 1 | P/D | 29 || 30 | | | | | GND(0V) | | | | 142 | 22 | GPIO4_B6 | IN | 0 | 1 | P/D | 31 || 32 | P/D | 1 | 0 | IN | GPIO3_D3 | 26 | 123 | | 13 | 23 | GPIO0_B5 | IN | 1 | 0 | P/U | 33 || 34 | | | | | GND(0V) | | | | 125 | 24 | GPIO3_D5 | IN | 0 | 1 | P/D | 35 || 36 | P/D | 1 | 0 | IN | GPIO3_D4 | 27 | 124 | | | 25 | ADC.AIN1 | | | | | 37 || 38 | | | | | 1V8 | 28 | | | | | GND(0V) | | | | | 39 || 40 | | | | | ADC.AIN0 | 29 | | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+---- Model ODROID-M1 ----+----+---+------+----------+-----+------+
ODROID-M1S
root@odroid:~# gpio readall +-----+-----+---------+------+---+ M1S +---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3V | | | 1 || 2 | | | 5V | | | | 110 | 8 | SDA0 | ALT5 | 1 | 3 || 4 | | | 5V | | | | 109 | 9 | SCL0 | ALT5 | 1 | 5 || 6 | | | 0V | | | | 14 | 7 | IO0_B6 | IN | 1 | 7 || 8 | 1 | IN | UART.TX | 15 | 68 | | | | 0V | | | 9 || 10 | 1 | IN | UART.RX | 16 | 67 | | 16 | 0 | IO0_C0 | IN | 0 | 11 || 12 | 1 | IN | IO2_A7 | 1 | 71 | | 17 | 2 | IO0_C1 | IN | 0 | 13 || 14 | | | 0V | | | | 18 | 3 | IO0_C2 | IN | 0 | 15 || 16 | 1 | IN | IO2_B5 | 4 | 77 | | | | 3.3V | | | 17 || 18 | 1 | IN | IO2_B6 | 5 | 78 | | 113 | 12 | SPI.TXD | ALT4 | 1 | 19 || 20 | | | 0V | | | | 114 | 13 | SPI.RXD | ALT4 | 1 | 21 || 22 | 0 | IN | IO2_B0 | 6 | 72 | | 115 | 14 | SPI.CLK | ALT4 | 0 | 23 || 24 | 1 | OUT | SPI.CS0 | 10 | 97 | | | | 0V | | | 25 || 26 | 0 | IN | IO2_B1 | 11 | 73 | | 12 | 30 | SDA1 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL1 | 31 | 11 | | 80 | 21 | IO2_C0 | IN | 0 | 29 || 30 | | | 0V | | | | 79 | 22 | IO2_B7 | IN | 0 | 31 || 32 | 1 | IN | IO2_B2 | 26 | 74 | | 13 | 23 | IO0_B5 | IN | 1 | 33 || 34 | | | 0V | | | | 69 | 24 | IO2_A5 | IN | 1 | 35 || 36 | 1 | IN | IO2_A6 | 27 | 70 | | | 25 | AIN1 | | | 37 || 38 | | | 1V8 | 28 | | | | | 0V | | | 39 || 40 | | | AIN0 | 29 | | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | I/O | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | I/O | +-----+-----+---------+------+---+ M1S +---+------+---------+-----+-----+
root@odroid:~# gpio readall -a +------+-----+----------+------+---+----+ Model ODROID-M1S +----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | | | 3.3V | | | | | 1 || 2 | | | | | 5V | | | | 110 | 8 | I2C0_SDA | ALT5 | 1 | 1 | DSBLD | 3 || 4 | | | | | 5V | | | | 109 | 9 | I2C0_SCL | ALT5 | 1 | 1 | DSBLD | 5 || 6 | | | | | GND(0V) | | | | 14 | 7 | GPIO0_B6 | IN | 1 | 0 | P/U | 7 || 8 | P/U | 3 | 1 | IN | UART1_TX | 15 | 68 | | | | GND(0V) | | | | | 9 || 10 | P/U | 3 | 1 | IN | UART1_RX | 16 | 67 | | 16 | 0 | GPIO0_C0 | IN | 0 | 0 | P/D | 11 || 12 | P/U | 3 | 1 | IN | GPIO2_A7 | 1 | 71 | | 17 | 2 | GPIO0_C1 | IN | 0 | 0 | P/D | 13 || 14 | | | | | GND(0V) | | | | 18 | 3 | GPIO0_C2 | IN | 0 | 0 | P/D | 15 || 16 | P/U | 3 | 1 | IN | GPIO2_B5 | 4 | 77 | | | | 3.3V | | | | | 17 || 18 | P/U | 1 | 1 | IN | GPIO2_B6 | 5 | 78 | | 113 | 12 | SPI_MOSI | ALT4 | 1 | 1 | DSBLD | 19 || 20 | | | | | GND(0V) | | | | 114 | 13 | SPI_MISO | ALT4 | 1 | 1 | DSBLD | 21 || 22 | P/D | 1 | 0 | IN | GPIO2_B0 | 6 | 72 | | 115 | 14 | SPI_CLK | ALT4 | 0 | 1 | DSBLD | 23 || 24 | P/D | 1 | 1 | OUT | SPI_CS0 | 10 | 97 | | | | GND(0V) | | | | | 25 || 26 | P/D | 1 | 0 | IN | GPIO2_B1 | 11 | 73 | | 12 | 30 | I2C1_SDA | ALT2 | 1 | 0 | DSBLD | 27 || 28 | DSBLD | 0 | 1 | ALT2 | I2C1_SCL | 31 | 11 | | 80 | 21 | GPIO2_C0 | IN | 0 | 1 | P/D | 29 || 30 | | | | | GND(0V) | | | | 79 | 22 | GPIO2_B7 | IN | 0 | 1 | P/D | 31 || 32 | P/U | 1 | 1 | IN | GPIO2_B2 | 26 | 74 | | 13 | 23 | GPIO0_B5 | IN | 1 | 0 | P/U | 33 || 34 | | | | | GND(0V) | | | | 69 | 24 | GPIO2_A5 | IN | 1 | 3 | P/U | 35 || 36 | P/U | 3 | 1 | IN | GPIO2_A6 | 27 | 70 | | | 25 | ADC.AIN1 | | | | | 37 || 38 | | | | | 1V8 | 28 | | | | | GND(0V) | | | | | 39 || 40 | | | | | ADC.AIN0 | 29 | | +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+ | GPIO | wPi | Name | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode | Name | wPi | GPIO | +------+-----+----------+------+---+----+ Model ODROID-M1S +----+---+------+----------+-----+------+
WiringPi Python Wrapper
Hardkernel also provides WiringPi Python binder for Python programmer called WiringPi-Python. WiringPi-Python is Python-wrapped version of Hardkernel's WiringPi.
Ubuntu PPA
We made a simple wrapper Debian package to install/update automatically for Python wrapper.
- target
sudo apt install software-properties-common sudo add-apt-repository ppa:hardkernel/ppa sudo apt update sudo apt install odroid-wiringpi-python
After installing this package, it installs odroid-wiringpi PyPI package using PIP.
This package has two dependency packages; python3, python3-pip. If you want to use Python 2, you can install like the below commands.
- target
sudo apt install python python-pip sudo odroid-wiringpi-python --install
Python PyPI
- target
sudo apt install python python3 python-pip python3-pip sudo python3 -m pip install odroid-wiringpi
Github repository
- target
sudo apt install git python-dev python-setuptools python3-dev python3-setuptools swig git clone --recursive https://github.com/hardkernel/WiringPi2-Python cd WiringPi2-Python sudo python3 setup.py install
Examples
LED On/Off
You can turn on/off a connected LED using WiringPi.
This example uses physical pin #11 (#0 on WiringPi) and a ground pin.
ODROID-XU4 (+Shifter Shield)
Please refer ShiftShield for more detail.
- Download Fritzing Example File: xu4_led.fzz
C
- target
# C $ gcc -o wpi_exam_led wpi_exam_led.c $(pkg-config --cflags --libs libwiringpi2) $ ./wpi_exam_led
- wpi_exam_led.c
#include <wiringPi.h> int main(void) { wiringPiSetup(); pinMode(0, OUTPUT); for (;;) { digitalWrite(0, HIGH); delay(1000); digitalWrite(0, LOW); delay(1000); } return 0; }
Python 2
- target
# Python 2 $ sudo python wpi_exam_led.py
- wpi_exam_led.py
#!/usr/bin/env python import odroid_wiringpi as wpi import time wpi.wiringPiSetup() wpi.pinMode(0, 1) while True: wpi.digitalWrite(0, 1) time.sleep(1) wpi.digitalWrite(0, 0) time.sleep(1)
Serial Loopback
A simple serial loopback example.
This example uses physical pin #8, #10 (#15, #16 on WiringPi).
Connect each other that two pins directly.
ODROID-XU4 (+Shifter Shield)
Please refer ShiftShield for more detail.
- Download Fritzing Example File: xu4_serial_loopback.fzz
- The serial device file name is different on each boards.
- ODROID-XU4: /dev/ttySAC0
- ODROID-C1/C1+: /dev/ttyS2
- ODROID-C2: /dev/ttyS1
- ODROID-N2: /dev/ttyS1
- ODROID-C4: /dev/ttyS1
- ODROID-M1/M1S: /dev/ttyS0
C
- target
# C $ gcc -o wpi_exam_serial_loopback wpi_exam_serial_loopback.c $(pkg-config --cflags --libs libwiringpi2) $ ./wpi_exam_serial_loopback
- wpi_exam_serial_loopback.c
#include <wiringSerial.h> #include <wiringPi.h> #include <stdio.h> int main(int argc, char ** argv) { int fd = serialOpen("/dev/ttyS0", 115200); char buf[255]; while (1) { printf("Serial Input> "); fgets(buf, 255, stdin); serialPuts(fd, buf); delay(10); printf("Serial Output> "); while (serialDataAvail(fd)) putchar(serialGetchar(fd)); } }
Python 2
- target
# Python 2 $ sudo python wpi_exam_serial_loopback.py # Will result like.. $ sudo python wpi_exam_serial_loopback.py Serial Input> test Serial Output> test Serial Input>
- wpi_exam_serial_loopback.py
#!/usr/bin/env python import odroid_wiringpi as wpi import time serial = wpi.serialOpen('/dev/ttyS0', 115200) while True: input_str = raw_input('Serial Input> ') wpi.serialPuts(serial, input_str) time.sleep(0.1) output_str = 'Serial Output> ' while wpi.serialDataAvail(serial): output_str += chr(wpi.serialGetchar(serial)) print output_str wpi.serialClose(serial)