SparkFun Auto pHAT for Raspberry Pi

The SparkFun Auto pHAT for Raspberry Pi is an all in one robotics package that focuses on quickly adding robot functionality and support to your Raspberry Pi or other single-board computer. The Auto pHAT can drive two small DC motors with or without encoders and up to four servo motors in a straightforward manner via an I2C connection. The servo control is based on the SparkFun servo pHAT and thanks to its I2C capabilities, this PWM add-on saves the Raspberry Pi's GPIO pins, allowing you to use them for other purposes. We have also provided a Qwiic connector for easy interfacing with the I2C bus using the Qwiic system. Whether you use the Auto pHAT with a Raspberry Pi, NVIDIA, Jetson Nano, Google Coral, or other SBC, it makes for a unique robotics addition for and board with a 2x20 GPIO.

The DC motor control comes from the same 4245 PSOC and 2-channel motor ports system used on the SparkFun Qwiic Motor Driver. This provides 1.2A steady state drive per channel (1.5A peak) and 127 levels of DC drive strength. The SparkFun Auto pHAT also supports up to two motor encoders thanks to the onboard ATTINY84A to provide more precise movement to your creation!

Additionally, the Auto pHAT has an on-board ICM-20948 9DOF IMU for all your motion sensing needs. This enables your robot to access the 3-Axis Gyroscope with four selectable ranges, 3-Axis Accelerometer, again with four selectable ranges, and 3-axis magnetometer with an FSR of ±4900µT.

Power to the SparkFun Auto pHAT can be supplied through USB-C connector or external power. This will power either the motors only, or power the motors as well as the Raspberry Pi that is connected to the HAT. We've even added power protection circuits to the design, to avoid damage to power sources.

  • 4245 PSOC and 2-channel motor ports programmable using Qwiic library
  • On board ATTINY84A supports up to two DC motor encoders
  • 5v pass-through from RPi
  • On board ICM-20948 9DOF IMU for motion sensing accessible via Qwiic library
  • PWM control for up to four servos
  • Qwiic connector for expansion to full SparkFun Qwiic ecosystem
  • Designed for stacking, full header support & can use additional pHATs on top of it
  • Uninhibited access to the RPi camera connector & display connector.
  • USB-C for powering 5V rail (Motors/Servos/backpowering Pi)
  • External power inputs broken out to PTH headers

SparkFun Auto pHAT for Raspberry Pi Product Help and Resources

SparkFun Auto pHAT Hookup Guide

April 16, 2020

The pHAT to get your projects moving. This guide will help you get started using the Auto pHAT.

Core Skill: Robotics

This skill concerns mechanical and robotics knowledge. You may need to know how mechanical parts interact, how motors work, or how to use motor drivers and controllers.

2 Robotics

Skill Level: Rookie - You will be required to know some basics about motors, basic motor drivers and how simple robotic motion can be accomplished.
See all skill levels

Core Skill: DIY

Whether it's for assembling a kit, hacking an enclosure, or creating your own parts; the DIY skill is all about knowing how to use tools and the techniques associated with them.


Skill Level: Noob - Basic assembly is required. You may need to provide your own basic tools like a screwdriver, hammer or scissors. Power tools or custom parts are not required. Instructions will be included and easy to follow. Sewing may be required, but only with included patterns.
See all skill levels

Core Skill: Programming

If a board needs code or communicates somehow, you're going to need to know how to program or interface with it. The programming skill is all about communication and code.

3 Programming

Skill Level: Competent - The toolchain for programming is a bit more complex and will examples may not be explicitly provided for you. You will be required to have a fundamental knowledge of programming and be required to provide your own code. You may need to modify existing libraries or code to work with your specific hardware. Sensor and hardware interfaces will be SPI or I2C.
See all skill levels

Core Skill: Electrical Prototyping

If it requires power, you need to know how much, what all the pins do, and how to hook it up. You may need to reference datasheets, schematics, and know the ins and outs of electronics.

2 Electrical Prototyping

Skill Level: Rookie - You may be required to know a bit more about the component, such as orientation, or how to hook it up, in addition to power requirements. You will need to understand polarized components.
See all skill levels


Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Sam Pratt / about 4 years ago / 2

    Is the PSOC able to talk to the encoder counter ATTINY as well? Ultimately everything on the board can support closing the loop with the encoders, but it's not clear if the PSOC is able to support master communication to the ATTINY and slave communication to the pi - is this possible the way the hardware is configured? It's so close to being perfect!

    • Member #690 / about 3 years ago / 1

      Did you ever manage to get this done? I want to use this for PID control - rotate a specific number of encoder counts, with given speed and acceleration.

      Thanks, Dan.

    • santaimpersonator / about 4 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Our technical support team will do their best to assist you.

      That being said, yes it is possible, as they are connected to the same I2C bus. However, you would need to re-program the PSOC using the SWD pins. Unfortunately, those instructions are beyond the scope of our support team. (I would recommend checking out the schematic and our Serial Controlled Motor Driver for information on the PSOC firmware.)

  • SebCestBien / about 4 years ago / 2

    Is it possible to have code source of the ATiny ? (if I ask kindfully...)

  • Member #142965 / about 4 years ago / 2

    Will this board be stackable, allowing for more motors and servos?

    • santaimpersonator / about 4 years ago / 1

      Yes, the I2C addresses just need to be modified for the motor driver and servo controller ICs, with the jumpers on the bottom.

      • Hey Santa and #965, Thanks for chiming in here! You are correct. But I also wanted to mention there are 2 more devices on the I2C bus: (1) the 9DoF IMU and (2) the Encoder Reader ATTiny84. (this means there are 4 total devices on the bus that you must consider while stacking). All of these have dedicated hardware address jumpers on the bottom side of the board, so this would enable stacking two of the HATs.

        Hey #965, how many HATs were you thinking of stacking? For what application?

  • pga_uw / about 3 years ago * / 1

    It's a great little board, but getting power to all those things is a challenge. Is there any chance the users could interest SparkFun in creating a power board for this system? For example, it would be great to have a board that would...

    • Take as Input some unregulated power supply, like a 2-3S LiPo battery

    • Provide three power outputs:

      • 5V 3A to power Auto phat board and back-power the Raspberry Pi

      • 5V 8A to power the Servo ports

      • Pass-through battery voltage to supply the Motors

    Then this power board would just solder to the available power inputs, and the challenge would be solved.

  • Member #1565689 / about 4 years ago * / 1

    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 !!!

    • Member #1565689 / about 4 years ago * / 1

      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.")
          while True:
              if IMU.dataReady():
                  IMU.getAgmt() # read all axis 
                  deg = math.atan2(IMU.myRaw,IMU.mxRaw) * 180/math.pi
                  print("HEADING: ",deg)
                 print("Waiting for data")
      if __name__ == '__main__':
          except (KeyboardInterrupt, SystemExit) as exErr:
              print("\nEnding Example 1")

  • Member #1565689 / about 4 years ago / 1

    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.", \
    print("Motor initialized.")
    # Zero Motor Speeds
    print("Motor enabled")
    while True:
        speed = 20
        for speed in range(20,255):
        for speed in range(254,20, -1):

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

  • Member #1614103 / about 4 years ago / 1

    Hi there, is it possible to stack more servos? Maybe stacking this servo controller "Zio 16 Servo Controller" ?

    • santaimpersonator / about 4 years ago / 1

      Hi there, it sounds like you are looking for technical assistance. Please use the link in the banner above, to get started with posting a topic in our forums. Our technical support team will do their best to assist you.

      That being said... yes, you can add more PCA9685 chips (i.e. servo controllers) to the I2C bus. You just need to modify the jumpers so that each controller has their own I2C address (i.e. similar idea to giving people their own phone number or home address). Then you would need to modify the code so that you are controlling each chip separately.

  • Adam Dean / about 4 years ago / 0

    The board has pins for powering the motors externally, but the hookup guide says that the DRV8835 H-bridge is hard wired to 5V. Do I need to disconnect the 5V hard wiring somehow before using the external power pins?
    I am using a pair of L-shaped TT motors and encoders and at only 3 Ohms of resistance I find that the motor needs to draw 1.7A to start from stall when powered with 5V. If I can power the H-bridge with only 3.3V then the current draw should remain below the 1.5A max and 1.2A steady state limit.

Customer Reviews

4 out of 5

Based on 1 ratings:

Currently viewing all customer reviews.

Interesting board with hidden advantages


i like this board because I can power the motors and the rpi from the same cell phone power block.

I haven't tried the servo subsystem yet. I have to figure out how to mount a RCWL-1601 (3.3 v HC-SR04) ) on a servo.

I haven't tried the IMU yet.


  1. The ethernet connector on the rpi 3b v1.2 blocks the qwiic connector a bit.

  2. More documentation !!!

  3. Build one for the ESP-32 Wrover.