Domipheus Labs

Stuff that interests Colin ‘Domipheus’ Riley

Content follows this message
If you have enjoyed my articles, please consider these charities for donation:
  • Young Lives vs Cancer - Donate.
  • Blood Cancer UK - Donate.
  • Children's Cancer and Leukaemia Group - Donate.

Pi On The Wall – wall mounted home server – Part 3: Reducing Power Consumption

Posted Aug 8, 2014, Reading time: 15 minutes.

If you missed Part 1 and Part 2, it’s probably best you at least read Part 1 to understand the scope of the project. Part 2 discusses how the hardware is modified to fit into a restrictive enclosure, measuring only 10mm deep.

From the start, I wanted to stretch the boundaries of the Pi On The Wall, and therefore, Raspberry Pi power consumption. It seemed like a rather fun exercise. This post describes what I did in reducing power consumption fairly drastically, given what can be done in this limited power space.

For those who want a jist of what follows: I reduced power requirements of the Raspberry Pi with PiTFT and WiFi drastically. Had to plan for high inrush currents in the designs. Choose switching regulators wisely given voltage and load characteristics. Efficiency varies drastically! Espressos are expensive!

Power outline – the situation as stands.

The major consumers of power are as follows

Pi model A: 300mA (source: RPi Wiki )

PiTFT: 100mA (source: Adafruit website )

Edimax Wifi dongle: unknown for sure. This uses the Realtek RTL8188CUS chipset. The only datasheet I could find for it was from a third party which suggested maximum 600mA at 3.3v. It did not provide minimum and typical current ratings, sadly. That’s nearly 400mA at 5v – Whoa.

So we are looking at around 400mA + wifi. Looking around, it seemed to be the WifF would cost about 100mA in active use, not the 400mA from the datasheet, so we’re looking at 700mA for the whole unit.

Since we are space constrained, the power supply situation is a sticky problem for me. The more power required, the more heat given off by the supply, so I want consumption to be low, and efficiency high. My original hope was that I could use the power supply provided with the thermostat casing, as it outputs 5v. Sadly, after testing it with an adjustable current load, it became clear the supply would not be suitable. At just below 200mA draw, the supply would give up, sending the voltage down to millivolts. In fact, even with 150mA, the voltage dropped by 600mV, so using it for the Pi isn’t very feasible.

From looking at various threads about power consumption online, I came to the figure of having this run at 250mA. I’d like this number at idle with the PiTFT backlight on, but peak will probably be higher. Nothing very scientific in how I came up with that number –it’s just a rough guess of what seemed reasonable to achieve.

Lowering Power

The first thing that jumps out at you when researching Raspberry Pi power consumption is the 3v3 linear voltage regulator, marked RG2. That component takes the 5v power input and outputs a stable 3v3 rail which powers most of the devices on the board.

Linear regulators are inefficient, and the power difference between the input and output is dissipated as heat. As I stated earlier, heat is something I want to stay clear from, and when it’s generated by an inefficient component that is not acceptable. We will change this component, swapping in a more efficient, switching regulator. However, we need to be very careful about which switching regulator we choose – efficiency at the given input, output and load of the various switching chips can vary drastically, sometimes falling below that of a linear regulator! Do not use those LM2596/LM2598 devices you see everywhere, efficiency at the characteristics we use is a poor 77%.

I decided, in the first instance, to use an MP2307 based DC-DC unit. They can be had very cheaply at retailers like banggood.com, and as you can see by the datasheet, efficiency is very good at the values we require (over 90%). That cheap unit has L at 10uH, too!

One thing to note about these cheap DC-DC converters is that they usually have a wide variable output range, and a terrible single turn pot as the adjustment pin. I spent at least 15 minutes attempting to get as close to 3.3v as possible. In the end, I settled for 3.34v. It would have been quicker soldering a 10-turn pot on here, but sadly I’m too constrained for space to have this luxury.

We will detach the stock 3v3 regulator from the circuit, and power the Pi using the GPIO 5v and 3v3 pins. Note: these pins bypass any protection circuitry on your Raspberry Pi. You’ve been warned!

Software Tips

We can also do some tuning in software. The tvservice, which operates the HDMI out of the raspberry pi, consumes power. Switching this off is simple, and can be done on startup.

Many people on the Raspberry Pi forums have indicated that underclocking the Broadcom SoC achieves nothing in terms of power saving. Despite this, as I’m going for a low-temperature solution, I’m still going to enable the OnDemand cpufreq governor, and set it to operate between 300-500MHz rather than flat out 700MHz. This basically makes the CPU clock down when idle, and ramp back up when under load. It’s a fairly common feature these days, and I must admit was surprised I had to enable it! Instructions for doing this can be found here and here. I installed cpufrequtils with apt-get and used that.

The GPU should handle itself and when idle (which, should be pretty much all the time) be very low power.

The measuring setup

To measure the power consumption, I’m going to measure voltage and current on the 5v line which powers the Pi and also any replacement switching regulators we connect.

Something which may catch folk out here is that first instincts may make you put your multimeter reading current onto the mA range. This has a large effect on the voltage into the Pi, due to Burden Voltage. Dave Jones of EEVblog has a good video on this, as well as Martin Lorton. All of my meters are budget ones (Vichy VC99) and the burden voltage of the mA range meant the Pi would not even boot. On the Amps range it booted fine, with a much smaller Burden Voltage, but still enough resolution to see a reasonable figure. A good compromise for this is to find a decent 0.1 Ohm precision resistor, which can be had fairly cheaply – then you simply measure the voltage across this resistor and read it off the meter like 20.5mV == 205mA. I like this method as it also shows you instantly the burden voltage in your circuit and you can adjust to reverse any ill effects of it. I just live with it in these tests as it is small enough not to cause issue. I confirmed my results using this method as well as simply using the multimeter current measurement.

The setup looks like the following diagram.

Power Measurements

The measurements I found were an average over a few test runs. The current measurement was taken using my Vichy VC99 meter that should be accurate enough, but I’ve not used precision measurement techniques or equipment so the figures should really be taken as a decent ballpark figure. Multimeter set to its maximum mode – so it captures and always displays the maximum reading it had during the test run. We need to know the maximum, because the Pi is very fragile with sudden voltage drops and it will fail to boot if the power it demands is unavailable. Current readings are always taken from the main 5v line into everything unless specified otherwise. The main source of the 5v rail to remain close to the final setup is an HTC TCB250 5V 1A charger.

The test is as follows: The PiOnTheWall is booted to X, PiTFT backlight on, USB wifi enabled and configured to connect to an access point 7 meters away and through several walls.

Test 1: Stock setup

The Pi booted and successfully completed the test with a maximum reading of 376mA.

This seemed promising already. It’s far lower than expected considering I was expecting 200mA alone for the WiFi and PiTFT.

Test 2: TV service off

The Pi booted and successfully completed the test with a maximum reading of 356mA.

That was a decent saving for doing pretty much nothing. All you need to do is add ‘/opt/vc/bin/tvservice –off’ to your init. This figure seems consistent with that observed by Dave Akerman.

Test 3: Replace 3v3 regulator with an MP2307 switching unit.

I simply desoldered the two bottom legs of the regulator off the board, keeping the tab on. This is in case I ever need it again, so it’s an easy change to revert.

The Pi booted and successfully completed the test with a maximum reading of 325mA.

This is disappointing**,** however, not unexpected. The biggest power draws, the WiFi and PiTFT take up 200mA alone, leaving just 156mA for the Pi (from test 2). If we assume the efficiency of the linear regulator is 70%, the maximum we could really get down to is in the 110mA area. But the MP2307 unit itself isn’t 100% efficient either, so if we consider it to be around 90% efficient (which is conservative, but still a great figure) we get a theoretical 121mA, which is very close when the 200mA is added back on to our 325mA figure.

Test 4: Power the whole setup – Pi, PiTFT, Wifi from a single 3v3 source, tying the 5v rail to 3v3.

This is supposedly doable – I’d read about it in the forums, and also via Dave Akermans blog mentioned above. If we look at the Schematic, we can see the +5v rail goes into the 3v3 regulator, which then becomes the main power rail, but +5v also goes to some pins on the Broadcom SoC, and the USB Power. The WiFi chipset datasheet indicated it ran from 3v3, however, I don’t know how that is delivered, so whether the USB +V pin being 3v3 would translate to an operating chipset is unknown. The Pins on the Broadcom SoC where 5v is present seems to mostly be sense pins for battery powered devices, and so hoped these were not actually used correctly, and that any significant voltage on them such as 3v3 would allow for boot.

Note that for these tests, the mA current readings are on the 5v input before any 3v3 converters.

The first attempt at the test was conclusive.

The Pi failed to boot fully.

The initial linux boot sequence looked promising at 3v3. The backlight of the PiTFT module was, of course, less bright – but still very useable even under my bright bench light. After several attempts at booting the culprit was clear – the WiFi stick initialization. As soon as the WiFi was initialized and it’s activity light came on, the PiTFT screen failed and went white. The Pi Itself continued to boot as I was able to SSH in after a short delay, so the WiFi worked, it’s simply something else was happening.

Inrush Current

When this happened, my first instinct was Inrush Current causing issues. Inrush current is the high draw which occurs when something first switches on, caps charging, etc. It’s well known that the Raspberry Pi does not cope well with this, and there are many mods that exist to make the Pi cope well with hot-plugging of USB devices. There is an article here which discusses inrush current and controlling motors, and indicated further filter capacitors on the input power would solve this issue. Remembering from Part 2, we removed the 220uF input capacitor, so there is certainly a lack of capacitance on the power inputs. In line with the article I link to, I fitted a 0.1uF ceramic, and some 1000uF Electrolytic capacitors I found in my junk bin to the power input. After I did this, it booted to X.

The Pi booted and successfully completed the test with a maximum reading of 254mA.

This seemed a huge jump, then I realized why: the LED backlight of the PiTFT. They were rated at 80mA, but on measuring them individually at 3.3v they were drawing only 22mA @ 3.3v! The brightness drop isn’t really a problem for me, so this is a welcome decrease in consumption. I’m not an expert at this, so it’s probably going to have a damaging effect on the LEDs life, but I’ll take that risk.

A problem remained, however – the PiOnTheWall was unstable. When I opened the web browser and pointed it to BBC news the PiTFT died like before. Damn. Additionally, there was a considerable flickering of the backlight of the screen. I initially thought it was synced to the activity light of the WiFi, but it wasn’t. Then I thought about it being activity on the SD card. I discovered this document on SD card stability which suggested a 22uF tantalum capacitor between pins 3 and 4 of the SD card. The Pi schematic didn’t show capacitance of this level in the SD card interface, so I added it. Thankfully I had a single 22uF tant left, albeit a slightly larger voltage one than I wanted. It still fits in the assembly, so soldered it direct to the SD card socket.

But sadly, the flickering remained!

Then I remembered there was a regulator on the PiTFT itself, as it was powered from the 5v GPIO. The TFT panel requires 3v3. I looked up the datasheet for the regulator and saw it would output around 2.8v for 3.3v in. This is actually still within the minimum spec of the raw TFT panel used in the PiTFT, but to make sure, I removed the regulator and bypassed the in/out pads on the board. The flicker remained. Ugh.

(Top tip: Keep the off cuts of through hole components for making jumpers like above!)

At this point I ordered some high quality ESR caps to use, but it still didn’t stop the backlight flicker. The quality caps did however make the device stable – I was able to load BBC news in the browser on the device fine. The backlight flicker pretty much ruled this solution out though.

Test 5: Power Pi & PiTFT from 3v3, Wifi from 5v

The Pi booted successfully and completed the test with a maximum reading of **269mA.**The flickering with this setup was drastically reduced – barely noticeable. The amount of capacitance on the input power could be reduced and it was still stable, loading web page in the browser well – the PiTFT screen remained on and active throughout. I think we have a winner!

The final input schematic contains several capacitors and they are rated for 6v. Interestingly I don’t need any on the 5v line that the WiFi is connected to, but this may change with other 5v power sources. I always needed to keep the 5v line, as my motion sensor runs off a very odd 4v4 – I couldn’t easily find any 3v3 PIR units that are small enough for my enclosure. Note, that the additional capacitors will fit in the enclosure fine, in the existing area where the old useless power supply was along with AC-DC converter.

Conclusions

I hit my power target. I’d expected around 250mA typical, in reality, I’m getting lower than that. I get around 270 peak, but during normal use, with the backlight on, and downloading a file over the WiFi it draws around 220mA. Idle, with the backlight off, with WiFi connected (but no traffic) we are at 140mA.

I don’t expect this device to be doing much; but when it is the backlight will no doubt be off. The backlight is controlled by a small motion sensor which automatically turns it off with no motion. With the WiFi active, it consumes around 200mA at 5v. A single watt of power, at a reasonable load. In fact, throughout these tests, the HTC adaptor was really only providing around 4.8V, so it’s even less than this!

Okay, when looking at the numbers this saving may seem a bit silly given the effort that went in to achieve it. But I’m confident this will achieve a cooler overall setup in terms of temperature and efficiency. As it’s inset into the wall, I don’t want a ‘phone charger’ type setup getting warm. I intend to power this device with a mains AC to 5V converter, and then a 5v to 3v3 switching DC-DC converter. As I said earlier, there are a variety of DC-DC converters for this purpose, and I ordered a variety in with different efficiencies to test. I may write another post looking at the efficiency of these units as they really do vary! For now I just used the MP2307 as it was easiest to procure and its datasheet suggested >90% efficiency.

To finish off, lets calculate how much it will cost to power this at a generous typical of 0.8W. If I assume a mains to DC voltage efficiency of 65% (i.e, the mains adapter used to produce the 5V and 3v3, which nobody ever takes into consideration in figures), we’re around 1.23W. For a year, that’s 1.23 * 24 * 365 = 10.78KWh.

**Given 2013’s average KWh unit of electricity cost in the UK of 13.52p, it will cost £1.46 to power the Pi On The Wall. For a whole year. Around $2.45 USD.
**

Thanks for reading, I hope it was interesting. As always, you can reach me on twitter @domipheus and the flickr album is full (230+ high res images) of build progress shots. If you liked the article, please consider sharing it on social media of your choice!

To be continued… Part 4 will be putting it all together, temperature, and preparing the case! A teaser of what’s to come is below…

– Espresso Image courtesy of Suat Eman / FreeDigitalPhotos.net –