4. case 02 Smart Fan

../../_images/abtHWmp.jpg

4.1. Goal


  • Make a smart temperature control fan.

4.2. Materials


  • 1 x Smart home Kit

  • 1 x corrugated board

  • 2 x small sticks

  • 1 x glue

4.3. Background


###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.

../../_images/06g0wlF.png

4.4. Practical operation


Materials: corrugated board and cutter

../../_images/PuJE7uj1.jpg

Build as below picture:

../../_images/5sc9bid.jpg

Side

../../_images/hvnmUhO.jpg

Paste devices as below piture:

../../_images/C1lu2Vz.jpg

4.5. Hardware connect


../../_images/hkOaYEu.png

4.6. Software


makecode

Edge Connector Data Sheet

4.7. Programming


Step 1

Go to MakeCode page, click Advanced in the code block and click on Extensions.

../../_images/2qCyzQ74.png

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.

../../_images/QR2s7LD.png

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.

Step 2

Drag on start block from Basic and drag initialize OLED block from OLED, change height to 64, width to 128.

../../_images/NSOCUxe.png

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.

../../_images/wPfZA5F.png

Step 3

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.

../../_images/gZwzVGd.png

Step 4

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.

../../_images/Ys6Hcm3.png

Step 5

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.

../../_images/FHAWwTm.png

Programming

Make code:https://makecode.microbit.org/_AqMEtEbUtPTE

You also could directly download program visit website as below:

4.8. Result


When temperature degree is higher than 30°, buzzer “ba ding” , fan driving to keep room comfortable.

../../_images/mv5oVws.jpg

When temperature degree is less than 30°,the fan will automatically stop, and the room at comfortable temperature.

../../_images/Rtptdzw.jpg

4.9. Think


How to adjust speed of fan to control cooling rate in the room.

4.10. Questions


4.11. More information