Connect with us

ESP8266 for controlling selenoid door lock

Discussion in 'Microcontrollers, Programming and IoT' started by Watha, Feb 4, 2022.

Scroll to continue with content
  1. Watha

    Watha

    5
    0
    Feb 4, 2022
    Hello, I'm new in electric and I'm trying to use ESP8266 for controlling selenoid door lock, as picture attached.

    I've checked ESP8266 works fine it could get data from firebase and send data to pin.
    But I could not make it works with Selenoid Door Lock.
    For battery I used 9v alkaline battery and it did work for selenoid door lock without relay when I checked it out. I've also already tried to replace battery with Adaptor 12V 2A.
    I've already tried to use a diode parallel to magnetic locks but still does not work.

    Could you please tell me where did the wiring go wrong?

    Did it not work because I use 3.3v in ESP8266 as VCC in Relay Module?
    Should I add Arduino Uno for Mikrocontroller to get 5v VCC? trial2_bb.jpg
    I would appreciate it if anyone could help me.

    Thank you.
     

    Attached Files:

  2. bertus

    bertus Moderator

    2,508
    978
    Nov 8, 2019
  3. Coen

    Coen

    8
    1
    Jan 31, 2022
    The SDR-05VDC-SL-C is a relay module that needs 5V to operate, and will require nominal 71 or 89 mA to operate (depends on type of relay (Standard or High Sensitivity)). The minimal pull-in voltage of the relay is 75% of the operating voltage, so 3.75V. Both the voltage and the current is a problem for the nodemcu. This module operates at 3.3V and can deliver a maximum of 20mA (in sync mode, 12mA source mode) per output.
    There are similar relays that can work on 3V but require even more current (120mA). An Arduino Uno does operate on 5V but also cannot deliver enough current (about 40mA max).

    So you have multiple issues here
    - In your schematics the nodemcu is not powered
    - the nodemcu cannot drive the relay (voltage and current issue) directly.

    You can power the nodemcu with the 9V battery when you connect it to the Power Vin.
    You should add a FET / transistor to drive the relay from the 3.3V output, but then you must also limit the voltage you provide to the relay (this one only allows 110% max (5.5V)). Simple solution here (but not really reliable / optimal when powered with a battery) is using a resistor that limits the voltage over the relay.
     
  4. Watha

    Watha

    5
    0
    Feb 4, 2022
    Hello Coen.
    Thanks for your reply.
    I'm currently using Relay Module JQC-3FF-S-Z, I have not found it's fritzing part anywhere else so I use SDR-05VDC-SL-C that most similar in fritzing.
    I've tried to use Vin pin as someone suggested to me.
    I could hear the "click" sound in relay it means that relay should be working.

    But when I change the value in D7 pin, it still does not change the state of door lock.
    When I tried to measure the voltage in pin D7, when the value is "HIGH", the voltage measured only 2.67V. Is that why the relay does not work?

    I've powered up NodeMCU using USB cable provided plugged in to my Laptop.
    I measured the voltage in VCC is around 4.35V.

    Should I change the relay module instead?
    Do you know what I should do?
     
  5. Watha

    Watha

    5
    0
    Feb 4, 2022
    Hello Bertus, thanks for your reply.
    I've powered up NodeMCU using USB Cable plugged in my laptop. Voltage measured around 4.35V.
    I'm pretty sure the relay does work but when I changed the value in "D7" pin the relay does not trigger.
    The voltage measured in D7 is around 2.67 V.
    Do you know what should I do?
     
  6. Coen

    Coen

    8
    1
    Jan 31, 2022
    Looking at the specifications of the relay and assuming it is the 5V version, it needs a minimal voltage of 3.75V. Besides that it will draw about 70mA. Both of these are above the output rating of the nodemcu.
    My previous suggestions to use a output driver like a transistor to enable the nodemcu to drive the higher current and voltage will help.
     
  7. Harald Kapp

    Harald Kapp Moderator Moderator

    12,456
    2,985
    Nov 17, 2011
    The JQC-3FF is the relay. There are sevral different modules using this relay. Some modules may have the required driver transistors, others not.Which specific module do you use?
    That is irrelevant. Your diagram shows you using the 3V3 pin to power the relay module which will not work for a 5 V relay:
    upload_2022-2-5_15-53-18.png

    If the relay module does not have a built-in driver, you need to add one. See our resource on how to do this.
     
  8. Watha

    Watha

    5
    0
    Feb 4, 2022
    I checked and I think the module already has a built-in driver.
    It has 2TY for npn resistor.
     
  9. Harald Kapp

    Harald Kapp Moderator Moderator

    12,456
    2,985
    Nov 17, 2011
    Then connect the Vcc pin to 5 V, not 3.3 V.
     
  10. Watha

    Watha

    5
    0
    Feb 4, 2022
    Already did, but still did not work

    I've decided to use 3.3 V module relay instead to make this works and thankfully it works out fine now.
    Thank you for your help. ^^
     
  11. ozkarah

    ozkarah

    1
    0
    Jun 19, 2022
    I did it several time and it should work:
    - If you use USB port as power supply, use VU pin to power (VCC) relay module.
    - With some modules, you need to set the logic pin to LOW to trigger the relay. If you set the pin to HIGH change your code and try again.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-