Auto Cooling Fan Using Servo and DHT11 Temperature and Humidity Sensor With Arduino

by RonFrtek in Circuits > Arduino

2057 Views, 3 Favorites, 0 Comments

Auto Cooling Fan Using Servo and DHT11 Temperature and Humidity Sensor With Arduino

2020-10-27_21-34-29.jpg

In this tutorial we will learn how to start & rotate a fan when the temperature raises above a certain level.

What You Will Need

arduino-fan2.jpg
HTB1TMikbyjrK1RjSsplq6xHmVXa3.jpg
oled.jpg
dht11.jpg
arduino.jpg
VisuinoAdvrtisementRaspberryPiRobot.jpg
jumper-wires.jpg
  • DHT11 sensor
  • Arduino UNO (or any other board)
  • Fan module L9110
  • OLED Display
  • Servo motor
  • Jumper wires
  • Breadboard
  • Visuino program: Download Visuino

The Circuit

2020-10-27_21-47-51.jpg

  • Connect Servo motor "Orange" (signal) pin to Arduino Digital pin[2]
  • Connect Servo motor "Red" pin to Arduino positive pin[5V]
  • Connect Servo motor "Brown" pin to Arduino negative pin[GND]
  • Connect fan module pin [VCC] to arduino pin [5V]
  • Connect fan module pin [GND] to arduino pin [GND]
  • Connect fan module pin [INA] to arduino digital pin [5]
  • Connect OLED Display pin[VCC] to Arduino pin[5V]
  • Connect OLED Display pin[GND] to Arduino pin[GND]
  • Connect OLED Display pin[SDA] to Arduino pin[SDA]
  • Connect OLED Display pin[SCL] to Arduino pin[SCL]
  • Connect DHT11 positive pin + (VCC) to Arduino pin +5V
  • Connect DHT11 negative pin - (GND) to Arduino pin GND
  • Connect DHT11 pin (Out) to Arduino digital pin (4)

Start Visuino, and Select the Arduino UNO Board Type

F756MJUKEIJALTQ.jpg
FHO2DUKKEIJALTR.jpg

The Visuino: https://www.visuino.eu needs to be installed. Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2020-09-12_13-23-02.jpg
2020-09-12_13-25-13.jpg
2020-09-12_11-45-14.jpg
2020-09-12_14-11-35.jpg
2020-09-12_14-12-05.jpg
2020-09-12_14-12-34.jpg

  • Add "Sine Analog Generator" component
  • Add "Servo" component
  • Add "DHT" component
  • Add "Analog Value" component
  • Add 2X "Compare Analog Value" component
  • Add "OLED" component

In Visuino Set Components

2020-09-12_14-17-50.jpg
2020-09-12_14-20-38.jpg
2020-09-12_14-20-57.jpg
2020-09-12_14-27-29.jpg
2020-09-12_14-26-51.jpg
2020-09-12_14-27-05.jpg
2020-09-12_14-29-48.jpg
2020-09-12_14-35-37.jpg
2020-09-12_14-35-53.jpg
2020-09-12_14-36-09.jpg
2020-09-12_14-36-26.jpg
2020-09-12_14-34-51.jpg
  • Select "SineAnalogGenerator1" and in the properties window set Amplitude to 0.30 and Frequency to 0.1,set enabled to False and click on the Pin icon and select Boolean sink pin
  • Select "CompareValue1" and in the properties window set Value to 24 (temperature that will start the fan) and Compare Type to ctBiggerOrEqual
  • Select "CompareValue2" and in the properties window set Value to 24 (temperature level that will stop the fan) and Compare Type to ctSmaller
  • Double click on the "AnalogValue1" and in the Elements window drag "Set Value" to the left
  • In the properties window set Value to 0.5
  • In the Elements window drag another "Set Value" to the left
  • In the properties window set Value to 1

Double click on the "DisplayOLED1"

In the Elements window:

  • Drag "Draw Text" to the left and in the properties window set Text to "TEMP"
  • Drag "Text Field" to the left and in the properties window set Size to 2 and Y to 9
  • Drag "Draw Text" to the left and in the properties window set Text to "HUMIDITY" and Y to 26
  • Drag "Text Field" to the left and in the properties window set Size to 2 and Y to 36
  • Drag "Draw Text" to the left and in the properties window set Text to "FAN ACTIVE" and Y to 54 and set Enabled to false, click on the pin icon and set BooleanSinkPin

Close the Elements window

In Visuino Connect Components

fan.png
2020-09-12_15-13-22.jpg
2020-09-12_15-13-05.jpg
  • Connect SineAnalogGenerator1 pin [Out] to Servo1 pin [In]
  • Connect Servo1 pin [Out] to Arduino digital pin [2]
  • Connect "HumidityThermometer1" pin[Sensor] to Arduino digital pin [4]
  • Connect "HumidityThermometer1" pin[Temperature] to DisplayOLED1>TextField1 pin[In] and CompareValue1 pin[In] and CompareValue2 pin[In]
  • Connect "HumidityThermometer1" pin[Temperature] to DisplayOLED1>TextField2 pin[In]
  • Connect "CompareValue1" pin[Out] to DisplayOLED1>DrawText3 pin[Iclock] and pin[Enabled]
  • Connect "CompareValue1" pin[Out] to AnalogValue1>Set Value1 pin[In] and SineAnalogGenerator1 pin[Enabled]
  • Connect "CompareValue2" pin[Out] to AnalogValue1>Set Value2 pin[In]
  • Connect "DisplayOLED1" pin I2C [Out] to Arduino board I2C [In]

Generate, Compile, and Upload the Code

2020-09-12_15-50-59.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino UNO module, the OLED Display will start to show the temperature and humidity values and if the fan is Active. Once the temperature raises above 24 degrees the fan will start to spin.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it and open it in Visuino: https://www.visuino.eu