12 sensor connected to an ESP32. Since the ESP32 works with 3.3 V and the sensor output voltage is 5 Vdc. I added a level shifter, in particular this level shifter mosfet.

Basically I have:

  1. 12 Vdc to power the sensor and the ESP32;
  2. A 12 Vdc to 3.3 V regulator and a 12 Vdc to 5 Vdc regulator;
  3. Common GND between ESP32 and sensor and power supplies;
  4. The sensor goes on HV1 and PIN of ESP32 for SDI goes to LV1 of the MOSFET level shifter;
  5. LV connected to 3.3 V, HV connected to 5V dc

List item

If I test with this setup I have some sort of offset from 0 V on the 3.3 V side, so the ESP does not detect the response.

enter image description here

If I use a simple voltage divider everything works properly.

In this case the voltage generator is the sensor output and the signal indicated with 3.205 is where I connected the input pin of the ESP32, GND in common.

enter image description here

Am I doing something wrong?

  • \$\begingroup\$ Check that your HV1 output is fully going to 0 volts when it should. \$\endgroup\$
    – Andy aka
    Aug 22, 2022 at 14:54
  • \$\begingroup\$ Are you actually using the SparkFun level shifter PCB (from SparkFun), or just their schematic? What is the magnitude of the offset? If your sensor does clock stretching, does the clock level shifter channel have the same issue? Can you add the 5V side of the level shifter to the scope trace? Does it happen if you use a different channel of the level shifter? \$\endgroup\$
    – W5VO
    Aug 22, 2022 at 14:58
  • \$\begingroup\$ @W5VO yes, sparkfun, no, I'm using only this signal, since I have only this output from the sensor, I'll try to check the HV side as suggested \$\endgroup\$
    – D_A_8
    Aug 22, 2022 at 15:10
  • 2
    \$\begingroup\$ Looks like a diode drop. Is the FET backwards? \$\endgroup\$
    – Aaron
    Aug 22, 2022 at 15:13
  • \$\begingroup\$ Unless you haven't switched LV and HV as Aaron stated, are you sure that the high side "HV1" is pulled to GND and not to the 0.5V-ish offset you see ? \$\endgroup\$
    – Rahmany
    Aug 23, 2022 at 13:41

1 Answer 1


If you have the gate connected to LV1 (or 0V) rather than LV you'll get that waveform.

enter image description here

That's because there is insufficient Vgs to turn the MOSFET on and only the body diode conducts.

If the MOSFET is not a BSS138 or equivalent you could also get similar behavior because Vgs(th) is too high.

  • \$\begingroup\$ Nope, Gates are connected to 3V3(LV) or 5Vdc(HV) \$\endgroup\$
    – D_A_8
    Aug 23, 2022 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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