0 votes
in ESPaper by (300 points)
edited by

Hi,

I added the "battery Icon" to my 4.2" ESPaper Plus Kit but it just shows "empty", which i don't think is the case.

Serial Monitor shows: X-ESPAPER-BATTERY: 1024
When double-clicking on the Icon, I see some context (but I can not copy it with FireFox). it says something like: <#if (Device.BatteryPercentage < 5) ...

Do I need to change something there?

And are there already pre-set Icons for Battery Percentage as Text, Battery Voltage as Text, and WiFi RSSI as Icon and or Text? As they showed up in the 2.9"ESPaper Header, which did at that time not have the WebScreen Editor.



Best Regards

Sergio





1 Answer

0 votes
by (19.9k points)

The battery percentage is a field available on the device object. Hence, it can be accessed in the GUI editor like so

${Device.batteryPercentage}%

The algorithm to derive percentage from the raw value read from the ADC produces an approximation that takes into account a number of additional attributes (one of which being the device type). If the device is not battery-powered (i.e. by USB or USB-to-Serial instead) the algorithm reports 0 as the system can't know for sure what the effective value is.

The battery symbol uses the following condition stack based on the percentage (it's all Freemarker):

<#if (Device.batteryPercentage < 5)>
${"\xf244"}
<#elseif (Device.batteryPercentage < 50)>
${"\xf243"}
<#elseif (Device.batteryPercentage < 75)>
${"\xf242"}
<#elseif (Device.batteryPercentage < 95)>
${"\xf241"}
<#else>
${"\xf240"}
</#if>

The effective symbol is a unicode character code referencing a character in the selected font "Font Awesome". If you add an icon to your screen (the smily button) and type "bat" you'll see the available ones.

by (19.9k points)
From OP: "But none the less, and although my device is running of it's battery it just shows an empty battery icon, and so does  ${Device.batteryPercentage}% show "0%"
Where is the mapping between "battery value" (1024.0 in my case) and percentage made?"
by (19.9k points)
@sergios I removed your synthetic answer and added its images to your original description, sorry.

The mapping is what our algorithm on the server does.

It factors in historical battery values (the ones you see on the statistics graph) to produce results as precise as possible. It appears there might be a bug for the very first run if the battery is fully charged and the device is NOT running on an external power source. I remember a discussion at ThingPulse a couple of months back but I forgot the details.

I'll add this to our backlog. Thank you for reporting this behavior.

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...