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:

0: under-voltage
1: arm frequency capped
2: currently throttled 
16: under-voltage has occurred
17: arm frequency capped has occurred
18: throttling has occurred

Reference: Raspbian Jessie linux 4.4.9 Severe Performance Degradation.

There is a more up to date list https://github.com/raspberrypi/documentation/blob/JamesH65-patch-vcgencmd-vcdbg-docs/raspbian/applications/vcgencmd.md

0: under-voltage
1: arm frequency capped
2: currently throttled
3: Soft Temp limit reached  3
16: under-voltage has occurred
17: arm frequency capped has occurred
18: throttling has occurred
19: Soft Temp limit has occurred
  • 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
  • ...Note we are not a discussion forum, whereby the meat of a thread is in casual back and forth time ordered posts. If you are asking a question and someone asks for more information, edit it into the question, don't just leave it in a reply comment. Likewise, if you have an answer and someone asks for clarifications, anything not already explicitly in the answer should be edited into the answer and not just leave in the comment trail. – goldilocks Nov 30 '18 at 21:18
  • 1
    It should be the accepted answer. – Feriman Oct 24 '19 at 8:31

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.