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 10 posts - 1 through 10 (of 10 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.

                      Viewing 10 posts - 1 through 10 (of 10 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