X
Home > Blog > STEM for Arduino > HOW to Make A Fan with Temperature Detection Function by KidsIOT

HOW to Make A Fan with Temperature Detection Function by KidsIOT

By r October 16th, 2024 43 views
The fan will monitor the operating temperature. When it is overheat, the fan will start to rotate automatically.
This temperature detection device adopts a DS18B20 temperature sensor and an 130 motor.

Flow

4101

Assembly

line1

Required Components

41_00

line1

Step 1

41_01

line1

Step 2

41_02

line1

Step 3

41_03

line1

Step 4

41_04

line1

Step 5

41_05

line1

Step 6

41_06

line1

Step7

41_07

line1

Completed

41_08

line1

Wiring Diagram

4102

Test Code

Open KidsBlock and connect the board to computer. Choose File –> Load from your computer.

3111

Choose path D:\Code\2.Code_kidsIOT and open 4.1Temperature detection.sb3.

4103

Click 3209 to connect to port and then 2210.

6top

Q :After uploading the code, with temperature rises, the fan starts to work, yet the monitor stops outputting temperature values, with a prompt reading:

4104

A :The power supply may be insufficient, so an external power supply may be required.

DC

6bottom

Explanations

5top

Code Blocks

Blocks

Code block

Events

begin

Vari

variablename

Vari

setvariable

Vari

variable

Serial

serialbegin

Serial

serialprint

Temp

temperature

Operators

greater

Motor

Motor_analogWrite

Control

forever

Control

ifelse

line5

Build blocks:

Click add to import libraries 18b20 and DC Motor for esp32.

4105

  1. Initialization

    Initialize the serial monitor.

    4106

line3

  1. Main Code

    Loop: DS18B20 sensor reads the temperature values and the serial monitor prints them. Then, it determines whether the value is greater than 30°C(this threshold is adjustable).

    • Temperature > 30: fan rotates to cool down.

    • Temperature < = 30: fan stops working.

    4107

5bottom

Test Result
4top
After uploading code, the fan will rotate for cooling down when the temperature value exceeds 30°.
You can raise the temperature by pinching the DS18B20 sensor with your finger or lighting a lighter near the sensor.
WARNING: Please use lighters with the guidance of an adult!
4103
4bottom
HOW to Make a Variable Speed Fan with Kidsuno
Previous
HOW to Make a Variable Speed Fan with Kidsuno
Read More
HOW to Make a Track Alarm with KidsIOT
Next
HOW to Make a Track Alarm with KidsIOT
Read More
Message Us