Transistor Circuit to Operate Relay from Arduino Uno

Advert

Transistor Circuit to Operate Relay from Arduino Uno

Home Forums Electronics in the Workshop Transistor Circuit to Operate Relay from Arduino Uno

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #779499
    James Alford
    Participant
      @jamesalford67616

      Having successfully got my code working and my LEDs flashing as required, I tested the circuit that I built to operate solenoids with the Uno. The idea is that each second, each minute, each hour and so forth, solenoids will operate to advance the time on a clock.

      I built a circuit using BC547b transistors to do this, on transistor circuit per solenoid. I also incorporated a LED so that I know when the solenoid should trigger.

      Testing this circuit, the LEDs all flash as expected, but the solenoids do not. Testing the output voltage on the circuit that flashes each second with a meter, I get a maximum of about 4.5 volts which drops with each flash and then goes back up to about 4.5 volts.

      I have clearly built the circuit wrongly, but I am not sure what is wrong. I was wondering whether the LED, which is across the load, is sapping the voltage or whether I have wired up the transistor incorrectly.

      Again, I should be grateful for advice. This is my circuit.

      20250124_080322

       

       

       

       

      Advert
      #779506
      John Haine
      Participant
        @johnhaine32865

        Trying to drive a relay or solenoid from a 9v battery, if it’s the usual pp3 type, is a hiding to nothing. 250mA needs a proper power supply.

        The maximum collector current rating of the bc547 is 100mA and base current 5mA.  If the base resistor is really 220R then you will be driving 25mA into the base.  I wouldn’t rely on it to switch 250mA. I would suggest that it would be much better to use a logic-level mosfet to switch the relay, lots of guidance on the Arduino forum.  Basically they take zero current from the logic level output.

        Please could you take a few minutes to learn to draw schematics correctly? There is a standard way to do this which makes it easy to see what you are trying to do, and comment. There’s also a free CAD tool, Fritzing, which allows you to draw a schematic and convert between that,  a breadboard, and pcb views.

        #779509
        Joseph Noci 1
        Participant
          @josephnoci1

          Relay should work , but the LED, not so much… The LED in that cct is the wrong way around.

          Transistor is wired OK – it is an NPN, so diagram is correct.

          Also, the resistor from the I/O pin ( 13) to the base is very low in ohm – The poor arduino has to provide around 10mA to drive the base( if the arduino is a 3.3v job, else 20mA if its 5v)  – 2k2 ohm is quite adequate.

          So, I am dismayed that the led flashes in this circuit – it cannot when reverse biased…

          Likewise dismayed that the relay does not activate, it should..unless the relay needs a higher voltage. What voltage does the relay coil require? Does it activate when you apply your 9v across the coil? If so..

          Correct the LED connection direction

          Remove the resistor from the arduino pin 13 and momentarily connect it to the arduino 3.3v or 5v supply.

          The relay should activate. If it does not, did the LED come on?

          If not, the voltage on the collector should be 9v with the base resistor unconnected. When connected to 3.3v/5v the collector voltage should be close to 0v. if not, transistor is dud..

          #779531
          Bazyle
          Participant
            @bazyle

            Find an IC chip called an ULN2003. There are little boards with them already on, also you can get boards with 2 or 4 relays on and the drivers.
            https://uk.rs-online.com/web/p/power-motor-robotics-development-tools/2651121?cm_mmc=UK-PLA-DS3A-_-google-_-CSS_UK_EN_PMAX_Catch+All-_–_-2651121&matchtype=&&gad_source=1&gclid=CjwKCAiAkc28BhB0EiwAM001TRxc0QjsCdmxCVzP822uwGgbNYJ2OKdtxrrja8A9NyJLbW93gup43xoCt-EQAvD_BwE&gclsrc=aw.ds

            It is incredibly hard to understand a non-standard circuit drawing. This is so much easier (though the transistor is inadequate.)
            https://www.electronics-tutorials.ws/blog/relay-switch-circuit.html

             

            #779544
            SillyOldDuffer
            Moderator
              @sillyoldduffer

              I re-drew the circuit to make sure it’s OK, and got this:

              relayDriver

              This is correct except:

              • make sure the LED is the right way round.  If it flashes, it probably is!
              • check the transistor connections.  James shows EBC, I think a BC545 is CBE

              Transistor is a bit small.  Max rating of the BC545 is 100mA.   Wasn’t able to find a blue miniature relay of the Arduino sort and measure it , but found a web source saying the 12V version has a 54ohm coil, which is 160mA at 9V.   Probably OK if the relay doesn’t stay on for long.

              Test the circuit without the relay and make sure the LED flashes correctly.   Then connect the relay.   If the relay doesn’t stir, it may be there isn’t enough energy in the time it takes to flash the LED to power the magnet.   Try a longer flash!  A few things may combine to reduce the energy put into the relay’s electromagnet:

              • Running a 12V relay at 9V is probably OK, but marginal
              • A 9V battery may not be able to provide enough current. A PP9 has more beef than a PP3.  Also, the battery technology matters – a cheap Zinc Carbon PP3 produces much less current than a pricey Alkaline PP9.     If necessary, put two or more batteries in parallel.
              • Pulse length too short    (I’d start with this one!)

              Never forget Sod’s Law: if it can go wrong it will, and in the worst possible way.   The relay could be faulty…

              Dave

               

              #779578
              John Haine
              Participant
                @johnhaine32865
                #779609
                duncan webster 1
                Participant
                  @duncanwebster1

                  If you can find some 12v,you can get little boards with 4 relays each with it’s own drive circuitry and freewheel diodes designed to be driven off Arduino or similar

                  #779634
                  Robert Atkinson 2
                  Participant
                    @robertatkinson2

                    James has the transistor pinout incorrect.

                    Viewed as drawn (looking at leads with flat uppermost) the left lead is Collector and right is Emitter.
                    SOD has the pinout correct but his schematic corrects James’ sketch.

                    Two other issues are that the BC547’s collector current rating is only 100mA so well below the intended load of 250mA plus the LED.
                    Second the sketch does not show any connection between the 0V of the transistor circuit and the 0V of the Arduino.
                    Looks like both design issues and an incorrect sketch.

                    https://www.farnell.com/datasheets/410427.pdf

                    Robert.

                    #779637
                    Stuart Smith 5
                    Participant
                      @stuartsmith5

                      You could buy a ready made relay board. This is one I have used from CPC.

                      https://cpc.farnell.com/whadda/wpm400/4-channel-relay-module-for-arduino/dp/SC17702?st=relay%20board

                      It also shows the circuit diagram on the website.

                      or these 2 from Hobby Components:

                      https://hobbycomponents.com/relays/75-4-channel-5v-relay-module

                      https://hobbycomponents.com/our-brand-exclusives/1090-mlink-4-channel-i2c-parallel-relay-module

                      They don’t charge much for delivery and usually arrive next day.

                      Stuart

                      #779640
                      Bazyle
                      Participant
                        @bazyle

                        Currently teh 2N2222 is considered the ‘do everything’ transistor.

                        #779648
                        duncan webster 1
                        Participant
                          @duncanwebster1

                          Having read on the other thread that the object is to drive an electromechanical clock I’d echo someone else’s suggestion to ditch the relays and use logic level fets to drive the clock coils direct.

                          Just to be pedantic (who me) a relay is not a solenoid. Solenoid has a hollow coil and the iron bit is pulled down the hole.

                          #779658
                          John Haine
                          Participant
                            @johnhaine32865
                            On Bazyle Said:

                            Currently teh 2N2222 is considered the ‘do everything’ transistor.

                            Since 1962…

                             

                            #779669
                            Michael Gilligan
                            Participant
                              @michaelgilligan61133

                              Given that the opening post included Solenoids … This is worth a look:

                              https://youtu.be/nwVRMU9grSI?feature=shared

                              MichaelG.

                              .

                              Edit: __ The pace is a bit laboured, but none the worse for that … his third circuit is the good one.

                              .

                              #779724
                              James Alford
                              Participant
                                @jamesalford67616

                                Thank you for all of the responses: I shall have a good read of them all and have another go.

                                Just to clarify a few points or comments:

                                • the 9v battery is only for the testing stage. The aim is to use a more substantial 12v power supply
                                • the relay works well on the battery if connected directly
                                • the type of relay I have been testing with is the like the relay in the first picture below
                                • the type of solenoid I plan to use is in the second picture below

                                Picture1Picture2

                                #779729
                                John Haine
                                Participant
                                  @johnhaine32865

                                  The problem with testing with a 9V battery is that it will likely run down quickly and start to cause other problems, possibly resetting the Arduino for example, which can be difficult to find unless you have a ‘scope.  This happens because the supply voltage dips when the current switches on, and the regulator on the Arduino board can’t handle it.

                                  Much better to use a proper PSU from the get-go.  It’s amazing how many people ask about problems using motors, relays etc on Arduino support who are using such a battery.

                                  That first picture is what Duncan calls a solenoid.  The second picture might be an electromagnet, but neither is a relay.  See https://en.wikipedia.org/wiki/Relay#:~:text=A%20relay%20allows%20circuits%20to,of%20controlling%20industrial%20electronic%20systems. for lots of pictures of different types of relays.

                                  #779744
                                  Grizzly bear
                                  Participant
                                    @grizzlybear

                                    Hi,

                                    If you are ordering components, I can recommend a few “N type” logic FETs.

                                    Good luck………..

                                     

                                    #779746
                                    Michael Gilligan
                                    Participant
                                      @michaelgilligan61133

                                      DataSheet for the MOSFET mentioned in the video:

                                      https://protostack.com.au/download/FQP30N06L.pdf

                                       

                                      Possibly overkill … but they are cheap enough.

                                      MichaelG.

                                    Viewing 17 posts - 1 through 17 (of 17 total)
                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                    Advert

                                    Latest Replies

                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                    View full reply list.

                                    Advert

                                    Newsletter Sign-up