If the temperature measured by the DS18B20 Waterproof Temperature Sensor is above the predefined threshold, it turns the L9110 Fan Motor on automatically unless the piezo disk sensor is pressed.
Advertisement:
Read Later
If the temperature measured by the DS18B20 Waterproof Temperature Sensor is above the predefined threshold, it turns the L9110 Fan Motor on automatically unless the piezo disk sensor is pressed.
Components :
[1]Arduino Nano
[1]DS18B20 Waterproof Temperature Sensor
[1]L9110 Fan Motor
[1]Piezo Disk Sensor
[1]Resistor 4.75k ohm
[1]Resistor 1k ohm
[2]Mini Breadboard
[1]Male/Male Jumper Wires
[1]Female/Male Jumper Wires
[1]Hot Glue Gun
[1]Soldering Iron
While measuring temperature produced by project structures I had built, I might need to act instantly to make it cooler to avoid any harm to the components attached to the structure. And therefore, I conceived a movable cooling fan design which can detect temperature in a long distance, running the fan if the measured temperature is above the predefined threshold. Also, I wanted to halt the process if an emergency occurs while monitoring the surrounding temperature in Celsius and Fahrenheit. To manage this project, I used an L9110 Fan Motor and a DS18B20 Waterproof Temperature Sensor, attached to Arduino Nano. For turning the fan on and off intentionally, I added a piezo disk sensor. After I finished the circuit, I decided to put all parts on a dilapidated jar and am now very happy for the outcome.
First of all, find an old jar and get resistors - 4.75 K and 1 K - for the piezo disk sensor and the DS18B20 Waterproof Temperature Sensor along with other components as depicted below.
Now, you need to attach three jumper wires to the DS18B20 legs - 5V, Signal, GND - to be able to connect it to mini breadboards by using a soldering iron.
All DS18B20 Sensor has three legs and same connection requirements. Just connect the red wire to 5V, the black wire to GND and the yellow or blue wire to a digital pin.
And include these two libraries down below to get temperature in Celsius and Fahrenheit.
OneWire from here.
DallasTemperature from here.
Most importantly, add a 4.75 K resistor between the red wire and the signal wire(yellow or blue) to elicit accurate temperature values from DS18B20 sensors.
Arduino Nano connections and pinmapping are well-explained at the source code down below.
As depicted below, attach the analog pin 0 between 1 K resistor and the piezo disk sensor to read it.
To control the L9110 Fan Motor rotation connect INA to the digital pin 3 and INB to the digital pin 4.
After making connections and uploading the source code to Arduino Nano, sturdier all connections by using a hot glue gun to place all parts on the old jar like this.
1-) Monitor temperature values gathered by the DS18B20 Temperature Sensor in Celsius and Fahrenheit along with the piezo disk sensor reading on the serial monitor.
2-) In an emergency, turn the fan motor off by pressing the piezo disk sensor.
3-) Define a threshold value to activate the fan motor in this case above 25 Celsius. Also, you can define another threshold to change the direction of the fan as an indicator in this case above 80 Celsius.
Source Code
Download
/////////////////////////////////////////////
// Jar Temperature Detector and Cooling //
// Fan //
// ----------------------------- //
// Arduino Nano //
// by Kutluhan Aktar //
// //
/////////////////////////////////////////////
// While measuring temperature on a project, you may need to act instantly to make connected parts cooler to protect the components as a fan works in a computer.
// Basically, this project is about to detecting temperature in Celsius above 25 degree to run the fan to descend it under the threshold, of course you can change it.
// Also, you will be able to monitor the temperature in Celsius and Fahrenheit along with the piezo disk sensor on the serial monitor by taking following steps down below.
//
// Connections
// Arduino Nano :
// Piezo Disk Sensor
// 5V --------------------------- 5V
// GND --------------------------- GND
// DS18B20 Temperature Sensor
// 5V --------------------------- 5V
// D2 --------------------------- OUT
// GND --------------------------- GND
// L9110 Fan Motor
// 5V --------------------------- 5V
// GND --------------------------- GND
// D3 --------------------------- INA
// D4 --------------------------- INB
// Libraries for DS18B20 Temperature Sensor
#include <OneWire.h>
#include <DallasTemperature.h>
// Attach the bus pin to the temperature sensor.
#define ONE_WIRE_BUS 2
// Initial OneWire and DallasTemperature Libraries.
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
// Define the piezoelectric disk pin to read.
#define piezoDisk A0
// Define INA and INB pins to change fan directions.
#define INA 3
#define INB 4
// Define variables to save values.
float Celsius, Fahrenheit;
int piezo;
// This boolean runs the fan if the temperature is above 25 Celsius.
boolean HighTemperature;
void setup() {
Serial.begin(9600);
pinMode(INA, OUTPUT);
pinMode(INB, OUTPUT);
// Activate the DS18B20.
DS18B20.begin();
}
void loop() {
get_Variables_From_Sensors();
digitalWrite(INA, LOW);
digitalWrite(INB, LOW);
// Depending on the state of the piezo disk, either end task or continue.
if(Celsius > 25 && piezo < 100){
HighTemperature = true;
while(HighTemperature == true){
get_Variables_From_Sensors();
digitalWrite(INA, HIGH);
digitalWrite(INB, LOW);
if(Celsius > 80){
// At this temperature, change the fan direction opposite as an indicator.
digitalWrite(INA, LOW);
digitalWrite(INB, HIGH);
}else if(Celsius < 25 || piezo > 100){
// If temperature is below 25 Celsius, halt the task.
HighTemperature = false;
}
}
}
}
void get_Variables_From_Sensors(){
// Get data from the piezo disk.
piezo = analogRead(piezoDisk);
// Get temperature in Celsius and Fahrenheit from the DS18B20.
DS18B20.requestTemperatures();
Celsius = DS18B20.getTempCByIndex(0);
Fahrenheit = DS18B20.toFahrenheit(Celsius);
// Debug variables.
Serial.print("Celsius: ");
Serial.print(Celsius);
Serial.print("\t\t");
Serial.print("Fahrenheit: ");
Serial.print(Fahrenheit);
Serial.print("\t\t");
Serial.print("PiezoDisk: ");
Serial.print(piezo);
Serial.print("\n");
}
Fritzing File
Download
1 ) Arduino Nano V3
2 ) DS18B20 Waterproof Digital Temperature Sensor
3 ) L9110 Fan Motor
4 ) Piezo Disk Sensor
5 ) Resistor Kit for Arduino
6 ) Mini Breadboard
7 ) LED Kit for Arduino