How does the Pi know it being underpowered and to show the lighting bolt?

As most of us know, if you use a bad power supply you get the lightning bolt telling you are underpowered.

I noticed that when I run my Pi on battery, the last 15 minutes or so before the Pi starts to reboot, the lightning bolt starts appearing, and eventually stays there until the reboots, which makes sense because my battery voltage is dropping as it is drained.

This got me thinking I could use this to make a program that turns the Pi off when it detects constant under-voltage. I know before this happened would be even better but I am not concerned about that.

Is there a command for voltage like sudo vcgenmd measure_temp for temperature to know what the voltage is? If not how does the Pi know when it is being underpowered?

EDIT: This is not a duplicate because the other question suggests you need external hardware. I am pointing out this is not strictly necessary.


Some Pi models have an onboard chip which detects a low voltage. This is used to drive the power LED on some Pi models.

Models A+, B+, Pi2B

The red power LED is connected to GPIO 35. You can monitor the GPIO to check for an under voltage condition (less than 4.65V).


To monitor the GPIO you would need to read its value. If the normal (good power state) value is high (1) then undervoltage will be indicated when it reads low (0). The GPIO will return to its normal state if the undervoltage condition is cleared. Therefore you would need to read the GPIO frequently to detect transient conditions.

  • How would I monitor that though...GPIO is a digital pin right? – NULL Jan 18 '17 at 20:02
  • @NULL edited answer. – joan Jan 18 '17 at 20:08

If you want to do it with a shell script, here is a solution that works on Pi 1, 2 & 3 (not tested in zero). With the command:

/opt/vc/bin/vcgencmd get_throttled

If the answer is:


You're good with the supplied voltage and SoC temperature.

The bits on the returned number mean:

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

A value of 0x50000 means 16 & 18 -- from the boot moment up to now Under-Voltage has ocurred at some point as well as Throrrling has occured.

Reference: vcgencmd Documentation.

  • This is only true if undervoltage and overheating are synonymous or have some kind of known relation such that we can say if the voltage is too low by 0.5 V the core temp will be...but that is not the case. – goldilocks Nov 30 '18 at 20:00
  • I just provided an example. The returned value contains several bits who are set if: 1) supply is not providing a safe input (which is what the OP wants); 2) ARM frequency was reduced due to hight temperatires; 3) Overvoltage was turned off due to very hight temperatures. The link I provided dismiss the doubt. – zertyz Nov 30 '18 at 20:45
  • 1
    Then why not write that in the first place? Anyway, welcome -- but please read our our policy regarding informationless link-only answers. This is not quite that, although the actual information in answer doesn't address the real question either. The idea is an answer is complete in itself; stuff like "read this link" belongs in comments. I realize you do not have enough reputation to post comments on the question, but it would be nice if you spent a few minutes restructuring this... – goldilocks Nov 30 '18 at 21:12
  • 1
    It should be the accepted answer. – Feriman Oct 24 '19 at 8:31
  • 1
    An up to date link for the documentation should be: github.com/raspberrypi/documentation/blob/master/raspbian/… The current one 404s – Technoloft May 29 '20 at 1:03

The following explains how the power circuitry of modern Pi (with 40 pin header) works Raspberry Pi Power Limitations.

The lightning bolt is controlled by the kernel, and AFAIK there is no simple way to access it.

The power state can be detected more easily. This is directly available through the system in B+ Pi2 /sys/class/leds/led1, and accessible through a program on Pi3 https://raspberrypi.stackexchange.com/a/60275/8697

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.