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.
Are you using Ardupilot or ROS?
I’m using Ardupilot
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.