Saturday, July 11, 2015

Raspberry Pi and external USB drives

OK, for no other reason than I can, I wanted to add an external hard drive to my test Pi (I have three Pis - two of the older Model B and one of the latest version).

The test Pi is a Model B in a blue case (to identify it easily!). Originally, I considered moving the Root partition to the hard drive and just booting from the SD card as this is supposed to be quicker, however, I rarely reboot the Pi and to be honest, they don't take very long to get up and running anyway.

So the plan was to simply connect the USB HDD to the Pi and use the extra space for whatever my latest crazy idea may be. All the spare USB HDDs I have lying about are those ones which don't have their own power supply - i.e they are those "portable" type ones with two USB connectors which need to be plugged in to a USB source to get the power needed to run the things and to take the data to and from.

From my own experiments, some research and of course common sense, I knew that the Pi - with its two USB ports (one of which has the wifi adapter in it anyway) would not have sufficient power to run the drive - and that I would need a powered USB hub to do this.  Luckily, I happen to have two spare!

Armed with all the bits I needed - Pi and power supply, powered  hub and power supply, connections and the USB HDD - I connected it all together and fired things up.

Looking good - lights all on and I could ssh into the Pi.
However, nothing showing under the "dmesg" command to suggest the USB HDD was there.
Perhaps faulty kit? After swapping the powered hub for my other one, I repeated the command - still nothing.  Although the USB HDD worked when connected to my PC, maybe it was faulty? It was, after all, just an old SATA 2.5" drive from a laptop in a cheap caddy. So I swapped the HDD for a "proper" one - a Maxtor as it happens. This time, when I fired things up, I got a clicking noise from the drive whenever access was tried. As a techie, I know this means either the drive is failing (which was unlikely) or a lack of power.....

Surely I had checked all the kit - tried different powered hubs - and no luck. Then, as I was pulling it all apart, I just happened to pull out the powered USB hub power supply and casually looked at the power output. 1000mA. That doesn't sound a lot to me I thought. I know these external drives need a fair bit of power. This was the power supply from the more generic of the two hubs I have, so I dug out the other power supply - 2000mA, twice the power.

Using the more powerful power supply, I connected all back up and .... hurray!  Success!

Moral:  Be wary of using cheap, generic kit with the Pi. Yes, some works fine but these things are very low power and need all the help they can get to ensure stable running.

Thursday, July 09, 2015

Raspberry Pi "UPS" experiment

My daughter recently bought one of those "power bar" things to charge her mobile whilst on holiday. As these are simply a rechargeable battery with some circuitry to avoid overcharging etc, they caught my eye as both an external power supply which would allow me to use the Pi outside without access to mains power and also, more intriguingly, as a form of UPS to keep the Pi running when there is a power cut (in much the same way that I use an EeePC as my weather server because it has a battery for these occasions.

Right, the first power bar she bought was an Anker Astro E1. Very pretty, small device which claims to supply 5v and 1A output. It has a capacity of 5200mAh, which is plenty to run a Pi and its ancillaries for a while!

A quick test and I ran my Pi, with wifi and a USB stick attached to take the images recorded by the Pi camera which was also attached.
I left it running for over three hours and all was fine. I am sure it would handle a bit more, but I didn't want to push things to start with.

When daughter returned from her holiday, having taken the Anker with her, she brought me a smaller power bar to play with for my very own! This one was from a very large store in the USA and carries the brand name Dynex. It is a model DX-1122 and supplies 5v and 1A output - although below that it gives 3.7v and 2200mAh. 3.7v sounds a bit iffy for a Pi, but having tested it with the Pi setup as above, it ran and completed a two hour imaging session without any problems.

So, onto the second part of my experiment!  I have read various reports that these power bars work as UPS devices - but also read that they don't!
Each has two plug holes - one for the little micro USB sockets for charging it and a standard USB socket which takes the lead to plug into your phone/Pi.
Theoretically, if I plug a lead from a power supply into the charging socket and also plug in the power out into my Pi, it will act as the UPS I am after....

No..  Neither of the power bars will work if both leads are plugged in. I have read this is the case with many of these devices. Not that I am terribly bothered (although a UPS would be nice) as I still have the power when outside functionality.

More research needed to see which ones get a mention as being able to fulfill this purpose.