Using M5Stack to publish messages to MakerCloud
Before publishing messages to MakerCloud, users must first learn how to connect M5Stack to MakerCloud via MQTT. For instructions on connecting, please refer to the following link. Using M5Stack to connect to MakerCloud
Publish message programing block
Users can use the MakerCloud programming blocks from Custom to publish messages to MakerCloud.
Publishing a key-value pair message
- Publishes a key-value pair or key-text message to the topic on MakerCloud.
- If the data sent is a number, a corresponding line chart will be automatically created on MakerCloud.
Publishing a key-value pair message
Learning Focus
- Learn how to use M5Stack to publish key-value pairs to a topic on MakerCloud
- Create a line graph on MakerCloud that displays and records key-value messages
Exercise: publish random numbers
- Make a button that publishes a random key-value message when clicked.
- Create a line graph on MakerCloud to display and record key-value messages
Preparation on MakerCloud:
- Create a project
- Create a topic
Programming on UiFlow:
- Connect M5Stack to Wi-Fi, then connect M5Stack to UiFlow
-
Add MakerCloud UiFlow Custom (Download MakerCloud UiFlow Custom)
-
Double-click the B Button of M5Stack in UiFlow to add the "Button B wasPressed" block
- In the "Button B wasPressed" building block, place the key-value pair message block from MakerCloud Custom.
- Copy the topic name in MakerCloud
- Paste the topic name in "Topic", enter "num" in "key", and add a "random integer from 0 to 10" block in "value"
When finished, return to the project homepage of MakerCloud. When you press the button, you should see the key-value pair message from your app in the data viewer.
Then refresh the project home page and go to the chart home page.
MakerCloud will automatically record the name of the key and create a chart to display and record the key-value pair.