8. How to Apply with HiveMQ#

HiveMQ is an MQTT broker and client-based messaging platform designed to move data in and out of connected IoT devices quickly, efficiently and reliably.

Website: https://www.hivemq.com/

8.1. Required materials#

1 x IOT:kit

8.2. Register#

Click the “Cloud” button on the page.

../../_images/IOT_HiveMQ_01.png

Click “Sign up now”.

../../_images/IOT_HiveMQ_02.png

Choose “Sign Up” to register your info(email, passwords).

../../_images/IOT_HiveMQ_03.png

Requirements of the passwords.

../../_images/IOT_HiveMQ_04.png

Following the guide to complete the registration.

8.3. Operation Guide#

After registration, go to: https://www.hivemq.com/mqtt-cloud-broker/ Choose “Sigh up now”.

../../_images/IOT_HiveMQ_02.png

Log in with your email and password.

../../_images/IOT_HiveMQ_05.png

Click “CREATE CLUSTER”.

../../_images/IOT_HiveMQ_06.png

Choose “Azure” and click “CREATE CLUSTER”.

../../_images/IOT_HiveMQ_07.png

Click “MANAGE CLUSTER”.

../../_images/IOT_HiveMQ_08.png

Click “Access Management”, set the “Username” and “Password”, then click “ADD”. (Add the user’s account)

../../_images/IOT_HiveMQ_09.png

Completed! Please remember the user name and the password, this info would be required on the settings of the MQTT in MakeCode.

../../_images/IOT_HiveMQ_10.png

For hardware connections, please refer to our wiki: https://www.elecfreaks.com/learn-en/microbitKit/iot_kit/iot_bit.html

Attention: Please use the USB port on the IoT:bit for power supply, or the Wifi module would not get powered.

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

Click “Advanced” in the MakeCode drawer to see more choices, and then click “Extensions”.

../../_images/IOT_HiveMQ_11.png

Search with “iot-environment-kit” to add the extension.

../../_images/IOT_HiveMQ_12.png

Choose “ESP8266_IoT”.

../../_images/IOT_HiveMQ_13.png

In the on start block, initialize esp8266 and enter with the name and password of the wifi for connecting.

../../_images/IOT_HiveMQ_14.png

Set the applications of MQTT, set “scheme” as “TSL”, self-define “clientID”, add the user name and password with the one on HiveMQ.

../../_images/IOT_HiveMQ_15.png

Click “Overview” and copy the “Host” and “port” to MakeCode.

../../_images/IOT_HiveMQ_16.png

Click “Getting started”, choose “HiveMQ Websocket Client”.

../../_images/IOT_HiveMQ_17.png

In the jumping page, click “here” on step 1.

../../_images/IOT_HiveMQ_18.png

In the jumping page, enter with the User and Password, then click “Connect” to get in touch with MQTT .

../../_images/IOT_HiveMQ_19.png

A notice of “connected” labled in green occurs if the connection is made successfully.

Click “Add New Topic Subscription” .

../../_images/IOT_HiveMQ_20.png

Choose “Subscribe”.

../../_images/IOT_HiveMQ_21.png

If completed, it is ok to send messages from MakeCode.

The “hello” in the block is the message we are going to send, you can set it by yourself. And the topic block: “testtopic/1” is the pre-settings on the platform, you can replace “#” with any number.

../../_images/IOT_HiveMQ_22.png

Following the former steps, press the button A on micro:bit to send “hello” to the platform.

../../_images/IOT_HiveMQ_23.png

Absolutely, we can send data from the platform to local part, set the topic as “testtopic/2”, and enter the messages on “Message”, then click “Publish” to send. And make sure to keep the topic in the blocks the same.

../../_images/IOT_HiveMQ_24.png

Send the number “2” from the platform and display it on the micro:bit.

../../_images/IOT_HiveMQ_25.png

Program:

../../_images/IOT_HiveMQ_26.png

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

8.4. FAQ#

Q: How to judge if the current IoT:bit supports MQTT? A: Please refer to the version number printed on the back of the IoT:bit, only V1.6 supports MQTT, V1.4 and the former are not availble for MQTT.

../../_images/IOT_HiveMQ_27.png