Start-up Voltage Spikes on Digital Pins - Problem for Relay

Hey everyone,

For my project I have a couple of digital out pins connected to a couple of solid state relays. However, when arduino first powers up I find that these digital pins have can small voltage spikes which activate the relay circuit momentarily, even with pull down resistors connected there. I need the digital pins to stay low until they are switched to high.

Is there another way to deal with this stray voltage so it doesn't trip the relay?

Make the output pins LOW before you use pinMode( ).

Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.

Default pin mode is Input with a pullup resistor, so try making your pulldown resistor smaller say 2K. corrected by @Paul_B

Other then that you can use a buffer driver with an enable pin that holds the chip disabled until you get your I/O in the correct state.
e.g. https://www.digikey.com.au/product-detail/en/texas-instruments/SN74LV125AN/296-34037-5-ND/1594902

What about using a NOT gate or just a PNP transistor in front of the digital out combined with a pull-up from the main 5V? That way the relay would only be activated if the digital out was active low. Would a digital pin momentarily go active low during start up and I have the same issue, or is this a solution?

Couldn't your simply rewire the SSR so the output has to be low for the SSR to be ON.

1 Like

As far as I'm aware the pins can't sink too much current, I need to run around 6ma through the relay in order to activate it.

You would have to specify what processor you are using for us to comment.

Nonsense! :face_with_raised_eyebrow:

Default pinMode is INPUT, not INPUT_PULLUP.

Unless you do write the output HIGH.

Something is clearly wrong with the invisible code or invisible wiring here.

Hi,
Can you please post picture(s) of you project so we can see your component layout?
Can you please post a circuit diagram including power supplies and pin labels?
Can you please post a link to data/specs of your SSR?

What model Arduino are you using?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

A common problem with "normally HIGH" opto relays, but never heard of that with solid state relays.

Connecting the opto of the SSR between VCC and pin instead of pin and ground, with pin set to INPUT_PULLUP before setting pin to OUTPUT could be a solution, but that shouldn't be needed.

Give us all the details.
Links, wiring diagram, pictures, code.
Leo..

Opps you are correct. I will just delete that part of the post

The is the text from the ATmega48PA/88PA/168PA/328P documentation

"Switching Between Input and Output
When switching between tri-state ({DDxn, PORTxn} = 0b00) and output high ({DDxn, PORTxn}= 0b11), an intermediate state with either pull-up enabled {DDxn, PORTxn} = 0b01) or output low ({DDxn, PORTxn} = 0b10) must occur. Normally, the pull-up enabled state is fully accept-able, as a high-impedance environment will not notice the difference between a strong high driver and a pull-up. If this is not the case, the PUD bit in the MCUCR Register can be set to dis-able all pull-ups in all ports.
Switching between input with pull-up and output low generates the same problem. The usermust use either the tri-state ({DDxn, PORTxn} = 0b00) or the output high state ({DDxn, PORTxn}= 0b11) as an intermediate step."

But that still suggest that if you start with mode INPUT and then choose mode OUTPUT it should just go the LOW output state.
Does your code set mode INPUT_PULLUP earlier on in which case you will get a high spike between mode OUTPUT and digitalWrite LOW

The secret code! :astonished:

Hi .
try this way:

void setup()
{
digitalWrite(x,LOW);
pinMode(x,OUTPUT);
.......
..............
}

RV mineirin

While we are at it. Exactly what board are you using?
ESP32 has a number of pins that output a PWM signal during startup.