I would like to design a flexible input interface for my embedded device, which will see a mixture of sensors connected. The sensors themselves (e.g. thermistors) will be two-wire, with the data/signal wire being pulled up to 5V prior to interfacing with an ADC. The issue I'm trying to address is that some sensors will interface with my device, which will then provide 5V pullup and GND, whereas some sensors will have an external 5V pullup and GND, with the single data/signal line interfacing with the device.

Example of case 1 (unpowered):

Unpowered sensor interfacing with the device (blue box)

Example of case 2 (powered):

enter image description here

Is there a way I can design the device circuitry to account for both scenarios? I would ensure the device GND is shared with the powered sensor GND, so my focus is on the 5V pullup. Can I use an IC of some sort to enable/disable the pullup resistor, such that the line up to 5V is open-circuited for powered sensors?


1 Answer 1


Some sort of analogue switch or FET in series with the pull-up will do fine here.


simulate this circuit – Schematic created using CircuitLab

NOTE: This is a P-Channel MOSFET, and note that the Source is at the top. This is because with MOSFETs, you need to be able to control/know what Vg and Vs are (i.e. to control it with Vgs). We don't know what the sensor voltage is/could be, so we need to tie that to the drain. We know 5V (when O/C) is at the Source, and so we can turn it on by changing the voltage relative to this at the Gate.

Since N-Channel MOSFETs are off when Vgs is 0V (i.e. when we would have 5V at the gate, too), and on when Vgs is positive (e.g. 5V), we would need greater than 5V to turn it on in this case (i.e. some sort of monster 10V I/O microcontroller). On the contrary, with P-Channel MOSFETs, they are off when Vgs is 0V too (i.e. when we have 5V at the gate), and are ON when Vgs is negative (e.g. -5V). When we make the microcontroller apply logic low (0V) to the gate, the Vgs is (0-5) = -5V, and so the P-Channel MOSFET will turn on, and the data line will be pulled high.

Edit following some additional queries/clarifications in the comments below: I'm considering using the following circuit to provide the necessary 0V Vgs to turn off the p-channel MOSFET. As this circuit inverts the logic, the default microcontroller GPIO output (low) will cause a 5V level to be applied to the MOSFET Gate, which will result in a 0V Vgs, turning off the MOSFET. Applying a high signal to the transistor will drive 0V to the MOSFET Gate, cause a -5V Vgs, turning on the MOSFET.

Logic level conversion and inversion from 3V3 to 5V

  • \$\begingroup\$ Brilliant, thank you. To confirm, I would drive the Gate pin low with my microcontroller for an unpowered sensor (i.e. requiring pullup to 5V), and drive the Gate pin high with my microcontroller for a powered sensor (i.e. leaving the pullup to 5V as an open circuit)? \$\endgroup\$
    – jars121
    Feb 27, 2018 at 2:04
  • \$\begingroup\$ A supplementary query: if I'm using a 3V3 logic level, pulling the Gate high will still result in a negative Vgs, so I'd need to pull the Gate to 5V to turn off the MOSFET? \$\endgroup\$
    – jars121
    Feb 27, 2018 at 2:24
  • \$\begingroup\$ Or could I find a P-Channel MOSFET which will still be off with a -1.7V Vgs? \$\endgroup\$
    – jars121
    Feb 27, 2018 at 2:55
  • \$\begingroup\$ I've just realised an additional requirement for the MOSFET to be off when the device is powered on. As such, perhaps an N-channel MOSFET would be more appropriate, with a transistor to turn on a ~12V Gate voltage from the 3V3 GPIO? This way, the MOSFET would be off by default, preventing the case of pulling up an already powered sensor to 5V. \$\endgroup\$
    – jars121
    Feb 27, 2018 at 3:54
  • \$\begingroup\$ I'm not sure what you are meaning sorry, haha. Your logic level is 3.3V but you still have access to a 5V rail? Then you should probably make the pullup resistor pulled up to 3.3V, not 5V. In that case, you can choose a appropriate transistor - like you said - which will turn off with -3.3V Vgs. As for the last comment, you could just have a pull-up resistor on the gate of the FET :) so when the microcontroller is off, the FET will also be off. \$\endgroup\$
    – DSWG
    Feb 27, 2018 at 4:21

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.