Airspeed Sensor with Navio2

So, I’ve got an analog airspeed sensor hooked up to Channel 4 of the Navio2 ADC, and I can see voltage in the C++ code example that seems to respond correctly to increasing pressure (using the very scientific method of blowing on the probe).

Only, nothing I try seems to result in an airspeed reading for APM. 0 airspeed.

I’ve scouted the logs and no reading is being stored for Airspeed or airspeed sensor voltage.

The only thing I can think of at the moment is that, in order to get the sonar ranger working I had to specifically de-select ‘radiometric’ - there’s not a similar parameter for airspeed, but looking at the code (due warning: C++ is new to me) it looks like the airspeed code is attempting to take a radiometric reading.

Truth is, I’m at a loss for the time being - anyone got any knowledge they can dump on me to get this working?

It seems like something does not work properly with passing the ADC sensor values to the APM, apart from the power module readings. We have an issue ticket about that and hopefully devs will look into it soon.

Thanks Igor,

For clarity, the sonar ranger seems to work just fine on either channel 4 or 5 - it’s just an airspeed issue.

Maybe I should compare the code driving each and see if there’s an obvious difference. But as I said, C++ isn’t exactly my kung-fu!

We’ll see

Not sure if this is related but log outputs

/sys/kernel/rcio/adc/ch65 not opened: No such file or directory

CH65 seems to be Airspeed channel by default (at least its in the example):

So i guess the airspeed channel is not mapped correctly or initialized correctly for navio2 target. In /sys/kernel/rcio/adc/ only ch0…ch5 exist.

Did some more digging… NAVIO2 is compiled with “HAL_BOARD_LINUX” and in Airspeed code this is defined:

#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX #define ARSPD_DEFAULT_PIN AP_AIRSPEED_I2C_PIN #else

Linux seems to try to use the I2C sensor pin as default pin, which BTW has the Pin Number 65:

Pin can be changed with this parameter:

Maybe that will help you.

Just compiled ArduPlane with Pin 4 instead of 65 and the error with CH65 does not appear anymore. So it all seems to be related to the Airspeed Pin setting. Check your logfile, maybe you have the same problem.

I created a pull request to change the default pin to 4 on navio2 boards as 65/i2c does not seem to work:

2 Likes

Thanks for the report! Added to our issue tracker.

1 Like

The 6x pins are virtual pins that indicate an I2C address. the ARSPD_PIN parameter successfully overwrites this.

After further investigation I’m actually getting an ‘Airspeed sensor unhealthy’ through MAVlink - I traced the error to the Airspeed library:

suggesting that the creation of the analog source isn’t behaving properly?

M

Thanks for your work, @Rangarid - I’ll try setting the default pin and recompiling as you have and report back!

I think setting the right pin with Mission Planner should do the trick, no need for recompiling. Try that first ;). the pin def just means its the default pin, but it can be changed. I dont have the navio2 here right now, so i can not test it, thats why i recompiled it to see if the error disappears from the log.

Gotcha. I have definitely got the correct pin set in mission planner (using pin 5), and the sonar ranger (also analog) when connected and set to that pin works flawlessly. Hence my thoughts on it being a problem with the Airspeed backend - something which looks to be consistent with the logged ‘Airspeed sensor unhealthy’ error.

Further to this, I decided to test my actual sensor to eliminate it as the cause of the fault. Using emlid’s navio2 c++ code examples, the ADC channel displays a voltage which increases when I force air over my airspeed sensor.

So the problem really is somewhere in the ardupilot code. I shall continue to dig, Thankyou all for your help and wisdom so far :smiley:

My board just arrived today, will check if i have the same problem once i set everything up.

Awesome, thanks!

Airspeed really seems to have an issue. Even when you set pin 0/1/2 (voltage or current or 5v rail) as airspeed pin the reading is 0. Will check if i can find out whats the problem…

I’ve just dug out and compiled the Airspeed Example code
in ardupilot/libraries/AP_Airspeed/Examples/Airspeed)

The pin in hard-coded to 65 in the example code, so I changed this to 5 (ie: what my airspeed sensor is attached to) and compiled (make navio2)

Compiling produces a lot of errors (nearly all APM_BOARD_TYPE related) but the code example still works as far as I can tell, and the compilation completes.

I then ran the Airspeed.elf image that resulted.

Running Airspeed.elf resulted in:
Raspberry Pi 2 with BCM2709! ArduPilot Airspeed library test /sys/kernel/rcio/adc/ch65 not opened: No such file or directory

Suggesting that the Pin wasn’t being set properly regardless.
So I went and changed the default pin for HAL_BOARD_LINUX as you have suggested, and then recompiled.

Running Airspeed.elf resulted in:

Raspberry Pi 2 with BCM2709! ArduPilot Airspeed library test airspeed 0.01 healthy=1 airspeed 0.02 healthy=1 airspeed 0.02 healthy=1

Which looks like a working sensor - ish! I can’t run further tests until I can get to my plane to blow air over the sensor (I’m currently ssh-ing in from a hotel!)

My modified code can be found in my fork of the emlid ardupilot repo:

@Mikebert4 @Rangarid

Guys, thanks for your report and digging into code. The fix has been merged.

Awesome, thanks!

Is there a preferred airspeed sensor to use with the Navio2 board?

Also any instructions on overall connections etc… would be much appreciated. Thanks in advanced

Hi,
I am using Navio2 board and MS4525DO airspeed sensor on the I2C on DF13 ports. i have seen this discussion

As far as i know Raspberry pins are directly connected to Navio2 DF13 I2C pins. Airspeed sensor specs states that both 3.3V and 5V operation is possible. But there is 5V supply voltage on I2C port and logic levels are 3.3V. Do you think it is a problem? Do i need to supply MS4525DO with 3.3V instead of 5V for regular operation?

Thanks

I quickly looked at the datasheet and couldn’t find any info about how the supply voltage is affecting the voltage level of the digital i/o pins. Probably it is equal, so it’s better to supply the sensor with 3.3V.

Hi Mikhail,
Yes there is no info about the voltage levels on sensor datasheet. I think its better to supply sensor with 3.3, i will report if i get unexpected results. Thanks for the answer