API for reading battery status

Discussions about quadcopters/multi-rotors
Post Reply
cgpenguin
Member
Posts: 35
Joined: Wed Aug 05, 2020 3:49 pm

API for reading battery status

Post by cgpenguin »

Hey!
I would like to know what would I need to put in a Python script to get the current battery status of a drone. Thank you!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: API for reading battery status

Post by arnaud »

The battery status is expose as log variables in the "pm? log group.

- pm.batteryLevel is the battery level from 0 to 100
- pm.state indicates if the battery is charging or discharging
- pm.vbat is the battery voltage in volts

There is examples in the python lib project that shows how to read log variables from a python script.

Most information about the Crazyflie are available as log variables. You can see all of the existing log variables in the client "LogTOC" tab. You can also plot the variables in the plotter in order to see the real time values.
Post Reply