cancel
Showing results for 
Search instead for 
Did you mean: 

ISM330DLC reading Registers failed Python

LT
Visitor

I am reaching out regarding an issue I am experiencing while reading register values from the ISM330DLC sensor using a Python script over SPI. Specifically, I am encountering incorrect data when accessing certain registers.

For example, when reading the WHO_AM_I register (0x0F), I receive a value of 0x7F instead of the expected 0x6A. This discrepancy suggests there may be an issue with the communication setup or the sensor response.

Here is a brief outline of my setup and process:

  • Hardware:Raspberry Pi 5 connected to the ISM330DLC via SPI.
  • Correct wiring verified (VDD, GND, SCL, SDA, CS).
  • Software:Python with spidev library for SPI communication.
  • SPI mode set to Mode 0 (CPOL=0, CPHA=0).
  • SPI clock speed: 1 MHz.

Code Snippet:

import spidev 

spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 1000000 
spi.mode = 0   

# Reading WHO_AM_I register 
reg = 0x80 | 0x0F  # Set MSB for read operation 
response = spi.xfer2([reg, 0x00]) 
print(f"Response: {response}") 

Despite these checks, the returned values remain inconsistent with the datasheet specifications. I would greatly appreciate your guidance on troubleshooting this issue and verifying the sensor’s communication settings.

Thank you for your support!

2 REPLIES 2

Welcome to the forum

 


@LT wrote:

reading register values from the ISM330DLC sensor using a Python script over SPI.

:

:

  • Correct wiring verified (VDD, GND, SCL, SDA, CS).

That doesn't make sense: SCL and SDA are I2C - not SPI.

Please show an actual schematic of your connections.

What Is the ISM330DLC sensor on - a breakout board? Please give details.

Please show the full Python code

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

Note that the Code Editor has an option for Python - it's not just for C

Thank you for editing my post.
Yor are right, i mixed some terms. The Data pins are only listet as SDO and SDA in the datasheet. I am using the MKI182V2 Adapterboard with ISM330DLC. The wiring with 4-Wire SPI:

MKI182V2 - Raspi5
GND - GND

VDD - 3.3V

SCL - SPI SCLK

CS - SPI CE0

SDA - SPI MOSI

SDO - SPI MISO

The Python-Code works perfectly with another Sensor (IIS2DH on MKI168v1). Any idea, why that gives me incorrect data on the ISM330DLC?