Battery Widget

When I transfer the following data (batt,p=50) with the MQTT API to cayenne , a battery widget automatically appears, but the data is not displayed correctly. I found out that the display of the charge state in % is converted according to the following function: [displayed_value = -3.14… * given_value + 164,…].
In order to display the desired value of 50%, it is necessary to transmit (50.0-164) / - 3.14 = 36.3.

Is this intended or a bug of the widget


Hi @rau

I have to tell you, it looks like a bug to me. I expect the intent was to allow you to pass the battery level as a simple number and not have to do any conversion on it. I will write this up to get it fixed.

Hi @rsiegel

now it works as expected. Thank you for the quick help.

@rau, Do you know how can I capture the battery level connected to Raspberry Pi?


By default the Raspberry Pi does not have a battery management. So, at first you need a battery fuel gauge connected to your RasPi (e.g. over I2C). Here is an example of such a module: LiPo fuel gauge. In the next step you have to determine the charge level with your application via I2C and transfer it to cayenne.
You can use the MQTT-API to transfer the charge level to cayenne. Please read the following doc how to do it: Manually Publishing / Subscribing.

I definitely will check out that LiPo fuel gauge. The built in ESP VCC function seems to be pretty inaccurate…

Since the Raspi requires 5V power supply, you need the following device: PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A - 1000C to bring the LiPo voltage to 5V.

Install the LiPo fuel gauge between battery and PowerBoost module.

Woow, thanks you a lot for the provided information. The LIPO fuel gauge looks very good. Now I am using this board:

Lithium Board

to power the Raspberry Pi.

For LiPo batteries, you really need a coulomb counter like this LTC4150 Coulomb Counter Hookup Guide -, or the LiPo fuel gauge.

Very interesting technology.