Pico PD Pro is a development board for USB Power Delivery development with Raspberry Pi Pico footprint. The board can help you negotiate voltage from USB PD 3.1 with PPS (programable power supply) and AVS (Adjustable Voltage Supply) up to 5A of current at 30V max. The board feature input current/voltage/temperture reading as well as power switch to cut of the current to external devices. The 30V voltage limit is the max input voltage of the AP33772S IC.
AP33772S CircuitPython Library -> Big thanks to @hansendc
Enable Serial print for debugging
To use AP33772 IC with the library, first you need to create a usbpd
object. Then set up your I2C pins and start collecting the power profiles from your charger. Ensure your delay after Wire.begin()
is more than 500ms for stable PDOs request. Enable pin 23 to allow VBUS pass-through.
AP33772S usbpd; // Automatically wire to Wire0
void setup()
{
Wire.setSDA(0); // Set the correct SDA0 pin
Wire.setSCL(1); // Set the correct SCL0 pin
Wire.begin();
Serial.begin(115200);
delay(1000); // Delay is needed for the IC to obtain PDOs
usbpd.begin(); // Start pulling the PDOs from power supply
pinMode(25, OUTPUT); // Built in LED
usbpd.printPDO(); //Print out PDO to Serial port
usbpd.setOutput(0); // Turn off output switch
}
Common functions are:
displayProfiles(); //Print out PDOs in Serial
mapPPSAVSInfo();
setFixPDO(int pdoIndex, int max_current);
setPPSPDO(int pdoIndex, int target_voltage, int max_current);
setAVSPDO(int pdoIndex, int target_voltage, int max_current);
setOutput(uint8_t flag);
readVoltage(); //Return voltage in mV
readCurrent(); //Return current in mA
readTemp(); //Return temperature in C
Calling usbpd.displayProfiles()
without Serial.begin()
can soft-brick your PicoPD. Causing the IC to be non-recognizable by your computer. You will have to use PicoProbe to reflash the chip. Check out @Patronics PicoProbePCB if you would like to make a stable fixture for firmware debugging.
If you want to use PicoPD Pro as an AP33772S evalulation board with your own micro-controller, flash the board with AP33772S_Eval.uf2 using the drag and drop method. This firmware will config GP0 and GP1 as INPUT to prevent I2C interferance with your own add on micro-controller like ESP32 or STM32.
To enable Serial debug, there are 2 main methods:
Using USB-C Power/Data splitter (easiest): Use a USB-C Splitter that separates the USB 2.0 signal into another USB-C port. You only need USB 2.0 FullSpeed (12Mbps) for the job, but never hurts to get extra speed if needed later.
- USB-C Power/Data Splitter (USB-HighSpeed)
- USB-C PD Power Splitter (USB-HighSpeed)
Using UART communication: Make sure you are not using GP0 and GP1 as they are reserved for I2C0 channel for AP33772 IC. Check out Youtube tutorial: Talk to Your Pico Over Serial
Open Arduino IDE, select File -> Preference
Copy this line below and place in "Aditional Boards Manager URLs" -> OK. This will allow you to pull the Earlephilhower Pico core that work with the AP33772 library.
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
From Board Manager, search for "Pico" and install the "Raspberry Pi Pico/RP2040" core by Earlephilhower
Now from Tool -> Board -> Raspberry Pi Pico/RP2040 -> Raspberry Pi Pico
Now download the latest AP33772 library as a Zip file
https://github.com/CentyLab/AP33772S-Cpp
Import the AP33772S library into your Arduino IDE. Sketch -> Include library -> Add .ZIP Library ...
Now you start using the Example code in File -> Examples -> AP33772-Cpp-main. The example is ready to compile and flash on to your PicoPD.
Now you can plug in your USB-C cable with Power Delivery 2.0/3.0/3.1. If you also like to have serial print out, check out Enable Serial print for debugging.
After VSCode installation, you will need to install PlatformIO extension.
Now create a new PlatformIO project
- Name:WhatEverYouWantToCallit
- Board: Pico (RasberryPi)
- Framework: Arduino (default)
Click "Finish"
In your new project, copy this and replace everything in platformio.ini. This is how you ask PlatformIO to compile using Earlephilhower Pico core, and enable upload via USB.
[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
;; If directly upload from PC
upload_protocol = picotool
Now download the latest AP33772 library as a Zip file. Unzip and place the folder in lib
https://github.com/CentyLab/AP33772S-Cpp
Your lib folder should look like this
To try out example code, you copy the content inside lib/Compiled for PicoPD/PPSCycling/PPSCycling.ino
, And replace everything in your src/main.cpp
Now you can plug the PicoPD to your computer via USB-C and hit the upload button. After this, you will have to connect a charger to PicoPD to see the voltage cycling example. If you also like to have serial print out, check out Enable Serial print for debugging.