Re the magnetometer issue I've now looked at this and can't replicate the fault. However here is some jiggery-pokery required to make the mag respond, and it's possible that you haven't spotted everything that has to happen first. I wired the MPU9250 with data on pin 12 and clock on pin 14, both pins with 1K pullups to 3.3V. I ran the following code:
Code: Select all
from machine import I2C, Pin
buf3 = bytearray('\x00\x00\x00')
buf1 = bytearray('\x00')
scl = Pin(14, Pin.OUT)
sda = Pin(12, Pin.OUT)
i2c = I2C(-1, scl, sda) # Clk 14 Data 12
i2c.scan() # will show only 105
i2c.readfrom_mem_into(105, 0x75, buf1)
if buf1[0] != 113:
print('Bad chip ID')
i2c.writeto_mem(105, 0x6B, b'\x01') # wake
i2c.writeto_mem(105, 0x37, b'\x02') # passthrough
i2c.writeto_mem(105, 0x6a, b'\x00')
i2c.scan() # should now show 12
i2c.writeto_mem(12, 0x0A, b'\x0f') # ROM access
i2c.readfrom_mem_into(12, 0x10, buf3)
print(buf3)
The final print statement produces the magnetometer correction values.
So, for the MPU9250 at least, the ESP8266 I2C implementation comes out with flying colours
