element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Am I using the 2N2222 correctly?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: scarcesam
  • Date Created: 10 Feb 2017 8:16 PM Date Created
  • Views 1644 views
  • Likes 1 like
  • Comments 9 comments
Related
Recommended

Am I using the 2N2222 correctly?

scarcesam
scarcesam
10 Feb 2017

This is my first use of transistors in a project. I need to control a SainSmart 16-Channel Relay Module using an Arduino 101(3v3 GPIOs). This Relay Module uses 5 vdc through Opto couplers to power the relays. The input pins on the relay board are at 4.4 vdc and need to be brought to GND to switch on.

When I connected the Arduino 101(3v3 GPIOs) directly to the relay module some of the relays would stay on while others would be controlled by the Arduino. It all worked fine when I tried an Arduino UNO(5v GPIOs) in place of the 101. But, I want to use the BLE capabilities of the 101.

So my solution is to use  2N22222N2222 transistors because I’ve read they are good at general purpose low-mid power switching Below is the configuration I think is correct Any feed back would be greatly appreciated I’ve tried reading the Data Sheet but I’m mostly going off of other forum posts

 

Relay Board inputs; +4.4vdc, input to ground 4mA

Arduino 101; 3.3vdc GPIOs, max 20mA per GPIO

T1  2N22222N2222

R1: 10K, to reduce current through the Base to 0.33 mA

R2: 100K, drop down resistor. (is it needed?)




  2N2222.JPG

 

Thanks!

 

Attachments:
image
  • Sign in to reply

Top Comments

  • rachaelp
    rachaelp over 8 years ago in reply to jc2048 +3
    Jon Clift wrote: I (probably) disagree with Don and Rachael on the need for a pull-up. Yes you are right! I (probably) blame that on trying to answer on a forum after 2am when I should really be in be…
  • D_Hersey
    D_Hersey over 8 years ago +2
    R2 doesn't hurt anything, turns the Q off faster, but the solenoid is probably too slow to notice. You might make R1 4-5x more conductive. You probably need a pull-up resistor for the collector. Remember…
  • D_Hersey
    D_Hersey over 8 years ago +2
    http://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF These guys claim a gain of 50 min and are using a 1K input resistor driven by 16V for their tests. Truth is, you can get along with a range of values…
  • scarcesam
    scarcesam over 8 years ago

    First, thanks for all the feedback!

     

    So, the 2N2222s I ordered turned out to be 2N2222As. I chose them because they were cheap on Amazon. And because this is a temporary project, for learning, I'm not too concerned with quality or having the perfect part. I do want to learn how to find the best fitting parts. So maybe MOSFETS next time. I'm still trying to figure out which specs to search on supplier web sites.

     

    However, I think Rachael had the right idea. The Arduino 101 GPIOs alone can't keep the Relay Module input high enough to keep the optos off. But, it works with a 1k pull up resistor on the input from the Arduino to the relay board. This setup should be draining roughly 9 mA through the Arduino. Well below is max of 20mA.

     

    image

     

     

    I Think I'll use the setup above with the pull up resistor. Do I need a resistor for each individual input? I tried 4 inputs though one 1K resistor and it didn't work. I'll play with the values a bit for power savings but that's not super important. The plan is to use the Arduino and relay module to control the two 12v motors on a kids electric ride-on vehicle. I plan on having a common ground between everything but the Relay module will run off of the cars 12v battery and the Arduino will run off of a separate 9v battery.

     

    Above all else this is a learning experience for me. It's my first dabbling in anything less than 110VAC (former electrician).  So, any other tips or suggestions would be greatly appreciated.

     

    Thanks,

    Sam

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 8 years ago in reply to D_Hersey

    I agree with Don - these days I always use FETs because they are more efficient - both input driving current and output voltage.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • D_Hersey
    D_Hersey over 8 years ago

    I didn't have a  clue to the nature of your load when I mentioned the PU.  In cases where you want some kind of bandwdith from the opto it helps drain the LED capacitance.  A relay isn't fast enough to benefit from this.  If you go to a MOSFET you can eliminate the input resistor

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • rachaelp
    rachaelp over 8 years ago in reply to jc2048

    Jon Clift wrote:

     

    I (probably) disagree with Don and Rachael on the need for a pull-up.

    Yes you are right! I (probably) blame that on trying to answer on a forum after 2am when I should really be in bed image

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 8 years ago

    I agree with Doug, R2 isn't needed. When the Arduino output is low you have R1 in parallel with R2 to ground, which is about 9k - that's not much different to R1 alone, so R2 isn't doing anything much.

     

    I (probably) disagree with Don and Rachael on the need for a pull-up. The input is an optocoupler and will look something like this

     

    image

     

    You wouldn't bother with a pull-up if you were driving an LED, so why bother with it here [that's based on my guess as to the circuit - though if you look at the photo you can see the optocouplers and the resistor packages next to them, so it's an educated guess].

     

    You don't need to fuss over the transistor too much - when people talk of switching transistors they mean switching at high speed, this is just slowly turning something on and off.

     

    If you were a real cheapskate, you might get it to work with just a signal diode between the Arduino output and the relay board input.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube