Pimoroni Pico LiPo I2C Not Connecting

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.

When using:

from machine import Pin, I2C
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=100000)
print( i2c.scan() )

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.

Compass Guide

Buzzer Guide

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)
1 Like

Welcome Lochlan!!

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)

Let us know how you go!
Liam

2 Likes

Hi Liam,
Thank you so much I can now see a heading.

Unfortuantely, the calibration is quite far off with it limited to about 150-240 and no matter what I change it doesn’t want to get much better.

Looking at the raw data I got the values below when rotating the the sensor on a table and writing down the highest / lowest values I could manage.

Max Min
X - -410 -910
Y - 1530 1020
Z - 590 580

3 Likes

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