When relay is connected, MFRC522 stops working.

Hi all,

I'm fairly new to Arduino and this is the first issue I'm having I can't make sense of.

I am developing various features for my car and long story short, I have RFID implemented using the MFRC522 module. Works great as I want it to. Scan the card, it runs an unlock operation. Scan again, it locks.

However, when I hook up a 2 channel relay module, the MFRC522 module stops responding.

If I'm lucky, the MFRC522 will work ONCE (one scan of the card and function being run) with the relay connected and then stop responding after that.

If I disconnect the relay module and unplug then replug the Arduino, the MFRC522 works as normal again.

I have tried changing the pins for the relay module but the behaviour is the same.

This same behaviour happens even with the default MFRC522 example sketch, so I know it's not particularly my code.

Does anyone have any idea why this might be happening?

I've attached some images and I could make a video if theres nothing obvious here.

I should also note the relay module works fine if I test with something in a fresh sketch but when I try to combine the MFRC522 and the relay, they don't both like being connected to the Arduino.

Update:

I have found that if I disconnect everything from the terminals (NO, C, NC) then the relay and MFRC522 work normally.

I can't understand why the relay works as expected when I test the relay with its own script but wont work when combining it with MFRC522 if I have the solenoid and battery power going through the end terminals of the relay....

Anyone?

I have tried powering the relay separately via its optical isolator but as soon as I introduce a load to the relay terminals, the MFRC522 stops detecting cards anymore.

kylegp:
Anyone?

I have tried powering the relay separately via its optical isolator but as soon as I introduce a load to the relay terminals, the MFRC522 stops detecting cards anymore.

The relays are not POWERED thru the opto-isolators. They are controlled that way. Power MUST come from a separate 5 volt power supply. Certainly not from the minuscule 5 volts available from the Arduino 5 volt pin.

Paul

I don't see a kickback diode across the solenoid.
Leo..

Wawa:
I don't see a kickback diode across the solenoid.
Leo..

What flyback diode would be appropriate?

I have some 1N4001.

Paul_KD7HB:
The relays are not POWERED thru the opto-isolators. They are controlled that way. Power MUST come from a separate 5 volt power supply. Certainly not from the minuscule 5 volts available from the Arduino 5 volt pin.

Paul

Ah yes, I misunderstood it. Thanks!
What I basically mean is I powered the relay separately to the Arduino via JD-VCC.

The latest update I have is that when I have everything hooked up (Battery for solenoid, external power to relay) except the SOLENOID, the relay switches according to my code just fine and the MFRC522 works normally, consistently.

Going back to what Leo (Wawa) said, I assume I need some extra diode? What diode would be appropriate?

The issue is definitely when the solenoid is connected, some interference is occurring.

If opto isolation is needed, then you must remove the JD-VCC jumper, and connect a separate 5volt supply to the JD-VCC (not VCC) pin and ground of the relay board.
And connect VCC and the IN terminals to 5volt and outputs of the Arduino.
DO NOT connect relay ground to Arduino ground. That would defeat opto isolation.

There are back-EMF diodes for the relay coils on the relay board,
But there are ofcourse no back-EMF diodes fitted for inductors you connect to the relay contacts.

Any diode that can handle the impulse current of the solenoid will do.
What does the solenoid draw, and what do you have in your junk box.
Leo..

Wawa:
If opto isolation is needed, then you must remove the JD-VCC jumper, and connect a separate 5volt supply to the JD-VCC (not VCC) pin and ground of the relay board.
And connect VCC and the IN terminals to 5volt and outputs of the Arduino.
DO NOT connect relay ground to Arduino ground. That would defeat opto isolation.

There are back-EMF diodes for the relay coils on the relay board,
But there are ofcourse no back-EMF diodes fitted for inductors you connect to the relay contacts.

Any diode that can handle the impulse current of the solenoid will do.
What does the solenoid draw, and what do you have in your junk box.
Leo..

Thanks for the advice. This might seem like a simple thing but where does the flyback diode (or diodes?) get placed in the circuit? Since the solenoids polarity gets reversed at times, this is what is confusing me.

If solenoid polarity is sometimes reversed, then you need a bi-derectional TVS or a bridge rectifier.

This post might help.

https://forum.arduino.cc/index.php?topic=492142.15

Leo..

Wawa:
If solenoid polarity is sometimes reversed, then you need a bi-derectional TVS or a bridge rectifier.

This post might help.

Using a relay to reverse polarity of a circuit. - General Electronics - Arduino Forum

Leo..

Thanks Leo.

The solenoid is 12V however I am testing using only a 6V battery. It works fine, just a little slower than normal operation.

I have had a look for bidirectional TVS and found these:
https://www.ebay.com.au/itm/5Pcs-Diode-Tvs-15V-600W-Bidirectional-P6KE15CA-Ic-New/282893874142?hash=item41ddc9f3de:g:jrcAAOSwNGRasgh3

Does the voltage (12v) need to match the TVS or is the 15V the maximum the load can be? Would these be appropriate?

kylegp:
The issue is definitely when the solenoid is connected, some interference is occurring.

That's the point where it sucks more power than you supply?

Probably easier to use a bridge rectifier.

For a TVS diode you only look at the 'standoff' voltage (part of the serial nr).
That's the voltage it can have on it continuously.
If that's the same or more than the supply, then you're ok.
Leo..