Basic Op Amp Question
It sounds like you want your Raspberry Pi to be able to control/provide a variable voltage supply for a 5V fan. I'll give you credit that you realized your RPI's pins don't have enough current to power the fan even though they have enough voltage.

This next part is to educate you about the approach you are trying to do take even though it won't work (or won't work well).

Op-amps are made to have as close to "infinite gain" as possible. In practice this means their gain is very large and not a specific gain of 1, or 2, or 100. They are then intended to be used with negative feedback which means some kind of connection from the output back to the inverting input (-IN). This causes the op-amp to keep itself under control and produce an overall gain based on the value of the components in the negative feedback loop.

We do this because it is difficult to construct transistors with specific gains. However, it is easy to construct transistors with very large, but unspecific gains.

You wanted a gain of 1 and no inverting of your signal so you need a voltage follower which is below. Note the negative feedback:







simulate this circuit &ndash; Schematic created using CircuitLab

However, this won't work very well for your circuit because though op-amps can probably supply more current than your RPI, it won't be enough for a fan, and if it is it won't be efficient.

Op-amps work similar to linear regulators where the extra voltage at the power pins which isn't required on the output is burned off as heat. The larger the output current, and the larger the difference between input and output voltage, the more heat is produced. Not good if you have a relatively "huge" load like fan.

This approach is more for applications require very precise outputs which are usually, but not always low current. Something like a large speaker which requires a precise voltage is a different story and takes a lot of effort to get a precise, pristine, high power signal. Fans (and motors) care a lot less about how pristine their power is. Which means the best balance between efficiency and simplicity is probably some kind of simple switching method (similar to that used for brushed motors).

Op-amps and linear regulators kind of work like variable switches that are always halfways on to control the voltage output. That's basically burning power in a resistance. It's not efficient.

What's more efficient is a switch that is fully on (very low resistance and high current) or off (high resistance but no current). So what you can do is use a transistor to switch the power to your fan on and off very rapidly (via PWM) through an inductor and capacitor to smooth out the square wave into something that more resembles DC.

This is the simplest way but has some caveats:







simulate this circuit

The caveat is that your fan is not reference to ground. This is okay as long as your fan doesn't have any control signals (which will to be referenced to the fan's negative supply pin, but the RPI's signals aren't referenced to the fan's negative supply pin. They're referenced to ground, and your fan's negative supply pin isn't connected to ground.

If such fan control signals do exist do, then you have to move the transistor to the "high-side" (i.e. somewhere on the positive supply leg of the fan) but this means it's not so simple to switch the transistor since the voltage that controls the transistor is the voltage between the gate and source pin. This means that the source pins is most conveniently connected to GND since your RPI is sending signals relative to GND. If you put the transistor somewhere else, then the source pin is no longer at GND but your RPI's signals still are so more circuitry is required to "float" the signal up to the transistor. Or you have to use a PMOS transistor which doesn't the same issues, but has other issues. A PMOS is probably the simplest way though.







simulate this circuit

The inductor smooths the current and the capacitor smooths the voltage so the fan sees an "average" rather than a full blast of the supply voltage every time the switch closes.

The diode is so the inductor's kick (flyback) doesn't blow the switch or anything else when you shut the switch off. When current flows through inductors, they store energy in their magnetic field. When you reduce the current (especially when you reduce it quickly like switching it off) it will start using the energy in it's magnetic field to act like a source and keep the current flowing through it in the same direction. It will produce any voltage necessary with its energy to push that current through the inductor. If there's a difficult path in the way, it means a very high voltage will be required which damages other components. If you give it an easy path like with the flyback diode the voltage will be smaller since less voltage is required to push the current around the inductor.

The 1K resistors are to give the transistors a default OFF state if the RPI isn't driving the line

You will need transistors that turn on at the RPI's pin voltages. This is NOT \$V_{gsth}\$ on the datasheet. \$V_{gsth}\$ is when the MOSFET just barely starts to turn on and is for analog applications. Yours is a switching application so you care about the Vgs voltage used to obtain the MOSFET's rated on resistance (\$R_{dsON}\$).

If you PWM switch too fast you will need to put a gate driver between your RPI and the MOSFET gate pin since there is a capacitance there that needs to be charged and discharged fast enough. But I will not talk about that right now.