1

The only real UPS solution for me where I live is "RCT", a UPS manufactured by a local PC Hardware supplier.

It has a USB port, but I can't find any details about it. I've even contacted the manufacturer specialist via email, but He doesn't seem to like answering potential customers, so I'm hoping that I can get your opinion here.

I want to use the UPS (650VA) to power a Raspberry Pi (2). The Pi will be monitoring freezer temperatures and will email the owners if their temperatures rise above a certain preset value. However, this all means nothing if the Pi looses power because no-one knew that the power was out.

This now becomes a question of "How can I determine whether the AC-in on the UPS is being powered". I've been trying to think of a number of really cheap, yet elegant ways to accomplish this, and the one that I've decided on is, quite unusual and I'm wondering if it's a good idea.

The UPS comes with a standard piezo-buzzer. When the lights go out, the UPS goes into battery-mode and emits a loud beep every few seconds. So I was thinking of linking 2 GPIO ports on the PI to the buzzer in parallel and monitoring it for power. If it's "buzzing", then the power is out and everyone important gets an email letting them know that they need to start making a plan to fix whatever went wrong.

I could even take it a bit further and determine the frequency of the buzzer (not the pitch, but how often the buzzing happens), and when the buzzing is once every second, send another email letting everyone know that the UPS is on it's last legs. (0.2Hz = Battery mode, 1 Hz = very little time left).

Good idea? Bad idea? I look forward to hearing your input.

P.S. Another solution that someone had was to buy a cheap (network) switch and plug it into the Pi (and power it from the mains). The idea behind this would be that when thee power goes out, the network will drop. Fine, but I don't really want to go buy more unnecessary hardware if it can be avoided.

P.P.S I have a spare Raspberry Pi that I'll be using for this. I'm comfortable with Raspbian and it works for what I want to do.

P.P.P.S The UPS I want to get is very cheap. I don't want to make too much of an effort building a custom home-baked UPS system. And I'm not too concerned about the energy efficiency loss because of the DC-AC-DC conversion.

Unlike the question here, My question is whether the solution that I proposed is a feasible one.

Jim
  • 133
  • 7
  • 2
    Sounds pretty inefficient, a backup battery for the Pi directly sounds much more appealing and likely much smaller too. Besides that a Pi seems to be vast overkill for that task. – PlasmaHH Aug 29 '16 at 13:31
  • 3
    Since you alread have the UPS, install [NUT](http://networkupstools.org/stable-hcl.html) on your Pi. NUT should be in the Raspbian repositories ([see tutorial here](http://abakalidis.blogspot.de/2013/04/using-raspberry-pi-as-ups-server-with.html)) Plug in your RCT, connect the USB to the Pi, see what NUT says. Costs you nothing but time to try. If it works, cool. If not, you aren't out any monetary costs. – JRE Aug 29 '16 at 13:37
  • Thanks for the feedback PlasmaHH, The Pi will be performing a number of other tasks as well, including temperature history graphing, access-controlled web site hosting for internal access etc. The UPS _is_ a battery backup for the Pi, unless I'm misunderstanding you. – Jim Aug 29 '16 at 13:40
  • 1
    Many cheap UPS devices are made by some OEM manufacturer. The name on the box is different from the name it calls itself when it talks to your computer through USB. – JRE Aug 29 '16 at 13:40
  • A UPS is inefficient as a backup, since the Pi runs on a low DC power supply. They charge the battery, convert that to line voltage (120VAC or 230VAC) then convert it back down to 5VDC for the Pi. There are dedicated battery backups for the Pi that skip the conversion to line voltage - they provide a 5VDC output to the Pi directly. But, if you've got the thing already, you might as well see if you can use it. – JRE Aug 29 '16 at 13:42
  • @Jim Having a battery's DC transformed up to mains voltage AC to feed into a USB power supply to transform the AC into 5V DC is inefficient. – JimmyB Aug 29 '16 at 13:42
  • Thanks JRE, I've read about NUT, and it would be fantastic if it works with this UPS. However, right now, I don't know if it will work with the RCT UPS or not, and will not have an opportunity to try it before I have to commit and buy the hardware. So I'll need to have a back-up plan if the RCT UPS manufacturer is sub-par (i.e. If they have the USB port, but it's not linked to anything). – Jim Aug 29 '16 at 13:43
  • Doesn't the UPS have any optical indicator? LED(s)? – JimmyB Aug 29 '16 at 13:43
  • If you haven't bought the UPS yet, google for "raspberry pi ups" first to see the host of options you may have. – JimmyB Aug 29 '16 at 13:45
  • @Jim: still a Pi overkill for that little things to do, but whatever floats your boat. Yes, you can use an OTS UPS as a battery backup, but its big, heavy and inefficient. Use some small micro that fits your task best and some few thousands mAh Lipo and you got yourself a device the size of a pack of cigarettes rather than a UPS sized heavy chunk of lead – PlasmaHH Aug 29 '16 at 13:46
  • I'm not terribly worried about efficiency, so yes, Battery>AC>wall-wart>5vDC not the best, but I can work with it. They're particularly cheap, and getting a DC solution would be more work/cost (in shipping). – Jim Aug 29 '16 at 13:46
  • JimmB: I believe that it does have LEDs that blink at the same time as the piezo-buzzer, but also stay on the whole time that the UPS has power. – Jim Aug 29 '16 at 13:49
  • @PlasmaHH The Pi *is* overkill. But even "just" connecting a µC to the internet and a mass storage for logging is a lot more complex and more work, needs more tools and saves you... a watt or two? – JimmyB Aug 29 '16 at 13:50
  • @Jim Tapping the LED's signal is probably easier, and can even be done without touching the UPS via a photo diode if you want. – JimmyB Aug 29 '16 at 13:51
  • @JimmyB: which in the case of 3->1W is quite a lot and overall can reduce the size of the backup battery and thus product size -> more profit. – PlasmaHH Aug 29 '16 at 13:51
  • 1
    FYI: I want to use the Pi as it's convenient, I have a spare one lying around, and I'm very comfortable with Raspbian. With regard to the UPS, It's cheap, and custom building a home-baked 6-cell AA Battery UPS (or battery-bank UPS) would just make more work for me that I'm trying to avoid. There are some really nice solutions for a UPS, but they get very expensive, and I'm trying to avoid that. (Sorry I should have included this in the OP). – Jim Aug 29 '16 at 13:54
  • @PlasmaHH Absolutely. Also, the Pi is pretty expensive compared to a µC + WiFi + SD card. For anything below maybe 100(s) devices the extra effort is probably not worth the µC approach though. – JimmyB Aug 29 '16 at 13:54
  • Have a look at the [UPS PIco](https://www.modmypi.com/raspberry-pi/breakout-boards/pi-modules/ups-pico) as an example for a relatively cheap DC UPS solution which reports if it is running on battery. – Arsenal Aug 29 '16 at 13:56
  • @Jim No need to build your own UPS. There *are* a host of attachments available for the Pi, many complete with software/driver support! - Compared to the Pi itself they're pricey (often around US$30) but a common UPS will not really be cheaper. – JimmyB Aug 29 '16 at 13:56
  • 1
    Oh, Also, I'm in South Africa, We have a weak currency and shipping stuff in from **anywhere** is not cheap. – Jim Aug 29 '16 at 13:57
  • Can you post a link to the RCT UPS you plan to use? – JRE Aug 29 '16 at 14:14
  • @JRE That's the best part, no I can't, one doesn't exist :-( (also, if you google it, the UPS manufacturer is **NOT** related to rct-systems) – Jim Aug 29 '16 at 14:18
  • 1
    I figured. I looked them up, and got something else entirely. So, I asked. So, you will buy it locally? See if you can get a salesman to let to plug it into a laptop or something. Get the USB IDs (Vendor and device) and see if that can get you enough info to see if NUT can talk to it. – JRE Aug 29 '16 at 14:20
  • 1
    If *you* lose power, what about your network equipment? Will you have a fully UPS-backed network? – W5VO Aug 29 '16 at 14:28
  • 1
    Fantastic idea @JRE , They're a local wholesaler so I'm sure I can find a computer shop that stocks it that will let me play with it, I'll take my pi in, power it from a battery bank, and ssh in to it from my phone and give it internet access via WiFi to my phone's hotspot. – Jim Aug 29 '16 at 14:31
  • @W5VO That's an argument for a full fledged UPS so it can handle the network and internet connection if the main power goes out. – JRE Aug 29 '16 at 14:33
  • Fantastic Question @W5VO! The internet is provided by WiFi and is on a GSM Network. The best part is that it is powered by USB, and that USB power will be coming from the Pi itself. So if the Pi has power to email, it has internet. – Jim Aug 29 '16 at 14:33
  • 4
    Possible duplicate of [Sensing AC high voltage to microcontroller](http://electronics.stackexchange.com/questions/150588/sensing-ac-high-voltage-to-microcontroller) – Dmitry Grigoryev Aug 29 '16 at 14:52
  • Can you make a 100pps clock and down count interval between buzzer Vdc events for 5 second and use result for beep rate. – Tony Stewart EE75 Sep 02 '16 at 12:38

2 Answers2

1

You can plug an AC to DC adapter to the mains. the output goes through a voltage divider to one of Rpi's IO. you can buy small USB adapters for as cheap as 2$. Now you can know when the mains goes off.

Powering the Rpi from a UPS is a very bad idea unless the UPS is actually used for some equipment or appliances. Check the quiescent power of the UPS. It's probably much more what the Rpi is consuming so you should know that the conversion efficiency of the inverter will be very low when you are consuming a small portion of the UPS power (which is the case you are only powering the Rpi) and will not be anywhere near the advertised efficiency. Simply buy a battery charger to charge the batteries along with a switching DC-DC converter to power your electronics. That will be more efficient and much cheaper (obvious) than buying a UPS!

fhlb
  • 1,440
  • 3
  • 15
  • 28
  • "AC to DC Adapter" as in a wall-wart? Buying a reliable one here is about R250 (at current exchange rate = about 17USD). As for the bad idea, I get that, it's highly inefficient, however, it's a cheap pre-built solution that would work in keeping the Pi running while there is no mains power coming in to the building. It would also be powering a GSM-Wifi router (that would need to stay on so that the Pi can send those emails). I wouldn't have to buy any other hardware other than the UPS, and I'm not very concerned about the DC-AC-DC efficiency loss. – Jim Aug 29 '16 at 14:10
  • 1
    The Question I'm actually asking is: _Is using the current to the Buzzer on the UPS as a way of determining power-out status a good idea or a bad idea?_ Is there a more elegant hack that I can use if the NUT software (mentioned by JRE above) doesn't go my way. – Jim Aug 29 '16 at 14:12
  • Well something similar along those lines would be an AC split core current transformer or hall effect sensor. However the Raspberry Pi doesn't have onboard ADC so may need to use a small circuit to have an on/off on a GPIO pin or an external ADC IC. – D-on Aug 29 '16 at 14:18
  • @D-on I was initially thinking about using something like a hall-effect sensor, but that would involve more money (I'm really very cheap). You don't think that hooking up 2 wires to the buzzer (or LED as mentioned by JimmyB) would be an easy answer? – Jim Aug 29 '16 at 14:22
  • to be specific on what you asked, the buzzer thing could work. If you're trying to impress someone or yourself, connect a microphone to the Pi and program the pi to detect a buzz, so you don't need to open the UPS and solder wires which can get messy. same thing with the UPS LEDs. you can place a phototransistor on the LED which will be save you from the inconvenience of soldering wires on the UPS's PCB – fhlb Aug 29 '16 at 14:32
0

The only "real" solution for you may be to consult the OEM UPS supplier to determine a low cost interface and COmm. Port with software and UPS backed network.

e.g. software solutions. http://www.power-software-download.com/viewpower.html

Tony Stewart EE75
  • 1
  • 3
  • 54
  • 182
  • I actually have that tab open in another browser window! So it's on the _To Investigate_ list. :-) Thanks! – Jim Aug 29 '16 at 14:36
  • synchronicity is amazing – Tony Stewart EE75 Aug 29 '16 at 14:36
  • Also - the problem is getting the manufacturer to actually get back to me - I am trying. – Jim Aug 29 '16 at 14:39
  • Downloaded the correct version of the software, unpacked it, made executable, and installed it. However, running it produces an error that I can't seem to solve. :-( – Jim Sep 01 '16 at 12:44
  • what errors? Run as admin? – Tony Stewart EE75 Sep 01 '16 at 14:08
  • Yes, run as root, error is: `RXTX fhs_lock() Error: Creating lock file: /var/lock/LCK..ttyS0: File exists` one solution was to delete that file, which I did, but it seems as if it tries to create it more than once, so the error happens anyway. – Jim Sep 02 '16 at 07:29
  • call RCT for tech support or try Linux stackexchange – Tony Stewart EE75 Sep 02 '16 at 12:32
  • I've been calling, and emailing. When I finally got through to the "main guy", he tells me to double-click on the EXE on the CD. **facepalm**. I did however, manage to get him to get some instructions from "above". He'll be sending it through shortly (I hope). – Jim Sep 02 '16 at 14:35