I am interfacing MQ7 gas sensor https://www.sparkfun.com/products/9403 with esp32. MQ7 is a carbon monoxide sensor which requires two cycles to work.

It requires 90 seconds cycle to release absorbed gas (by powering it with 5V) and 60 seconds cycle to start absorbing CO (by powering it with 1.5V). I have written code to achieve this toggle on a GPIO of esp32.

I have designed following circuit to achieve the toggle.

enter image description here

In this circuit, RH is the resistance of the MQ7 sensor. If I apply 0V on Base, VRH = 1.5V (precise) If I apply 3.3V on Base, VRH = 4.84V (instead of 5V)

Fore time being, I am using Powerbank for 5V Vcc supply.

The problem I am facing is that due to large VCE saturation of pn2222 (max=1V), I am unable to get 5V during saturation phase.

I think I can use a Transistor with small VCE saturation to resolve this issue? Should I do it? Or there is better alternative available?


  • \$\begingroup\$ Did I correctly read a 48 hour pre-heat time on that datasheet? Or is that just for testing the device? \$\endgroup\$ – jonk Mar 8 '20 at 22:13
  • \$\begingroup\$ Yes. For it's best working, preheat is mandatory. Otherwise readings may not be precise as they claim. \$\endgroup\$ – Amir Salman Mar 8 '20 at 23:06
  • \$\begingroup\$ So, what you really need is a switchable 5 V and 1.5 V supply for the heater element, where you reduce it to 1.5 V while taking a measurement, and a separate continual 5 V supply for the measurement across the load resistor? Or does that 5 V measurement supply have to be turned off? And is all this why you included the 80 Ohm resistor? Did you notice the range of resistance in the heater element and also note that this range is only true at room temp? \$\endgroup\$ – jonk Mar 8 '20 at 23:41
  • \$\begingroup\$ I'm going to toss out a thought. With 5 V applied for 48 hours, the device will heat up to some temperature. The steady state temperature will be different from device to device, whose resistance may vary from 26 to 32 Ohms, when 5 V is applied. This temperature will be different in different ambient environments. This temperature will be different with different circuit board arrangements. In short, you can probably expect a lot of temperature variation across situations. You may want to test its repeatability over these differences. You may learn something important. \$\endgroup\$ – jonk Mar 9 '20 at 0:12
  • \$\begingroup\$ "5V±0.1V" this device is fussy, TTL only needs is 5V±0.25V \$\endgroup\$ – Jasen Mar 9 '20 at 7:39

If you want lower voltage, you can use a MOSFET, for example, AO3400A which has a maximum 32m\$\Omega\$ Rds(on) with 5V drive. The maximum current draw at room temperature and 5V is 217mA, so less than 10mV drop.

However I don't think your series resistor is adequate to guarantee 1.5V +/-100mV during the measure phase, which may be more critical. The tolerance of the resistance is +/-10% and it may change with temperature and self heating.

You could consider using a small regulator such as this one to get 1.50V and shunting the feedback network to get the dropout resistance. This would also provide a power-down function through the enable pin.

  • \$\begingroup\$ Thanks alot. I will get this regulator asap then. \$\endgroup\$ – Amir Salman Mar 13 '20 at 7:21
  • \$\begingroup\$ I have tried using MOSFET. I already had one in my stuff IRF540N. It has V_GS_threshold = 2 to 4 V. Although i want one whose threshold voltage is less than 3.3V. But the issue is that i tried the same circuit as above and replaced the BJT with MOSFET, it never enters the saturation mode. I tried applying V_GS up to 10V and couldn't get it to work. It enter the saturation mode only if I remove Rx. Can you please explain what is going on? Thanks in advance. \$\endgroup\$ – Amir Salman Mar 13 '20 at 7:47
  • \$\begingroup\$ No, that doesn't make much sense. Check your connections. IRF540N is unsuitable for 3.3V drive Vgs(th) means it conducts a few hundred uA, not fully on. \$\endgroup\$ – Spehro Pefhany Mar 13 '20 at 12:24

VCE saturated on the OnSemi PN2222 is less than 0.1V at 150mA or less (datasheet figure 11)

With nearly 150mA through the transistor you'll need 15mA or more into the base to meet the requiremnts of that graph your 100 ohm resistor should work fine for this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.