Gentlefolk,
Greetings. I am trying to access the MAG-3110 magnetometer on the M5STACK FIRE but have been unsuccessful so far. However, I am able to access the MPU-6050 without any discernible issues.
I have a Windows environment and am using MicroPython. I've tried a number of MicroPython firmware and the latest one I'm using is m5cloud-psram-20180516-v0.4.0.bin. I am also using M5Burner for Windows to flash the M5STACK FIRE.
I've tried to reverse-engineer a number of Python modules in order to see if I can access the magnetometer via REPL. Here are some of the results I have obtained:
from machine import I2C
i2c = I2C(scl=Pin(22), sda=Pin(21), speed=400000)
i2c.scan()
[14, 104, 117] # addr 104 is the MPU-6050 and 14 should be the MAG-3110
struct.unpack("B", i2c.readfrom_mem(14, 7, 1)) # check who_am_i register on device with addr 14
(196,) # is this the correct response (0xC4) according to the spec sheet
i2c.writeto_mem(14, 16, 1) # set operation mode, RW register according to the spec sheet (CTRL_REG1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object with buffer protocol required
i2c.writeto_mem(14 17, 1) # try the other register, RW register according to the spec sheet (CTRL_REG1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object with buffer protocol required
Note that the same things happen when I try to access address 117 although I get a different response WHO_AM_I (i.e., 0x80 instead of 0xC4). If I try to read the data registers, the contents do not change even if I aggressively move the M5STACK FIRE. I am, however, able to get accelerometer and gyroscope readings.
Has anyone else encountered this or have successfully accessed the magnetometer on the M5STACK FIRE?
Best regards.