Micor:bit Environment Monitoring and Temperature-controlled Motor Fan

by ElecFreaks in Teachers > Coding

1462 Views, 3 Favorites, 0 Comments

Micor:bit Environment Monitoring and Temperature-controlled Motor Fan

micobit_temperature.png

Result

The current moisture, temperature, air pressure and the altitude are displaying on the OLED screen. If the detected temperature is no less than 30℃, the motor starts driving the fan for cooling, or it stops driving to save the energy.

Supplies

  • micro:bit x 1
  • Nezha extension board x 1
  • Planet X – BME280 Sensor x 1
  • Planet X-OLED Display x 1
  • Planet X -Motor Fan x 1
  • 16*32 Baseboard x 1
  • 2*3 Bricks x 12
  • RJ11 Wires x 3

​Hardware Connections

micobit_temperature.png

Insert the micro:bit to Nezha extension board and connect BME280 and OLED display to IIC port on Nezha board with the RJ11 connectors, and then connect the Motor fan to J1 port.(You can see the color of the connection is the same with the equivalent port in the sensor you connect.)

Bricks Building Up

96-1.jpg
96-2.jpg

Connect 2*3 bricks on the 16*32 baseboard as the picture shows.(Note: There are six bricks used in the right upper side)

Connect the devices on the baseboard through 2*3 bricks we just connected as the picture shows.

Software Programming

96-3.png

Go to MakeCode page:(https://makecode.microbit.org/#editor)

Add the Planet X entension and click extension on the menu of the settings.

Search With “PlanetX”in the Dialogue Box to Add the Package.

96-4.png

Go to the coding page to edit the program.

Programme to show an icon while on start. In forever brick, programme to let the OLED display Hello,ELECFREAKS. Display the temperature on the third line on the OLED display. Here we need to use the text brick in the MakeCode to show the text info and the detected value from BME280.

Now We Program in a Similar to To Display the Moisture, the Air Pressure and the Altitude on the Fourth, the Fifth and the Sixth Line on the OLED Screen.

96-5.png
96-7.png
96-8.png

Here comes to the part of making the motor fan controlled by the temperature. We use BME280 module to detect if the current temperature is no less than 30.

If the temperature is over 30℃, the motor fan drives to cool the environment, if it is below 30℃, the motor stops driving to save energy. (You can see the color of the connection is the same with the equivalent port in the sensor you connect.)

Link: https://makecode.microbit.org/_g2hXKLhHpEe9