Example Code for micro:bit-Temperature Monitoring and Fan Control

This article guides you through setting up a temperature monitoring and fan control system using micro:bit, IoT, and Mind+. It covers hardware and software preparation, wiring, and programming, along with step-by-step instructions to integrate Easy IoT for real-time data monitoring and control.

Hardware Preparation

Software Preparation

Wiring Diagram

The Tx and Rx have been encapsulated onto two independent 3Pin connectors, which can be connected two random ports of micro:bit expansion board. Of course you should select the corresponding pins in code. Here we connect RX to P1, Tx to P0, the fan module to P8. As shown below:

Connection 1

Other Preparation Work

Easy IoT Platform

  • Easy IoT from DFRobot is dedicated to simple solutions for Internet of Things.
  • Features Included:
    • Get started in 10 minutes, plug and operate
    • OBLOQ supported, serial port transmission
    • Real time monitoring, data analysis

Sign in and Setting Easy IoT

  • Open the easy IoT website:http://iot.dfrobot.com.cn/

Easy IoT

  • With a micro:bit board, a micro:bit IoT expansion board and Easy IoT, a whole IoT system will be ready.

  • Sign up and Sign In

    • Click the Sign up/Sign in at the upper right corner of the webpage to register a account.
    • Fill in the black with your personal information, you can register via phone or email.
    • Sign in the Easy IoT, then it will enter into Workshop interface. You need to add a new device to match your micro:bit.

Click Sign Up/In

Add a new device

  • Easy IoT Setting
    • When added a new device, a device topic Topic: elJA7JHZg will be generated randomly, and you can click the device name to change it.
    • Click "send message", then the webpage of message receiving and transmitting will appear. You can find the details of the received data.
    • Get to know other information in this page- ID account interface

Device Setting

ID account Interface

Sample Code

Mind+ Graphical Programming

  • Initial Setup

Open Mind+ graphical programming software, first load micro:bit block in "extension", then add the Obloq IoT module related block(Load micro:bit first, otherwise, you may cannot find IoT block when open communication).

Initial Setup

Initial setup 2

Initial Setup 3

Initial Setup 4

  • Programming

You can directly drag and snap the block from the command section, the final program is shown as below:

Mind+ 1

Click the setting icon in the block to set IoT parameters. They should be consistent with setting in the IoT Platform. Input your WiFi and password, and configure the Tx/Rx as the hardware connection.

Result

When downloaded the program, the RGB LED on the Obloq IoT module changes from red to blue, and to green and stays green, which indicates the IoT communicaton works well. The indications of the RGB LED are as below:

Color Function
Red Not work properly
Blue Connecting to WiFI
Green Work well
Purple MQTT disconnected

Additional Information

Fan module pinout

Pinout

Open the workshop to view the details.

Charts

Click send message in the workshop to remotely control the operation of the fan through the network. When the Obloq IoT Module received the data, the micro:bit get and process it to control the fan. Here the Obloq IoT module works as a transfer station. For controlling other different actuators, you only need to adjust the program in the receiving part.

Information Check

Was this article helpful?

TOP