How can I use a 2N2222 transistor as a temperature sensor?
Ask QuestionAsked 2 days agoActive todayViewed 2k times71
I’m supposed to use a TMP36 transistor for a class to read the temperature of the environment, but I only have a 2N2222 transistor; the Arduino will have an analog read of it, but the numbers won’t change even if I heat it up. Am I screwed or can I fix this?arduinotransistorssensortemperatureshareedit follow flagedited yesterdayPeter Mortensen1,63633 gold badges1616 silver badges2323 bronze badgesasked 2 days agoJohn Rawls17922 bronze badges New contributor
- 9A TMP36 is not a transistor, so there is no way to substitute it with a 2N2222 which will give you useful results. – brhans 2 days ago
- 3@John Rawls, Ah yes, you can turn 2N2222 into a TMP2222 for your class to read temperature of the environment. The problem is that Arduino ADC is only 8 bit so it is not precise enough to detect the small 2N2222 characteristic differences (eg, hFE, Ic etc) as temperature changes. A workaround is to use a dirt cheap 10bit/12bit ADC such as MCP3008/MCP3201/MCP3208 which enable you to read 0.!% to 0.025% accuracy. Then you need a thermometer to calibrate the hFE/Ic vs temperature graph. The graph might not be that linear. But / to continue, … – tlfong01 2 days ago
- 3/ continue, … you can show your class that you are an innovative future engineer, and of course they would see you as a hero, and your teacher couldn’t resist to give you a A grade, and your school principal to give you an outstanding R&D academic award, Then your principal can write to Analog Device about your fake TMP36 studies, and request them to give your class 40 real TMP transistors to do real research. 🙂 – tlfong01 2 days ago
- 2Vbe of the transistor depends on temperature in a fairly predictable way. Using a diode or base-emitter junction as a temperature sensor is a fairly common application. Spehro already answered, though, so I won’t write another answer saying the same thing. – mkeith 2 days ago
- 1Does Vbe really depend on temperature? I think, instead it is the collector current which depends on temperature (for a fixed Vbe) – and Vbe must be reduced by app. 2mV/K to bring Ic back to its former value. – LvW yesterday
- 1@tlfong01 “The problem is that Arduino ADC is only 8 bit” – The Arduino Uno and comparable boards use an Atmega328P, which has 10 bit ADCs. – marcelm yesterday
- 3“the Arduino will have an analog read of it but the numbers wont change even if I heat it up.” – Sooo, how did you connect the transistor and your Arduino? Provide a schematic please. – marcelm yesterday
- @marcelm, Ah, the first line of my updated answer says that that I will be using MCP3008/3201 ADC, and followed by the schematic. 2N2222 is biased by fixed value Rb (Gloen_geek, suggests 1 Meg, so I will blindly try it.) As shown in the schematic, 2N2222 output will go to ADC, controlled by Arduino/Rpi through SPI. – tlfong01 yesterday
- I know the 2N2222 output vs temperature might be very non sensitive and very non-linear, and even 12 bit ADC is not accurate enough to process. So I already have 16/24 bit ADC standby, to brute force do ADC and massage non linear curve to become linear. I know I am walking a long and winding road, and at the end of the journey find nothing. But think I will at least know more 2N2222 inside out, and also 24 bit ADC usage. – tlfong01 yesterday
- 1@tlfong01 My second comment (asking for a schematic) was intended for the OP 😉 – marcelm yesterday
- @marcelm, (1) Many thanks for pointing out my careless mistake of wrongly thinking that Arduino ADC is only 8 bits resolution. I wrongly mixed up Arduino ADC with PWM. Actually Arduino PWM has 8 bits only, but Arduino ADC has 10 bits. (2) Now I think Arduino 10 bits ADC is OK to start our experiments. Actually many applications might not need to accurate, 2 Celsius degrees is enough. / to continue, … – tlfong01 yesterday
- (3) Therefore I decided to remove the external ADC (MCP3008) in my answer. I will also remove Rpi from my answer, because it is only Rpi that needs MCP3008 ADC. Arduino is just about right for our project here. I will update my schematic ASAP. Thanks a lot. Cheers. PS – I would suggest to move our discussion to chat. See you in the chat room. – tlfong01 yesterday
- Let us continue this discussion in chat. – tlfong01 yesterday
- I just dropped in (been busy.) Top rated answer says “no can do.” Not one single person here has even given the slightest nod to using the collector region where the lower doping and a higher electric field can be used to advantage in providing better linearity and sensitivity. – jonk yesterday
- @LvW, yes, Vbe depends on temperature. If you can find it, Bob Pease covered this at length in “what’s all this Vbe stuff anyhow.” This link is working, for the moment. forum.vegalab.ru/… – mkeith 22 hours ago
- @jonk you mean forward bias the base/collector junction and use it as a temperature sensing diode? – mkeith 22 hours ago
- @mkeith, I am afraid you did not interpret the article from Bob Pease correctly. In connection with Fig. 2 he wrote: “This illustrates the bias of transistors at various constant currents versus temperature.”. So – as I have stated: Vbe does not vary with temperature, but it MUST be changed EXTERNALLY by app. 2mV/K for a constant collector current Ic. This is because Ic is the source of temp. dependence! – LvW 22 hours ago
- @LvW I have biased Vbe junctions with constant current on the bench and watched Vbe change with temperature. Same holds for diodes. Please try it yourself. – mkeith 22 hours ago
- @LvW you may be right that I misinterpreted the direct applicability of Bob Pease’s article to this situation. Still, diodes are often used as temperature sensors on IC’s. The Vbe junction can be used as a diode. Or the base and collector can be tied together. Either way, Vbe will change with temperature under constant bias. – mkeith 21 hours ago
- @LvW ti.com/lit/an/sboa277a/sboa277a.pdf – mkeith 21 hours ago
- @mkeith, am I wrong when I think that it is the CURRENT change which is used as an indicator for temp. variations? – LvW 21 hours ago
- continued: But – with reference to the linked TI note, of course, I agree that for a constant current, the Vbe change can be used in a special circuit (as shown) for temp. measurements. – LvW 21 hours ago
- You don’t need a special circuit if your ADC has enough effective bits. But you do need to calibrate. – mkeith 15 hours ago
- @mkeith No. I guess no one here ever reads BJT-as-temperature-sensor research papers from folks who actually research this stuff. For example, there are innumerable papers on using BJTs created on CMOS process technology exactly for this purpose. And that’s only one small category of research papers on this specific topic. Some of the knowledge there would apply to discrete design (not all of it, obviously.) I guess for engineers, it’s work; and unless they work in this field they don’t read research papers just for fun and enjoyment as I do. They have a life. 😉 – jonk 10 hours ago
- Well, @jonk, enlighten us! Or at least give a link or something. LOL. – mkeith 10 hours ago
- 1@mkeith “The temperature characteristics of bipolar transistors fabricated in CMOS technology,” Guijie Wang & Gerard C.M. Meijer, 2000, is one I quickly see on disk here at home (searched, since I knew what to look for in this case.) – jonk 10 hours ago
- @jonk, Many thanks for the reference. Unluckily it is a book costing US$40!. Luckily I googled the book author Meijer and found a free PDF paper also by him: Precision Temperature Measurement Using CMOS Substrate PNP Transistors, M Pertijs, G Meijer, IEEE SENSORS JOURNAL, VOL. 4, NO. 3, JUNE 2004 citeseerx.ist.psu.edu/viewdoc/…. – tlfong01 1 hour ago
4 Answers
TMP36 is specifically a temperature sensor, not an NPN transistor like the 2N2222. You might have them confused because they both can come in TO-92 package. It might be possible to look at the various properties of 2N2222 transistor and correlate it to temperature, but that seems not practical for your applicationshareedit follow flag answered 2 days agosyntax46911 silver badge55 bronze badges
- 11This is the only answer so far that is actually an answer to the question, rather than a science experiment – BeB00 2 days ago
- @BeB00 actually, the use of a BJT as a crude temperature sensor is usually taught in microelectronic courses to stress the dependency of the characteristics from temperaure. If anything, this answer misunderstood the OP intention to create the best temp sensor possible with a single BJT transistor. Scroll down to see actual answers to the question asked. – Sredni Vashtar 45 mins ago
- @SredniVashtar Yes, it is, but thats not what the question was. You can use many different things as temperature sensors, and most of them are not very good (for example, BJT transistors). A system built with the 2N2222 will not be a good temperature sensor without significant calibration and effort. The fact that the poster mentions the TMP36 suggests that they are supposed to use an actual temperature sensor, and OP did not understand that although the two devices look similar, they are very different. You can see from the upvotes that people agree with this comment. – BeB00 25 mins ago
If you connect the transistor as a diode and bias it with a reasonable current, maybe a couple hundred uA, you can read the voltage. It will require calibration (say at room temperature and 0°C in an ice-water slurry.
Sensitivity will be about -2mV/K so with a 5mV resolution ADC you’ll have 2.5 degrees C resolution, not great.
If you connect it as a Vbe multiplier, say with 5:1, and average many measurements you might be able to get a usable resolution of about 0.5°C. Or just use an op-amp.
Edit: Here is a simulation result used as a simple Vbe multiplier.

0°C 3.591V
25°C 3.328V
50°C 3.057V
75°C 2.781V
100°C 2.500V
The current drops as the voltage increases (due to the use of a simple resistor as a current source) so the linearity isn’t great= 11.2mV/K average at 0..25°C and 10.5mV/K average at 75..100°C, but for narrow excursions around room temperature it should be fine, or it can be corrected digitally. With a 10-bit ADC and 5V Vref the resolution is about 0.5°C, which is adequate for many purposes.
There are much better ways to measure temperature with a transistor, however the complexity is increased. Using matched transistors or multiple (2 or 3) currents with a single transistor allows cancellation of many of the transistor parameters that vary from unit to unit, as well as connection resistance. Unfortunately, the sensitivity is reduced by at least an order of magnitude so better analog circuitry is required.
Edit/Epilog:-
I tried this with a single diode-connected BJT (base connected to collector) with a 10K resistor to the regulated (and otherwise unused) 3.3V rail on an Arduino Nano. Reference set to nominal 1.1V as suggested by @EdgarBonet, summed 100 sequential readings.
- Calibrated the voltage by adding a multiplier so the reading was accurate in mV compared to a handheld 3.5 digit DMM.
- Wrote the equation for temperature based on the current room temperature and the mV, with an estimate of -2.0mV/K for the Vbe temperature coefficient.
- Tested it at 0°C and 45°C against a type K bead thermocouple.
- Adjusted the 2.0 to 2.2 to reduce the error at the temperature extremes.
adc *= 1.0532319391 * 0.01; // calibrated voltage in millivolts, 100 summed
temp = -(adc - 556)/2.2 + 24.0;
Works quite well with only one unexpected thing- the INTERNAL1V1 constant was not defined even though the Arduino environment knows it is an ATMega328p (using an Arduino Nano). I added one line to code the definition:
#define INTERNAL1V1 2
analogReference(INTERNAL1V1);
shareedit follow flagedited 14 hours agoanswered 2 days agoSpehro Pefhany264k1111 gold badges218218 silver badges546546 bronze badges
- 1The sensitivity depends inversely on bias current. Lower bias current will give slightly higher sensitivity. And I am not sure but I think maybe a couple hundred microamps will give sensitivity of more like 1.8mV per degree. I think maybe 10uA is enough, but I guess it depends on the ADC leakage current spec. You want the bias current to be much higher than the ADC leakage current. – mkeith 2 days ago
- Note that you need an OP amp in order to read the signal using an Arduino (as the OP mentions in the main question). The Arduino required an impedance of 10kOhm or lower in order to stay within spec for the analog inputs – Ferrybig yesterday
- @Ferrybig There are techniques for allowing several hundred K input impedance without significant error (10n cap + certain delays), or reduce the resistors 5:1 for similar results. – Spehro Pefhany yesterday
- Well, I would just try it. With a cap at the BE junction the AC impedance will be very low. Leakage or resistance looking into the ADC will calibrate out to some extent. – mkeith 23 hours ago
- 2Note that on most Arduinos you can set the voltage reference of the ADC to some internal reference lower than Vcc: 1.1V or 2.56V on AVR boards, 1.0V on the SAMD boards… – Edgar Bonet 21 hours ago
- 1At 1.1V a single diode-connected transistor with a 10K series resistor to +5 would work very nicely. Resolution about 0.5°C. Might have to average a bunch of readings. – Spehro Pefhany 21 hours ago
Question
Can 2N2222 transistor be converted to a temperature sensor, such as TMP36?
Answer
Update 2020oct05hkt2230
After making sure that if I change Rb from 180k to 1M, and Ib changes from 4.2uA to 244uA, I moved on to test Ib, Ic, and Vc at the same time, when changes Rb.
This time I need to use 3 multi-meters. As mentioned earlier, I blindly followed the advice from @glen_geek, using Rb = 1M, and adjust Rc. But I didn’t know why doing this and what to expect when adjusting Rc, I don’t even know why use Rb = 1M.
I used to use 2N2222 as a switch, never for small signal amplification, so actually I always use resistor in the range 470Ω to 10kΩ, never higher that 20kΩ, and 1MΩ is unthinkable, and so I don’t have 1MΩ in my components box. So I use 180kΩ x 6 ~= 1MΩ. I have no confidence of start using 1MΩ directly, so I increment 180kΩ in steps until 1MΩ.
Now the set up and test results is shown below.

I original test plan is something like this.
(1) Vary Rb to get different values of Ib.
(2) For each Ib, I measure corresponding Ic and Vc.
(3) Calculate current gain β. I expected β should be more or less constant, around 245, as measured by my cheapy multi-meter.
(5) Ideally I should get β value around 245.
(6) Next step should be the fun part:
Repeat the above experiment with different temperatures, using ice water for zero degree Celcius, and 90 degree hot water as the other extreme.
Ideally β should decrease when getting cooler, and increase when getting hotter. Then I can calibrate temperature based on beta value, eg, 245 = 25 degrees, 205 = zero degrees, 300 = 90 degrees, etc, then I can do some interpolation. So much for my dream experiment.
However, I had the following unpleasant surprise:
When I changed Ib, Ic always stays no change (the red column). So I cannot get any reasonable change in current gain. In other words, my test plan and dream was broken.
However, I was happy to realize why @glen_geek told me to use Rb = 1MΩ, and vary Rc.
I guess his objective is to vary Rc to move to the small signal amplification operating region, but the saturation region is what I am now.
So I guess I should decrease Rc, to move to the amplification region, then I should find Ic varies with Ib, and β almost constant.
Then I use ice cold water and very hoot water to find how β varies with temperature, and do the calibration, finish my 2N2222 faking TMP36 experiment. 🙂
/ to continue, …
Update 2020oct05hkt1701

Update 2016oct05hkt1027
Apologies and Update
(1) I apologize that earlier I wrongly said that Arduino build in ADC is only 8 bits. Actually Arduino ADC pins are all 10 bit. Many thanks to @marcelm for pointing out my mistake.
(2) Now I think that Arduino with 10 bit ADC is adequate to handle our experiments. So w don’t need to consider Raspberrby Pi, because it is only Rpi which does not have any built in ADC that needs external ADC such as MCP3008.
(3) So I will update my answer and schematic by removing Rpi and external ADC MCP3008.
(4) Because our discussion is exploratory and experimental, I expect to make more mistakes and suggestions which later proved wrong. So I think it is better that we first do discussion, brainstorming, and preferably experiments to verify our suggestions right or wrong, because we update our answers here, frome time to time, or when we reach one milestone.
(5) I would welcome everybody:newbie, ninja, and pros alike,to suggest ideas, and give advice. I do welcome brainstorming suggestions which might prove wrong later, because we are: (a) Doing problem based learning, (b) We learn by making mistakes.
(6) I also wish to point out that I am assuming the OP is of middle school physics level, perhaps a member of his school’s science club, so I hope we can solve their problem without using professional tools, such as college level simulation tools, or prerequisite knowledge too advanced than Ohm’s Law or middle school electricity syllabus.
Yes, no problem, though not a very precise one, and you need the help of an ADC, such as MCP3008/MCP3201. (Errata 2020oct05 – Arduino does not need external ADC, see update above.)

Now let us first look at the temperature dependent part of the 2N2222 characteristics, and see if it is worth doing an experiment or feasibility study.

You see that the DC current gain β(hFE), and collector current Ic changes when temperature changes in the range of 0°C to 50°C.
The current gain β is about 150 at 25°C and increases to 200 when temperature rises to 50°C, and decreases to 100 when temperature drops to 0°C.
We need to design a circuit to perhaps measure the voltage across a resistor when β and Ic changes and calibrate it.
/ to continue, …
References
(1) P2N2222A Amplifier Transistors NPN Silicon – On Semiconductor
(2) TMP36 Voltage Output Temperature Sensors Overview – Analog Devices
(3) TMP36 Voltage Output Temperature Sensors Datasheet – Analog Devices
(4) Low Voltage Temperature Sensors TMP35/TMP36/TMP37 Data Sheet – Analog Devices
(5) TMP36 Temperature Sensor Tutorial – Lady Ada
(6) TMP36 Example Projects – AdaFruit
(7) TMP36 CircuitPython Demo Programs – AdaFruit
(8) AliExpress TMP36 Temperature Sensor Catalog
(9) Analog to Digital Conversion (Introduction, using Arduino as example) – Nate, Sparkfun
(10) 2N2222A Mismatch between emitter and collector – EESE 2014, Viewed 18k times
(11) 2n2222a Datasheet- OnSemi
(12) MMBT2222L, MMBT2222AL, SMMBT2222AL General Purpose Transistors NPN Silicon – On Semi
(15) MMBT2222 (SMD) transistor over 2N2222 (Non SMD) transistor – EE SE 2018
(16) OPA347 MicroPower, Rail-to-Rail Operational Amplifiers – Blur Brown / TI 2007jul
Appendices
Appendix A – TMP36 Overview
Before the 2N2222 faking team attacks the real thing, they need to get to know their enemy. Below is the first spy report coming back.

Appendix B – TMP36 Spec Summary

Appendix C – 2N2222 Based Temperature Sensor Spec

Appendix D – 2N2222 Temperature Coefficients

Appendix E – 2N2222 Testing Record

Appendix F – Warning on 2N2222’s non standard pinout

shareeditdeleteflagedited 45 mins agoanswered 2 days agotlfong011,06244 silver badges77 bronze badges
- 5The dreadful P2N2222 is about to strike again. To the OP: watch out for inverted C and E terminals, if you have a 2N2222. – Sredni Vashtar 2 days ago
- 2@Sredni Vashtar, Many thanks for your very important and critical warning. Do you know why some chips have the two terminals inverted? In my long electronics hobbyist life, I have never heard of such a ridiculously dangerous pinout trap, for newbies, ninjas, and even pros alike. – tlfong01 yesterday
- 1That 2N2222 circuit shown here with one base resistor, and one collector resistor is about the best you can do for a simple temp sensor. However, choice of resistor values depends greatly on transistor HfeHfe, which varies greatly from device-to-device. Try a base resistor of 1Meg, and then choose Rc so that collector voltage is roughly half-way at room temperature. – glen_geek yesterday
- @glen_geek. Ha, many thanks for your instruction, which I think is simple and concise. I must confess I don’t know at all your rationale or theory behind. But it so simple, so I guess both me and the OP which I guess is around 16 old student can also blindly follow your tip, and then do some measurement to see if your circuit might lead to anything promising. Then I will study the datasheet or other theories behind, and try to find why you suggest your design. / to continue, … – tlfong01 yesterday
- I now see our approach is odd, because it is not like the photo transistor, which sort of using CE junction, without electrical but only photo/light input from base. Of course I know I can just use a diode, which according to the (Schottky?) diode equation, is current dependent to temperature. Anyway, I will stop selfie brainstorming, and start experimenting @glen-geek’s geek tip.. – tlfong01 yesterday
- @glen_geek, now I have set up the test circuit to test out your suggestion of using 1MR for Rb, varying Rc and see how it goes. I have also update the circuit and put it at the very top of my answer. Comments and counter suggestions welcome. Cheers. – tlfong01 21 hours ago
- 1tlfong, my opinion is that the pn2n2222 was created for the Japanese market (I have no hard evidence, though) where transistors have usually the CBE pinout, opposite to the customary (but not universally shared) EBC pinout of American and European transistors (I am talking about small signal BJTs – power transistor are another thing and the usually have to middle pin connected to the collector or drain). – Sredni Vashtar 13 hours ago
- 1@tlfong01 Please keep your edits to a minimum and your answers a bit shorter, the answers are a bit long. Thanks – Voltage Spike♦ 30 mins ago
- @Voltage Spike, Thank you for your advice. Actually some of the suggestions and tests in my answer are out of date, misleading and plain wrong. So I have decided to set up a GitHub page, and place the datasheet summaries there. This way I can make my answer perhpas many times shorter, and only refer to my GitHub page for not too relevant details. Thanks again. Cheers. – tlfong01 8 mins ago
If there is an unnecessary operational amplifier in the drawer, a very nice signal can be output from the transistor.
At zero degrees, set 3V at the output with a 47k resistor. Then at 100 degrees with 10k resistor to 1V. (Ice water or boiling water.)
Of course, if you only use it on your own machine, calibration can be purely with software.shareedit follow flag answered 13 hours agocsabahu1,54155 bronze badges
- 1You probably meant to write ‘potentiometer’ instead of resistor. – Sredni Vashtar 12 hours ago
- 1Almost. A smaller potentiometer with which the ratio of the given resistors can be fine-tuned. For example, a 2k potentiometer between 47k and 10k. Here, it is not the absolute value of the resistance that is interesting, but the voltage setting of the non-inverting input. Of course, this is only needed if we want to calibrate the thermometer. – csabahu 11 hours ago
- @csabahu, Ah, your colourful schematic is looking nice, and the opAmp Vout vs Temperature chart is impressively ideal. So I will search my jun bin for an opAmp and try it out. – tlfong01 2 hours ago
Question
Can 2N2222 transistor be converted to a temperature sensor, such as TMP36?
Answer
Update 2020oct05hkt2230
After making sure that if I change Rb from 180k to 1M, and Ib changes from 4.2uA to 244uA, I moved on to test Ib, Ic, and Vc at the same time, when changes Rb.
This time I need to use 3 multi-meters. As mentioned earlier, I blindly followed the advice from @glen_geek, using Rb = 1M, and adjust Rc. But I didn’t know why doing this and what to expect when adjusting Rc, I don’t even know why use Rb = 1M.
I used to use 2N2222 as a switch, never for small signal amplification, so actually I always use resistor in the range 470Ω to 10kΩ, never higher that 20kΩ, and 1MΩ is unthinkable, and so I don’t have 1MΩ in my components box. So I use 180kΩ x 6 ~= 1MΩ. I have no confidence of start using 1MΩ directly, so I increment 180kΩ in steps until 1MΩ.
Now the set up and test results is shown below.

I original test plan is something like this.
(1) Vary Rb to get different values of Ib.
(2) For each Ib, I measure corresponding Ic and Vc.
(3) Calculate current gain β. I expected β should be more or less constant, around 245, as measured by my cheapy multi-meter.
(5) Ideally I should get β value around 245.
(6) Next step should be the fun part:
Repeat the above experiment with different temperatures, using ice water for zero degree Celcius, and 90 degree hot water as the other extreme.
Ideally β should decrease when getting cooler, and increase when getting hotter. Then I can calibrate temperature based on beta value, eg, 245 = 25 degrees, 205 = zero degrees, 300 = 90 degrees, etc, then I can do some interpolation. So much for my dream experiment.
However, I had the following unpleasant surprise:
When I changed Ib, Ic always stays no change (the red column). So I cannot get any reasonable change in current gain. In other words, my test plan and dream was broken.
However, I was happy to realize why @glen_geek told me to use Rb = 1MΩ, and vary Rc.
I guess his objective is to vary Rc to move to the small signal amplification operating region, but the saturation region is what I am now.
So I guess I should decrease Rc, to move to the amplification region, then I should find Ic varies with Ib, and β almost constant.
Then I use ice cold water and very hoot water to find how β varies with temperature, and do the calibration, finish my 2N2222 faking TMP36 experiment. 🙂
/ to continue, …
Update 2020oct05hkt1701

Update 2016oct05hkt1027
Apologies and Update
(1) I apologize that earlier I wrongly said that Arduino build in ADC is only 8 bits. Actually Arduino ADC pins are all 10 bit. Many thanks to @marcelm for pointing out my mistake.
(2) Now I think that Arduino with 10 bit ADC is adequate to handle our experiments. So w don’t need to consider Raspberrby Pi, because it is only Rpi which does not have any built in ADC that needs external ADC such as MCP3008.
(3) So I will update my answer and schematic by removing Rpi and external ADC MCP3008.
(4) Because our discussion is exploratory and experimental, I expect to make more mistakes and suggestions which later proved wrong. So I think it is better that we first do discussion, brainstorming, and preferably experiments to verify our suggestions right or wrong, because we update our answers here, frome time to time, or when we reach one milestone.
(5) I would welcome everybody:newbie, ninja, and pros alike,to suggest ideas, and give advice. I do welcome brainstorming suggestions which might prove wrong later, because we are: (a) Doing problem based learning, (b) We learn by making mistakes.
(6) I also wish to point out that I am assuming the OP is of middle school physics level, perhaps a member of his school’s science club, so I hope we can solve their problem without using professional tools, such as college level simulation tools, or prerequisite knowledge too advanced than Ohm’s Law or middle school electricity syllabus.
Yes, no problem, though not a very precise one, and you need the help of an ADC, such as MCP3008/MCP3201. (Errata 2020oct05 – Arduino does not need external ADC, see update above.)

Now let us first look at the temperature dependent part of the 2N2222 characteristics, and see if it is worth doing an experiment or feasibility study.

You see that the DC current gain β(hFE), and collector current Ic changes when temperature changes in the range of 0°C to 50°C.
The current gain β is about 150 at 25°C and increases to 200 when temperature rises to 50°C, and decreases to 100 when temperature drops to 0°C.
We need to design a circuit to perhaps measure the voltage across a resistor when β and Ic changes and calibrate it.
/ to continue, …
References
(1) P2N2222A Amplifier Transistors NPN Silicon – On Semiconductor
(2) TMP36 Voltage Output Temperature Sensors Overview – Analog Devices
(3) TMP36 Voltage Output Temperature Sensors Datasheet – Analog Devices
(4) Low Voltage Temperature Sensors TMP35/TMP36/TMP37 Data Sheet – Analog Devices
(5) TMP36 Temperature Sensor Tutorial – Lady Ada
(6) TMP36 Example Projects – AdaFruit
(7) TMP36 CircuitPython Demo Programs – AdaFruit
(8) AliExpress TMP36 Temperature Sensor Catalog
(9) Analog to Digital Conversion (Introduction, using Arduino as example) – Nate, Sparkfun
(10) 2N2222A Mismatch between emitter and collector – EESE 2014, Viewed 18k times
(11) 2n2222a Datasheet- OnSemi
(12) MMBT2222L, MMBT2222AL, SMMBT2222AL General Purpose Transistors NPN Silicon – On Semi
(15) MMBT2222 (SMD) transistor over 2N2222 (Non SMD) transistor – EE SE 2018
(16) OPA347 MicroPower, Rail-to-Rail Operational Amplifiers – Blur Brown / TI 2007jul
Appendices
Appendix A – TMP36 Overview
Before the 2N2222 faking team attacks the real thing, they need to get to know their enemy. Below is the first spy report coming back.

Appendix B – TMP36 Spec Summary

Appendix C – 2N2222 Based Temperature Sensor Spec

Appendix D – 2N2222 Temperature Coefficients

Appendix E – 2N2222 Testing Record

Appendix F – Warning on 2N2222’s non standard pinout

Update 2020oct05hkt2230
After making sure that if I change Rb from 180k to 1M, and Ib changes from 4.2uA to 244uA, I moved on to test Ib, Ic, and Vc at the same time, when changes Rb.
This time I need to use 3 multi-meters. As mentioned earlier, I blindly followed the advice from @glen_geek, using Rb = 1M, and adjust Rc. But I didn’t know why doing this and what to expect when adjusting Rc, I don’t even know why use Rb = 1M.
I used to use 2N2222 as a switch, never for small signal amplification, so actually I always use resistor in the range 470Ω to 10kΩ, never higher that 20kΩ, and 1MΩ is unthinkable, and so I don’t have 1MΩ in my components box. So I use 180kΩ x 6 ~= 1MΩ. I have no confidence of start using 1MΩ directly, so I increment 180kΩ in steps until 1MΩ.
Now the set up and test results is shown below.
[![pn2222 test][1]][1]
I original test plan is something like this.
(1) Vary Rb to get different values of Ib.
(2) For each Ib, I measure corresponding Ic and Vc.
(3) Calculate current gain β. I expected β should be more or less constant, around 245, as measured by my cheapy multi-meter.
(5) Ideally I should get β value around 245.
(6) Next step should be the fun part:
Repeat the above experiment with different temperatures, using ice water for zero degree Celcius, and 90 degree hot water as the other extreme.
Ideally β should decrease when getting cooler, and increase when getting hotter. Then I can calibrate temperature based on beta value, eg, 245 = 25 degrees, 205 = zero degrees, 300 = 90 degrees, etc, then I can do some interpolation. So much for my dream experiment.
However, I had the following unpleasant surprise:
When I changed Ib, Ic always stays no change (the red column). So I cannot get any reasonable change in current gain. In other words, my test plan and dream was broken.
However, I was happy to realize why @glen_geek told me to use Rb = 1MΩ, and vary Rc.
I guess his objective is to vary Rc to move to the small signal amplification operating region, but the saturation region is what I am now.
So I guess I should decrease Rc, to move to the amplification region, then I should find Ic varies with Ib, and β almost constant.
Then I use ice cold water and very hoot water to find how β varies with temperature, and do the calibration, finish my 2N2222 faking TMP36 experiment. 🙂
/ to continue, …
Update 2020oct05hkt1701
[![2n2222 test 1][2]][2]
Update 2016oct05hkt1027
Apologies and Update
(1) I apologize that earlier I wrongly said that Arduino build in ADC is only 8 bits. Actually Arduino ADC pins are all 10 bit. Many thanks to @marcelm for pointing out my mistake.
(2) Now I think that Arduino with 10 bit ADC is adequate to handle our experiments. So w don’t need to consider Raspberrby Pi, because it is only Rpi which does not have any built in ADC that needs external ADC such as MCP3008.
(3) So I will update my answer and schematic by removing Rpi and external ADC MCP3008.
(4) Because our discussion is exploratory and experimental, I expect to make more mistakes and suggestions which later proved wrong. So I think it is better that we first do discussion, brainstorming, and preferably experiments to verify our suggestions right or wrong, because we update our answers here, frome time to time, or when we reach one milestone.
(5) I would welcome everybody:newbie, ninja, and pros alike,to suggest ideas, and give advice. I do welcome brainstorming suggestions which might prove wrong later, because we are: (a) Doing problem based learning, (b) We learn by making mistakes.
(6) I also wish to point out that I am assuming the OP is of middle school physics level, perhaps a member of his school’s science club, so I hope we can solve their problem without using professional tools, such as college level simulation tools, or prerequisite knowledge too advanced than Ohm’s Law or middle school electricity syllabus.
Yes, no problem, though not a very precise one, and you need the help of an ADC, such as MCP3008/MCP3201. (Errata 2020oct05 – Arduino does not need external ADC, see update above.)
[![2n2222 temp sensor][3]][3]
Now let us first look at the temperature dependent part of the 2N2222 characteristics, and see if it is worth doing an experiment or feasibility study.
[![2n2222 temp char][4]][4]
You see that the DC current gain β(hFE), and collector current Ic changes when temperature changes in the range of 0°C to 50°C.
The current gain β is about 150 at 25°C and increases to 200 when temperature rises to 50°C, and decreases to 100 when temperature drops to 0°C.
We need to design a circuit to perhaps measure the voltage across a resistor when β and Ic changes and calibrate it.
/ to continue, …
Appendix A – TMP36 Overview
Before the 2N2222 faking team attacks the real thing, [they need to get to know their enemy][19]. Below is the first spy report coming back.
[![tmp36 overview][20]][20]
Appendix B – TMP36 Spec Summary
[![tmp36 spec][21]][21]
Appendix C – 2N2222 Based Temperature Sensor Spec
[![2n2222 fake][22]][22]
Appendix D – 2N2222 Temperature Coefficients
[![2n2222 temp coefficients][23]][23]
Categories: Uncategorized