Example Code for Raspberry Pi – Read 14-byte raw data of accelerometer, temperature and gyroscope

This tutorial shows how to read the 14-byte raw output data of the accelerometer, onboard temperature sensor, and gyroscope from the ICG-20660L on a Raspberry Pi.

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_get_sensor_raw_data.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

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_get_sensor_raw_data.py

Result:

Was this article helpful?

TOP