Go Down

Topic: [SOLVED]help with transistor recomendation. (Read 599 times) previous topic - next topic


Aug 31, 2018, 02:04 am Last Edit: Sep 01, 2018, 04:24 am by surepic
This circuit is working great no voltage spikes or ripples everything is stable. Now the issue that I come across.
mq sensors need warmup time to stabilise resistance which in my case can be done through arduino pins. First I wanted to make buzzer circuit independent from arduino but I have no idea how to add delay without adding rtc timer to the circuit. So I thought the cheapest and most convenient way would be to add NPN transistor between comparator output which is giving 0 volts when sensor`s resistance is dropping and   +5v when is within reference (via pot).

Now if I will add NPN transistor: LM393 output-collector, base to arduino pin pulled low and emitter to buzzer.  This way I can control preheating time of around 5mins to stabilise sensor before reading it or triggering hardware interrupt.

Question is is the modification I`m going to do seems right ? if yes then do I need resistor between pins of transistor?

And of course if there are any suggestions or if whole circuit can be improved without major modifications will really appreciate.

the part that I want to put transistor I highlighted with circle and line at the bottom of the schematic.



Aug 31, 2018, 04:09 am Last Edit: Aug 31, 2018, 04:35 pm by CurtCarpenter
If I'm understanding you (and I may not be!) )It looks to me like you are wanting to connect the emitter of your NPN transistor to the output of your voltage regulato, through the buzzer and that 220 Ohm resistor.  If that's right (?), the base-emitter junction of the transistor will always be reverse biased, so no current will ever flow from the transistor's collector to its emitter.  That's not what you're after.

Can you add the transistor to your (very nice!) diagram to clarify your description?

PS -- what program did you use to draw your schematic?  Nice.


Aug 31, 2018, 04:33 am Last Edit: Aug 31, 2018, 04:59 am by surepic
Actually i come up with another idea using lm393 second comparator to take output from comparator1 to inverted input of comparator2 and arduino pin to non inverted input of comparator2 then after warmup inverse pin from high to low. I would need some resistance there though which have to probe through pot at first.

To answer your question yes i was going to do exact that way and i dont need any current flow it will act as a off switch before warmup but after warmup as comparators output will shift to vcc side and base will get 5v from arduino pin it will open collector emitter junction. Im not good at transistora but logically must work like that.

Program for circuits im using eagle from autodesk.


explanation of my logic.
lm393 ic consists of 2 independent comparators in 1 package and not to add extra hardware thought of using second comparator of lm393 that currently am not using.

comparator 1
inverting input(-)
noninverting input(+)
before warmup output (-)
after warmup output(+)

comparator 2
noninverting input(output from comparator 1(+)) will always be higher then clean gnd
inverting input(from arduino pin low(-)) 0v/gnd
output from comparator 2 before comparator 1 warmup (+)
after 5 minutes full warmup comparator 1 will output (+)

case 1:
inversing signal from LOW to HIGH from arduino
noninverting input (output from comparator 1(+)) always below VCC
inverting input from arduino pin HIGH(+)) right at VCC level

so output of comparator 2 will be (-)

case 2:
inversing signal from LOW TO HIGH from arduino + voltage divider for 4.3v
noninverting input (output from comparator 1(+) below vcc
inverting input from arduino pin HIGH(+)) 4.3v

after warmup output of comparator1 is around vcc level

so output of comparator 2 will be (+);

if sensor will change resistance output of comparator 1 will drop to 0 that will cause noninverting input of comparator 2 to go below 4.3v level which will shift output to gnd level.

Am I right ?


Aug 31, 2018, 05:00 am Last Edit: Aug 31, 2018, 05:01 am by jremington
I would eliminate the comparator(s) and associated circuitry entirely. Since the Arduino is already monitoring the output of the sensor, it can determine whether stability has been achieved and time the process as well. No RTC required, as a timer with 0.5-1% accuracy is built in.

The Arduino can also activate the buzzer, possibly needing a transistor current booster.

You are of course aware that all the MQ sensors require a 24 to 48 hour burn in time. Excellent, comprehensive tutorial here.


with current schematic mq2 will activate buzzer regardless arduino is working or no.
so thats said I tried to eliminate controller dependency as much as possible . but was stucked with warmup time issue that I tried to explained.
about warmup time:

mq2 sensors that I tested for long period of time require preheating for 72 hours at least only at first warmup after that they are reaching to their resistance within 30minutes.

but not to wait 30 minutes to get kinda exact resistance I decided to go with 5mins may be will need another 5mins .... have to test.



Aug 31, 2018, 05:08 am Last Edit: Aug 31, 2018, 05:08 am by jremington
was stucked with warmup time issue
Why? Just read the sensor (every 30 seconds or so) in a loop and exit when the reading has stabilized.


Aug 31, 2018, 05:14 am Last Edit: Aug 31, 2018, 05:20 am by surepic
I`m reading resistance in code after warmup only but alarm circuit needs to be independant from microcontroller as much as possible. Arduino is processing data from 4 esp modules in realtime plus acting as a web server for users .... and is doing bunch of stuff. I dont want alarm circuit which purpose is to activate buzzer to depend on arduino. right now its fully independant even if I will cut power from arduino or esp then alarm circuit will still work. but as of warmup issue I want arduino at least to do 1 thing after 5 or 10 mins switch 1 pin from low to high or vice versa and thats it. or if with transistor just change the state of the pin for comparator to do its work.

just to clarify situation. Within warmup period buzzer is on because of low resistance of sensor before warmup. after warmup buzzer is off and will go on only when smoke will be detected and sensors resistance will drop below reference point which is controlled via pot .



Thanks for the pointer to Eagle surepic.  Are you using the free download version?  How long did it take you to learn to use it?  Which operating system are you using it with?


No im using licensed full version.
Took me roughly 5 hours to learn enough to use it. Win10

Now back yo my transistor question. How to implement transistorized solution?


Thanks!  I'll check out the free version of Eagle if I can find one that's for 32-bit Linux.

Don't think I can provide anything more on the transistor issue.  Sorry.  I'm sure you'll find a way forward.


Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.



Thanks for the link to Autodesk.  Alas, the newer versions for Linux are 64-bit only now, and I'm still running 32-bit.
I found a link to an archived 32-bit version here though:  http://eagle.autodesk.com/eagle/software-versions/2  and the install under Ubuntu Linux was painless.  (Note for others: the 32-bit version at this link uses a .run script that you need to execute from a terminal, not from the graphics environment). 

Looking forward to exploring it!


Go Up