As I mentioned earlier that I have been taking classes on Automation in a company @speedvibe-hub which I recently brought to hive and the CEO would be making his introductory post soon. I have been taught some things about Arduino, you can check the post here and here. I had only written two posts so far but it is quite educative.
In the above image we have a regular fan that changes speed which switch in which we would make it detect temperature changes and adjust its speed level depending on the temperature of the room.
This project is not a personal project but a group project in which our teacher had explained the whole process on how to make this possible. From our previous classes, we have treated how to detect temperature of the environment using a dht11 sensor, we have been thought how to make some codes on an Arduino. The process of making this project is very easy for us to build.
How do we plan on building this project, first we have a box where we placed in our LCD which would display the room temperature and the changes in speed of the fan. For the fan, there are four wires, in which we have the wire 1, wire 2, wire 3, and the neutral (wire4). Each of those wires signifies the speed of the fan.
Above is the relay module in which we connect to the fan. We loop in the Normally close to each relay and connect each speed to the normally open of the relay module.
Above is the fan motor used to test our code if it would work. We have the 3speeds and ground wire in it.
Below is the connection of the fan motor to the relay and arduino..
In the pictures below is the code for this project on my system.
Below is the code written in my system for the dht11, led light and relay module
// Programming the Arduino for the temperature controlled fan
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
#include <DHT.h>
#include <DHT_U.h>
DHT dht(10, DHT11);
float temp;
float humi;
int off=6;
int speed1=7;
int speed2=8;
int speed3=9;
void setup() {
// put your setup code here, to run once:
dht.begin();
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0, 0);
delay(1000);
lcd.print("SPEEDVIBE");
delay(1000);
lcd.clear();
pinMode(off,OUTPUT);
pinMode(speed1,OUTPUT);
pinMode(speed2,OUTPUT);
pinMode(speed3,OUTPUT);
digitalWrite(off,LOW);
digitalWrite(speed1,LOW);
digitalWrite(speed2,LOW);
digitalWrite(speed3,HIGH);
delay(1000);
digitalWrite(off,LOW);
digitalWrite(speed1,LOW);
digitalWrite(speed2,LOW);
digitalWrite(speed3,LOW);
}
void loop() {
// put your main code here, to run repeatedly:
temp=dht.readTemperature();
lcd.setCursor(0,1);
lcd.print("Temp (C)");
lcd.setCursor(10,1);
lcd.print(temp);
delay(500);
Serial.println(temp);
if (temp<31){
digitalWrite(off,LOW);
digitalWrite(speed1,LOW);
digitalWrite(speed2,LOW);
digitalWrite(speed3,LOW);
lcd.setCursor(0,0);
lcd.print("off speedvibe");
}
else if (temp>31&&temp<34){
digitalWrite(off,LOW);
digitalWrite(speed1,HIGH);
digitalWrite(speed2,LOW);
digitalWrite(speed3,LOW);
lcd.setCursor(0,0);
lcd.print("low speedvibe");
}
else if (temp>34&&temp<38){
digitalWrite(off,LOW);
digitalWrite(speed1,LOW);
digitalWrite(speed2,HIGH);
digitalWrite(speed3,LOW);
lcd.setCursor(0,0);
lcd.print("medium speedvibe");
}
else if (temp>38&&temp<100){
digitalWrite(off,LOW);
digitalWrite(speed1,LOW);
digitalWrite(speed2,LOW);
digitalWrite(speed3,HIGH);
lcd.setCursor(0,0);
lcd.print("high speedvibe");
}
}