This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Relay doesnt work toggling GPIO Output? how can pull it down

Hi triying to drive a Relay with Output but have tried every functon in "nrf_gpio.h"

this works with a LED perfectly : nrf_gpio_pin_toggle(23);

in the main i configure :

nrf_gpio_cfg_output(23); nrf_gpio_pin_write(23, 0);

but the relay dont change state with Toggle, with STM32 i change the pullup, pulldown configuration and it works, i have to send a "0v" signal for the Relay to change state to off, and a voltage to go on.

how can output configuration be change in a output pin? thanks.

  • A relay. How much current does your relay coil need to operate, what voltage? The GPIOs on the nRF series are VERY current limited and work only to the voltage on the chip which may be 3.3v, they are not the monster 5-10mA outputs some of the STM and Atmel etc chips have.

    I wouldn't even think of considering driving a relay from an nRF chip without a transistor to drive it, and a reverse diode (flyback)

  • Hi it does not need any curent since is this module controlled by a transistor : i.stack.imgur.com/PwhHT.png

    it just need a pulldown output gpio, the chip actually turns it all the time on with the current, it needs 0v or ground in a pin to turn it down.

  • also claims to need a 5v battery. If you're hooking nRF chips up to 5v then bad things are going to happen. If you are hooking that relay module up to 3v3 it's impossible to say whether or not it will work.

    Either way those are the correct functions for turning a pin high and low so either you don't have enough voltage on the relay to activate it, or you don't have common ground, or you've blown up the GPIO

  • circuit its ok its on a ble400 board and its receiving energy from the Computer, do you know how to activate the pulldown resistor in a Output Pin?

  • Hello acidguy

    When a pin on the nRF51822 is configured as an output, setting it high will source current, and setting it low will sink current. The exception to this is if you specifically configure it to disconnect on either high or low. As long as you haven't done that, there is no need to use any additional pull-up or pull-downs.

    As RK mentioned driving a relay straight from a GPIO may not be the best idea. The GPIO are limited in how much current they can source/sink, as well as how large voltage they can withstand. See page 38 and 66 of the nrf51822 product specification for the absolute maximum ratings and the electrical specifications of the GPIO respectively.

    I found the datasheet for the relay in your picture. Its markings indicate that this relay has a nominal coil voltage of 12VDC, and a nominal coil current of 30mA. Both of these are far beyond what the nRF51 is capable of producing, and I would recommend you use a proper relay driving circuit.

    You mention it is already driven by a transistor, do you have a link to the specification of the specific module you are using?

    Best regards

    Jørn Frøysa

Related