HC-SR04 Sonar Rangefinder to Pixhark

Tf mini is unidirectional and when you will set the parameters in avoidance under MP you will see you will not have a reading.
As previously said only one can be use as landing sensor and as altimeter, if you need a full 360 degrees obstacle avoidance you must look for and advanced obstacle avoidance

How should I set it when using it as an altimeter?

https://ardupilot.org/copter/docs/common-rangefinder-landingpage.html

how i can connect ultra sonic sensor directly to pixhawk ?

personally i don’t suggest the Hcrs04 sensor, coz its really limited in reading due the cone.
Btw it’s spi or i2c…

I don’t think the TF-Mini S works with Pixhawk. It’s the TF-Mini Plus that does. I have an S model and it doesn’t work.