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-r1/
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. For the Orange Pi R1, you will also need to solder a header for debugging and GPIO access to the Orange Pi R1.
Connecting the GPIO/Debug Header
Because the Orange Pi R1 does not come with any GPIO headers, you will need to solder one in order to connect breakout boards.
Prepare the header strip:
Cut the strip to length. You will want to make a cut to the side of the blue strip that is closer to the center. After cutting, you should have one piece that is 2x13 pins and another that is 2x7 pins.
Place the header:
Because the ethernet ports are on the tall side, we found that placing a small object under the header such as a small piece of foam works well.
And Solder!
Be sure to solder all pins for reliable electrical contact.
(For tips on soldering, be sure to check out our Guide to Excellent Soldering).
Logging in using Serial
To log in through serial, you will need to connect a USB to TTL Serial cable up to the Orange Pi. You may also need to install some software. Be sure to check out our Adafruit's Raspberry Pi Lesson 5. Using a Console Cable guide. Although it is written for a Raspberry Pi, the drivers and cable connection should be the same.
Connect the serial cable's TX (White), RX (Green), and Ground (Black) wires to the 3 pins next to the ethernet ports as shown in the photo and start your terminal program.
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 [email protected]
instead of needing to know the IP address:
sudo apt-get install avahi-daemon
then reboot
Connecting using DHCP and SSH
Another option that you may be available to you is to connect using SSH, or Secure Shell. To connect, you will need to have DHCP, or Dynamic Host Configuration Protocol, enabled and configured on your network and look up the IP address assigned to the Orange Pi R1.
By default, most routers have DHCP enabled and some routers will display all of the hosts connected to them through the web configuration panel. If you are able to retrieve the IP address, then you can connect through SSH.
MacOS/Linux
Mac and Linux should have SSH installed by default and you can access it by going to the command line and typing ssh [email protected]
if the IP address of your Orange Pi is 192.168.0.25.
Windows
The easiest way to connect with windows is to use a Terminal program called PuTTY from https://www.putty.org.
You can read more about connecting through SSH in our Adafruit's Raspberry Pi Lesson 6. Using SSH guide. Although this is written for Raspberry Pi, the steps should be the same.
Set your Python install to Python 3 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
Install Required pip3 Modules
For the Orange Pi R1, a couple of pip modules are required to smooth out the installation.
Run the following command.
sudo pip3 install wheel flask
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=uart1 i2c0 spi-spidev usbhost2 usbhost3
param_spidev_spi_bus=1
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)
In this case I do have a sensor on the 'standard' i2c port i2c-0 under address 0x77
You can also install WiringOP-Zero and then run gpio readall
to see the MUX status. If you see ALT3 next to a pin, it's 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
sudo 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
Text editor powered by tinymce.