Controling a four wire fan with an Arduino uno

I am trying to control a 12 volt 4 wire PC fan via an Arduino Uno. I want to be able to adjust the speed of the fan with a potentiometer. I am also using a LDR and an Ultrasonic Sensor as safety devices. The fan will only run if my desk lamp and office lights are one. The fan will also automatically shut off is there is something closer than 6 inches from the fan. I am also toying with the idea of monitoring the RPMs of the fan so that if the RPMs suddenly drop, the fan will also shut off.

The problem that I am running into at the moment is how to power everything and using a transistor. I’ve been told that I should use the same power supply to run both my Arduino and my fan. I’ve also been told that I can run both my Arduino and fan from the same power supply.

I’ve attached the schematic of my project. I am mostly wondering if I were to wire my project like the schematic would it work or how can I improve upon the design.

Any help would be greatly appreciated

Desktop Fan_schem.png
OK now, a number of points here.

A 4-wire fan is not controlled by a transistor, you feed PWM directly to the control wire while the fan remains connected to 12 V and ground.

You use the "tacho" wire as an input to the Arduino to monitor the fan speed. I seem to recall it is an open-collector so you would use INPUT_PULLUP on that pin.

If you were to use a transistor, you need a base resistor in series. A MOSFET is now the more appropriate component.

Your diagram shows a spurious connection from the LDR to "N/C"!

The 1k resistor on the LDR is probably too low. 10k may be more appropriate. And in general, it is a good idea to connect the LDR from input to ground and use a pull-up resistor to 5 V. Just using INPUT_PULLUP may work quite well.

For practical projects such as this, a Nano is easier to use than the clumsy UNO.

Powering "Vin" with 12 V is probably a bad idea. An external regulator (preferably a switchmode module) to supply 5 V to the "5V" pin would be better.

Hi,
What is the make and model of the fan?

Thanks.. Tom... :slight_smile:

The fan is a FOXCONN DC Brush less fan Model number PVA080G12Q. The wires from the fan are Yellow, Green, Black and Blue. Black is the ground and Yellow is the voltage. I am still working to identify the blue and green wires.

If I am understanding the previous post correctly

A 4-wire fan is not controlled by a transistor, you feed PWM directly to the control wire while the fan remains connected to 12 V and ground.

I can eliminate the transistor from my design since the via PWN directly from the pin

Powering "Vin" with 12 V is probably a bad idea. An external regulator (preferably a switchmode module) to supply 5 V to the "5V" pin would be better.

Then to power the Arduino, I need to drop the voltage coming from the power supply from 12 volts to 5 volts with an external regulator.

Would I be using a buck converter then? And can I use the same power supply to power both the regulator and the fan?

Also, I did my diagram wrong, the LDR is connected to analog pin 5

Hi,
There is some sort of standard;
This project my help, as the PWM frequency for most 4 wire fans is not the normal PWM frequencies available from a UNO PWM pin.

Tom... :slight_smile:

That project is helpful, but to monitor the actual fan speed as indicated in the Original Post, you need to interface the "tach" wire as well. I won't call the "tach" wire the "fourth wire" as it is actually the third wire on a three wire fan; the important requirement to verify that the fan was actually operating precedes the ability to control the fan speed directly.

Yes, you want to use a "buck" converter from your 12 V to power your Arduino at 5 V.

At this point, I think I need to look for a new fan, because I can't find a datasheet for my fan and I am not sure how to test the remaining wires to see which is the tach wire and which is the control wire. I know the fan works. I was playing around with using a relay to turn the fan on and off before I decided to control the speed of the fan via PWM.

Just our of curiosity, what makes the UNO so clunky besides the size of the board?

Connect one of the other wires to an Arduino input using pinMode of INPUT_PULLUP and count transitions for a second, then display it.

If no transitions, it is the PWM control to the fan, if lots of them it is the "tach" wire. :grinning:

Read the article TomGeorge cites.

The problem with the UNO is that it is too wide to fit on a solderless breadboard and one set of pin headers is offset so it does not match a breadboard or perfboard at all.

Also, it is supplied fitted with socket headers. Single wire connections to these are not secure; and you cannot solder directly to it.

And the "barrel jack" supplying the impractical on-board regulator is pretty much useless.

It is useful if an available "shield" allows you to perform every function you want all in one.

Hopefully this post hasn't completely died. August was a busy month.

I have identified all of the wires on my fan. I looked at the sketch that was posted by TomGeorge and I can get the sketch to work with my fan. But I am not understanding what is going on in the sketch.

I don't understand what the timers and registers are for.