You went to do a temperature-Controlled Fan Using Arduino. Today I show you How to Temperature-Controlled Fan with Arduino. we’ll use an LM35 temperature sensor to turn a fan on automatically when the temperature is too high.
≡ Required Component
1.Arduino
3. Breadboard
5. 5V single-channel relay module
6. 12V mini-computer cooling fan
7. 9V battery snap and battery
≡ Circuit diagram for the temperature-controlled fan:
The computer fan requires more power than the Arduino can not give, so we need to deliver it its possess control supply: a 9V battery.
LM35 sensor Connection Build:
Embed the LM35 sensor into the breadboard with the front of the sensor facing you. Interface the left pin to the +5V rail on the breadboard, the center pin to Arduino A0, and the right pin to the GND rail, as shown within the taking after the table.
LM35 SENSOR | ARDUINO |
Left pin | +5V |
Center pin | A0 |
Right pin | GND |
Relay Module connections Build:
the relay pins on the right side of the relay module are Signal, GND, and +5V. Join the relay’s Signal pin to Arduino pin 5, GND to Arduino GND, and +5V to the Arduino power via the breadboard rails.
5V RELAY | ARDUINO |
Signal | Pin 5 |
GND | GND |
+5V | +5V |
On the left side of the relay module are the connections for the electromagnetic switch. The center pin is the common connection; the left pin is marked NO for regularly open, meaning the circuit is broken and the default state is off; and the right pin is marked NC for regularly closed, meaning the default state is on. On the off chance that the relay isn’t switched, the common pin is connected to the NC pin. On the off chance that the relay is switched, the common pin is connected to the NO pin. Since we need the circuit to be off until we utilize the switch, we are going to utilize the NO pin.
Now interface the black GND wire of the fan to the GND wire of the 9V battery. At that point, as shown within the following table, join the red positive wire of the fan to the common pin on the relay, and interface the positive wire of the 9V battery to NO on the relay.
5V RELAY | FAN/9V BATTERY |
NO (normally open) | 9V battery’s positive wire |
Common | Fan’s positive wire |
NC (normally closed) | Not connected |
Now Connect the breadboard power rails to each other and to the Arduino GND and +5V pins.
≡ Code Temperature Controlled Fan Arduino:
#define SENS_PIN A0 // Defines A0 pin as "sensor" #define FAN_PIN 5 int Vin; // Reads value from Arduino pin float Temperature; // Receives converted voltage value to temp float TF; // Receives converted value in °F void setup() { pinMode(FAN_PIN, OUTPUT); // Fan pin as an output Serial.begin(9600); // Start Serial Monitor } void loop() { // Tells Arduino to read pin and stores value in Vin Vin = analogRead(SENS_PIN); // Converts voltage value into temperature and // stores value in Temperature (as °F) Temperature = (500 * Vin) / 1023 * (1.8) + 32; TF = Temperature; Serial.print("Temperature: "); // Sends text to display screen Serial.print(TF); // Shows value of temperature in Serial Monitor Serial.println(" F"); // Writes F to indicate it is in Fahrenheit if (TF > 71) { // If temperature is more than 71 digitalWrite(FAN_PIN, HIGH); // Turn fan on } else if (TF < 71) { digitalWrite(FAN_PIN, LOW); // Or keep fan off } delay(1000); // Waits for a second to read the pin again }
All Arduino tutorial available Click here
ARDUINO TUTORIAL
270 total views, 1 views today