How to make a USB cable for APC Smart-UPS SC450RMI1U


Note: Updated on 2021-04-19 to fix the wrong naming. It’s not DB9, it’s apparently DE-9. Oops. So beware, because the incorrect DB9M is rather widespread (and I also fell victim to it).


In this post I’m going to look at the task of making a USB cable for monitoring of APC Smart-UPS SC 450 RMI 1U using apcupsd.

Because I have recently bought one of these UPSes without realizing that my relatively dated Supermicro 1U server doesn’t have a COM port. So the shiny APC 940-0024E cable they ship with the UPS is as useful as a fur coat in summer1.

Before I unveil the ultimate solution, let me tell you an overly detailed recount of how I got to it. Or just skip it. ;)

Backstory

I was coming into this adventure poorly prepared without even knowing it.

The last time I touched any RS232 hardware2 was when tweaking something on Ubiquiti ERLite-3, and my RS232-fu was basically non-existent.

But I thought I had this reasonably in the bag because:

So after finding a documentation page with APC’s smart protocol and cable pinout, and the pinout guide for the Cisco console cable3, I sacrificed some DE-9M lamb and cobbled together a prototype:

prototype Hacked up prototype: keystone and DE-9 male from a “donor”.

The final pinout etc is described below.

Anyway…

Having a cable, I proceeded to test the cable on the UPS, thinking that all I need is a 2400 8N1 terminal4 settings on the /dev/ttyUSB0.

I expected (according to the “APC’s smart protocol” page above5) that I’ll just type B or b and get a response back.

No dice. Silence.

So it was checking and re-checking time. I even pulled up an oscilloscope to check what the hell’s up. It should have been working… and didn’t.

Out of desperation, since the waveform looked OK, I also shorted pins 1 and 2, and it was correctly feeding me back the data when typing in the terminal. So it should have been working. There was nothing wrong.

What the hell?

Well, it took one look into apcupsd’s source6.

Turns out, Smart UPS will be by default using a “dumb” protocol. I don’t even want to know what that exactly is. Who cares.

The most important thing is the one teeny tiny insignificant detail… that’s burried in the middle of “The Smart Protocol” section of the reference web page:

You have to first send Y to the UPS, to have it start responding correctly to the other commands.

In other words, the guides all over the ’Net gloss over this detail (or rather bury it in the middle of the table). Sad.

Now you, gentle reader, also know. You’re welcome.

So anyway, prototype works (worked from the start), but it’s ugly. Let’s tidy it up.

Final solution

For final solution I combined two things:

First, the “Cisco Rollover Cable” (search “cisco console usb cable” and I’ll be damned if you don’t find it on AliEx or Amazon). Basically, any USB-serial to RJ45 cable looking like so:

cable USB serial to RJ45 male, also known as Cisco console USB cable.

Second, an RJ45-to-DE9M (male) adapter. These also sell on AliExpress, or you can get the GC98MF from StarTech7:

final GC98MF from StarTech.com, a RJ45 (female) to DE-9 (male)

In case you’re not sure how to wire it, it’s essentially as follows:

There’s exactly one way to mess this up: by swapping TxD and RxD. If you want to check the resulting cable, you can plug the converter to USB and measure with a voltmeter DE-9M pin 9 (GND) against DE-9M pin 1. You should get some voltage across it (typically anywhere from -6V to -9V). Similarly, pin 9 against pin 2 should have near-zero voltage.9

After that, you can connect your UPS, set your terminal to 2400 8N1, type Y and then converse with your UPS using the APC’s Smart protocol until your fingers bleed.

Or you can configure apcupsd. :)

For me the (minimal) apcupsd configuration is:

## apcupsd.conf v1.1 ##
UPSCABLE smart
UPSTYPE apcsmart
DEVICE /dev/ttyUSB0
LOCKFILE /var/lock
UPSCLASS standalone
UPSMODE disable
##
## You definitely want more directives here.
## This just describes the protocol setup.
##

In closing

Hope this was useful. If you struggle, shoot me an email, I’ll be happy to help.

  1. To be fair, there’s also a possibility to get a DE-9 (male) to USB serial cable and using it with the 940-0024E (because it won’t work without it!). But have you seen these dongles? They’re huge, ugly, and definitely not a “tidy Rack” material. I’ll pass.

  2. And I really mean RS232 proper, not the TTL stuff you use to normally flash ESP32 and the like.

  3. Page 5-5, table 5-2 in the PDF.

  4. I like miniterm but I’ve seen people use screen and whatnot.

  5. Funnily enough, this website is also linked from apcupsd’s manual and bunch of other places all over the ’Net. And if not linked, then at least the exact same material is shallow copied over, word for word.

  6. Let’s be more specific, ApcSmartUpsDriver::setup in apcupsd-3.14.14/src/drivers/apcsmart/smartsetup.c.

  7. Sells through Amazon and other retailers, e.g. our local Digitec.ch.

  8. You DO have a soldering iron, yes?! If not, get creative? :-) You could also skip this shorting step completely, if you turn off flow control (it will work with apcupsd, but I still think it’s a bad form).

  9. The reason is left as an exercise to the reader.