While attempting to read data from an ak8963c sensor board over i2c I am only getting 0s as a response except when reading the first 2 registries. I have checked my connections and tried other devices but they all work as expected. I also tried placing a magnet nearby in the hopes interference would be overpowered by said magnet.
Code:
import smbus
import time
CHL = 1
#AK8963 registers
AK8963_ADDR = 0x0C
AK8963_ST1 = 0x02
HID = 0x00
HX = 0x03
HY = 0x05
HZ = 0x07
AK8963_ST2 = 0x09
AK8963_CNTL = 0x0A
mag_sens = 4900.0 # magnetometer sensitivity: 4800 uT
bus = smbus.SMBus(CHL)
print('recording data')
#val = bus.read_i2c_block_data(AK8963_ADDR, HXH, 6)
val = bus.read_byte_data(AK8963_ADDR, HX)
valH = bus.read_byte_data(AK8963_ADDR, HX+1)
#mx = (val[0] << 8) | val[1]
#my = (val[2] << 8) | val[3]
#mz = (val[4] << 8) | val[5]
mx = (valH << 8) | val
val = bus.read_byte_data(AK8963_ADDR, HY)
valH = bus.read_byte_data(AK8963_ADDR, HY+1)
my = (valH << 8) | val
val = bus.read_byte_data(AK8963_ADDR, HZ)
valH = bus.read_byte_data(AK8963_ADDR, HZ+1)
mz = (valH << 8) | val
misc = bus.read_byte_data(AK8963_ADDR, 0x00)
print('{}'.format('-'*50))
#print('mag [uT]: x = , y = , z = '.format(mx,my,mz))
print('mag [uT]: x= % 2d, y= % 2d, z= % 2d, misc= % 2d' %(mx, my, mz, misc))
print('{}'.format('-'*50))