Example Code for Raspberry Pi – Interrupt Function

This tutorial shows how to configure and read interrupt events from the ICG-20660L on a Raspberry Pi, including data-ready and motion-triggered interrupts.

Hardware Preparation

Software Preparation

  1. Install the Raspberry Pi OS
    Download from the official website:
    Raspberry Pi Official OS

  2. Download the ICG-20660L Python library
    GitHub repository:
    DFRobot_ICG20660L

  3. Ensure Python and required dependencies are installed (included in steps below).

  4. Open the demo_motion_wakr.py example file from the downloaded library.

Wiring Diagram

Connect the module to the Raspberry Pi according to the wiring diagram.
The default I²C address of the sensor is 0x69.

Raspberry Pi Wiring

Demo Interrupt Pin Mapping

Mainboard Default Pin
Micro:bit P9
ESP32 D9
ESP8266 D5
Raspberry Pi BCM27

Connect the interrupt pin only if the interrupt function is required.

Driver Installation

  • Enable the I2C interface of the Raspberry Pi. If it is already enabled, you can skip this step. Open Terminal, type the following command, and press Enter:
 sudo raspi-config

Then use the up and down keys to select "5 Interfacing Options", press Enter, select "P5 I2C", and press Enter to confirm "YES". Restart the Raspberry Pi main control board.

  • To install Python dependent libraries and git, the Raspberry Pi needs to be connected to the Internet. If it is already installed, you can skip this step. In the terminal, type the following commands in sequence, and press Enter:
sudo apt-get update
sudo apt-get install build-essential python-dev python-smbus git
  • Download the LIS series driver library. In the terminal, type the following commands in sequence and press Enter:
cd Desktop
git clone https://github.com/DFRobot/DFRobot_ICG20660L

Sample Code

In the terminal, type the following command and press Enter, run the sample code:

  cd DFRobot_ICG20660L/Python/raspberrypi/examples
  python demo_motion_wakr.py

Result:

Was this article helpful?

TOP