# BatteryInfo message

**URL:** <https://forum.opencyphal.org/t/batteryinfo-message/977>\
**Category:** Applications & Usage\
**Created:** [November 2, 2020, 8:00am UTC](https://forum.opencyphal.org/t/batteryinfo-message/977 "2020-11-02T08:00:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [November 3, 2020, 9:06pm UTC](https://forum.opencyphal.org/t/batteryinfo-message/977/5 "2020-11-03T21:06:13Z")

</div>

> [@kishore](#):
>
> First, is the equivalent of a power brick and hence should provide a minimum of current voltage and current. Charge (mah or watt) can be a optional additional parameter.

Charge is an integral of current over time; common units are coulomb or ampere-hour (not watt, that is a unit of power). I don’t know what your business requirements are, but in case it is related to endurance estimation, you should be aware that contrary to a common misconception, electric charge alone may not be an accurate representation of the amount of energy (integral of power over time) that can be reclaimed from the battery. Perhaps what you are looking for is [`reg.drone.phy.electricity.Source`](https://github.com/UAVCAN/public_regulated_data_types/blob/master/reg/drone/phy/electricity/Source.0.1.uavcan) — this type is the correct choice as far as the physics is concerned. If my guess about your application was incorrect, then please ignore this remark.

> [@kishore](#):
>
> Second, is a BMS which should provide the additional information of battery % (or absolute values)

The smart battery service is specified in [`reg.drone.srv.battery`](https://github.com/UAVCAN/public_regulated_data_types/blob/acc9ef0f9e54f220712f21f0cea8123986b94def/reg/drone/srv/battery/_.0.1.uavcan).

> [@kishore](#):
>
> What should be the sign of the value for current in each product?

Negative when discharging, positive when charging. This is specified in reg.drone.phy.electricity.Power/Source.

> [@kishore](#):
>
> What should be the subject id? I suspect, it should be negotiated. I dont yet fully understand how the negotiation works. A timing / sequence diagram with the messages involved would be helpful.

It can be arbitrary, chosen at the time of integration when the device is connected to the vehicle. The device is supposed to have configuration parameters that are assigned by the integrator or the end user once and then stored in the non-volatile memory. The UAVCAN Guide might also be helpful here; additionally, you may have a look at [Choosing Message and Service IDs](https://forum.opencyphal.org/t/choosing-message-and-service-ids/889).

> [@kishore](#):
>
> Since, I’m new to the DSDL and the .uavcan file format would this be the format for [Power.0.1.uavcan](https://github.com/UAVCAN/public_regulated_data_types/blob/master/reg/drone/phy/electricity/Power.0.1.uavcan)

Yes and no. Yes because serialization-wise you will get the correct representation on the wire. No because your example omits valuable type information from the nested types; you can see that they are not primitives:

> <https://github.com/OpenCyphal/public_regulated_data_types/blob/acc9ef0f9e54f220712f21f0cea8123986b94def/reg/drone/phy/electricity/Power.0.1.uavcan#L7-L8>

If you look up their definitions, you will see that they specify the unit of measurement, eliminating the risk of accidental misuse:

> <https://github.com/OpenCyphal/public_regulated_data_types/blob/acc9ef0f9e54f220712f21f0cea8123986b94def/uavcan/si/unit/electric_current/Scalar.1.0.uavcan#L1-L2>

> <https://github.com/OpenCyphal/public_regulated_data_types/blob/acc9ef0f9e54f220712f21f0cea8123986b94def/uavcan/si/unit/voltage/Scalar.1.0.uavcan#L1-L2>

We are currently working on an automatic code generation tool for this, by the way. ETA next week, you can follow the progress by subscribing to [GitHub - OpenCyphal/nunavut: Generate code from DSDL using PyDSDL and Jinja2](https://github.com/UAVCAN/nunavut).

Hope this helps!

---

_[View the full topic](https://forum.opencyphal.org/t/batteryinfo-message/977)._
