Control variable external power supply

Dears,

I'm currently working on an air pollution controller project and I have a trouble to control an external power supply to supply 5v, 1.5v or 0v to an MQ7 gas sensor.

Using the direct PWM output to power the MQ7 is a bad idea because it drains 150mA at 5v for heating. I planned to control the voltage through a NPN transistor. The voltage of 5v and 1.5v are important to be sure that the output values are consistent.

I started with Experiment 1 which was to obvious way of achieving it for me (see pictures enclosed for breadboard and schematics). The PIN 2 (PWM) controls the S8850.

With Experiment 1:

  • Voltage measured at points A and B.
  • Without the MQ7, the voltage was just great (5v, 1.5v and 0v depending on analogWrite() values)
  • With the MQ7, the voltage dropped at 3.8v, 1.1v and 0v with the same analogWrite() values)

With Experiment 2:

  • External supply for the MQ7.
  • Voltage measured at points A and B.
  • With the MQ7, the voltage is correct (5v, 1.5v and 0v with the same analogWrite() values)... as long as I provide 8v on the external power supply.

I checked the internet and all schematics use direct output of the Arduino to power the MQ7. IMHO, it could work for an experiment of some cycles in the lab but not for a long-term solution.

The usage of an 8v additional power supply is not convenient and I'm pretty sure that it is possible to have a better schematics to select the 3 different voltage easily from the Arduino.

Any ideas how to achieve it?

Kind regards,
Olivier