MQTT communication with Node-RED (Node-RED MCU, M5Stack)

Introduction

 In this article, I used MQTT communication with Node-RED; MQTT communication is used to communicate with IoT devices and is said to be low-power consumption.

 I was able to use it with the M5Stack, which I programmed with a Node-RED MCU. Data could be sent to the Raspberry Pi via MQTT communication and processed by Node-RED. Communication between the microcontroller and the server is going to be easy.

▼I use Raspberry Pi 400.

▼Here is the page about MQTT

https://www.ibm.com/docs/ja/ibm-mq/7.5?topic=mobile-messaging-m2m

▼Previous articles are here

Using Node-RED MCU Part 1 (Node-RED, M5Stack)

Introduction  In this article, I used a Node-RED MCU to write a program on the M5Stack. I had introduced a bit […]

xs-devでRaspberry PiにNode-RED MCUの環境を構築する

はじめに  今回はRaspberry PiにNode-RED MCUの環境を構築してみました。  少し前に発売された書籍での方法とは違って、xs-devを使っています。構築が楽になるそうです…

▼Here's a short introduction to Node-RED and Node-RED MCU

書籍紹介:『はじめてのNode-RED』/『はじめてのNode-RED MCU Edition』

Node-REDとは  一言でいうと、Node-REDはプログラミングが簡単にできるツールです。ビジュアルプログラミングの一種で、視覚的にわかりやすくなっています。 ▼百聞は一見…

Start MQTT broker with Aedes MQTT broker

 I tried running an MQTT broker on Node-RED on a Raspberry Pi. This time I used Aedes MQTT broker.

 You can add a node by going to Manage Palette -> Add Node and searching for node-red-contrib-aedes.

▼Here is the flow.

▼Here is the configuration. The port is 1883.

Configure mqtt in/out nodes

 It is received by the mqtt in node and sent by the mqtt out node.

 Each node is configured with a server where the MQTT broker is located and a topic. Communication takes place between nodes with the same topic.

▼The mqtt out node is configured here and the mqtt in node is the same.

▼The icon next to the server choice allows you to configure it in detail.

Execute MQTT communication

 Data from the inject node is sent to the mqtt out node and received by the mqtt in node. The topic is set to /test.

▼Here is the flow.

▼Here is the content of the inject node. msg.payload is sent, so the debug node should show mqtt test.

▼When the button on the inject node is pressed. mqtt test is displayed in the debug window.

Using Shiftr.io's servers as MQTT brokers

 You can use Shiftr.io, an external service MQTT server. This is also easy and convenient to use.

 There is a trial server that is open to the whole world instead of being free to use, and a server that has a 6 hour limit instead of being free to use with account registration.

▼The page for Shiftr.io is here.

https://www.shiftr.io/

▼You can get the URL of the publicly available server on the Try page here.

https://www.shiftr.io/try/

▼Here is what MQTT communication looks like between M5Stack and Node-RED using Shiftr.io. It is easy to see the flow of data.

Finally

 I was able to easily try MQTT communication using Node-RED. I would like to use it with the Node-RED MCU to communicate between the microcontroller and the server.

 I also saw something called MQTTS, which may allow for more secure communication, like HTTPS. Since Moddable SDK has recently been able to support HTTPS, I would like to try that as well.

▼The data flow, which can be seen on Shiftr.io's Try page. It's kind of like a neural network.

Leave a Reply

Your email address will not be published. Required fields are marked *