---
title: "MQTT Communication with Micro:bit and Pico using MakeCode"
url: "https://maker.wiznet.io/scarlet/projects/mqtt-communication-with-microbit-and-pico-using-makecode/"
markdown_url: "https://maker.wiznet.io/scarlet/projects/mqtt-communication-with-microbit-and-pico-using-makecode/md"
type: "WCC: WIZnet Created Content"
author: "이경진"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "이경진"
published: "2024-02-23"
language: "en"
tags: ["MQTT"]
likes: 2
views: 3050
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# MQTT Communication with Micro:bit and Pico using MakeCode

> MQTT Communication with Micro:bit and Pico using MakeCode

Original author: 이경진

## Article

ssI previously created firmware that allows the use of MicroPython on a micro:bit board.

> https://github.com/Wiznet/micropython-microbit-v2/tree/master

However, this method can only be used with Python Editor or MicroPython Editor programs. Additionally, it requires connecting the SPI pin, which makes it somewhat challenging.

So, this time, I have prepared firmware that allows for block coding using MakeCode.

The network block in MakeCode is for the ESP8266. It's firmware that makes the block for the ESP8266 usable with WIZnet products.

---

### HW

Prepare the micro:bit module (including adapter) and the W5500-EVB-Pico.

Connect the UART of the two devices. The pin settings are as follows:
![](https://maker.wiznet.io/upload/ckeditor5/470603300%5F1708943467%2Epng)

**Micro:bit: RX= p8/ Tx=p12W5500-EVB-Pico: RX= p5/ Tx=p4**

Please download the firmware to the Pico.

The MicroPython official firmware can be downloaded from the link below. Then, please

> <https://micropython.org/download/W5500_EVB_PICO/>

---

## SW

## MQTT config

Set up a broker for MQTT communication. I use Mosquitto. Please refer to this side for how to use it.

> <https://github.com/Wiznet/micropython-microbit-v2/tree/master/examples/Mqtt/Publish#step-4-upload-and-run>

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683246%2Epng)

### W5500-EVB-Pico

By default, it is set to use DHCP, so there's no need to configure IP.

The logic that transmits messages received from the microbit to Ethernet is in operation.

The ESP8266 block is designed to send `ATcommands'` to the network module from the microbit. This part has been modified to be handled by the W5500-evb-pico instead, to control the network. Currently, MQTT-related functions have been implemented.

download and run the code below.

> <https://github.com/wiznetmaker/WIZNET5K_to_Microbit/>

### Micro:bit make code

You can access it at the following site:

> <https://makecode.microbit.org/>

Please run a new project.

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683574%2Epng)

Since ESP8266 is not a default feature, please install the `extension` additionally.

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683626%2Epng)

search ESP8266

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683647%2Epng)

The `ESP8266_IoT` block has been added.

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683771%2Epng)

Let's code with MakeCode.

In the `ESP8266_IoT` block configuration, set up the UART (w5500-evb-pico) and connect it.

In the `MQTT` block configuration, create the code in the order of setting up MQTT -> connecting to the Broker -> publishing.

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683859%2Epng)

Download the code to the Microbit.

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683893%2Epng)

Then, execute subscribe in Mosquitto.

```plaintext
mosquitto_sub -h 192.168.11.100 -t 'topic’
```

Verify that the message you entered is displayed in the subscribe output.

![](https://maker.wiznet.io/upload/ckeditor5/902907100%5F1708683988%2Epng)

---

Source: https://maker.wiznet.io/scarlet/projects/mqtt-communication-with-microbit-and-pico-using-makecode/
