ESP32 - Control Fan
ESP32 can not only turn on/off the fan but also control the fan's speed.
In this tutorial, we are going to learn how to turn on/off a fan using ESP32. Controlling the fan's speed will be presented in another tutorial.
|1||×||ESP-WROOM-32 Dev Module|
|1||×||Micro USB Cable|
|1||×||12V Cooling Fan|
|1||×||12V Power Adapter|
How to Control Fan
- If 12V fan is powered by 12V power supply, it run with full speed.
- If 12V fan is powered by 12V PWM signal, The fan's speed can be controlled.
In this tutorial, we are going to learn how to turn on/off a fan using ESP32. Controlling the fan's speed will be presented in another tutorial. To turn on/off a fan, we need to use a relay in between ESP32 and fan. ESP32 can turn on/off the fan via the relay. If you do not have knowledge of relay (pinout, how they work, how to connect them to ESP32, how to program for them...), learn about relay in the ESP32 - Relay tutorial
Image is developed using Fritzing. Click to enlarge image
The below code repeatedly turns the fan ON in five seconds and OFF in five seconds,
- If this is the first time you use ESP32, see how to setup environment for ESP32 on Arduino IDE
- Connect the ESP32 board to your PC via a micro USB cable
- Open Arduino IDE, select the right ESP32 board and COM port
- Copy the above code and paste it to Arduino IDE
- Click Upload button on Arduino IDE to compile and upload code to ESP32 board
- See the fan's state
Read the line-by-line explanation in comment lines of code!
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.
Do more with fan
※ NOTE THAT:
Note that this tutorial is incomplete. We will post on our Facebook Page when the tutorial is complete. Like it to get updated.