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

    M5Paper v1.1: Detect charging state and progress

    PRODUCTS
    3
    3
    3.9k
    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.
    • M
      MauriceX111
      last edited by

      I have an M5 Paper v1.1 with ESP32 and it works very nice. I program it in C++ using the Arduino IDE. How can I detect detect whether the device is charging and how can I measure how far the battery is charged? I cannot find that in the documentation.

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by felmue

        Hello @MauriceX111

        the M5Paper uses an SLM6635 to handle the battery. Unfortunately this IC has no control lines (like I2C) so it cannot be queried about the battery state. It does have two pins which indicate charging and full charge, but both pins are not connected / used in M5Paper.

        All there is, is the battery (through a voltage divider) is connected to GPIO35 of the ESP32.

        Thanks
        Felix

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

        1 Reply Last reply Reply Quote 0
        • H
          Hamnet
          last edited by

          Hi @MauriceX111 I've also just got an M5 Paper v1.1 (my first experience of M5 or ESP32) and it is a very nice product but I'm also struggling to find out things... Very grateful that this community - and especially @felmue - are here, otherwise I'd be completely stuck!

          Felix pointed me at the code that the device ships with.

          Searching this, I found here the following code

              // Battery
              _bar->setTextDatum(CR_DATUM);
              _bar->pushImage(498, 8, 32, 32, ImageResource_status_bar_battery_32x32);
              uint32_t vol = M5.getBatteryVoltage();
          
              if (vol < 3300) {
                  vol = 3300;
              } else if (vol > 4350) {
                  vol = 4350;
              }
              float battery = (float)(vol - 3300) / (float)(4350 - 3300);
              if (battery <= 0.01) {
                  battery = 0.01;
              }
              if (battery > 1) {
                  battery = 1;
              }
              uint8_t px = battery * 25;
              sprintf(buf, "%d%%", (int)(battery * 100));
              // _bar->drawString(buf, 498 - 10, 27);
              _bar->fillRect(498 + 3, 8 + 10, px, 13, 15);
          

          So that doesn't help with finding out whether the battery is charging; but it does seem to be the best available way to represent the charge level.

          HTH.

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