6. Case 03: Environmental Motor Fan

Level: level auto_fit

6.1. Goal


Make an environmentally friendly automated motor fan by detecting the surrounding temperature.

6.2. Background


What is an Environmental Motor Fan??

Smart motor fan is a fan that can adjust the power, turn on and off automatically to save electricity when not needed. Nowadays, for example, the temperature in the room is very low and cold, the air-conditioner also keeps turned on at high intensity. If there is a temperature sensor to detect surrounding parameters and change the power automatically, it can save much energy.

Environmental Motor Fan Principle

The temperature and humidity sensor installed in the house will scan for surrounding conditions continuously. When the temperature is too low or at average, the fan will change the intensity to off or low. When the temperature is high the fan will adjust to max power.

pic_90

6.3. Part List


pic_90

6.4. Assembly step


Step1

To start with, build the Big House Model.

pic_90

Step 2

To build a small living room at the right side in the home, put Model E4 onto A model as a wall.

pic

Step 3

Attach the Temperature and humidity sensor to Model E4 using M4 * 10mm screws and nuts.

pic

Step 4

Attach OLED Display to the Model E4 using M2 * 10mm screws and nuts.

pic

Step 5

Attach motor fan to the Model F using M4 * 10mm screws and nuts. And the connecting wire could be bended to the hole next to it.

pic

Step 6

To build a fan stand, put Model F into the B3, B4 model.

pic

Step 7

To build a table, put the Model I1 onto the model I2.

pic

Step 8

The table completed!

pic

Step 9

Place the table at the living room.

pic

Step 10

Assembly Completed!

pic

6.5. Hardware connect


  1. Connect the Temperature and Humidity sensor (DHT11) to P2

  2. Connect the extended OLED display to I2C Port

  3. Connect the Motor module to P1 pic_80

6.6. Programming (MakeCode)


Step 1. Initialize OLED display

  • In on start, put initialize OLED with width 128 height 64 to initialize the OLED display pic_70

Step 2. Create variable

  • Create a variable called temperature pic_50

Step 3. Read and show the reading from DHT11

  • In Forever, read the data by Read Temperature & Humidity Sensor at pin P2

  • Get the temperature value from data, and save it to variable by (set temperature to Get Temperature °C)

  • Before update the screen infomation, suggest clear up the OLED display each time

  • Use clear OLED display to clear the display

  • Then use show string join Temperature: temperature to show the temperature value with formatted text on display pic_80

Step 4. Examine the temperature

  • In Forever, put a nested if-else statement

  • Use the temperature < 22 as first condition

  • In the first if segment, turn off the fan by Set Motor fan with speed 0 at P1

  • Use the temperature < 26 as second condition

  • In the second if segment, turn on the fan with half speed by Set Motor fan with speed 600 at P1

  • Use the temperature >= 26 as third condition

  • In the third if segment, turn on the fan with full speed by Set Motor fan with speed 1023 at P1 pic_90

Full Solution

MakeCode: https://makecode.microbit.org/_c2637VXcbfHP

You could also download the program from the following website:

6.7. Result


When the room temperature changing, it will match either one of the condition, and the fans will turn on or off with different speed according to the room temperature.

pic

6.8. Think


Q1. Apart from open the fans, any other method to reduce the temperature?