{"id":20520864,"url":"https://github.com/manuelbl/usb-pd-arduino","last_synced_at":"2025-04-14T02:33:24.532Z","repository":{"id":155530104,"uuid":"632170022","full_name":"manuelbl/usb-pd-arduino","owner":"manuelbl","description":"USB Power Delivery for Arduino","archived":false,"fork":false,"pushed_at":"2024-04-30T21:43:08.000Z","size":225,"stargazers_count":66,"open_issues_count":9,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T16:40:01.240Z","etag":null,"topics":["arduino","arduino-library","platformio","usb","usb-pd"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manuelbl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-24T21:23:57.000Z","updated_at":"2025-03-18T14:54:11.000Z","dependencies_parsed_at":"2024-02-05T21:27:32.436Z","dependency_job_id":"fcf074cf-75ac-44b3-9b27-55d47b51e563","html_url":"https://github.com/manuelbl/usb-pd-arduino","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelbl%2Fusb-pd-arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelbl%2Fusb-pd-arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelbl%2Fusb-pd-arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelbl%2Fusb-pd-arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manuelbl","download_url":"https://codeload.github.com/manuelbl/usb-pd-arduino/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248811037,"owners_count":21165214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-library","platformio","usb","usb-pd"],"created_at":"2024-11-15T22:24:02.402Z","updated_at":"2025-04-14T02:33:24.486Z","avatar_url":"https://github.com/manuelbl.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# USB Power Delivery for Arduino\n\nImplement a USB PD protocol analyzer, a USB PD trigger board or a more sophisticated power sink using a few additional components and simple Arduino code. Supports several STM32 microcontrollers.\n\nDepending on the microcontroller, a comparator and a few resistors are needed, or just the resistors or no additional component at all. See below for more details. For 5 USD in parts, you can build a USB PD protocol analyzer.\n\n\n\n## Supported Boards\n\n| Board | Required additional components |\n| - | - |\n| Blue Pill (STM32F103C8) | Dual comparator, several resistors |\n| Black Pill (STM32F401CC) | Dual comparator, several resistors |\n| Nucleo-L432KC | Several resistors (for power sink) or none (for protocol analyzer) |\n| Nucleo-G071RB | None |\n| Nucleo-G431KB | None |\n| Nucleo-G474RE | None |\n\nAll boards require an additional USB C connector as the standard connector is not ready for USB Power Delivery (no USB C connector, CC1/CC2 signals not available, voltage regular cannot handle more than 5V).\nFor the Nucelo boards in Nucleo-64 form factor, the X-NUCLEO-SNK1M1 shield can be used.\n\nSee the Wiki for how to wire the board and the additional components.\n\n\n## Library Installation (Arduino IDE)\n\n1. In the Arduino IDE, navigate to *Sketch \u003e Include Library \u003e Manage Libraries...*\n\n2. The Library Manager will open and you will find a list of libraries that are already installed or ready for installation.\n\n3. Search for *Power Delivery* using the search bar.\n\n4. Click on the *INSTALL* button to install it.\n\n\n\n## Examples\n\n### Protocol Analyzer\n\nThe protocol analyzer can be connected between two USB PD devices to monitor the USB PD communication.\n\n```c++\n#include \"USBPowerDelivery.h\"\n\nvoid setup() {\n  Serial.begin(115200);\n  PowerController.startMonitor();\n}\n\nvoid loop() {\n  PDProtocolAnalyzer.poll();\n}\n```\n\nSee the Wiki for details regarding the required components and wiring.\n\n\n\n### Trigger Board\n\nThe trigger boards communicates with a USB power supply and requests a different voltage than the initial 5V.\n\n```c++\n#include \"USBPowerDelivery.h\"\n\nvoid setup() {\n  PowerSink.start();\n  // request 12V @ 1A once power supply is connected\n  PowerSink.requestPower(12000, 1000);\n}\n\nvoid loop() {\n  // nothing to do\n}\n```\n\nSee the Wiki for details regarding the required components and wiring.\n\n\n## Restrictions\n\n- This library uses several peripherals exclusively (e.g. one or two timers and the ADC in many cases). The peripheral can no longer be used by your own code as it would interfer with the operation of this library. Please read to restrictions that apply to your board.\n\n- The USB PD protocol is very timing sensitive. In order to be robust even in the presence of blocking code (e.g. `Serial.println()`), most of the USB PD processing is done in interrupt handlers. While receiving a USB PD message, interrupt handlers can consume up to 40% of the CPU time.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanuelbl%2Fusb-pd-arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanuelbl%2Fusb-pd-arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanuelbl%2Fusb-pd-arduino/lists"}