Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Lopy and 5V relays

    Scheduled Pinned Locked Moved LoPy
    lopyrelay
    13 Posts 3 Posters 3.4k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      alex89
      last edited by

      @robert-hh thank you for your answer. I can't understand all your explanations but I get your point. So something like this could work ?
      I am also using one arduino sending sensor values to the lopy by UART, maybe it would be easier to connect the relay to the arduino. What do you think?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @alex89
        last edited by

        @alex89 You would need a two transitor driver, like the half of an output bridge, e.g. like this picture. The transistors could be any small signal NPN/PNP type. But as said, you could also use a 7cHC04, which has 6 drivers in a single package, with no need to add any other analog components. Anf that chip is widely available. Almost any electronic stor should have it.
        0_1507714264690_Interface.jpg

        A 1 Reply Last reply Reply Quote 0
        • A Offline
          alex89 @robert-hh
          last edited by

          @robert-hh I am doing this project in Ethiopia, I will never find this transistor here. What I don't understand is these kind of relays works well with raspberry pi which I think allows 15mA max. Also I don't understand why the driving current is too low as I connect directly the relay to my 5V power source. I am sorry to be a total noob in electronic...

          robert-hhR 2 Replies Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @alex89
            last edited by

            @alex89 The model of transistor is not very critical. You can use almost any npn and pnp small signal type. But as said, the 74hc04 is the more convenient choice.
            The reason is, that the input of the relay board requires like 10 mA into GND to drive the LED in the Optocoupler on the board. Using the level converter, this current comes from the pull-up resistor in the converter, which is like 10k, resulting in am inrush current of about 20µA, which is too low to drive the optocoupler. The two diodes are connected in series, with a voltage of about 1.5 V each at 10mA, resultuing in a minium drivin voltage of 3.3 V
            What you could try is to bridge the external LED and drive the input directly for the WiPy/LoPy. It can supply that current, and then the voltage required is within the output range of the unit.

            1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @alex89
              last edited by

              @alex89 Equivalent parts for BC549/BC558 are:
              2N2222/2N2907 or
              2N3904/2N3906 or
              .....

              1 Reply Last reply Reply Quote 0
              • A Offline
                alex89
                last edited by alex89

                @robert-hh I have these: 2N3904/2N3906. So if I understood well, if I use these transistors, I don't need the logic level converter anymore ? Also, I will need 4 X 2N3904 and 4 X 2N3906 ; two transistors for each relay ?
                Do you think it will work if I do this but using only one 2N3904 ? Why would I need the 2N3906 ?

                robert-hhR 1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @alex89
                  last edited by

                  @alex89 That's correct. The transistor circuit replaces the level converter. And you need that 4 times.
                  You need both to supply sufficient current to the input w/o a high standby current.
                  You could use just one 2N3904, but then the resistor between Vcc and Collector would have to be much smaller, like 150..220 Ohm to get sufficient current into the input, and the logic level is inverted. So to switch the relay on, you'll need output a 0, and to switch it off, you'll need a 1. And the default state would be ON.

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    kots
                    last edited by

                    @robert-hh said in Lopy and 5V relays:

                    7cHC04

                    I made something different but i dont know if it really works. Let me share it with you. I use the type of relays that @alex89 mentioned, to drive a hunter solenoid.
                    I connect my lopy's G2 pin(expansion board) to this boost converter. Then i connect the output of my converter to the relay's shield Vin and Ground Pins. I power my relay through 5v pin of arduino Uno. And my relay works. I can hear it switching and the green led on the shield goes on and off as expected. What it doesnt work is the hunter solenoid. Any ideas?

                    robert-hhR 1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @kots
                      last edited by

                      @kots Are you sure about G2, because that is the TX ouput of the UART0, and not meant to supply a buck converter.
                      About the solenoid: Since the relais is a simple switch, it does not power the solenoid. It can only switch the power to the solenoid on and off, but the appropriate power for the solenoid must be provided additionaly.

                      K 1 Reply Last reply Reply Quote 0
                      • K Offline
                        kots @robert-hh
                        last edited by

                        @robert-hh thank you very much for your answer!
                        You are right about the G2 but i dont think it can cause an issue on lopy! I am only taking the 3.3V of that pin and step it up to 5V...

                        robert-hhR 1 Reply Last reply Reply Quote 0
                        • robert-hhR Offline
                          robert-hh @kots
                          last edited by

                          @kots Even it that is true, it does not sound reasonable. G2 is used for the REPL communication. You might use another GPIO port for switching, but G2 seems to be an odd choice, as well as driving a step-up converter power input with a GPIO port, especially if a single transistor switch or digital gate is sufficient for the purpose.

                          1 Reply Last reply Reply Quote 0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • 1 / 1
                          • First post
                            Last post

                          Pycom on Twitter

                          Pycom