The Orange PI Zero 2 is one of the many Orange Pi boards offering interesting features:
- 64-bit ARM H616 4-core processor
- 1GB ethernet
- WIFI + BT
- 512MB or 1GB RAM
- USB 2
- Micro HDMI
- OS: DEBIAN. See article here for installation
- price around 30 € at Aliexpress
To access the GPIO of an Orange PI, you can use one of the libraries (if it exists) or use the Sysfs virtual file system introduced by the Linux kernel which allows system commands to activate the GPIO pins.
If the Sysfs virtual file method is simple and adapts to all cards, it does not allow the input resistance to be positioned in PULLUP or PULLDOWN. In addition, the actions sometimes take ms which makes it impossible to check for a few micro seconds.
Orange Pi Zero2 board connector
The Pi Zero 2 board has a 26-pin connector as shown in the diagram below.
Toaddress one of the input or output pins, you have to find the reference of the corresponding GPIO. The table below is valid for the Orange Pi Zero 2 H616. So if you want to use pin 10, it corresponds to GPIO 227. This table is for example different for an Orange Pi One Plus H6 or GPIO 227 corresponds to pin 26.
Example Oscillator on pin 10
Below is a program in python 3. Attention, important constraint. You must be root to access the GPIO.
#!/usr/bin/python3 Python 3 environment #-- coding: utf-8 -- import os # To execute system command from time import sleep # this lets us have a time delay numgpio=227 numgpio=str(numgpio) print ("numgpio:"+numgpio) os.system("sudo echo "+numgpio+" > /sys/class/gpio/export") os.system("sudo echo out > /sys/class/gpio/gpio"+numgpio+"/direction") try: print ("Square signal around 50Hz . Press CTRL+C to exit") while True: os.system("echo 0 > /sys/class/gpio/gpio"+numgpio+"/value") sleep(0.01) os.system("echo 1 > /sys/class/gpio/gpio"+numgpio+"/value") sleep(0.01) except KeyboardInterrupt: # set port/pin value to 0/LOW/False os.system("echo 0 > /sys/class/gpio/gpio"+numgpio+"/value") # Clean GPIO os.system("sudo echo "+numgpio+" > /sys/class/gpio/unexport") print ("Bye from F1ATB.")
to launch it, if the program is on your desktop:
You can enter commands manually from a terminal window.
The … export command activates the GPIO 227 which corresponds to pin 10.
The direction command, here out to be in output.
The commands value alternately to 0 or 1 to make an oscillator.
Then in case of Ctrl-C, we finish cleanly by freeing the GPIO 227.
To get rid of the root problem, a solution can be to run the program when starting up the Orange PI which in this case is root before switching to user mode. All you have to do is modify the /etc/rc.local file (sudo nano /etc/rc.local). Put the launch command with the absolute path (python. /Home/……py) before exit 0 of the rc.local file. Another solution is a cron job.
Posts about the Orange Pi Zero 2
- Remote SDR V5 -Raspberry 4B or Orange Pi Image Installation
- Remote SDR v5 – Manual Installation
- Remote SDR v5
- Communication Ports
- Setting of GPIO outputs
- CPU Cooling
- Introduction to Remote SDR
- VHF and UHF NBFM Transceiver
- Remote SDR v4
- Remote SDR V4 – Raspberry Pi 4B or Orange Pi Zero 2 image installation
- Remote SDR v4 – Manual Installation
- SA818 – RTL-SDR
- Orange Pi Zero 2 setup – Armbian Bullseye
- Remote SDR V2 – Software Architecture
- Orange PI Zero 2 H616 GPIO
- Orange Pi Zero 2 Setup – Debian Buster
- Remote SDR v2 – Orange Pi One Plus or Orange Pi Zero 2 image installation
- Remote SDR V2 – Manual installation
- Remote SDR V1- Purchase
- Remote SSB Transmitter