Once armbian is installed, its easy to tell what board you have, simply cat /etc/armbian-release and look for BOARD_NAME
Install ARMbian on your Orange Pi
We're only going to be using armbian, other distros could be made to work but you'd probably need to figure out how to detect the platform since we rely on /etc/armbian-release
existing.
Download and install the latest armbian, for example we're using https://www.armbian.com/orange-pi-pc-plus/
There's some documentation to get started at https://docs.armbian.com/User-Guide_Getting-Started/
We've found the easiest way to connect is through a console cable, wired to the debug port, and then on your computer, use a serial monitor at 115200 baud.

After logging in you may be asked to create a new username, we recommend pi - if our instructions end up adding gpio access for the pi user, you can copy and paste em
Once installed, you may want to enable mdns so you can ssh pi@orangepipc
instead of needing to know the IP address:
sudo apt-get install avahi-daemon
then reboot
Install Python and set Python 3 to Default
There's a few ways to do this, we recommend something like this
sudo apt-get install -y python3 git python3-pip sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2 sudo update-alternatives --config python
Of course change the version numbers if newer Python is distributed
sudo apt-get install libgpiod2 python3-libgpiod pip3 install gpiod
After installation you should be able to import gpiod
from within Python3
Update Your Board and Python
Run the standard updates:
sudo apt-get update
sudo apt-get upgrade
and
sudo pip3 install --upgrade setuptools
Update all your python 3 packages with
pip3 freeze - local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
and
sudo bash
pip3 freeze - local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
Enable UART, I2C and SPI
A vast number of our CircuitPython drivers use UART, I2C and SPI for interfacing so you'll want to get those enabled.
You only have to do this once per board but by default all three interfaces are disabled!
Install the support software with
sudo apt-get install -y python-smbus python-dev i2c-tools
sudo adduser pi i2c
Edit /boot/armbianEnv.txt and add these lines at the end, adjusting the overlay_prefix
for your particular board
overlay_prefix=sun8i-h3
overlays=uart3 i2c0 spi-spidev
param_spidev_spi_bus=0
Once you're done with both and have rebooted, verify you have the I2C and SPI devices with the command ls /dev/i2c* /dev/spi*
You should see at least one i2c device and one spi device
You can test to see what I2C addresses are connected by running sudo i2cdetect -y 0
(on PA11/PA12) or sudo i2cdetect -y 1
(on PA18/PA19)
In this case I do have a sensor on the 'standard' i2c port i2c-0 under address 0x77
You can also install WiringOP and then run gpio readall
to see the MUX status. If you see ALT3 next to a pin, its a plain GPIO. If you see ALT4 or ALT5, its an SPI/I2C/UART peripheral
Install Python libraries
Now you're ready to install all the python support
Run the following command to install adafruit_blinka
pip3 install adafruit-blinka
The computer will install a few different libraries such as adafruit-pureio
(our ioctl-only i2c library), spidev
(for SPI interfacing), Adafruit-GPIO
(for detecting your board) and of course adafruit-blinka
That's pretty much it! You're now ready to test.
Create a new file called blinkatest.py with nano or your favorite text editor and put the following in:
import board import digitalio import busio print("Hello blinka!") # Try to great a Digital input pin = digitalio.DigitalInOut(board.PA6) print("Digital IO ok!") # Try to create an I2C device i2c = busio.I2C(board.SCL, board.SDA) print("I2C ok!") # Try to create an SPI device spi = busio.SPI(board.SCLK, board.MOSI, board.MISO) print("SPI ok!") print("done!")
Save it and run at the command line with
sudo python3 blinkatest.py
You should see the following, indicating digital i/o, I2C and SPI all worked
Page last edited March 08, 2024
Text editor powered by tinymce.