PX4/Pixhawk compatible RPM sensor?

Hi all, I am looking for an RPM sensor that can be used with the pixhawk to measure prop speed(s) on a quadcopter. Does anyone know of one?

If no out of the box products exist, I was thinking of using a hall effect or optical sensor and an Arduino Trinket to make one that could communicate to the Pixhawk over I2C. Does this sound viable? I don’t have any experience writing sensor drivers for Pixhawk (or anything else), so could anyone point me to code that I could use as a jumping-off point?

Thanks in advance,

1 Like


It is absolutely viable. I did this last year using the Castle Creation Edge ESC which can be configured to output a pulsetrain proportional to motor RPM. This was then fed into an interupt pin on the Arduino and then transmitted to the autopilot via i2c. Reading the data on the autopilot is easy if you start from another i2c driver for reference, e.g. the lidar lite.
Essentially what you will have to do is turn of any filtering of the data and publish it to a topic as is done here.

Thanks, that’s great news! I’m trying to adapt the lidar code as you suggested, but I’m getting a compile error:

/home/user/src/Firmware/build_px4fmu-v3_default/src/systemcmds/topic_listener/topic_listener.cpp:78:29: fatal error: uORB/topics/rpm.h: No such file or directory

 #include <uORB/topics/rpm.h>

I see that the other files in uORB/topics say in the header, “/* Auto-generated by genmsg_cpp from file /home/user/src/Firmware/msg/[topic_name].msg */”

I’ve created a rpm.msg file at that location. Any idea what else could be missing?

Edit: what’s missing was adding it to the make file :rolling_eyes:

Okay, I’ve made some progress - PX4 code seems to compile and the Trinket is doing what it’s supposed to. One thing I’m confused about, how do I log the incoming data? I see here that you can create a file on the SD card with custom topics to log, but it replaces all the default logged topics. I still want to log all the default topics, just add this new sensor. Is there a more graceful way to do this?

Not sure if you consider it more graceful but you can add it here

Thanks! Yes, that seems easier than re-listing all the defaults in a new file.

OK, added that but still no sign of the data. Looking at the compile output, I see a line, “Built target drivers__<driver_name>” for all the standard drivers but not for mine–is there another make file or something that I need to add the driver to so that it compiles? I have one in the new driver’s folder (i.e. src/drivers/rpm/CMakeLists.txt) but that’s it.

@CarlOlsson, did you use the Arduino Wire library for the Arduino side of your project? I’ve got my driver to compile on the Pixhawk, but it doesn’t seem to recognize the Trinket board. The Trinket (3.3V version) is set up as a slave sender using this version of the Wire library. It communicates fine with another Arduino, but not with the Pixhawk.

I’m also using and I2C-based airspeed sensor with this Pixhawk, and to get it to work I had to download Mission Planner and set parameter ARSPD_PIN to 65. Is there a similar procedure to make the Pixhawk recognize other custom sensors? (Not exactly related, but where/how is the ARSPD_PIN parameter used? As far as I can see it exists nowhere in the PX4 codebase…)

Edit: Figured out part of my problem, I needed to add the start command for the driver to ROMFS/px4fmu_common/init.d/rc.sensors under the right “if” statement for my board. Now on to the next quandary–why is it always reporting 0 rpm…

Edit again: I was sending one byte from the Trinket and the Pixhawk code was still trying to read two. Works like a charm now!

1 Like

Need to bumb this topic … !!

Is it possible to measure the rpm of the propeller using a simple optical sensor which have just high and low states and use the pixhawk aux pins to read the pulses ? Can somebody shed some light into this.


There is a possibility to use I²C RPM sensor.

It takes more advantage than readout the aux pins. Because it does not need real-time readout of pulses at MCU pins. Therefore it could be used even for high rpm propellers without risk of aliasing.