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 vcgencmd 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.

EDIT 2: fixed typo in quoted command


4 Answers 4


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, 2017 at 20:02
  • @NULL edited answer.
    – joan
    Jan 18, 2017 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.

  • 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, 2018 at 21:12
  • 1
    ...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, 2018 at 21:18
  • 2
    It should be the accepted answer.
    – Feriman
    Oct 24, 2019 at 8:31
  • 2
    An up to date link for the documentation should be: github.com/raspberrypi/documentation/blob/master/raspbian/… The current one 404s
    – Technoloft
    May 29, 2020 at 1:03
  • 1
    @user3123159, don't know if I got your question right, but, for practical uses, power and voltage are always related -- voltage drops when amperage rises. By how much, depends on the quality of your adapter and cable. Also, devices can consume a lot of power and different parts of the Pi can handle different loads -- I recently came across a cheap HDMI to VGA converter that was causing me troubles on rPi1 but not on rPi2 nor rPi3 (with the same adapter, cable, OS and apps)...
    – zertyz
    May 19, 2021 at 22:13

How does the Pi know it being under-powered and to show the lighting bolt?

This is a very good question, IMHO, and since it doesn't seem to have a current and complete answer, I'd like to chime in. First, I need to credit @Ghanima's Q&A here for calling out the PMIC (Power Management IC) as the MXL7704.

The operation of the MxL7704 is covered here, and in the data sheet.

If we begin with the Rev 4 schematics for the RPi 4B, we see the pertinent connections between the MxL7704 and the USB-C power input summarized in the schematic below:


simulate this circuit – Schematic created using CircuitLab

Note first the 5V_SYS node is simply a low-pass filtered version of the VBUS 5V input power. The filter has a time constant determined by R5 & C12 of 0.1 msec. 5V_SYS is the voltage monitored by the MxL7704, and compared to its 4.63V internal reference to determine the state of the Power Good outputs (PG1 & PG2) at pins 5 & 20, respectively. Please refer to the MxL7704 data sheet, and the block diagram (copied below) for details.

MxL7704 Block Diagram

Knowing how the RPi's 5V power input is low-pass filtered, and routed to the MxL7704 as 5V_SYS, the Block Diagram fills in most of the other details to answer the question:

  • The 4.63V voltage monitor (MON) provides a binary output indicating whether 5V_SYS is above the 4.63V threshold, or below it. This output is stored in a data register in the I2C block, and from there it is also available to the PGOOD state machine.

  • The PGOOD state machine receives inputs from the "external system" (RPi's SOC) via the I2C bus that configure the state machine. This configuration, in turn, determines how it processes its various inputs to yield the PG1 and PG2 outputs at pins 5 & 20 of the MxL7704.

  • The status of the 5V_SYS voltage (i.e. above or below 4.63V) is kept in one of the registers internal to the MxL7704. The section of the data sheet titled Input Voltage Monitor Flag covers details, but of course cannot tell us how the RPi's proprietary hardware and firmware interact with the MxL7704.

  • Nevertheless, it is evident that this binary representation of the 5V_SYS status stored in these registers is the value used by the RPi to set and clear the Low Voltage Warning flag.


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.