I'm using a HMC5883L magnetic sensor and a ESP32-PICO-KIT, I'm having trouble trying to run the following code
Code: Select all
import machine
import utime
i2c = machine.I2C(scl=machine.Pin(26), sda=machine.Pin(25),freq=100000)
i2c.start()
i2c.writeto(0x3C, bytes([0, 112]))
i2c.writeto(0x3C, bytes([1, 176]))
i2c.writeto(0x3C, bytes([2, 0]))
utime.sleep(6)
def loop():
while True:
B=i2c.readfrom(0x3D,0x06)
print(B)
try:
loop()
except KeyboardInterrupt:
i2c.stop()
print('Got Ctrl-C')
finally:
print("Finishing...")
Code: Select all
Traceback (most recent call last):
File "main.py", line 6, in <module>
OSError: [Errno 19] ENODEV
MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
Type "help()" for more information.
Thank you all for your time.