<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Am I using the 2N2222 correctly?</title><link>/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><description>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 </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Mon, 13 Feb 2017 01:18:31 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>scarcesam</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;First, thanks for all the feedback!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;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&amp;#39;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&amp;#39;m still trying to figure out which specs to search on supplier web sites.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;However, I think Rachael had the right idea. The Arduino 101 GPIOs alone can&amp;#39;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.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/620x827/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-99f2fd41-0dc4-4e26-b52b-2837b13c0e32/6825.contentimage_5F00_183624.jpg:620:827]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I Think I&amp;#39;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&amp;#39;t work. I&amp;#39;ll play with the values a bit for power savings but that&amp;#39;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.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Above all else this is a learning experience for me. It&amp;#39;s my first dabbling in anything less than 110VAC (former electrician).&amp;nbsp; So, any other tips or suggestions would be greatly appreciated.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt;Sam&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Sun, 12 Feb 2017 19:10:20 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>D_Hersey</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I didn&amp;#39;t have a&amp;nbsp; clue to the nature of your load when I mentioned the PU.&amp;nbsp; In cases where you want some kind of bandwdith from the opto it helps drain the LED capacitance.&amp;nbsp; A relay isn&amp;#39;t fast enough to benefit from this.&amp;nbsp; If you go to a MOSFET you can eliminate the input resistor&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Sun, 12 Feb 2017 10:02:27 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>jc2048</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I agree with Doug, R2 isn&amp;#39;t needed. When the Arduino output is low you have R1 in parallel with R2 to ground, which is about 9k - that&amp;#39;s not much different to R1 alone, so R2 isn&amp;#39;t doing anything much.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;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&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;[View:/resized-image/__size/400x300/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-99f2fd41-0dc4-4e26-b52b-2837b13c0e32/contentimage_5F00_183623.jpg:400:300]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;You wouldn&amp;#39;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].&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;You don&amp;#39;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.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Sun, 12 Feb 2017 02:12:03 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>rachaelp</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The relay module that is listed above I believe has opto-isolated active low inputs so pulling them down switches the relay on. So your inverting transistor circuit will make it more logical in your Arduino code as &amp;#39;1&amp;quot; will be ON. I agree with Don, you probably want a pull up on the collector too otherwise it might not switch the relay off properly.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Sat, 11 Feb 2017 03:57:26 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>D_Hersey</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a class="jive-link-external-small" href="http://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF" rel="nofollow ugc noopener" target="_blank" title="http://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF"&gt;http://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;These guys claim a gain of 50 min and are using a 1K input resistor driven by 16V for their tests.&amp;nbsp; Truth is, you can get along with a range of values.&amp;nbsp; Going smaller, if B-E capacitance is your limiter, will make your circuit a little faster, going larger makes you a little more fuel-efficent&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Sat, 11 Feb 2017 02:24:09 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>dougw</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Looks good. As Don mentioned, R2 is probably not needed. The 2n2222 should sink at least 100 times the current into the base which would be about 43 mA. With R1 set to 4.7K you could sink at least 90 mA.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Am I using the 2N2222 correctly?</title><link>https://community.element14.com/products/arduino/b/blog/posts/am-i-using-the-2n2222-correctly</link><pubDate>Sat, 11 Feb 2017 00:14:14 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:99f2fd41-0dc4-4e26-b52b-2837b13c0e32</guid><dc:creator>D_Hersey</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;R2 doesn&amp;#39;t hurt anything, turns the Q off faster, but the solenoid is probably too slow to notice.&amp;nbsp; You might make R1 4-5x more conductive.&amp;nbsp; You probably need a pull-up resistor for the collector.&amp;nbsp; Remember, this circuit inverts so you will probably have to alter your code slightly&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=2532&amp;AppID=145&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>