Inkplate 10 detecting Wake button press and charging status in ESPHome

Customer:

I’ve set up my Inkplate 10 with ESPHome and want to implement two features:

  1. Detect when the physical Wake button is pressed so I can trigger screen updates or switch between dashboards. When I press the button nothing happens. Is there a GPIO connected to this button that I can use as a button sensor in ESPHome?

  2. Detect whether the battery is being charged. Is there a GPIO connected to the battery charger that I can read to determine charging status?

I haven’t found GPIO information for Inkplate 10 v2 on the website yet.

Originally submitted via the contact form on soldered.com on 21 October 2023. Migrated to the forum for community visibility.

Soldered Support:

The WAKE button is connected to GPIO_36 and has a hardware pull-up. Configure it as an INPUT - the button is pressed when the input is LOW. See the schematic for details.

For battery charging detection: The battery charges whenever Inkplate is plugged in via USB and discharges when unplugged. You can read the battery voltage using the readBattery function from the library:

For implementation details, see:

The V_BAT pin is GPIO 35. You’ll need to copy all the functionality to get a full correct reading.

Attachment omitted in migration: image.png

Attachment omitted in migration: image.png

Customer:

I’ve implemented the Wake button control based on the GPIO_36 information. For battery detection, I’ve already created a working sensor that reads battery voltage on GPIO 35:

sensor:
  - platform: adc
    id: battery_input
    update_interval: never
    attenuation: 11db
    pin: 35
  - platform: template
    id: battery_voltage
    name: "Battery Voltage"
    device_class: voltage
    lambda: |-
      id(battery_read_mosfet).turn_off();
      delay(1);
      float adc = id(battery_input).sample();
      id(battery_read_mosfet).turn_on();
      return adc;
    filters:
      - multiply: 2

pca6416a:
  - id: pca6416a_hub
    address: 0x20

switch:
  - platform: gpio
    id: battery_read_mosfet
    pin:
      pca6416a: pca6416a_hub
      number: 9
      inverted: true

The sensor reads values between 3.6V and 4.2V, but it can’t tell me whether the USB charger is connected or if the battery is charging. I need to implement different logic when USB is plugged in (for example, disable deep sleep mode) versus when running on battery only. Is there a way to detect via software whether the USB cable is plugged in or the battery is charging? I didn’t find such a function in the links provided.

Attachment omitted in migration: image.png

Attachment omitted in migration: image.png

Soldered Support:

There is no dedicated GPIO pin for this, but you can use the red charge LED indicator. Connect the MCP73831 STAT pin (Pin 1 of the charger) to a GPIO and read it - when it goes HIGH, Inkplate is charging. You can also get the input of the red charge LED and connect it to a GPIO to read its state.