How to switch on/off leds using relay switch

Hello everybody,

I’m trying to switch on/off some leds using switch relay.

I need to turn a relay on or off based on the PWM value.

5v are provided to Aux ports using an external BEC which also performs the function of secondary power supply.

I’ve read this wiki page http://ardupilot.org/copter/docs/common-relay.html but after many attempts I have never succeded.

Anybody knows how to solve this issue?

Best regards

If you want to switch a separat circut you can use a PWM driven relay switch.
Something like this: https://hobbyking.com/en_us/turnigy-tx-controlled-relay-switch.html
Denis

Can I plug this device directly to Pixhawk AUX 5 or 6 and then switch on and off my separate circuit?

Yes, you can. The switch relay just needs a normal PWM signal.

Thanks Denis for your help, what’s the difference with this device? https://hobbyking.com/en_us/turnigy-receiver-controlled-switch-1.html

1 Like

That seems to be an electronical switch, no mechanical relay. From what I see.

In the device you suggest there are 2 output, this means that can switch on and off 2 separate circuit simultaneously?

No, its just one circuit. The black wire is short cut, the red wire is switched. Means, on one side you can hook a battery, on the other side something you want to switch.

Unless you need complete isolation, the HK switches @3Denis mentioned work great. I have over 20 of them for various projects and the are reliable, light weight and easy to use. I usually remove the existing wire and solder JST pigtails on them with a shared the ground.

The aircraft in this video uses three of the modules with 10W led/drivers for anti-collision lighting:

So if I have understood:

  1. the black socket will be plugged directly to AUX 5 on Pixhawk
  2. Pixhawk will provide 5 V to the device you suggested
  3. one pair of cables will be hocked to the battery
  4. the other pair of cables will close the circuit

Through RC I can send PWM input to switch on and off my device. Correct?

what if the circuit I want to switch on and off is completely isolated?

The two red wires are coming from the relay. They are closing the circuit. The black wire together with the two red plugs just provide you the possibility to directly plug a battery (on the one side) and a device like LEDs (on the other side). The battery is not for the switch itself but for the device you want to switch.
The black plug goes to the pixhawk, like a servo. PWM under 1500 = relay off, PWM over 1500 = relay on.

The circuit is, as I think, completely isolated, due to the mechanical relay.

Hi,

I have further questions and points that need to be clarified, Hope you can help.

let’s assume that I’m not using a BEC, after booting pixhawk I thought to find 3.3 v on each of the AUX ports. Especially from AUX 1 to AUX 6. This does not happen.

  1. Do you know why?

In order to have voltage I’m using an UBEC which provides a constant 5 V.
Ok , this is cool because can provide a secondary power supply system and it can also be used to trigger a camera. Just perfect!

Now I need to use the AUX 6 as a relay switch, I have understood that I need the device you pointed out, but reading the wiki page about relay switch it states tha voltage based on PWM values should vary between 5V and 0V.

I have tried many times but voltage remains constant.
Have I figured the wiki page out badly?
Do you have any advices?

Bests

What kind of device do you want to switch?

so far I just need to switch on and off this separated circuit with two leds. Actually this is just the beginning for a more complex task which involves the use of a sensor thought for collecting air samples.

Do you have answers for the doubts I have raised in the previous reply?

Bests

I think you’ll need to check and set this parameter and reboot:
BRD_PWM_COUNT 1 or more, up to 6
Connectors AUX1 to AUX4 will be a PWM output and the other AUX outputs will be relay outputs or potentially inputs, but that’s another story. By default AUX5 and AUX6 are relay outputs and NOT what you want if using the PWM-operated switch.
http://ardupilot.org/copter/docs/common-relay.html
The easiest thing to do is connect your PWM-operated switch into AUX1, and set SERVO_9 parameters accordingly, for example:
SERVO9_FUNCTION 58 (RCIN 8) and set you transmitter switch for Channel 8 to operate the LEDs.
Or SERVO9_FUNCTION 30 for Armed/Disarmed indication.
http://ardupilot.org/copter/docs/common-rcoutput-mapping.html
You can also use DO_SET_SERVO in missions.

If you really must use AUX6, then set BRD_PWM_COUNT 6 (and SERVO_14 accordingly)

The alternative is just use one of the MAIN outputs for you PWM switch and SERVO_x assuming you’ve got spare main outputs.

Dears,

I have received the PWM driven relay switch, the one that has been mentioned before on this post: https://hobbyking.com/en_us/turnigy-tx-controlled-relay-switch.html

This what I have done so far:

  • plugged the black socket to pixhawk AUX6

  • assigned channel 7 for relay control

  • RELAY_DEFAULT=0

After rebooting drone, the led is off, if I active CH7 the led turns on, if I still change CH7 the led never turn off.

why It doesn’t go off? Should I set PWM properly?
I would like to use CH9 on my Taranis…do you have any advice?

Try setting your AUX6 output to Servo.