Is there a way to read the battery's voltage directly from the cortex?

We want to read the battery’s status so we can make some variables depend on the voltage for there to be no loss of power on our launcher, we don’t know if this could actually work or if we would have to implement a PID controller.

Thanks.

You can read the value of the main cortex battery using the nAvgBatteryLevel system variable. This will return the battery voltage in mV, for example, a battery with a voltage of 7.2V will return a value of 7200 from the nAvgBatteryLevel function.