# Regarding push pull solenoid with a raspberry pi3

#### Raj Waghmare

Joined May 8, 2019
30
hello guys,
I have made a circuit of connecting a 5V push pull solenoid with a Rapberry PI but its not working. I have attached a circuit diagram where i have used an N channel mosfet of 60V 30A and diode rectifier with 1A 50V and a resistor of 10KR. I have also written a code please do have a look and tell me whas wrong.

Here,s the code:
Code:
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module

GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BCM) # Use physical pin numbering
GPIO.setup(10, GPIO.OUT, initial=GPIO.LOW) # Set GPIO 10 to be an output pin and set initial value to low (off)

while True: # Run forever
GPIO.output(10, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second
GPIO.output(10, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second

#### Attachments

• 95.1 KB Views: 15

#### Sensacell

Joined Jun 19, 2012
2,567
First tell us what's wrong?

Does the code compile?

Does the IO pin change state?

What type of FET is it?

Be more specific.

#### Sensacell

Joined Jun 19, 2012
2,567
Does the IO pin change state? (read with a DC voltmeter)

How are you powering the solenoid? Volts?

What is the resistance of the solenoid? Ohms?

#### Raj Waghmare

Joined May 8, 2019
30
I have just checked the GPIO it is changing the state

#### Sensacell

Joined Jun 19, 2012
2,567

Check that your power supply can supply the 1.1 A required.

The FET you are using is not very good for a 5V gate drive- look at the data sheet
To really saturate it you need more like 10V

It might work, but you really need an FET designed for lower gate voltage.

#### Raj Waghmare

Joined May 8, 2019
30

Check that your power supply can supply the 1.1 A required.

The FET you are using is not very good for a 5V gate drive- look at the data sheet
To really saturate it you need more like 10V

It might work, but you really need an FET designed for lower gate voltage.
Acc to you what should I do?? Please suggest or re wired the circuit diagram. It would be so grateful of you as i am so confused in it hence getting no clue what to do.

#### Raj Waghmare

Joined May 8, 2019
30
Should i give external power supply to it. If thats the case what should be my circuit diagram??

#### Sensacell

Joined Jun 19, 2012
2,567
See the sketch attached.

#### Attachments

• 194 KB Views: 9

#### Raj Waghmare

Joined May 8, 2019
30
Sorry it didnot work. Could you please once check with the code whether its proper or not?? I am not able to figure it out whats wrong

#### Sensacell

Joined Jun 19, 2012
2,567
I have just checked the GPIO it is changing the state
So then the problem is not the code.

Double-check the wiring, and pin connections on the FET.

#### Raj Waghmare

Joined May 8, 2019
30
I again built the circuit checked the wires twice still its not working.

In the code when i am exiting it manually by the keyboard input it is saying

^CTraceback (most recent call last):
File "button.py", line 12, in <module>
time.sleep(1) # Sleep for 1 second

#### Raj Waghmare

Joined May 8, 2019
30
Could you please suggest me one which is suitable for the circuit??

#### Sensacell

Joined Jun 19, 2012
2,567
This one

#### Attachments

• 481.2 KB Views: 5

#### Raj Waghmare

Joined May 8, 2019
30
I changed the mosfet and still i got voltage in pV.

#### Attachments

• 13.6 KB Views: 5

#### Raj Waghmare

Joined May 8, 2019
30
I have measured the voltage it is providing the voltage what we are giving to the solenoid but not enough current to run it. It is giving 0.004A of current while I need 0.8A min to run the solenoid. Whats wrong here????

#### djsfantasi

Joined Apr 11, 2010
6,196
With 12V to the drain, even with a logic level MOSFET, the difference between the gate and drain voltage may be too great. You may need a driver for the solenoid mosfet.

I used a P-channel MOSFET to switch the high side (IRF9Z34P). I couldn’t drive it directly, (had similar issues to you), so I fed the P-channel with a logic level N-channel MOSFET (p2N7000). The drain to gate junction of the two MOSFETs had a pull up resistor to 12VDC.

The bottom lower-left line is connected to an Arduino. But the signal on that line was 5VDC. However, it should work. You may be able to use two N-channel MOSFETs, but your logic will be inverted.