From the course: Raspberry Pi Weekly

Dealing with undervoltage - Raspberry Pi Tutorial

From the course: Raspberry Pi Weekly

Dealing with undervoltage

- There, do you see that lightning bolt? That says your Raspberry Pi is under voltage. Your power supply isn't keeping up with your Raspberry Pi. You might want to know how to detect this, how to test it, and how to fix it. Hi, I'm Mark Niemann-Ross, and welcome to this week's edition of "Raspberry Pi Weekly." Every week, we explore the Raspberry Pi and share useful tips. The Raspberry Pi needs five volts. At 4.63 volts, it's going to complain about low voltage. The Raspberry Pi will slow down the processor to match the drop in voltage. Much lower than 4.63 volts and your Raspberry Pi will stop working. Possibly worse than this, lower voltages will cause corruption on your SD card. To detect a low voltage, you can watch for the lightning bolt. But you can also the vcgencmd operation. To use vcgencmd, open a terminal and type in vcgencmd, followed by a space and then get_throttled, T-H-R-O-T-T-L-E-D. You'll get back the string throttled= followed by a number that starts with 0x. In this case, we're looking at throttled=0x50000. This is a hex number. It's actually a hex representation of a collection of one-bit flags. If only the first flag is on, the hex number would be 0x1. That would indicate an undervoltage is detected. Now, here's a table of all the flags. Notice that in the table, the first bit of vcgencmd get_throttled is referred to as bit zero. If an error occurs, that flag is turned on, and the binary value of that bit is added to vcgencmd get_throttled. In this case, bit one has a binary value of two, which is added to vcgencmd get_throttled and returns a result of two. So if an undervoltage is detected and the Raspberry Pi is currently throttled because of it, vcgencmd get_throttled will return throttled=0x5 followed by zeroes, which is the first bit plus the value of the third bit. And the Raspberry Pi is currently throttled because of it. Vcgencmd get_throttled will return throttled=0x5 which is the value of the first bit plus the value of the third bit. This is totally confusing, so I wrote a Python program that will read the value from vcgencmd get_throttled, then decipher the warning messages. Look in the Exercise Files for vcgencmd.pi, run it, and then compare your results to the suggestions on the table. In this case, you can see that vcgencmd has returned 0x5. The warning is undervoltage has occurred and throttling has occurred. Fixing undervoltage is easy. Get a better power supply. You may not be getting enough power from your old phone charger. Look for a higher quality unit, and test it with a voltmeter to make sure it's providing the power it's supposed to. Thanks for joining me for this episode of "Raspberry Pi Weekly." Be sure to join the LinkedIn group and check out previous episodes on LinkedIn Learning. I'll see you next week with more Raspberry Pi adventures.

Contents