Message boards : Number crunching : Pi Power-Up
Message board moderation

To post messages, you must log in.

AuthorMessage
Brummig
Avatar

Send message
Joined: 23 Mar 16
Posts: 95
Credit: 23,431,842
RAC: 2
Message 5043 - Posted: 14 Jan 2022, 10:42:11 UTC
Last modified: 14 Jan 2022, 10:50:13 UTC

Some time ago I noticed that my Raspberry Pi 2 was significantly outperforming my Pi 3 running Universe@Home. I didn't have the time to look into it, but I just assumed it was a weak power supply on the Pi 3. The Pi 3 in question was powered from the USB socket on the back of my router (and it wasn't convenient to change this arrangement), whilst the Pi 2 was powered from a switched-mode power supply on a HAT that I designed myself. Over the holiday period I decided to look into it, and discovered my assumption was wrong.

To help me, I wrote two scripts, which I've provided below. These did indeed reveal the Pi 3 was running under-voltage, and as a result throttling the CPU, but not for the reason I thought. I discovered it also ran under-voltage when plugged into a 2 Amp wall-wart (and yes, it was bang on 5 V). There then followed much switching around of Pies, power supplies, and USB cables. This revealed that both Pies always ran under-voltage when I used a random USB cable that came with something. It made no difference whether the cable was anonymous rubbish, or came with a good quality branded product. The only cables with which they didn't run under-voltage were either of the two Anker USB cables I bought simply to allow me to charge and use a device at the same time without finding myself on a short leash that somehow shortened itself further by slowly tying itself in knots. With these cables it made no difference which (potentially adequate) power supply I used, despite the fact that these are quite long cables. I've since bought two more, and these also allow my Pies to perform to their full potential. This is probably because these Anker cables simply have a lower resistance than generic cables. As an added bonus, they are (approximately) Raspberry Pi red. Here's an Amazon link (UK site): https://www.amazon.co.uk/gp/product/B01DEMTOQ6/.

So you might want to use my scripts to check on your own Pies.

This isn't the end of the Pi 2 vs Pi 3 story, but I'll leave that for a second exciting, fun-packed episode.

~/bin/show-status:
#!/bin/bash

# I was fiddling around with the most convenient way (for me) to deal with the need to run vcgencmd as root.
# In the end I left it as a script where the script is called without "sudo", but the first command demands the password.
# You may want to do something different.

sudo echo ""

# Assume Bullseye...
VCGENCMD=/usr/bin/vcgencmd
if [ ! -f "$VCGENCMD" ];
then
  # Nope
  echo "Please upgrade me."
  VCGENCMD=/opt/vc/bin/vcgencmd
fi

awk 'NR==3 {print "WiFi Signal Strength=" $3 "00 %"}''' /proc/net/wireless
sudo $VCGENCMD measure_volts
sudo $VCGENCMD measure_temp
sudo $VCGENCMD measure_clock arm

source <(sudo $VCGENCMD get_throttled)

# Bit Hex value   Meaning
# 0          1    Under-voltage detected
# 1          2    CPU frequency capped
# 2          4    Currently throttled
# 3          8    Soft temperature limit active
# 16     10000    Under-voltage has occurred
# 17     20000    CPU frequency capping has occurred
# 18     40000    Throttling has occurred
# 19     80000    Soft temperature limit has occurred

if [[ $(($throttled & 0x1)) -ne 0 ]];
then
  echo "Under-voltage detected"
elif [[ $(($throttled & 0x10000)) -ne 0 ]];
then
  echo "Under-voltage has occured"
fi

if [[ $(($throttled & 0x2)) -ne 0 ]];
then
  echo "Frequency capped"
elif [[ $(($throttled & 0x20000)) -ne 0 ]];
then
  echo "Frequency capping has occured"
fi

if [[ $(($throttled & 0x4)) -ne 0 ]];
then
  echo "Currently throttled"
elif [[ $(($throttled & 0x40000)) -ne 0 ]];
then
  echo "Throttling has occured"
fi

if [[ $(($throttled & 0x8)) -ne 0 ]];
then
  echo "Soft temperature limit"
elif [[ $(($throttled & 0x80000)) -ne 0 ]];
then
  echo "Soft temperature limit has occured"
fi

echo ""

~/bin/monitor-status:
#!/bin/bash
watch -n 30 "show-status"
ID: 5043 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
frankhagen

Send message
Joined: 12 Aug 17
Posts: 21
Credit: 58,957,280
RAC: 0
Message 5044 - Posted: 14 Jan 2022, 12:59:21 UTC

hi,

this good advice!

me myself being a veteran with digital devices and not using any pi's gives 5 stars for this.

HELPFULL at least for the unexperienced around..

gruss, fs.
ID: 5044 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote

Message boards : Number crunching : Pi Power-Up




Copyright © 2024 Copernicus Astronomical Centre of the Polish Academy of Sciences
Project server and website managed by Krzysztof 'krzyszp' Piszczek