For my project, I am using Micropython. I am unable to activate the APEX-motion features using I2C interface. All other sensor readings are working fine.
def enable_imu(self):
# we want to put both accelerometer and gyroscope to LN mode
# if you want to put to LP mode write 0x0A
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _PWR_MGMT0, b'\x1F')
#self.i2c.stop()
time.sleep(0.05)
return 0
def set_accel_rate(self):
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _ACCEL_CONFIG0, b'\x08')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _ACCEL_CONFIG1, b'\x07')
time.sleep(0.05)
return 0
def enable_APEX(self):
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _INT_CONFIG, b'\x3F')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _INT_SOURCE0, b'\x00')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _INT_SOURCE1, b'\x00')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _INT_SOURCE3, b'\x00')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _INT_SOURCE4, b'\x00')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _APEX_CONFIG0, b'\x01')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _APEX_CONFIG1, b'\x22')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _APEX_CONFIG12, b'\x00')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _APEX_DATA4, b'\x03')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _APEX_DATA5, b'\x00')
time.sleep(0.05)
def write_mag_register(self, banknum, registeraddr, value):
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _BLK_SEL_W, b'\x00')
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _MADDR_W, registeraddr.to_bytes(1))
time.sleep(0.05)
self.i2c.writeto_mem(_ICM2670P_ADDRESS, _M_W, value.to_bytes(1))
time.sleep(0.05)
def clear_int(self):
print()
self.i2c.readfrom_mem(_ICM2670P_ADDRESS, _INT_STATUS3, 1)
def read_padometer(self):
data = self.i2c.readfrom_mem(_ICM2670P_ADDRESS, _PADOMETER_LOW, 2)
steps = int.from_bytes(data[0:2], "big")
print(self.get_twos_complement(steps))
print('detected activity')
act = self.i2c.readfrom_mem(_ICM2670P_ADDRESS, _APEX_DATA3, 1)
print(act)