×

Please see all COVID-19 updates here as some shipments may be delayed due to CDC safety and staffing guidelines. If you have an order or shipping question please refer to our Customer Support page. For technical questions please check out our Forums. Thank you for your continued support.

Member #1565689

Member Since: December 16, 2019

Country: United States

  • I tried getting the compass heading off the imu using this code:

    import qwiic_icm20948
    import time
    import sys
    import math
    
    def runExample():
        print("\nSparkFun 9DoF ICM-20948 Sensor  Example 1\n")
        IMU = qwiic_icm20948.QwiicIcm20948()
        if IMU.connected == False:
            print("The Qwiic ICM20948 device isn't connected to the system.")
            return
        IMU.begin()
        while True:
            if IMU.dataReady():
                IMU.getAgmt() # read all axis 
                deg = math.atan2(IMU.myRaw,IMU.mxRaw) * 180/math.pi
                print("HEADING: ",deg)
                time.sleep(0.03)
            else:
               print("Waiting for data")
               time.sleep(0.5)
    
    if __name__ == '__main__':
        try:
            runExample()
        except (KeyboardInterrupt, SystemExit) as exErr:
            print("\nEnding Example 1")
            sys.exit(0)
    
  • Has anyone figured out how to use the imu on the auto-phat to get a compass bearing (0-360) in Python ? I have been using various formulas but nothing is making any sense. Do I need to calibrate the magnetometer on the imu ? According to the specs, there is some sort of self-test.

    I have been using deg = math.atan2(rawy,rawx) * 180/math.pi to get my degrees but it only seems to give a range between about 97 for north and 67 for south. 97 is not on magnetic north. 67 does seem to be a low point close to the opposite side of 97.

    Help !!!

  • Hmmm. Everytime I ctrl-c out of the python motor test code the raspberry pi locks up and finally shuts down with a 'client_loop: send disconnect: Broken pipe' I am running via ssh. rpi 3b+ code: ========= import time import sys import math import qwiic_scmd

    myMotor = qwiic_scmd.QwiicScmd()

    def runExample(): print("Motor Test.") R_MTR = 0 L_MTR = 1 FWD = 0 BWD = 1

    if myMotor.connected == False:
        print("Motor Driver not connected. Check connections.", \
            file=sys.stderr)
        return
    myMotor.begin()
    print("Motor initialized.")
    time.sleep(.250)
    
    # Zero Motor Speeds
    myMotor.set_drive(0,0,0)
    myMotor.set_drive(1,0,0)
    
    myMotor.enable()
    print("Motor enabled")
    time.sleep(.250)
    
    
    while True:
        speed = 20
        for speed in range(20,255):
            print(speed)
            myMotor.set_drive(R_MTR,FWD,speed)
            myMotor.set_drive(L_MTR,FWD,speed)
            time.sleep(.05)
        for speed in range(254,20, -1):
            print(speed)
            myMotor.set_drive(R_MTR,FWD,speed)
            myMotor.set_drive(L_MTR,FWD,speed)
            time.sleep(.05)
    

    if name == 'main': try: runExample() except (KeyboardInterrupt, SystemExit) as exErr: print("Ending example.") myMotor.disable() sys.exit(0)

  • So, I need to have a power supply for the rpi AND a power supply for the Auto pHAT to run the motors ?

    It will not hurt either to have both plugged in at the same time ?

No public wish lists :(