Project Bounty: Particle Photon UPS Monitor

Looking for someone to take on a coding project that I believe a Particle Photon might be perfect for. Here’s the particulars…

There are plenty of APC UPS devices on the market that have USB interfaces so a PC can monitor the power state and shut down before battery dies. But network-capable UPS devices are generally bigger and MUCH more expensive. But there are a lot of applications where those are overkill and no PC is available to monitor the UPS, but monitoring would be desired. Think small network closet.

APC UPS devices made since 2003 with USB interfaces appear to have the same protocol, which is very simple and I’m fairly certain adapted directly from the RS-232 devices that proceeded them. The protocol is here:

There is sample open source code here:

http://www.apcupsd.org/

Now, it appears from this thread:

That the USB device on the Particle Photon does indeed support Host mode. So I think that all that would be required to connect the two is a cable like this:

I don’t think you need the 5V hack as mentioned in the thread above because the UPS is already self-powered. If so, you may indeed need a full custom cable. I believe this is the cheapest UPS available with a USB port:

Now, what I really want is to combine the relay-board application firmware for the NCD.io boards with this newly written support for talking to the APC UPS. So in my ideal world my 2-Relay board I already use for another application could have a UPS plugged in to the USB port and then it would become an IFTTT trigger for UPS events like “on battery power”, “battery level below X percent”, etc. NCD board and their application particulars are here:

Assuming the above referenced USB Host code can be fairly easily leveraged, the hardest part might be debugging while the USB port is occupied. But maybe that’s not as hard as I think, too. Anyway, anyone interested should come up with an idea of what you would need to be paid and send me a DM. FWIW, I would prefer to open source everything once done, too. But I’m willing to pay to have it done.

–Donnie

I have a rock-solid apcupsd Raspberry Pi setup for my home server. Whenever the power goes out it can ssh into the Dell PowerEdge to shut it off, and when the power is restored it can ssh into the iDRAC to turn the PowerEdge back on.

I have zero experience using the Photon as a USB host but your idea is cool nonetheless.

I’ve actually done the same. I have a Pi at my vacation house talking to a UPS and it actually tweets the power status.

It’s been 100% rock solid for over a year now. I still fear it some because any file system based device that’s losing power can get corrupted. But the bigger reason I want a Photon solution is I already have Photons in situations where they could do this and I would have to add Pi’s. Also, it just seems like this is the kind of thing the world needs. A pi is just a lot of overkill even if the cost is similar.

—Donnie

2 Likes

Bump. Nobody interested in this one?

–Donnie

I can only speak for my APC UPS, its USB cable has a Prolific RS232 adaptor built into it so in theory there wouldn’t be any need to do any USB host trickery you could just build your own cable. However the impression I have always had with is that APC hasn’t really made a single universal protocol & there are slight variants/featuresets and that is why you need to tell APCUPSD or NUT the model you are using. There are also at least two different main protocols they call MODBUS and Microlink.

The info you would need is all here http://networkupstools.org/protocols/apcsmart.html

On the Host USB front I don’t think it is a route to follow, yes it can act as one but as implemented its really for connecting mice and keyboards (simple HID), there’s a lot of work involved getting it to do anything else. I would also suggest that given devices like the Pi exist using the already fully functional existing tools on such low powered machines is the best option - hence lots of people already do so as above.