🛠 Mastering I/O on AIWorld P1

AIWorld P1 AI Module for BPI-M2 Ultra and Berry · intermediaire · Apprenez à lire les données du capteur IMU et à contrôler les GPIO via Vecoo Linux.

Objectives

This tutorial aims to understand hardware interaction on the AIWorld P1 board. You will learn to access raw data from the ICM20602 inertial sensor (IMU) and manipulate GPIO pins for external device control. Although the kit is optimized for vision, understanding I/O is crucial for autonomous robotics.

Materials needed

Steps

Connect the AIWorld P1 to the host. Ensure Vecoo Linux is booted. Use the VecooAT tool to establish a stable ADB connection, essential for file transfer and debugging. ``bash adb devices ``

  1. Environment Preparation

Open a shell on the board to interact with the Linux kernel. ``bash adb shell ``

  1. File System Access

The ICM20602 sensor is typically exposed via the I2C interface or a dedicated driver in Vecoo. Verify the device presence. ``bash ls /dev/i2c* # If the driver is loaded, data can be read via sysfs or a dedicated binary cat /sys/class/iio/device*/in_accel_x_raw ` *Note: Exact paths depend on the Vecoo kernel configuration. Use dmesg` to check bus initialization.*

  1. Reading IMU Data (ICM20602)

GPIOs are accessible via the physical port. To manipulate them under Linux, use the sysfs filesystem or the provided GPIO library. ``bash # Generic example of exporting a GPIO (number to be adapted according to schematic) echo 100 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio100/direction echo 1 > /sys/class/gpio/gpio100/value ``

  1. GPIO Control

Use ARM Computer Library 17.06 for more complex tests if needed. Compile a small C program using OpenMP to process IMU data in real-time.

  1. Compilation and Test Execution

Verification

Further Reading

Integrate these IMU data streams with the OV5640 camera video feed via Gstreamer to create an image stabilization or motion detection system. Explore using OpenCV to correct image distortion based on IMU data.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials