# On my Arduino, why is my relay always on? [closed]

I am just learning how to use an arduino and as a test project wanted to set up a wifi garage door controller. This seems pretty straight forward with lots of guides on the net where you use the arduino to trigger a relay. I have the code set up and using my multimeter I can see it is doing what I expect, triggering a HIGH voltage for a short time when I press the button on my webpage running on the arduino. However, when I connect my relay it is always on. I wonder whether this is because when the digital pin is set to low it still outputs a small voltage, and this is sufficient to trigger the relay already.

My set up is basic: TONGLING 5VDC relay board (JQC-3FF-S-Z) connected to an ESPduino.

• VCC on relay connected to 5V on arduino
• GND on relay connected to GND on arduino
• IN on relay connected to digital out on arduino

The signal on the IN pin on the relay is about 0.4V when the Arduino output is low.

The signal on the IN pin on the relay is about 5V when the arduino output is high.

As soon as I plug the relay in to the board it switches, even though the output pin is set low.

With a bit of googling, I found something (https://www.futurlec.com/Relays/JQC-3FF-05.shtml) that suggests the pick voltage is 3.8V and the dropout voltage is 0.5V.

My take on all this is that the low voltage is already high enough to switch the relay. Does this seem correct?

If so, is there any way to control the "LOW" voltage on the arduino so that it is closer to 0V?

## closed as unclear what you're asking by Olin Lathrop, Matt Young, laptop2d, PeterJ, winnyJun 4 '18 at 9:07

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• connect a led+resistor instead of the relay board and see if your arduino is commanding the output correctly.. – Jasen Jun 2 '18 at 10:30
• Find the schematic of the relay board. I had a quick look but found only pictures. Looks like it has an opto-coupler plus transistor. Also you do not tell us what happens if you make the output pin high. e.g. is it working inverted. – Oldfart Jun 2 '18 at 10:33
• 1) I think you have the wireing wrong. The relay has a coil with 2 pins that you connect to the arduino and 2 or 3 pins for the switch depending on model. So you would connect either the 5V or the GND but never both. 2) The relay seems to draw 71mA at 5V making it unsuitable for an AVR based arduino. I'm unsure what the current rating is for an ESPduino but better check that you may draw 71mA from a pin. – Goswin von Brederlow Jun 2 '18 at 10:50
• When connected to the 5V on the arduino, the relay stays switched whether the output is high or low. Interestingly, I just tried running the relay off the 3.3V supply on the arduino and it now seems to switch correctly – DJnoob Jun 2 '18 at 11:01
• You mentioned "arduino" in the title and the first line of the question. It seems there are more mentions scattered about the question. This leaves one of two possibilities: 1 - This is a arduino user level question and doesn't belong here. 2 - It's a more generic microcontroller and electronics question, and the adruinoness is not important, but you haven't thought out the problem logically enough to realize that. Either way, if you want to be taken seriously, don't mention "arduino". In any case, closing due to missing schematic. – Olin Lathrop Jun 2 '18 at 11:09

Please do not post a question like this without links to the products you purchased and schematics. I happen to know what is wrong (most likely) but your question is presented in a misleading way.

• you do not have an Arduino (at least not one based on the normal Atmel/Microchip ATMega 5V chip), you have a PCB based on the WiFi-enabled Expressif chip, which operates on 3.3V supply (and can be compatible with the Arduino IDE but that's irrelevant to the hardware). Expressif is a Shanghai-based chip manufacturer and did not make your board. It was assembled by some 3rd party to some design or another.

• Tongling is a Chinese relay manufacturer (based in Jiangsu province). They did not make the board you bought, it was assembled by some 3rd party to some design or another.

There are at least 3 common schematics for the relay PCBs, one with an optoisolator and 4 input pins, one with an NPN transistor and 3 input pins and one with a PNP transistor and 3 input pins. The latter is what you probably have. The 3rd type requires a low input voltage to turn the relay on, and a high (meaning 5V) voltage to turn the relay off. Your 3.3V system cannot provide a 5V signal so the relay never turns off.

To make it work, add a transistor and resistor as follows:

simulate this circuit – Schematic created using CircuitLab

For example: (amusing translations "suck right" = energized)

• You know, I'd have assumed that a product calling itself "ESPduino" would have made at least a vague attempt at Arduino compatibility on a physical level. There's more than enough space on such a board for level converters, or even just enough protection to prevent the board being destroyed when you plug it in to an existing design that provides 5v to the non-5v-tolerant inputs of the ESP2866, but it seems that the "ESPduino" does none of this. Honestly, it seems like an entirely pointless board. Take a $3 ESP12 breakout board, ... – Jules Jun 3 '18 at 2:11 • ... dump it onto a larger board with a$0.50 voltage regulator and a $1.50 USB serial converter, sell it for$10. Yeah, I think I'll stick to the ESP12, thanks. – Jules Jun 3 '18 at 2:13
• Thanks. This sounds like it is on the right track to answering the problem. However the strange thing is that it runs nicely connected to the 3.3V pin and does not run off the 5V pin. I am powering the board off a 9V power supply and if I use the VIN pin (running at 9V) it still doesn't switch off. – DJnoob Jun 3 '18 at 3:48
• Clarification: the relay doesnt switch off provided the output trigger pin is also connected. – DJnoob Jun 3 '18 at 4:06
• So it seems to be related to the voltage getting sufficiently low on the trigger pin I am using. I will try connecting the transistor as you suggest. But do you have any explanation for the good operation on the 3.3V pin? – DJnoob Jun 3 '18 at 4:06

These relay boards are active-low. Means, the relay turns on if you give LOW at its input and turn off if you give HIGH.

You must change the code in the software to take care of this.

digitalWrite(LOW) to turn on relay. digitalWrite(HIGH) to turn off relay.