This guide covers what the PiicoDev Magnetometer is reading, a simple setup using some 3D printed parts, a walkthrough of the code that runs the module and how you can use it in your projects!
So my PiicoDev Magnetometer and SSD1306 modules arrived today.
Setup as per this guide and it doesn’t work.
I get the following error from Micropython:
PiicoDev could not communicate with module at address 0x1C, check wiring
Traceback (most recent call last):
File “”, line 10, in
File “PiicoDev_QMC6310.py”, line 68, in init
File “PiicoDev_QMC6310.py”, line 61, in init
File “PiicoDev_QMC6310.py”, line 81, in _setMode
OSError: [Errno 5] EIO
Using
Thonny version 3.2.7
Ubuntu version 20.0.4
MicroPython v1.21.0 on 2023-10-06; Raspberry Pi Pico with RP2040
I’ve also run the calibration example from Arduino QMC5883L library and get the following:
19:04:09.993 → This will provide calibration settings for your QMC5883L chip. When prompted, move the magnetometer in all directions until the calibration is complete.
19:04:10.126 → Calibration will begin in 5 seconds.
19:04:15.112 → CALIBRATING. Keep moving your sensor…
19:04:25.115 → DONE. Copy the lines below and paste it into your projects sketch.);
19:04:25.182 →
19:04:25.182 → compass.setCalibrationOffsets(0.00, 0.00, 0.00);
19:04:25.215 → compass.setCalibrationScales(nan, nan, nan);
An i2c scan on the arduino nano reports the magnetometer at 0x1C as expected.
Thanks for testing and sending everything through
Everything looks fine there, I’d also try downgrading your micropython to 1.19: MicroPython - Python for microcontrollers
I’ll get a version of it setup once I have a spare moment
Hi Liam,
Tried Micropython 1.19.1 didn’t work.
Went to Micropython 1.18 and works as per the guide.
So obviously there is some change in 1.19.1 that breaks your library.
Cheers
Ross
Hi Liam,
I now have it working with Arduino Nano as well.
This is what it will be used on. It’s a 60 year old Marklin 7186 all metal turntable.
The magnet is mounted on the bottom of the central shaft and the module is mounted on the 3D printed mount from the guide.