# Sensors

PX4-based systems use sensors to determine vehicle state (needed for stabilization and to enable autonomous control). The vehicle states include: position/altitude, heading, speed, airspeed, orientation (attitude), rates of rotation in different directions, battery level, etc.

The system _minimally requires_ a gyroscope, accelerometer, magnetometer (compass) and barometer. A GPS or other positioning system is needed to enable all automatic [modes](../flight_modes#categories), and some assisted modes. Fixed wing and VTOL-vehicles should additionally include an airspeed sensor (very highly recommended).

The minimal set of sensors is incorporated into [Pixhawk Series](../drone_parts/flight_controller/pixhawk_series) flight controllers (and may also be in other controller platforms). Additional/external sensors can be attached to the controller.

Below we describe some of the sensors. At the end there are links to information about [sensor wiring](#wiring).

## GPS & Compass

PX4 supports a number of Global Navigation Satellite System (GNSS) receivers and compasses (magnetometers). It also supports Real Time Kinematic (RTK) GPS Receivers, which extend GPS systems to centimetre-level precision.

We recommend the use of an external "combined" compass/GPS module mounted as far away from the motor/ESC power supply lines as possible - typically on a pedestal or wing (for fixed-wing).

![GPS + Compass](https://4155462212-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LArEa7z2SPawfl3HpCD%2Fuploads%2Fgit-blob-efc6fdc4496b5764284a23363827b6f70a167e2d%2Fgps_compass.jpg?alt=media)

GPS/compass hardware options are listed in:

* [GPS/Compass](../drone_parts/peripherals/gps_compass)
* [RTK GPS](../drone_parts/peripherals/rtk_gps)

:::note [Pixhawk-series](../drone_parts/flight_controller/pixhawk_series) controllers include an _internal_ compass. This _may_ be useful on larger vehicles (e.g. VTOL) where it is possible to reduce electromagnetic interference by mounting the Pixhawk a long way from power supply lines. On small vehicles an external compass is almost always required. :::

## Airspeed

Airspeed sensors are _highly recommended_ for fixed-wing and VTOL frames.

They are so important because the autopilot does not have other means to detect stall. For fixed-wing flight it is the airspeed that guarantees lift not ground speed!

![Digital airspeed sensor](https://4155462212-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LArEa7z2SPawfl3HpCD%2Fuploads%2Fgit-blob-cf552e2a1532e9d6951b0fc617541c9819fd3fb1%2Fdigital_airspeed_sensor.jpg?alt=media)

For more information and recommended hardware see: [Airspeed Sensors](../drone_parts/peripherals/airspeed).

## Tachometer

Tachometers ([revolution-counter sensors](https://en.wikipedia.org/wiki/Tachometer#In_automobiles,_trucks,_tractors_and_aircraft)) are _highly recommended_ for rotor-wing frames because they allow the autopilot to detect stall or another rotor failure (for rotor-wing flight it is the rotation of blades that guarantees lift not airspeed or ground speed).

![Digital RPM Sensor - TFRPM01A](https://4155462212-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LArEa7z2SPawfl3HpCD%2Fuploads%2Fgit-blob-5c9aa8a0346046a9965f660cdab902b58bf0c69f%2Ftfrpm01_electronics.jpg?alt=media)

For more information and recommended hardware see: [Sensors > Tachometers](../drone_parts/peripherals/tachometers).

## Distance

Distance sensors are used for precision landing, object avoidance and terrain following.

PX4 supports many affordable distance sensors, using different technologies, and supporting different ranges and features. For more information see: [Distance Sensors](../drone_parts/peripherals/rangefinders).

![](https://4155462212-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LArEa7z2SPawfl3HpCD%2Fuploads%2Fgit-blob-b9f918607db4ed22e97de42102f38b0b477d6bc4%2Flidar_lite_1.png?alt=media)

## Optical Flow

[Optical Flow sensors](../drone_parts/peripherals/optical_flow) use a downward facing camera and a downward facing distance sensor for velocity estimation. PX4 blends the sensor output with information from other position sources (e.g. GPS) to provide a more accurate position lock. This sensor can be used indoors, when no GPS signal is available.

![Image of ARK Flow optical flow sensor](https://4155462212-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LArEa7z2SPawfl3HpCD%2Fuploads%2Fgit-blob-30fc2093871019a7abac7aee161a417f2bf72740%2Fark_flow.jpg?alt=media)

## Sensor Wiring

Sensor wiring information is usually provided in manufacturer documentation for flight controllers and the sensors themselves.

In addition, see:

* [Basic Assembly](../assembly) contains flight controller quick start guides. These cover wiring of the core sensors to specific flight controller hardware.
* [Flight Controller](../drone_parts/flight_controller) topics often contain wiring information.
* [Peripheral Hardware](../drone_parts/peripherals) contains documentation for other sensors.
