4. case 02 Smart Fan¶
Make a smart temperature control fan.
1 x Smart home Kit
1 x corrugated board
2 x small sticks
1 x glue
###Meaning of smart temperature control fan
The smart temperature control fan is a created product base on smart home.That’s say, science come from life.
What is smart temperature control fan¶
The room will at high temperature when temperature degree is higher than 30° and make people feel uncomfortable.The temperature sensor will send this signal to micro:bit，and micro:bit send this signal to the fan. Then, the fan will drive until the degree of room under 30° to keeping room at comfortable temperature.
4.4. Practical operation¶
Materials: corrugated board and cutter
Build as below picture：
Paste devices as below piture:
4.5. Hardware connect¶
Go to MakeCode page, click Advanced in the code block and click on Extensions.
We need to add a new codebase for programming of smart home. Finding “Add Package” in the bottom of code block and click it. Then a message box will show up, search “smart home”， and download this new codebase.
Note：If there is a hint says some codebase will be deleted because of incompatibility. Don’t worry. You could go ahead as the hint or build a new item in item menu bar.
Drag on start block from Basic and drag initialize OLED block from OLED, change height to 64, width to 128.
Drag forever block from Basic, add temp variables in Variable, then drag set item to snap into forever, change item to temp and drag value of temperature behind it. Change value of temperature to ℃ and at pin to P1.
Now let’s start OLED code.
Drag clear OLED display under set temp to. Then,drag show (without newline) string ‘Temperature’ under clear OLED display. Last, drag show(without newline) number temp.”Without newline” is for newline displaying string and temperature value.
Our goal is using micro:bit driving the fan when the value of temperature is higher than 30°, so temp>30 is a judgement condition. In that way, we need drag “if else” from Logic, set temp>30.
We add start melody repeating under if ,set melody to ba ding and repeat once，micro:bit will send signal to fan through P2. Then set fan works 5 seconds and stops 5 seconds. The temperature sensor judge whether go loop by gotting the temperature degree. Else means if above condistion were false, the fan will keep rest.
When temperature degree is higher than 30°, buzzer “ba ding” , fan driving to keep room comfortable.
When temperature degree is less than 30°，the fan will automatically stop, and the room at comfortable temperature.
How to adjust speed of fan to control cooling rate in the room.
It works well if powering by the USB only without the battery holders, but if the current temperature is over the threshold value, the fan doesn’t.
If powering by the battery holders only without the USB, the fan works well and the detected temperature will be slightly higher than the real one.
If powering by the battery holders and the USB simultaneously, the fan works well and it gets the normal temperature( Do note that you have to detect the temperature under the premise of the motor fan doesn’t drive).