Physics Tom

Raspberry maths

25 May, 2021Readtime: 6 mins

raspberry

I love raspberries but they are certainly not cheap. While it is not sustainable for me to eat them everyday, the occasional punnet is a nice treat every now and then. The last time I went to buy some (last week) they were 3 EUR a punnet (2.99 EUR to be exact but who counts the pennies?). They usually contain between 15 and 20 raspberries based on some rather rough observation. Given a raspberry efficiency of α=0.85 \alpha = 0.85 I calculate the cost at roughly 0.18 EUR per raspberry, that’s not cheap. It may be worth comparing to other fruits to back this claim up but that’s maybe for another time.

You may be wondering what I mean with raspberry efficiency? This strict scientific definition is of course the fraction of non-mouldy and edible raspberries for each punnet. Unless you eat them straight after purchase I can guarantee that you never have α=1\alpha = 1. Anyone who has left raspberries in the fridge for a few days will know what I am talking about. Of course I am (very roughly) estimating my efficiency here as an average, that is, 8.5 out of 10 raspberries are good to eat and not mushy or mouldy - I know you can’t have half a raspberry but this is on average depending on my eating habits, and depending on how long after purchase I eat them. I could take into account the expontential decay of them as a function of time, but that’s just insane!

Recently I find myself buying them quite frequently, once or twice a month perhaps, and definitely much more in season. Let’s say on average per month I buy 2 punnets (I am not actually sure if you call them punnets for a collection of raspberries but anyway back to raspberry maths…) that is 24 per year costing me 72 EUR (71.76 EUR to be exact), indeed not a cheap habit, especially for something that leaves me more hungry after eating them. We are assuming that the cost of raspberries are constant and they are inflation proof - something anyone who has been to the supermarket lately can tell me is certainly not the case, but I am not doing a supply chain analysis right now.

Well instead of comparing this to other fruit, why not compare it to another type of raspberry, the non-ediable one, namely the Raspberry Pi.

raspberrypi

After recently purchasing the Raspberry Pi 4 I am leaving it on permanently to run 24/7 and use it for a private server on my home network (amongst other things). But after a few days I began to wonder if I would be in for a nasty shock when I got my next electricity bill, so I decided to do some more raspberry maths. To figure out the cost of running one of these bad boys for a whole year 24/7 we first need to know a few things:

  • Cost of one kWh (βkWh\beta_{kWh})
  • Voltage of the Pi power supply (VV)
  • Current drawn by the Pi (AA)

The first two we can assume are constant with time, with the first dependent on your provider, and the second fixed at 5.1 V (the same for all Raspbeery Pi versions). The last one, however, will change with time, depending on what we are doing. Since I do not have any way to measure the current I must make some assumptions and use some external data to help me here. Looking at various websites and blog posts of people measuring current as a function of load and idle, I assume that the idle current is 600 mA with more than double that for on-load, at 1400 mA. We denote these as AidleA_{idle} and AloadA_{load} respectively.

Note I turned off the HDMI, Wifi and USB (all of which are controlled with systemd - see this create post (external) for more details on how to do that). So in actuality my current estimates may be too high, but I’d rather this than estimate it too low.

So we can write the cost of running for a year βyear\beta_{year} with λidle\lambda_{idle} fraction of the time in idle and λload\lambda_{load} of the time on load as below. Obviously λidle+λload=1\lambda_{idle} + \lambda_{load} = 1. Remember from school physics that power is voltage ×\times current (P=VIP = VI).

βyear=βkWhV(λidleAidle+λloadAload)τ×103\beta_{year} = \beta_{kWh}V(\lambda_{idle}A_{idle} + \lambda_{load}A_{load})\tau \times 10^{-3}

Where τ\tau is the number of hours in a year (365×24=8760365 \times 24 = 8760), since we have our cost in kWh, and the factor 10310^{-3} is because we want kW not W.

OK so now for some numbers - we know V,Aidle,AloadV, A_{idle}, A_{load} and τ\tau - but we don’t know βkWh\beta_{kWh} or λidle\lambda_{idle} or λload\lambda_{load}. The last two will be specific to the use case but since my Pi does not actually do much most of the day (bar a few small cron jobs and the odd computation/simulation) I can assume λidle=0.95\lambda_{idle} = 0.95 and λload=0.05\lambda_{load} = 0.05.

Finally, my cost of one kWh is 0.18 EUR so I get the grand cost of 5.15 EUR / year to run it - less than 2 punnets of real raspberries or roughly 29 edible raspberries in total. I think that’s pretty cheap.

To be clear here is the final calculation, with numbers in place of the symbols in the equation above.

βyear=0.18×5.1×((0.95×0.6)+(0.05×1.4))×8760×103\beta_{year} = 0.18 \times 5.1 \times ((0.95 \times 0.6) + (0.05 \times 1.4)) \times 8760 \times 10^{-3}
βyear=5.15\beta_{year} = € 5.15
βyear=29 Rs\beta_{year} = 29 \textrm{ Rs}

Where, Rs is the number of raspberries.

Feel free to play with the numbers below to see how much it costs you! Move the range bar to the left for more idle and right for more load.

Idle Load

Cost of one kWh =

Cost per year = €5.15 or 28.6 Rs

Update: As someone has pointed out, I failed to take into account the cost of the machine itself (about €80) and the expected life expectancy. Assuming it would last for 5 years then that does indeed put our cost up to about € 21/22 per year. Still small compared to the equivalent setup on the cloud!


Thomas Stainer

Written by Thomas Stainer who likes to develop software for applications mainly in maths and physics, but also to solve everyday problems. Check out my GitHub page here.