🛠 Controlling GPIOs on Banana Pi BPI-RT2

Banana Pi BPI-RT2: AX3000 WiFi 6 Router Board · debutant · Apprenez à activer et utiliser les broches GPIO et I2C pour connecter des capteurs ou des afficheurs.

Objectives

This tutorial introduces physical interaction with the Banana Pi BPI-RT2. Although designed as a WiFi 6 router, it exposes GPIO and I2C extension interfaces for simple electronic components. You will learn to identify pins, install necessary tools, and light an LED via a simple script.

Required Hardware

Steps

  1. System Access: Connect the card to your network via the WAN port. Access the web interface (default 192.168.1.1) and enable the SSH server in the System menu.
  2. SSH Connection: Open a terminal on your computer and connect via ssh root@192.168.1.1. Accept security keys and enter the defined password.
  3. Tool Installation: The card uses OpenWrt. Update package lists with opkg update then install GPIO tools with opkg install kmod-gpio-button-hotplug gpioctl. These tools allow manipulation of physical pins on the 5 and 9-pin headers.
  4. Pin Identification: Consult technical documentation to identify available GPIO pins on the headers. GPIO and I2C signals are shared; ensure you do not use a pin already occupied by the system if configured as output.
  5. Wiring: Connect the long leg (anode) of the LED to an identified GPIO pin. Connect the short leg (cathode) to a 330 Ohm resistor, then connect the other end of the resistor to the GND (ground) pin of the card.
  6. Pin Activation: In the SSH terminal, activate the pin as output. For example, if GPIO 10 is free, use echo 10 > /sys/class/gpio/export to make it accessible.
  7. Configuration and Test: Set direction to output with echo out > /sys/class/gpio/gpio10/direction. To light the LED, send a high signal: echo 1 > /sys/class/gpio/gpio10/value. The LED should light up.
  8. Turning Off: To turn off the LED, send a low signal: echo 0 > /sys/class/gpio/gpio10/value.

Verification

Physically observe the LED. It should light up when executing echo 1 and turn off with echo 0. If nothing happens, check LED orientation, resistor connection, and ensure the selected pin is not conflicting. Use cat /sys/class/gpio/gpio10/value to check the current logical state.

Going Further

Explore the I2C interface exposed on the same connectors to connect a small OLED screen or temperature sensor. You will need to install kmod-i2c-core and kmod-i2c-dev. Note that the firmware is based on an older OpenWrt version; ensure drivers are available in official Banana Pi repositories to avoid conflicts.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials