Pixhawk AUX OUT Pins need a serious explanation!

I have been labouring through a lot of code to understand the Pixhawk AUX OUT Pins.

I have written several tests to turn them ON & OFF and not much makes sense.
Pins 5 & 6 ( Virtual 54 & 55 ) react very oddly despite how I set the parameters for Virtual pin numbers and the maximum number of PWM pins set. I am using 0.

By addressing pin 6 and using the relay.on(6) function and relay.off(6) I can get some results noted by a voltmeter reading 0 or 3.29 volts.
Pins 50 through 53 do not react ever.

So I would appreciate it ( and so would a number of other folks ) if a Developer would jump in here and explain what is going on!

I was just playing with this.

I set the number of BRD_PWM_COUNT to 0 and restarted the board.
From there I set the relay pin to each number 50 - 55 and it works just fine.
I have channel 8 set to the relay pin and changing it causes the pin to go from .296 to 3.39.


Maybe your getting confused as to Relay number and Aux Pins.

RELAY_PIN - is the first relay or (0).
RELAY_PIN2 - is the second relay or (1).

So you need to set what Aux pin you want the relay to enable. There are only two relays.
You were thinking you could use all 6 Aux pins at once like a 6 shooter. That would be way too easy.


Thanks very much for your notes. I have a few questions.

I am using BRD_PWM_COUNT = 0.

In one note you said “From there I set the relay pin to each number 50 - 55”.
Where did you do this? In Mission Planner, I can see a place to set only 4:

In the other note, you said " there are only 2 relays". Did you mean that only 2 AUX OUT pins can control relays?
I got the feeling that if I set BRD_PWM_COUNT to 0, then I could use all 6 AUX OUT pins for relays.

You said “I have channel 8 set to the relay pin”. How/where did you set this up and which pin did you use?

Also, I am not using an RC channel from my Spektrum radio to do any on this. I am writing c/c++ code within the Pixhawk to do this stuff. If you have working code in that area, I would be very interested.


Ok, you’ve add a layer of complexity.
You say you are using C code to do the relay. Is that Firmware code or Mavlink code.

From your example you were sending Mavlink codes to the Pixhawk to control the relay pins.

Mavlink is not specific to Pixhawk and only supports 2 relay pins. (0 and 1).

I am using a radio to turn a pin on and off which works the same way with Mavlink code and works just fine.

Don’t know your environment at this point.


Looking at some of your previous posts I see you are deep into the code. While I can code I am not a Pixhawk coder.

From the outside the Radio relay and Mavlink relay code works for two Aux pins.



I am building from the APMrover2 base code, strictly c/c++ stuff. While I do use MP (& Mavlink ) for mission planning, I am not using relays through the MP commands.

I guess I will have to dive into the fundamental I/O code to see where this thing is going.

Is there anyone else doing c/c++ control of relay pins on a Pixhawk ???