stack twitter tryhackme rss linkedin cross

Wilco van Esch

Skip to main content

Search results

    Why your EV3 might appear to shut down arbitrarily

    The EV3 programmable brick should be powered with 6 1.5 V AA batteries for a total voltage of 9 V.

    When total voltage drops below 5 V, you will get strange issues such as the programmable brick spontaneously shutting down.

    Connecting to Wi-Fi can quickly drop the voltage.

    If you use ev3dev, you can make it easier to learn when the EV3 is dipping below 5 V. The following is an example using ev3dev with Python.

    In a shell or script, use PowerSupply() to access the power_supply class:

    ps = PowerSupply()

    Then get the battery's voltage at the time of measuring through:

    ps.measured_volts

    Now you can have the EV3 give you a warning if the voltage drops below a threshold you specify. For example:

    while True:
      if ps.measured_volts < 5:
        ALL_LEDS = [Leds.LEFT, Leds.RIGHT]
        for l in ALL_LEDS:
          Leds.set_color(l, Leds.RED)
        Sound.play("Feed me. Feed me. Feed me.")

    Read more about the available methods in the ev3dev documentation.