SparkFun Linear 3D Hall-Effect Sensor - TMAG5273 (Qwiic) with Raspberry Pi python

Hello,

I am trying to create a rotary encoder using the 3D Hall-Effect sensor (TMAG5273) using my Raspberry Pi 4 model B with Python. I want to read the current angle of the magnet. I am using a diametrically polarized ring magnet.

However, I am having a hard time finding any resources on how to read data from the TMAG5273.

I wrote a sample code in Python to read the data from the sensor using I2C, however, I was not able to get anything that did make sense. (I attached my code below)

I also attached below the output from the code

I would really appreciate it if you could help me out with an example code.

Thank you,

Tozturk

from smbus2 import SMBus
import time

# I2C channel 1 is connected to the GPIO pins
channel = 1

# Device Address
address = 0x22

# Initialize I2C (SMBus)
with SMBus(channel) as bus:
    try:
            bus.pec = 1  # Enable PEC

            # Loop forever
            while(True):
                # Read 32 bits of block data
                block = bus.read_i2c_block_data(address, 0, 32)
                # Print out the block
                print(f"\nData: {block}")
                # Delay for 0.5 seconds
                time.sleep(0.5)

    except KeyboardInterrupt:
        bus.close()

It just repeats the output below, even when moving the magnet on top of it:

Data: [0, 0, 0, 0, 16, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

https://docs.sparkfun.com/SparkFun_Qwii … ple_basic/ :slight_smile: