This paper presents the design and development of an automatic fan control system based on the ESP32 microcontroller and a DHT22 temperature sensor. The system is designed to automatically turn the fan on or off and adjust its speed using PWM signals, depending on the ambient temperature. The fan remains off when the temperature is below 21°C and operates at increasing speeds for temperatures above 21°C, with PWM values ranging from 90 to 255. The primary goal is to offer an energy-efficient solution that can effectively respond to changing environmental conditions. Compared to manual systems, this automatic system offers faster response times, reduces energy consumption, and eliminates the need for human intervention. Testing demonstrated a clear and consistent relationship between temperature and fan speed, confirming that the control logic functioning as intended. This system can be effectively implemented in small-scale cooling systems requiring responsive and efficient temperature regulation.