🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    My Tab5 Extended GPIO and Power management library.

    Micropython
    2
    2
    322
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • easytargetE
      easytarget
      last edited by

      Hi all;

      This is something I've been working on; a easy way of taking control of the Tab5's power management circuitry from vanilla MicroPython; without needing a special board build.

      https://codeberg.org/easytarget/tab5-egpio-micropython

      The README there has the full install and usage notes; plus a list of the (30!) methods it provides. This is deigned to be very simple in use; it is self-contained and lets you:

      • Control power on/off for the WiFi chip, Speaker Amplifier, USB-A port and Expansion port 5V power.
      • Switch WiFi between internal and external antennas
      • Enable and disable battery charging, set the quick charge status, read the charge indicator pin.
      • Read the battery voltage and current in/out.
      • Detect if headphones are plugged in.
      • Set LCD backlight brightness
      • Trigger a poweroff event.
      • Send reset signals to the LCD, TouchPanel and Camera modules.

      Use it to create a power control object and set the device up as you need:

      from tab5_egpio import TAB5_EGPIO
      
      tab5pwr = TAB5_EGPIO()
      tab5pwr.wlan_pwr_on()
      tab5pwr.charge_enable()
      
      # later (let the charge controller settle first)
      voltage, current = tab5pwr.battery_status()
      print('Battery: {:.2f}V @ {:.3f}A'.format(voltage, current))
      

      There are some demo's in the repo that show how to use this in more detail. And I have a page where I am documenting general hardware related Tab5 micropython information at: https://codeberg.org/easytarget/m5-tab5-micropython

      [note: I'm cross-posting this here from the micropython official discussions, since it is specific to the Tab5]

      felmueF 1 Reply Last reply Reply Quote 1
      • felmueF
        felmue @easytarget
        last edited by

        Hello @easytarget

        for me your current implementation to turn off M5Tab5 actually only does a reset.

        The power off pulse needs to pulse to turn off M5Tab5. See here.

        I modified poweroff_now function in your library like below:

        def poweroff_now(self):
                """Instant full power off. Be sure you want to use this!"""
        #        self._e2.set_output(_PWROFF_PULSE_PIN, HIGH)
                for x in range(10):
                    self._e2.set_output(_PWROFF_PULSE_PIN, LOW)
                    sleep(0.05)
                    self._e2.set_output(_PWROFF_PULSE_PIN, HIGH)
                    sleep(0.05)
        

        and now my M5Tab5 turns off.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • First post
          Last post