How to calculate altitude from pressure/temperature?

I’m able to get readings for pressure and temperature from the barometer, but cannot figure out how to calculate the altitude. I’ve looked through the code and there doesn’t seem to be a built-in API for retrieving altitude.

Hi Victor,

Are you using Ardupilot or ROS?

@dmitriy.ershov

I’m using Ardupilot

Hi @victorzyin,

Navio2 examples show measured values from sensors. Altitude is a calculated value. It’s usually displayed in the Ground control station.

I can hardly provide you with a ready solution, however, you can write your own script that calculates the altitude value. I believe the ArduPilot source code will be of great help here.