Introduction: Control Power Supply Via UART

About: Making stuff that makes life easier or more interesting.

For my alternative energy hobby project I need to control the power output twice.

Once to ensure the solar panels do not overcharge the batteries (and to achieve MPPT).

Second, to restrict power to the accessories and ensure the batteries do not drain too fast.

I tried building my own buck converter.

I tried modifying existing buck converters (more).

Those are worthy efforts, but the easier answer is to use the power supply unit (PSU) that ships with a serial interface.

The problem is the interface is poorly documented, and the device has been revised and older projects do not quite match the current device parameters. Also, the manufacturer device information is outdated and inaccurate.

(it appears that though the manufacture includes this capability, and even mentions it on their product page, "connect the reserved port to single chip microcomputer or computer comunication", they are reluctant to support this feature. Hopefully this instructable will benefit others)


This instrucable is intended only as a way to test a new PSU; Validate that the PSU is functional and document the commands.

Supplies

Related links:

Step 1: Optional: Add Connector Pins

[OPTIONAL] Add pins to made connecting the microcontroller easier.

Step 2: Optional: Add Diode

[OPTIONAL] Add a diode to protect the PSU from backfed power.

Step 3: Connect Power Source

[OPTIONAL] Add a barrel connector at power input.

The makes power off/on easier when testing.

Note: few barrel connectors can handle the 12A capacities of the PSU, so remove the barrel connector after testing is complete.

For this instructable an extra power-brick (20V) from a discarded laptop was used.

Step 4: Set the PSU Address

This version of the PSU can have one of 26 addresses - represented by the alphabet.

As shipped most PSUs seem to have a false setting "-51-" and need to be set to the first address "-00-" (aka 'a').

Press and hold (for < 1/2 second) to launch the menu.

Use the up triangle to reach "-F3-", click OK.

Scroll down, using the down triangle, until "-00-", press OK.

Disconnect power, wait 10 seconds, reconnect power.

Verify the -F3- setting is still -00- (One PSU needed to be set 3 times before it saved correctly)

Step 5: Connect Serial

The UART in the ESP32 can be assigned to any pins.

For this instructable:

  • ESP32 Pin 4: RX (receive) => PSU pin "R"
  • ESP32 Pin 5: TX (transmit) => PSU pin "T"

(note: typically transmit, on the controller, goes to receive on the device, but that is not how this PSU is labeled)

Step 6: Upload Sketch

Upload the code for this instructable to the ESP32.

(This instructable assumes your environment (PC, compiler, libraries, etc., are already fully functional and successfully write to the ESP32.)

Step 7: Usage

In a serial terminal (e.g., the Serial Monitor in the Arduino IDE) enter/send a number corresponding to a command.

Observe the result received from the PSU.

(in the code, see the comments in the array declaration for what each number does.)

Step 8: Conclusion

Notice the commands are inconsistent; some binary commands use 0/1 others use 00/01.

Some terminate with carriage-return (\r) new-line (\n), others use only \n.

Determining what worked was a significant trial & error process. Thus, while this works in this scenario, with this version of the Drok PSU, your results may vary.