1

I recently bought a Wemos D1 board and tried to connect a relay and test its connection.

I got an example server from here and executed. I connected D5 to a Relay's data and 5v and GND from Wemos board.

But this does not change the state of relay, it always remains high. I connected a LED for D5, it works perfectly with client's response.

Then I powered relay using an external 5v and ground connection, but the same result.

I have checked for possible solution, but coulnt find an answer.

The relay I am using is this one

9
  • 1
    Normally it is because people work under the misconception that D5 in the code is D5 on the board, but using the LED means you are using the right port in the code and hardware, so have you looked at it the board can supply enough current to trigger the relay (it only outputs <20mA). Commented May 22, 2018 at 11:48
  • 1
    Sounds like the pin cannot provide enough current to drive the relais. Try to use a transistor or MOSFET for it
    – chrisl
    Commented May 22, 2018 at 11:53
  • @chrisl can you provide me an example? I am not good with electronic stuffs. Thanks for the comment. Commented May 22, 2018 at 12:07
  • 1
    You may need a BJT transistor to amplify the current. Look at electronics.stackexchange.com/questions/220492/…. Do you use a bare-bones relay or a relay board? Which one exactly? Commented May 22, 2018 at 12:15
  • 1
    you have a relay module? add a link to it
    – Juraj
    Commented May 22, 2018 at 13:00

1 Answer 1

3

The board which you are using is operating on 3v3. Even if you try to run the relay using the D5 or any other pin on the board, you may not be able to run it successfully at all times. In this case, you can go for either MOSFETs or Pull-up resistors so that you can hold the voltage to 5V for triggering the relay. I would personally suggest to go for a PNP type.

As requested by Sachith, here is the circuit suggested for the problem stated. Just note that the voltage source should be +5 V (which is +1 V in the schematic). Also, the MOSFET is not the specific one, it is just for the schematic purpose.

schematic

simulate this circuit – Schematic created using CircuitLab

15
  • I would expect that a 5 V TTL senses 3.3 V as HIGH. I think he has some other problem.
    – Juraj
    Commented May 24, 2018 at 13:56
  • 1
    @Juraj I understand that it feels awkward to have a TTL with external MOSFET, but the best solution could be possible only when we would be clear with the actual scenario. So, Sachith please let us know which relay you are actually trying in your case. If possible, share a link of the same. Commented May 25, 2018 at 10:54
  • 1
    @SumitPanse I have updated the relay I am using. Commented May 25, 2018 at 11:18
  • 1
    Okay @Sachith. I saw that update just now. I would need a little time to check and revert back on it. Commented May 25, 2018 at 11:50
  • 1
    @Sachith I have updated and modified my answer with the circuit you have requested. Please check it let me know whether it is clear to you or not. Commented May 29, 2018 at 4:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.