Example Code for MakeCode-Upload Data-UART

This tutorial demonstrates how to send data from a micro:bit to the Easy IoT platform via a WiFi IoT module. Pressing Button A sends the message “Hi, DFRobot.”

Hardware Preparation

  • MBT0039 micro:bit board x 1
  • MBT0008 IO Extender for micro:bit x1
  • WiFi IoT module x1
  • Wires

Software Preparation

This section mainly introduces how to use the WiFi IoT module and how to program it using MakeCode.

MakeCode Programming Platform:
https://makecode.microbit.org/

UART Library
MakeCode UART Library – DFRobot WiFi IoT

  • Configure IoT Platform

Open the Easy IoT website: https://iot.dfrobot.com, register an account if you don't have one, and then sign in.

4-1

Click the icon to check the generated ID and Password, and fill them in the corresponding MQTT configuration blocks. Select server "Easy IoT_EN".

2

Find your local WiFi and Password, fill them in the WiFi configuration block.

3

Wiring Diagram

Connect the pin D/R, C/T, GND and VCC of the WiFi IoT module to P13, 14, GND and VCC of the IO expansion board respectively. You can also define them by programming. Connect them as follows.

Sample Code

Program Link:
MakeCode Project – micro:bit WiFi IoT Demo

Program Blocks

5

Please fill in the correct Easy IoT ID and password.

Result

Since we use UART communication mode here, the control switch on the WiFi IOT module needs to be turned to the UART side, otherwise the initialization of the module will fail and the data transmission will not be possible.

After the program is burned successfully, the WiFi IOT module indicator will shows the connection process: red-blue-green. Press the button A on micro:bit, the WiFi IOT sends a "Hi DFRobot" message to the Easy IOT platform. Click "view details" in the position as shown in the figure below to enter the data page to see the received data.

7

9

Please power the IO shield via USB when running the program.

Was this article helpful?

TOP