Ground a 5V input

Hi,

I'm testing a sketch with an Arduino and a relay board.

Relay:

The relayboard is self powered by a 12V power supply.
It has 5V, GND and controller pins.
By default a controller pin is 5V.

If I wire a controller pin to the relayboard ground, it switchs.

+Arduino:

Now, I wire:

  • the Arduino ground to the relay board ground
  • a relayboard controller pin to an Arduino digital pin
    My Arduino code is like:
digitalWrite(pinId, isActive? HIGH : LOW)

Even if my Arduino pin is HIGH or LOW, the relayboard controller is not (perfectly) grounded: there is no switch.

Alternatives:

If I plug the Arduino ground to the relayboard controller pin (both grounds are connected): it works
If I unlink both grounds, and I plus the Arduino ground to the relayboard controller, it does not work.

No change:

If I use another Arduino board, I have the same results.
If I power the Arduino from the relayboard or USB, I have the same result (it could have change the ground?)

Conclusion I'm not sure if I can create a ground contact with:

digitalWrite(pinId, LOW)

Can you help me?

I thank you by advance

I'm testing a sketch with an Arduino and a relay board.

What relay board, please supply a link.

Please supply a schematic drawing of how you have wired this up. ( not a Frtizing pile of crap ) just draw it and post a photograph.

Please read this:-
How to use this forum
It tells you what you need to supply when asking a question here.

digitalWrite(pinId, isActive? HIGH : LOW)

That could work but we have no idea what isActive evaluates to...

Conclusion I'm not sure if I can create a ground contact with:

digitalWrite(pinId, LOW)

A digital low is approximately 0V which is approximately ground potential but it's not exactly a "ground connection" because it can't handle the same current as a direct ground connection.

A digital high is approximately 5V, but again it's not a "power supply".

So yes, assuming your relay board is wired correctly, assuming it's working, and assuming it's compatible with the Arduino, switching between high and low should switch the relay.

Sorry,

Just a software issue. I missed to pinMode OUTPUT...

Never mind.

I am sorry for the inconvenience.

So you did...

pinMode(relayPin, INPUT_PULLUP); // first set the pin HIGH
pinMode(relayPin, OUTPUT); // before setting the pin to OUTPUT

to stop possible involuntary relay activation (relay chatter) during bootup.

You learn more if you post questions according to the forum guidelines.
Leo..