Adding a new SPI sensor

Hello everyone,

I’m trying to understand how to add a new SPI sensor to my PX4 UAV running fmu-v5. Its an mpu9250, so all the drivers are already present. I just need to tell the system about the device and where to find it. I can then use it’s data in my (yet to be written) custom code.

I can’t find much information about adding a new SPI device. I think I just need to add a line to rc.board_sensors in /…/boards/px4/fmu-v5/init. E.g. For one of the internal IMU sensors the file states:

# Internal SPI bus ICM-20602
mpu6000 -R 8 -s -T 20602 start

I’m guessing I can do something similar for my IMU, but I can’t find the documentation that defines these switches. I assume they set things like the SPI bus number, CS, etc??

Grateful for any help. This feels like it should be simple, but I can’t find the information I need.


Hi there,

Have you seen the board config where the buses are defined?

However, I’m not sure if that’s required or if you just need to specify the bus using -b X?

Thanks for the suggestion Julian.

I should have defined my environment in the first post: fmu-v5 for PX4.

I added ‘mpu92500 -R 8 -S start’ to rc.board_sensors as that seems to be the file that controls sensor activation. (I don’t know if 8 for the rotation is correct, but don’t care right now. I just want to see data flowing.) I also added imu/mpu9250 to the DRIVERS section in multicopter.cmake to actually load the packaged driver for my sensor with the build.

There are still a few dots I’m trying to join up, like how do I know which SPI bus this device gets assigned too? The ‘-S’ is just a switch that says use the external SPI bus. Which one is that, 5 or 6?

I was kinda hoping I could just load the driver and add the start commend into the board_sensors file and boom. Nope! (sigh…)

Anyone have any pointers?

I see there are two external SPI buses:

I looked at the Pixhawk 4 resources everywhere and could not actually figure out which external SPI port is the one broken out through the connector and case.

@david_s5 do you know?

@JulianOes It is SPI5 EXTERNAL1

1 Like

Hi I am trying to add a new SPI airspeed sensor onto PX4, i dont have a driver for the same. Is there any documents i can refer for making driver for SPI air speed sensors.?
Thanks in advance