Still more problems with 3v relays and Arduinos

I am troubleshooting an issue where I am trying to put 240AC through a relay, and every time it goes under load, it hangs the swipe system.

Attached is the PDF of the plan for this system. it works already, I have multiple instances already installed and functioning.

Device Access Box sketch 10A Update 2026_1_bb.pdf (797.4 KB)

I am attempting to control the attached relay using Pin D1, with the VCC connected to 3V and ground to ground.
I am setting the D1 port high on setup, and then low to initiate.

My testing has proved that when I power the system through either the power adaptor in the diagram, or the USB power while connected to my laptop and running Arduino IDE and with the relay functionality disabled, it works. I can merrily swipe away and the code does it things and detects swipes and switches the LEDs accordingly.

When I enable the relay functionality and power the arduino through by computer, it works fine as well. I can hear the click as the relay is switched on or off, can repeatedly swipe on and off.
The moment I connect mains power through the relay, the system will swipe on AND THEN ACCEPT NO MORE SWIPES!

I have added a truth table to demonstrate

Arduino Power | Relay Connected | Result
-----------------+-----------------+--------
Computer | No | OK
Mains Adaptor | No | OK
Computer | 240V AC | HANG
Mains Adaptor | 240V AC | HANG

I have tried out 2 relays, so the component is not the issue. Is the general model of relay unsuitable for Arduino?

Is there some magic exception in electronics land that is causing this issue? The relay has no dip switches or jumpers, so I don't think it is configuration.

Any advice appreciated.

It is best if you put your table in code tags.
That will select a font that has equal width for all characters (incl. Spaces).

Why did you chose a 3v3 relay? A 5V relay could be fed directly from the adaptor.
What type of load is controlled by the relay?
Can you post a picture of your setup?

Dies your relay respond to a blynk sketch?
(Ruling out card reader issues).

Hi, @iandennison

Can you post some images of your project?
So we can see your component layout.

What is the load you are switching power to?

Do you have a DMM? Digital MultiMeter?

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

So what is different between the instance that does not work and the ones that do work?

I use 3.3v for the relay because that’s the base voltage that Arduino ESP8266 serves best. (If I use 5V, I need a separate 5V power supply which means a bigger box which means retooling.) These configs already work, I have 5 other builds working using this plan.

What’s a “blynk sketch”? I have modified the code (1000+ lines) to use booleans for Wifi Functionality, Card Reader Functionality, and Relay function. it only stops working when 240v AC goes through the relay.

Hi Tom

Yes I have a multimeter. I am switching 240v AC through the relay, but powering via 3.3v pin on Arduino ESP8266.

See layout enclosed.

hi Jim

No idea. Am pretty sure the other completed devices (which I did not build but am now responsible for) have at least one using this model of relay.

Well from your debugging procedure it should be obvious that the relay is not the problem but the 240V is.
What does the 240V operate?

I see USB power, so why didn't you use a 5volt relay.
Trying to power a 3volt relay from the 3V3 pin of the ESP is asking for trouble.
A 3V relay coil draws more current than a 5volt relay, overloading the 3V3 regulator.
What are you switching. Did you use a suitable snubber circuit on the AC side.
Leo..

Hi Jim,

Nothing on the power side. No draw at all, no object plugged into the socket. I did try a column heater but had the same result as before.

Hi Leo,

I am not using a snubber circuit on the other 5 boxes that use this configuration, as well as 3.3v across them. They all seem to work fine. When I use 5V on an ESP8266, it does bad things to the device, so I need a separate PSU for the 5V feed.

There is nothing connected to the other side of the power connection. I did try a column heater but that had the same result as when nothing was plugged in.

Well somehow the AC is interferring with the D1 mini and/or reader.

If the AC is present but you power everything via USB does it work or fail?

I should say and with the adaptor and relay disconnected from the AC.

Have you tried a different make of relay module? It sounds rather like there is a problem with the module. I have found some makes of relay module are more reliable than others.

As I said it seems like the AC is interferring with the reader and/or D1 mini.

Leave the box open like you show and remove the AC adaptor and power everything from USB computer. Move all the AC wires away from the D1 mini.
Does it still fail?

The spark from a mechanical mains switching event can cause interference which could disrupt your controller. You could try a Solid State Relay to see if that cures the problem.

You might want to check how much current that relay module draws when the relay is energised. They can be as much as 50 or 100mA for a single relay. Some 3.3V microcontroller boards are fine with that much coming out of Vcc but yours might not be. Need to check the spec sheets.

Maybe it is named blink sketch. Anyway, it just puts one DO on and off (repeat).
My approach follows @jim-p method: isolation of the problem...

Your 3.3v relay probably draws about 120mA via the internal regulator of the Wemos board. Much better, as already pointed out, would have been to use a 5v relay module powered from the 5v pin of the Wemos board.

However, this is probably not your main problem if, as you have implied, with no mains power to that box and powering the Wemos via a computer connected usb cable seems to show that the circuit including the relay functions as expected. When the box is shut, those signal wires to the RFID device appear to be in close contact to the mains wiring.