Inkplate 4 TEMPERA battery API returns invalid values

Customer:

I’m experimenting with my Inkplate 4 TEMPERA. I’m trying to get battery information but I keep getting nonsensical values.

a) The Inkplate::readBattery method always returns a value of 0.284. It does that after 3 days of not charging, but also after a few hours of charging. The value never changes.

b) After calling Inkplate::battery.start I try to use some of the methods on the battery object:

  • Inkplate::battery.voltage and Inkplate::battery.current always return -NaN.
  • Inkplate::battery.capacity gives me a value of 1.778271 the first time it is read after booting the device, and 0 any time it’s read after the first time.
  • Inkplate::battery.power gives me 0.284 just like the readBattery method does.

Meanwhile all I really want to do is get a battery percentage level.

Originally submitted via email support on 4 June 2024. Migrated to the forum for community visibility.

Soldered Support:

The example you should use is in sensors → fuel gauge. This example will read the battery level using the fuel gauge peripheral. The readBattery method you mentioned uses a different approach, but the Inkplate 4 TEMPERA has a dedicated chip to do this job.

Customer:

I’m calling display.wakePeripheral and battery.begin() to init the gauge, and battery.setCapacity to set the max capacity, all during setup. I then use battery.soc() in the loop function to get the battery level. However, every time I compile a sketch and upload it to my Inkplate, the SOC starts back at 0 and slowly goes up (probably because it’s charging over the USB cable). I’m not quite sure why it starts at 0 every time.

Soldered Support:

You can use the peripheral exactly as you mentioned, waking it up only when you need to read the battery value. By default, the peripherals are in sleep, which is noted in the examples with the wakePeripheral function.

The fuel gauge IC does have a learning cycle. After re-uploading code, as it gets re-initialized, it will take some time to pass the learning cycle to get accurate readings. The best approach is to check the fuel gauge example and make sure you’re reading and initializing everything in the exact same way, then handle the time it takes to read the correct value in your own sketch. For example, if you’re reading each 30 seconds, only after 20 readings take the SOC%.

Customer:

I am experimenting with deep sleep now. The “click” when the device boots or comes back from deep sleep is a bit annoying though. I wake up from deep sleep every minute or so, meaning the device clicks once a minute. Is there any way to disable it if you don’t need to use the speaker/buzzer for any reason?

Soldered Support:

Place this in your src\boards\Inkplate4TEMPERA.cpp in the Inkplate library. This is a simple adjustment that disables the click—I can’t hear any click whatsoever now. Let me know how that works for you! We might add this to the actual library release because it makes sense.