<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Acessing the MAG-3110 on the M5STACK FIRE]]></title><description><![CDATA[<p dir="auto">Gentlefolk,</p>
<p dir="auto">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.</p>
<p dir="auto">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 <em><strong>m5cloud-psram-20180516-v0.4.0.bin</strong></em>. I am also using M5Burner for Windows to flash the M5STACK FIRE.</p>
<p dir="auto">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:</p>
<p dir="auto">from machine import I2C</p>
<p dir="auto">i2c = I2C(scl=Pin(22), sda=Pin(21), speed=400000)</p>
<p dir="auto">i2c.scan()<br />
[14, 104, 117]    # addr 104 is the MPU-6050 and 14 should be the MAG-3110</p>
<p dir="auto">struct.unpack("B", i2c.readfrom_mem(14, 7, 1))    # check who_am_i register on device with addr 14<br />
(196,)    # is this the correct response (0xC4) according to the spec sheet</p>
<p dir="auto">i2c.writeto_mem(14, 16, 1)    # set operation mode, RW register according to the spec sheet (CTRL_REG1)<br />
Traceback (most recent call last):<br />
File "&lt;stdin&gt;", line 1, in &lt;module&gt;<br />
TypeError: object with buffer protocol required</p>
<p dir="auto">i2c.writeto_mem(14 17, 1)    # try the other register, RW register according to the spec sheet (CTRL_REG1)<br />
Traceback (most recent call last):<br />
File "&lt;stdin&gt;", line 1, in &lt;module&gt;<br />
TypeError: object with buffer protocol required</p>
<p dir="auto">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.</p>
<p dir="auto">Has anyone else encountered this or have successfully accessed the magnetometer on the M5STACK FIRE?</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://community.m5stack.com/topic/355/acessing-the-mag-3110-on-the-m5stack-fire</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 00:16:46 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/355.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Oct 2018 13:33:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Acessing the MAG-3110 on the M5STACK FIRE on Thu, 11 Oct 2018 14:22:12 GMT]]></title><description><![CDATA[<p dir="auto">Hey Lukas,</p>
<p dir="auto">This won't work. The mpu9250 module expects to find an MPU6500 accelerometer so even instantiating an mpu9250 object will fail during <strong>init</strong>(). Even if I remove the part of the code that checks for the MPU6500, instantiation will still fail when it attempts to initialize the magnetometer by writing to one of it's registers.</p>
]]></description><link>https://community.m5stack.com/post/1704</link><guid isPermaLink="true">https://community.m5stack.com/post/1704</guid><dc:creator><![CDATA[AmbiDextrose]]></dc:creator><pubDate>Thu, 11 Oct 2018 14:22:12 GMT</pubDate></item><item><title><![CDATA[Reply to Acessing the MAG-3110 on the M5STACK FIRE on Mon, 08 Oct 2018 04:29:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi there you can try this code.</p>
<p dir="auto">from m5stack import lcd, buttonA<br />
from mpu9250 import MPU9250<br />
from time import sleep_ms<br />
from machine import I2C</p>
<p dir="auto">i2c = I2C(sda = 21, scl = 22)<br />
imu = MPU9250(i2c)</p>
<p dir="auto">lcd.clear()<br />
lcd.font(lcd.FONT_Small)<br />
lcd.setTextColor(lcd.WHITE, lcd.BLACK)</p>
<p dir="auto">while not buttonA.isPressed():<br />
mag = imu.magnetic<br />
print("MAG:    {:8.3f}   {:8.3f}   {:8.3f}".format(mag[0], mag[1], mag[2]))<br />
print('')<br />
lcd.print("MAG:{:+7.2f}  {:+7.2f}  {:+7.2f}".format(mag[0], mag[1], mag[2]), lcd.CENTER, 60)<br />
sleep_ms(20)</p>
<p dir="auto">lcd.print('Exit.', 0, 100)</p>
<p dir="auto">Remember that there are magnets in the base of the m5 core, so maybe best to remove it if you don't want any interference in the magnetometer reading</p>
]]></description><link>https://community.m5stack.com/post/1686</link><guid isPermaLink="true">https://community.m5stack.com/post/1686</guid><dc:creator><![CDATA[lukasmaximus]]></dc:creator><pubDate>Mon, 08 Oct 2018 04:29:04 GMT</pubDate></item></channel></rss>