Control a fan 230VAC using arduino with temperature sensor

Thread Starter


Joined May 26, 2020
Hello people!

I want to control a fan AC 230V, the speed of fan depents on how is the temperature.
Once the temperature reaches and exceeds 24 degrees Celsius, the fan should start working at a lower speed.
The speed will increase every 4 degrees Celsius until the temperature becomes equal to 40 degrees Celsius, then the fan will have the maximum speed.
So far I have bought the fan of course, a MOC3021 (Opto-coupler), a temperature sensor, a step-down transformer 230V/9V, a 4N25 (zero crossing detector) and a BT136 TRIAC

I found these components from here, but in the link the user used a potentiometer

I'm confused by this link because I don't know how to use the circuits. e.g. Why does it use 4N25?


Joined Sep 17, 2013
Welcome to AAC!
Section 1 of the description in the link explains the function of the 4N25 as a zero-crossing detector. That crossing is the reference which the Arduino uses as its 'time zero' for setting the phase delay before the triac switches on.
The circuit schematic and the breadboard layout show how the components are interconnected, but the schematic has an omission. In addition to the components described you should have a diode (type not critical, e.g. a 1N4148 or a 1N4001) connected in reverse across the input LED of the 4N25, to protect the LED from reverse-voltage breakdown.
Last edited: