Connecting microcontrollers with SNS and email with Node-RED

Introduction

 This is a technical summary of the two days of production at "Heroes League Hybrid Hackathon". It was a short time, but I tried to make it possible to handle LINE, Slack, Discord, and Gmail via Node-RED.

▼I was participating in this event.

https://mashupawards.connpass.com/event/291510/?utm_campaign=event_participate_to_follower&utm_source=notifications&utm_medium=twitter

▼I have submitted my work to ProtoPedia.

https://protopedia.net/prototype/4716

 In this case, I not only send and receive messages from Node-RED running on a PC, but also exchange messages with a microcontroller.

▼The system configuration looks like the following, via Node-RED.

▼I use Raspberry Pi 400.

About Moddable Two

 I used Moddable Two as the device for sending and receiving messages.

▼Here is the Moddable Two, with a thin touch display. Text input is also possible.

 It is embedded with an ESP32 so it can use WiFi and Bluetooth.

 The program for Moddable Two is created with Node-RED MCU and writes the flow created in Node-RED. This means that the writing to the microcontroller and the communication with the server is completed on Node-RED.

 Note that I am building the Node-RED MCU environment on a Raspberry Pi 400. I had an error when I tried to use it after a while, but typing the xs-dev command again solved the problem.

▼See here for information on building an environment for Node-RED MCU. The biggest challenge is building the environment…

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

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

Connect with various message services

 I added more and more, referring to articles I found on the Internet. In common with all of the services, I needed the channel IDs and API keys.

LINE

LINE Notify

 LINE Notify is very easy to use. It is most recommended if you just want to send messages.

▼Article about connecting with LINE Notify

https://zenn.dev/dsl_gunma/articles/78218c47efa9d8

▼Here is the flow: Data received at the mqtt node is sent to LINE Notify.

▼The application screen looks like this.

LINE Messaging API

▼Article about connecting with LINE Messagint API

https://qiita.com/youtoy/items/287a0782fdd185fc2004

▼There is an image of the use of Node-RED.

https://flows.nodered.org/node/node-red-contrib-line-messaging-api

 I once tried to use the LINE Messaging API with Node-RED, but gave up because the API requires https communication in order to use it.

 In this case, I can use the API via an external service called enebular. With the free framework, the startup time is limited and the URL is also regenerated when restarting, so the URL of the API on the LINE side needs to be reset each time.

▼The page for enebular is here.

https://www.enebular.com/ja/

 I have not been able to send and receive the data completely, but I think I can if I process the data. This time I was only able to parrot the data.

▼Here is the flow.

▼The data included in the webhook was described here.

https://developers.line.biz/ja/docs/messaging-api/getting-user-ids/

▼The application screen looks like this.

Slack

▼Article about connecting with Slack

https://zenn.dev/dsl_gunma/articles/9fc4e58783d7da

▼Article on retrieving a mentioned message

Node-REDでSlackの特定の投稿に反応して返答する (zenn.dev)

 One thing I am concerned about is that I get a “failed to stop node” error on the debug node. This may be why it takes so long to deploy each time.

▼Here is the flow: data received via Slack Listen is partly converted using JavaScript.

▼The application screen looks like this.

Discord

 I felt that there is not much information about Discord in Japanese. The node itself is simple and easy to use.

 There is a node related to Discord named node-red-contrib-discord, but it is no longer maintained and is deprecated. This time I used node-red-contrib-discord-advanced.

▼The node page is here.

https://flows.nodered.org/node/node-red-contrib-discord

▼You must be in developer mode to obtain the channel ID.

https://note.com/bardbot/n/na70832cb70a3#7d216f1f-9988-4772-aa20-dfdfbf97c6eb

▼This video was helpful to me on how to use it.

 When I tried to run the video with reference to part way through the video, I got an error “Error Used Disallowed Intents”.

▼This article solved the problem. It seems that the bot is initially restricted.

https://zenn.dev/disneyresidents/articles/discordintents

▼Here is the flow. It's very simple.

▼The application screen looks like this.

Gmail

 Gmail can only be sent from the microcontroller. This one is running on enebular's Node-RED. There is also a node for receiving.

▼Article about connecting with Gmail

メール・ノードを使おう | enebular blog

▼Here is the flow. It's also very simple.

▼The application screen looks like this.

Write a flow to Moddable Two

▼Here is the flow. The mqtt node is used to communicate with the server.

 The Node-RED dashboard screen appears in Moddable Two. Not only can button and switch input be used, but also a keyboard can be displayed for text input.

▼The display looks like this. You can also switch tabs.

▼Here is the video of the presentation at the hackathon. It's a little hard to hear the sound…

Finally

 It was a short two day hackathon, but using a low-code tool like Node-RED, I was able to create something. I also could write the details in JavaScript.

 Since I could use low-code for the UI of the microcontroller, I focused on the integration with the service. Thankfully, my predecessors had published information on that connection, so I used it right away.

 I would like to learn more about Node-RED and networking relationships. I am a mechanical engineering student, but I feel like I am getting further and further away from it…


Discover more from 趣味的ロボット研究所

Subscribe to get the latest posts sent to your email.

Leave a Reply

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