Note

Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

👉 Ready to explore and create with us? Click [here] and join today!

Smart Fan

This Arduino project automatically adjusts the fan’s speed to maintain the temperature within a suitable range. Additionally, users can enter manual mode through a button to operate the fan at maximum speed.

Required Components

In this project, we need the following components.

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

Elite Explorer Kit

300+

Elite Explorer Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

Arduino Uno R4 WiFi

-

Breadboard

BUY

Jumper Wires

BUY

Resistor

BUY

LED

BUY

Button

BUY

Thermistor

BUY

DC Motor

BUY

TA6586 - Motor Driver Chip

-

Power Supply Module

-

Wiring

Note

To protect the Power Supply Module’s battery, please fully charge it before using it for the first time.

../_images/06_smart_fan_bb.png

Schematic

../_images/06_smart_fan_schematic.png

Code

Note

  • You can open the file 06_smart_fan.ino under the path of elite-explorer-kit-main\fun_project\06_smart_fan directly.

  • Or copy this code into Arduino IDE.

How it works?

Here is a step-by-step explanation of the code:

  1. Constants and Variable Definitions:

    Use #define to define the pins for various hardware connections. TEMP_THRESHOLD is defined as 25°C, which is the temperature threshold to start the fan. manualMode: A boolean variable that indicates whether it is in manual mode.

  2. setup():

    Set the mode for relevant pins (output, input, input with pull-up). Initially set to automatic mode, so LED_AUTO is lit while LED_MANUAL is off.

  3. loop():

    Monitor the button’s state. When the button is pressed, it toggles the mode and changes the LED’s status. In manual mode, the fan operates at maximum speed. In automatic mode, the code first reads the voltage value from the temperature sensor and converts it to a temperature value. If the temperature exceeds the threshold, the fan’s speed is adjusted based on the temperature.

  4. voltageToTemperature():

    This is an auxiliary function used to convert the voltage value from the temperature sensor into a temperature value (in Celsius). The function uses the standard formula for a thermistor to estimate the temperature. The return value is in degrees Celsius.