I have been trying to use a Pimoroni Pico LiPo with the latest 1.19.12 (Releases · pimoroni/pimoroni-pico · GitHub) MicroPython. However, I have been unable to get it to connect to my PiicoDev Buzzer Module or PiicoDev Magnetometer QMC6310.
The Piico will output the correct address. However, when running though either of the below guides I get the error “OSError: [Errno 5] EIO” when trying to initialise either sensor.
Finally, I tried following some of the recommendations from this thread but was unable to make any progress. Similar Issue Thread
Any help would be amazing.
My Code:
from PiicoDev_QMC6310 import PiicoDev_QMC6310
from PiicoDev_Unified import sleep_ms # Cross-platform compatible sleep function
compass = PiicoDev_QMC6310(range=800) # Initialise the sensor with 800uT range
# compass = PiicoDev_QMC6310(0, sda=Pin(5), scl=Pin(4), freq=100000, range=800)
# Calibration recommended for best results.
compass.calibrate() # only need to calibrate once
# Optional: Declination is the difference between magnetic-north and true-north ("heading") and depends on location
# compass.setDeclination(12.3) # Found with: https://www.magnetic-declination.com/Australia/Newcastle/122944.html
while True:
heading = compass.readHeading() # get the heading from the sensor
if compass.dataValid(): # Rejects invalid data
heading = round(heading) # round to the nearest degree
print( str(heading) + "°") # print the data with a degree symbol
sleep_ms(100)
With all PiicoDev device drivers on the Pico it is assumed that the Expansion board is used where the default pins are 8/9 for SDA and SCL respectively.
Just like in your I2C scan code if you setup the magnetometer with the correct arguments it should work no worries
from PiicoDev_QMC6310 import PiicoDev_QMC6310
from PiicoDev_Unified import sleep_ms # Cross-platform compatible sleep function
from machine import Pin
compass = PiicoDev_QMC6310(bus=0, sda=Pin(4), scl=Pin(5), freq=100000,range=800) # Initialise the sensor with 800uT range
# compass = PiicoDev_QMC6310(0, sda=Pin(5), scl=Pin(4), freq=100000, range=800)
# Calibration recommended for best results.
compass.calibrate() # only need to calibrate once
# Optional: Declination is the difference between magnetic-north and true-north ("heading") and depends on location
# compass.setDeclination(12.3) # Found with: https://www.magnetic-declination.com/Australia/Newcastle/122944.html
while True:
heading = compass.readHeading() # get the heading from the sensor
if compass.dataValid(): # Rejects invalid data
heading = round(heading) # round to the nearest degree
print( str(heading) + "°") # print the data with a degree symbol
sleep_ms(100)
Update:
It turns out just deleteing the calibration file and commenting out the line compass.calibrate() # only need to calibrate once
got the compass within 2 degrees for me according to my phone.
3 Likes
And you can get our latest projects and tips straight away by following us on: