Connecting 5V devices to Photon?

For the MQ135 this is already done via the load resistor Rl which builds a voltage divider that can be calculated via Ohm’s Law.
You just need to choose an Rl less than the minimal expected Rs times 2 (Rl < 2 * Rs,min).
Rl = 2*Rs,min would give you a voltage drop of Vcc * 1/3 across Rs leaving you with Vcc * 2/3 on your sensor pin (5V * 2/3 = 3.3333V - just a bit too much, hence less than! Best with some margin for tolerance of resistance, voltage and temp drift).

If you have other sensors that actively output up to 5V (and you don’t know the output impedance) you might want an OpAmp circuit with a voltage devider in the feedback loop.

like here

1 Like