Smart fan with speed control via Bluetooth module
This week, my project focuses on developing a Smart Fan controlled via a Bluetooth module. The fan can be operated remotely using a mobile app or a microcontroller (such as Arduino or ESP32), allowing users to adjust speed, oscillation, and on/off functions wirelessly.
electronics tools
aurduino
Jumper wires
Bluetooth module
breadboard
1298n motor driver
DC fan
I began by assembling the components on Tinkercad to simulate the circuit before building it in real life.
This circuit is designed to control a DC fan using an Arduino Uno, Bluetooth module (HC-05), and an L298N motor driver.
The Bluetooth module receives commands from a mobile app.
The Arduino processes the input and sends control signals to the L298N motor driver.
The motor driver adjusts the fan speed and direction accordingly.
The user can turn the fan on/off, change speed, or reverse the direction via a Bluetooth app.
The Bluetooth app was essential for sending remote control signals from a smartphone.
Instead of manually adjusting the fan using buttons or switches, a mobile app allowed wireless control.
Main Components & Connections
Power Supply (5V Battery)
Provides power to the motor and motor driver.
The ground (GND) is shared among all components for proper operation.
Arduino Uno
Acts as the brain of the system, receiving commands from a mobile device via Bluetooth.
L298N Motor Driver
Controls the speed and direction of the motor.
Inputs (IN1 & IN2) receive signals from the Arduino.
Outputs (OUT1 & OUT2) are connected to the DC motor.
HC-05 Bluetooth Module
Connects wirelessly to a smartphone for remote control.
TX (Transmit) → Arduino RX (Receive)
RX (Receive) → Arduino TX (Transmit)
VCC (Power) → 5V, GND → GND
The Code Writing
char userInput = 0;
This variable is used to store the incoming data from the serial communication. It is initialized to 0 and will later hold the character received from the serial input.
Serial.begin(9600);
Initializes serial communication at a baud rate of 9600. This allows the Arduino to communicate with a computer or other devices via the serial port.
pinMode(9, OUTPUT);
Sets pin 9 as an output pin, meaning it will send voltage out to control an external component (e.g., an LED or motor).
pinMode(8, OUTPUT);
Sets pin 8 as an output pin, meaning it will send voltage out to control another external component.
while (Serial.available() == 0);
This line waits for data to be available in the serial buffer. The program pauses here until the user sends data via the serial communication.
userInput = Serial.read();
Reads the incoming data from the serial buffer and stores it in the userInput variable.
Conditional Statements:
if (userInput == '1') { ... }
If the received character is '1', pin 8 is set to HIGH (turned on), and pin 9 is set to LOW (turned off). This could be used to control two components, such as turning on one LED while turning off another.
else if (userInput == '2') { ... }
If the received character is '2', both pin 8 and pin 9 are set to LOW (turned off). This could be used to turn off both components.
Serial.println(userInput);
Prints the received character (userInput) back to the serial monitor. This is useful for debugging or confirming the input.
userInput = '0';
Resets the userInput variable to '0' to prepare for the next iteration of the loop.
Bluetooth Module:
RX ===> TX Arduino Uno
TX ===> RX Arduino Uno
GND ===> -ve rail breadboard
Vcc ===> +ve rail breadboard
DC Fan:
Positive Terminal (Red Wire) ===> Collector of Transistor (TIP122)
Negative Terminal (Black Wire) ===> Negative Rail on Breadboard (GND)
Transistor (TIP122):
Base ===> Pin 9 (Arduino Uno) through a 1kΩ Resistor
Collector ===> Positive Terminal of DC Fan
Emitter ===> Negative Rail on Breadboard (GND)
Diode (1N4007):
Anode ===> Negative Rail on Breadboard (GND)
Cathode ===> Positive Terminal of DC Fan
Power Supply:
Positive Terminal (12V) ===> Positive Terminal of DC Fan
Negative Terminal (GND) ===> Negative Rail on Breadboard (GND)
Arduino Uno:
GND ===> Negative Rail on Breadboard (GND)
The Circuit didn't work at first but it turns out the problem with the circuit was due to incorrect wiring between the Bluetooth module and the Arduino Uno.
the TXD (Transmit Data) pin of the Bluetooth module must be connected to the RX (Receive) pin of the Arduino Uno, while the RXD (Receive Data) pin of the Bluetooth module should be connected to the TX (Transmit) pin of the Arduino Uno.
Title of Media