Zum Hauptinhalt springen

Quick Start

The board works without a controller: plug a USB-C PD charger in, switch the slide switch on, and the HUSB238 asks for the voltage set on the DIP switches. With every switch off, that is 20 V at 3.25 A. The purple LED lights while the output is on. To read what the charger agreed to from code, connect the I2C header to a controller and run the library's first example.

You program the controller connected to this breakout. The breakout itself is not flashed.

VOUT carries the negotiated voltage, up to 20 V. Never connect VOUT to your controller's 3.3 V or 5 V pins. Only SDA, SCL and GND go to the controller.

1. Connect the breakout board​

Solder the included header pins, then wire the 3-pin I2C header to your controller's I2C pins. Basic.ino calls begin() without pins, so the library uses your controller's default I2C pins (its Wire pins). The table and drawing below show one example controller, whose default pins are IO8 (SDA) and IO9 (SCL). On another board, connect SDA and SCL to that board's default I2C pins, and GND to GND. The HUSB238 takes its power from USB-C, so the header has no supply pin. The board has no pull-up resistors on SDA and SCL: the bus needs them on your controller board or as separate resistors.

NULA DeepSleepSoldered HUSB238 USB-C Power Delivery Breakout
IO9SCL
IO8SDA
GNDGND
Wiring diagram: the NULA DeepSleep connected to the Soldered HUSB238 USB-C Power Delivery Breakout: IO9 to SCL, IO8 to SDA, GND to GND

Then plug a USB-C PD charger into the board and switch the slide switch on. The HUSB238 only answers on I2C while it has power from USB-C.

2. Install the library​

Download the HUSB238 Soldered library from its GitHub repository and add it to the Arduino IDE as a ZIP library.

🔗HUSB238 Soldered Arduino library

Verified Arduino library at commit f66dd25

→

Tip: downloading from GitHub. On the library's GitHub page, click the green Code button and choose Download ZIP, then add it in Arduino IDE with Sketch → Include Library → Add .ZIP Library....

The ZIP from the library's GitHub page holds the repository's default branch, so you get its latest version. The examples on these pages were checked against commit f66dd25, linked above.

3. Run the first example​

This is Basic.ino, the library's simplest example. Once a second it checks whether a PD charger is attached and prints the voltage and current the charger agreed to. Upload it, then open the Serial Monitor at 115200 baud.

Select Board
Basic.ino
#include "HUSB238-SOLDERED.h"

Husb238 husb238;

void setup()
{
Serial.begin(115200);
husb238.begin();
}

void loop()
{
if (husb238.isAttached())
{
Serial.print("Attached, voltage: ");
Serial.print(husb238.getPDSrcVoltage());
Serial.print(" V, current: ");
Serial.print(husb238.getPDSrcCurrent());
Serial.println(" A");
}
else
{
Serial.println("Not attached");
}

delay(1000);
}

4. Check the result​

With a PD charger attached, a new line appears every second. It starts with Attached, voltage:, then gives the agreed voltage in volts and the charger's current in amps. When no PD charger is attached, each line reads Not attached. The numbers depend on your charger and on the DIP switches.

With a 65 W USB-C PD charger that offers 20 V at 3.25 A, and every DIP switch off, the Serial Monitor shows:

Serial MonitorAutoscrollShow timestampNewline115200 baud
Message (Enter to send message to the board)
Attached, voltage: 20.00 V, current: 3.25 A
Attached, voltage: 20.00 V, current: 3.25 A
Attached, voltage: 20.00 V, current: 3.25 A
Attached, voltage: 20.00 V, current: 3.25 A

5. If it does not work​

Continue with Troubleshooting and retry this smallest example after each change.