Passing 5VDC through Omron relay to Arduino Mega seems to keep input High all the time?

Hi there
I'm very new to electronics. I'm switching an Omron relay (12VDC) from a separate source and trying to send 5VDC through the contacts to alternate two arduino inputs on (i.e. relay = ON then switch one of my arduino inputs on and if relay is OFF then switch another of my arduino inputs on).

I've got 5VDC (same 5VDC that I'm using to power the Arduino Mega) that goes through the relay contacts N/O and N/C and on to two different arduino inputs.

I've set up the input pins in the software as "Pinmode(xx, INPUT)" and INPUT_PULLUP.

However, it doesn't seem to "switch" the input?

When I've belled out the relay - the "switched" contact has the +5VDC (as expected) but the other contact has +1.5VDC and I wondered if the Arduino will just see both of them as "High" ??

I'm presuming I need to do something with resistors across something or some setting in the software but thought it best to just ask for advice before I break something!

Thank you for your help.

(after a request - I've uploaded a quick sketch below)

The Omron relay I'm using is here:

Features

  1. Arc barrier equipped
  2. High dielectric strength (2,000 VAC)
  3. Long dependable service life assured by AgCdO contacts
  4. Choose models with single or bifurcated contacts, LED indicator, diode surge suppression, push-to-test button, or RC circuit
  5. All models meet UL and CSA approvals; VDE, LR, and SEV approved versions are available

CHARACTERISTICS

  1. Contact resistance : 50 mW max.
  2. Operate time : 25 ms max.
  3. Release time : 25 ms max.
  4. Operating frequency
    (1) Mechanically : 18,000 operations/hour
    (2) Under rated load : 1,800 operations/hour
  5. Insulation resistance : 100 MW min. (at 500 VDC)

A schematic would be of more help than your description. A picture of a hand drawn circuit is good enough

I would question the need to use 2 Arduino pins to detect the 2 states (on and off) because if the relay is on it is not off and vice versa. You could, therefore, detect the state of the relay with a single pin and deal with it in software

Hi Bob
Thanks for replying. I've uploaded a quick sketch to my post which hopefully shows what I'm trying to describe.

You're correct about not needing the two pins but, at this stage, I'm just learning things and so experimenting. But, it's a very good point for when I get my head around it more.

Thanks.

Please provide the link, specs or datasheet to the Omron relay

Using pinMode(xx, INPUT_PULLUP); causes the input to be pulled high when it is not connected, so it remains high whether the relay contacts are open or closed.

Use INPUT_PULLUP, but use the relay to connect each of the two inputs to GND instead of +5V.

1 Like

Thanks for adding the sketch

A minor point, but has the relay really got two sets of contacts or has it got a single contact that is switched between two outputs ?

Ahhh okay. That makes sense. I'll try that tomorrow and post back.

Thank you :slight_smile:

It's a single contact switched between two outputs. Apologies for the misleading drawing, I'm not very good at trying to illustrate things so it was just a "best effort" (and not a very good one!!) :smile:

Thanks

Hi there, I can maybe try and find this tomorrow. I'm in bed at the moment but can have a Google tomorrow and let you know.

Thanks for your help :smiley:

Your diagram shows only one Arduino. More clarification is needed.

One Arduino, two inputs to said Arduino. At least that’s what I got from the statement and the diagram.

1 Like

Yep, it's just poorly worded. There's just one arduino.

Perhaps should have written "switch one of the arduino inputs on"

Thanks

Hi @UKHeliBob

I've now updated my drawing. Hopefully it makes it clearer. I've also added details about the relay.

Thanks

@b707

I've updated my original post, as promised, with some more details now.

Thanks :slight_smile:

When the relay contact is open the input to the Arduino is 'floating' i.e. it is not defined. If you add a resistor, say 10k (value is not critical) to 0V then the input will be pulled to 0V and the Arduino will be able to read accordingly.

1 Like

Excellent - thank you for your help.

I'll do that. Much appreciated.

Even easier, use INPUT_PULLUP in pinMode() for both pins and wire the circuit so that the common relay contact is wired to GND so that it takes one or other pin LOW when connected to that contact. Detect the LOW state of the pin to indicate that the contact is connected to that pin

1 Like

@UKHeliBob thanks for that. That was also @JohnLincoln suggestion. And, it would certainly solve the problem but it's good to know "why" it doesn't work the way it is so I've marked Steve's answer as the solution in this case but thank you very much for all your help.

Have you got it working now ? If so, then please post your full sketch. Even without seeing it I suspect that it can be made shorter and/or smarter and you might learn something else, but we shall see

Hi Bob

Yep, I've got it working now. I did learn something else though... I'd fed the Arduino with 5VDC and wondered why my 5VDC pin had dropped voltage to 3.5VDC.

Yesterday, whilst testing, I had the board plugged in via USB so this must have been supplying a higher voltage. I've no idea why I convinced myself that the board needed 5VDC?

However, I've connected it up to 12VDC now and all is good. And my relay is switching the inputs too which is excellent.

No point posting the sketch as I'm literally just playing around with it at the moment. There's nothing to see. I'll post again when I hit my next hurdle... something tells me it won' t be far away!

Thanks again for all your help :slight_smile: