Incredible. Finally someone who's building their code around their layout and not copying the code and pasting it .... hats off brother. So informative.
Jacob - I am totally new to Arduino but something struck me and I am curious to ask you. Why do you use the PWM output of the Arduino rather than an analogue out to provide you with the 0-5v into the MOSFET? Would the fan be better controlled with an analogue 0-5v signal to control the 0-12v supply circuit?
John Burns analog out on arduino is not true analog, it is pwm. It can be filtered into analog voltages but mosfets are really good with all the way on or off states and not in between. most likely the mosfet will latch into the full on state once the threshold voltage is reached.
Thanks for the reply Jacob. I'm new to Arduino and when I wrote the initial reply I thought the Uno had analogue outputs - when really they're simply the digitised PWM outs as you say. I am thoroughly enjoying coding and learning - just managed an LM35 temp sensor thing, and am going to work on a huge (for me) project which will utilise some of what I learned watching your vid, so thanks for that.
Bro this worked like a charm. Using this to pull in cool air into my electrical enclosure for my mobile solar panel kit to prevent a greenhouse affect. This is super useful because it will only use power when necessary to cool the enclosure what with the PWM and being able to set the desired temp. Thanks so much for this great video. This was basically the first time I was able to successfully make something work with the Arduino other than turn on an LED lol.
There's an observation about that gate drive... Whenever you are PWM switching an inductive load (i.e. like that fan), without a gate resistor, there's a good chance that gate is going to ring (oscillate), that might cause electrical noise issues that could interfere with other circuits, including parts of the microprocessor, especially if you are making that microprocessor to multitask. It happened to me with some serial data I was using, it looked all erratic and did not know where it came from until I hooked up a scope to the power supply line, you could see all kind of noise along... At first I thought the freewheel diode alone and the decoupling capacitor would eliminate good part of the noise, but it did not. The gate resistor was the saver here...
Thank you for showing the wiring of the mosfet clearly on the breadboard, and the details of the shared grounding. I wasn't sharing the ground properly, but now I have got the temperature control working, thanks to this video (and it is the fourth that I have watched looking for enlightenment). I am using a k-thermocouple and an LCD display but the mosfet circuit is the same.
thank u very much ,i looked all over RU-vid for help ,to under limiting system your circuit is the only one that made sense .now im finish. my on or off grid ,anti-back-feed , chinese solar grid tie inverter diy ( simple energy limiter ) with arduino. Thanks again :)
Genuine question: would it not be easier to simply use a 4-wire PWM fan and control it directly via your PWM output pin, rather than driving a Non-PWM fan via a MOSFET? Would love to hear your thoughts on this, if you think there are Pro's and Con's, etc?
You legend, exactly what i was looking for... I'm making solar powered cooling fans for beehives. using a Arduno Nano.. charge controller, lithium battery and some solar panels.
Thank you, exactly what I needed. Also interesting you used a voltage divider on the A0 pin, that is a nice touch with the R1, cheaper than the TMPs used in many other applications. Additionally, 12V is probably better than Mains, so this is a relatively safe project.
Hi I only have a 2k thermistor which resistance would you recommend to put on the second resistance. Also, im using a NPN transistor so what resistance would you put before the gate
One more question. Do you think it is possible to display the temperature change from the circuit on a display? If possible, let me know how i can integrate in the circuit. Thank you very much
is there any risk of having the motor emf Fry your board? I think heard that diodes are recommended for motors for that reason, but I don't know much about it.
If you are running a program on your computer that gives CPU temps, could you use those values to communicate with the Arduino and drive the fan based on those values?
Thank you so much for this very interesting video! You explained everything so well as a beginner in arduino I will try to rebuild this circuit. Wish you all the best and I hope you‘re going on with such interesting projects. Boris. 🇨🇭
Hi, I wanted to tell you that your project is very fine to me as an arduino beginner! One question: is it normal to hear the ringing sound of the fan maybe coming from pwm? Is there a solution against this ugly sound? Thanks! Boris, Swiss
It's good practice yes but the benefit in this particular case would not be there because brushless dc fans already have them built in their driver circuitry. Also it is very common for mosfets to have some sort of reversed biased diode there for back emf. If the fan was not a brushless fan with its own driver circuitry then yes a diode should be used. It won't hurt to add the diode but with these fans there is no benefit.
i would like to be good at this stuff but I suck, I have been looking around for a simple fan controller and this one Rocks, Simple and it works great, GOOD JOB
00:01 Creating a temperature-controlled fan controller using an Arduino and a thermistor. 01:57 Arduino allows for flexible control of fan speeds based on temperature. 05:28 Explaining the circuit setup for controlling fan speed using MOSFET 07:10 Arduino Temperature Controlled Fan Speed Wiring 10:51 Setting up the sensor pin and voltage divider network. 12:44 Understanding the temperature sensor readings. 16:22 Pulse Width Modulation (PWM) controls fan speed based on sensor values. 17:57 Explaining the fan's power startup and operation with PWM. 21:17 PWM control allows fan speed adjustment based on temperature. 23:08 Using fan speed control based on temperature sensor readings. Crafted by Merlin AI.
What the heck is up dude! (I laughed alot of your intro! Lol) Would it be possible to replace the temp sensor with a potentiometer? So i can control the speed up and down how i want? And i guess its possible to read the RPM, and "print" it to a display or something? Im figuring out how i can make a fan controller that shows fan rpm and can control pwm fans (for testing only, not to use in a computer or such things) I just want to be able to turn it up to full blast etc.
You don't have any issues with noise from the fan while under PWM? I'm driving a L298N with my arduino but at 50% duty cycle I get a really annoying noise from the fan.
Justin Fielding that is dependent on the fan used. You can change the PWM frequency but it is a bit more involved. I believe libraries have been created to change the PWM frequency for arduino. You can also program it using AVR C if you have the experience with it. You could also just try different fans and see how they sound.
Hey Jacob. I had done some research, I tried changing the PWM frequency but that didn't really help - even with the frequency at 31.5Khz which should be inaudible. Testing the fan with a 4.8v battery it runs at reduced speed without the noise so it's 100% the PWM. I have read about using a basic RC low pass filter to smooth the PWM output in to an analog voltage - I tried experimenting with a few randomly selected components without joy - needs more work. Seems much simpler in your example so I'm thinking I'll try with a MOSFET rahter than the L298N (H-bridge) before getting in too deep!
This was an very helpful video, thanks so much! Question that you or perhaps another viewer could answer - Can I control the fan speed using a PWM signal sent to a MOSFET (such as a IRFLZ44n) or does the MOSFET only act as an "On/Off" switch that is controled by the PWM? Thanks.
In short, yes, you can use the IRFLZ44n to PWM controll a fan. Both of your questions together are a bit puzzling though. You can control the fan speed by using the MOSFET you said and the MOSFET does only act as an On/Off switch. PWM signal has a duty cycle and a frequency. Frequency of 1Hz (unreal, only for demonstration purposes) says that the signal repeats every second ( Time period = 1/frequency ). And duty cycle of 75% says that during this 1s time interval, the device will be on for 0,75s and off for 0,25s. You can make a PWM signal by simply switching power on and off by hand (nice way to test it). It works ok for a fan, but light sources, need much greater frequency.
Could you not have your thermistor wired as a switch? Negative to negative post on which ever system is is your wanting to keep cool, say it was a heat sync. Mount the thermistor to the heat sync and run your + wire threw the thermistor to the fan.....? Just a question, lots of good info in your vid.
I tried to reverse the code to have fan slow as temperature increased (as in a heater). But, the fan got into a loop where it would stop, run at full speed, stop, run at full sped, and so on. Any suggestions?
Thanks guy for your explanation! Eventually I used a MCP9700-E/TO temp sensor, instead of the thermoresistor and the resistance, and it worked perfect! :)
Thank you much. Great video, clear and clean. Much simpler than I expected. I need to choose a mosfet that will handle a 2 amp 200cfm 12vdc fan. My only trick now is how to mount the thermistor to my RF amp heatsink. I think I will give this a try. I was just going to switch the fan on using a relay and some op amp temp circuit, but the pwm capability of the Arduino is just too cool not to try. Take care :)
Loved the video with a good explanation of the circuit thanks so much but a quick question where did you get the pencil? would love to buy one thanks Bob - UK
The Arduino Uno specs are 40 mA per pin other than 5V and GND, 200 mA total (other than 5V and DNG), 1 A max through 5V and GND. So if the motor draw more than 1A, the ground, of the Arduino, may be unable to sink that current?
Dear Jacob, I want to set this up in my livingroom so noise should be -0-. I was warned that the use of pwm makes noise and only didappears at full speed. Is this true? Rgds Tom Hoekstra
Hi, can I use the same 5V pin from Arduino (the one that goes to MOSFETs gate) for fan powering (instead +12V in diagram, see scheme at 0:44 in video)? In other words, the 5V Arduino pin will be connected to MOSFET gate, MOSFET drain will be connected to negative fan wire, positive fan wire will be connected to 5V Arduino pin. Could this work or (i) should I include 10k resistor between 5V pin and MOSFET or (ii) should I use lower voltage 3.3V pin of Arduino to connect positive fan wire and sacrifice a bit of small 5V fan speed..?? Thanks for advise.
Trying my hardest to follow lol i have fans and a arduino im trying to cool down a car amplifer on its heatsink when the temperature goes up. I will study this video as reference. Thank you for this awesome information
would it be possible to control a fan like this with a sound sensor? and additionally have the sounds sensor interprut live music and have the fan respond to the music?
Yes it would. A sensor is basically nothing else than an input like a button, but the button can only send 1/0 (on/off) signals, whereas a sensor can usually send a range of signals (depending on the type of sensor). In your arduino code you read the value of the sensor and react to it, like turning on a fan if the sound level reaches 100db for instance.
Great video. Very insightful. I have a few questions though. Can the 2N7000 handle a 3.3V PWM? and Does it heat up significantly when load is connected? How much is V across collector and emitter? Thanks in advance
Rodney Yrureta according to the datasheet the maximum gate threshold voltage for a 2n7000 is 3v so yes 3.3 should trigger the gate but it is pretty close, however, 3v is the max so it should be fine. The transistor does not heat up much under normal operation. It is a switching transistor so the voltage drop across it is pretty low. It should remain cool switching any current less than its 500mA pulsed rating.
Ow. great videos and fast response too. You are the man!! LOL maybe I can add a resistor before the transistor to lower it down or is it more advisable to find another trans? I'm trying to control with pwm a 12V at about 400mA.
I have few questions: 1) if you are to use 5V fan, do you need to modify resistor values and if yes, what values should they be? 2) as I understand it, the type of transistor depends upon the voltage that I use to speed up the fan, and which one would I use for my case of 5V-fan? I would be really thankfull if someone answered me because I'm having this as my project and I can't find this information anywhere.
1) no. The resistors are only used to read a sensor value. But when using a 12V Fan you might need a bigger Mosfet or transistor 2)you can use almost any type of Mosfet e.g. the IRLB8743PBF but the Gate Threshold Voltage shouldnt be too big (2-4V)
hi another question can i apply this test with 3 phase ac compressor connected with inverter , and which type of transistor has been used in this test....thank you very much
Hey brother can you tell me the code for my project . ds18b20 temperature sensor , LCD 16×2 , arduino UNO & fan , all connected . As the temperature rises , fan goes fast or Start rotating and if temperature goes low , fan slows or stops down...
I understand that in this case your switching the circuit on and off from positive to ground as a percentage of being fully on But what about a 3 pinout fan, Im trying to control a fan that has 3 pins, ones vcc ones signal and the others ground, I tried proving the 12v and the ground but when I use the analogWrite to control pwm signal it doesnot work, can you explain this??
Usually 3-pin fans have VCC, Ground and a speed output so the motherboard can determine how fast the fan spins. To do what you want you need a 4-pin fan. These have VCC, GND, speed out and pwm in. You can also just PWM the VCC coming into the fan.
Very Nice Jacob.. very good explained. THank you.. i am working on a Irrigation PRoject.. i will share it with you if you want.. i m. in to the nodemcu. and oled..
what am i missing here... i can get the thing to work with a transistor and 12v fan and a separate power supply for the fan. but i want to run the entire thing from a bank of 12v batteries that run my beehouse/hives etc. this is to turn on small fans to extract humidity from each hive in the winter when they're all insulated up. obviously i already have the stepdowns to go from 12 to 5vdc, but i just can't noodle the wiring for the 5vdc fan... it should be easier right? just set the value of the fan speed based on the output of the sensor pin, and.... and... that's the part i don't seem to get. if i just make two spliced wires so the 5vdc goes to the sensor and the fan, clearly it will run forever without the logic. so it has to go in and out of either the nano (want to keep everything small and cheap - multiple hives)
Hi there I would interested in buying a project like this! It's possible to buy from where? I have a garage and I will use a car battery ans 2 computer fans and I woudl like to connect with this board because I have a damp effect inside 😦 Thank you
Hey man i was wondering if you could help me out? a tutorial on using multiple pressure sensors (6) with each one using the same principle to control a fan each (with a scaling value). any tips?
i have question plz i need a quick answer for that as i need to submit my assignment ... can we get analogue voltage from microcontroller it self ... or it should connected in arduino board to get that... because in the above circuit we r providing analogue value to microcontroller and getting an analogue voltage in output.... how we r getting analogue value in output of micro controller... plz clarify me ... i have to submit my assignment on saturday....
Ayaan Khan we are giving the microcontroller an analog input from our voltage divider. The microcontroller will use its onboard ADC to convert that to a 10 bit value and store it. The microcontroller itself can not output an analog signal. To control the fan it uses pulse width modulation which is still discrete output values 0v and 5v however its average is analog like. The pulse with modulation is still however digital. The microcontroller operates only in the digital domain and never directly deals with analog signals, the build in ADC handles all analog inputs. Hope this helps let me know if you need anymore clarification.
Great video!!! I know this vid is almost a year old, but anyway, here is the question: If I want to control the fan with a potentiometer, the "output" part of the system, is it just the mosfet and the fan? Thanks in advance!
Perfect video for me, but instead I am doing this with the radiator of my car, so the fan of the radiator turns on when the coolant temperature reaches higher than normal temperature
whether it is possible to connect this fan,(Noctua NF-A14 2000RPM | industrialPPC)to an ordinary ,12v. power adapter,if possible, it would be very helpful for me to write me how to connect it!! i don't want to connect it to the computer motherboard.to be connected separately only to12v power adapter. I appreciate verry much if you can answer this question
I’ll check the channel for follow up videos but a great next step would be to show an application of this with a much smaller Arduino (or clone) and a smaller fan in a project such as a Raspberry Pi enclosure.
Hey, what do I need from all of this, if I want to control the fan Just from time, like 1min 25% the next 50% no temperature sensor. Just thes time intervals?
This is just the perfect video for my upcoming arduino project. I'm planning to build a fan that keeps my smoker at a constant heat for various longjobs like pulled pork. You mentioned that the mosfet isn't powerful enough for a project like this. Could you be so kind and recommend a mosfet that will do the trick for sure? Thank you very much!
That's a useful video thanks Jacob. Perhaps adding a piezo buzzer that sounds when sensorVal is greater than 800? I realise there is no end to the list of "enhancements" that could be added.
Very solid video. Any chance you know, how to set up a circuit, where a heater is turned on once temperature falls below a certain point and a cooler is turned on once it is over a certain threshold by using a thermistor?
I am a genuine rookie. That being said: Wouldn't u just need to replace the temperature resistor that lowers it's resistance the higher the temperature gets with one that increases its voltage the higher the temperature gets and otherwise use the same circuit?
My fan only works well when the PWM signal is at 255 and at every value below that it rattles and gets really slow. Below 200 it barely even moves anymore. Does anybody have a solution for that?