# Are these MOSFETs wired correctly?

I have an ESP32 that I'm trying to use to control a motor and a water-level sensor. Both of these devices are 12 V DC, so I'm using a DC-DC converter that takes 12 V input and outputs both 5 V and 12 V. The 5 V powers the ESP32 while the 12 V supplies the devices.

The devices are power gated with P30N06LE MOSFETs, and these are activated via GPIO pins on the ESP32.

The problem is that I am only getting readings from the water-level sensor when the DC motor is powered.

The circuit diagram doesn't show the two momentary push buttons wired to other GPIO pins. When the first of these is pushed the embedded code sets the motor MOSFET gate to HIGH, thereby powering the motor. When the second button is pushed the water-level MOSFET gate is set HIGH, thereby powering the water-level sensor. Each MOSFET is set LOW when the relevant button is released.

The loop() code looks to see if the push button associated with the water-level sensor is HIGH, and if so takes an AnalogRead() of the sensor wire connected at A2, and sets a globally scoped int variable, WATER_LEVEL_VALUE, to that value, e.g. WATER_LEVEL_VALUE = AnalogRead(WATER_LEVEL_SENSOR);.

When the push button associated with the motor MOSFET is pressed, the motor powers up as expected, then stops when the button is released.

When the push button associated with the water-level MOSFET is pressed, WATER_LEVEL_VALUE remains at zero.

I have tried making the AnalogRead() run if EITHER switch is pressed, and I do get a value in WATER_LEVEL_VALUE when the motor MOSFET is activated, which is not ideal, because the two devices need to operate independently.

It seems like I might have a wiring problem, because the water-level sensor should not be powered by the motor MOSFET being activated.

Some assumptions about the diagram. I was limited by parts in Fritzing, so:

• I'm using an ESP32 S2 Saola, not the pictured Nano
• The DC-DC converter I'm using has separate output for 5 V and 12 V. I have used the NC connectors in the circuit to depict 5 V. I have added another image of the actual converter that I'm using.

• Welcome! Please draw a schematic using the built in function here on EE.SE. Click on edit and then the schematic symbol. Draw your schematic and press insert. Jun 24 at 7:39
• tangential: you are missing a reverse polarity diode in parallel with the motor, which prevents the motor from possibly damaging the MOSFET when it turns off. Keyword: "freewheeling diode" Jun 24 at 10:36