pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

AWS

Creating Products and Devices
Please complete the creation of products and devices via AWS Management Console before using UIFlow AWS.

Example

from m5stack import *
from m5stack_ui import *
from uiflow import *
from IoTcloud.AWS import AWS
import time

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)

label0 = M5Label('Text', x=40, y=42, color=0x000, font=FONT_MONT_38, parent=None)
label1 = M5Label('Text', x=43, y=134, color=0x000, font=FONT_MONT_38, parent=None)

def fun_subtopic_(topic_data):
  # global params
  label0.set_text(str(topic_data))
  pass

aws = AWS(things_name='UIFlow_TEST', host='xxxxxxxxxxx-ats.iot.ap-southeast-1.amazonaws.com', port=8883, keepalive=60, cert_file_path="/flash/res/certificate.pem.crt", private_key_path="/flash/res/private.pem.key")
aws.subscribe(str('subtopic'), fun_subtopic_)
aws.start()
while True:
  aws.publish(str('pubtopic'),str('hello'))
  wait(4)
  wait_ms(2)

API

from IoTcloud.AWS import AWS
aws = AWS(things_name='', host='', port=0, keepalive=0, cert_file_path='', private_key_path='')
  • Initialize client:
    • Click the Add button in the initialization block to import Device certificate + Private Key File, Note: The default key and certificate file name is too long, try to change it to a shorter string.
    • The things name is the name of the device we created, and it needs to match the name in the AWS Management Console.
    • Copy the Endpoint field from AWS Management Console->Settings and populate it with the HOST parameter.
    • For the port parameter we use the MQTT service port 8883
    • keepalive 60
    • For more information on service ports please refer to AWS Official Documentation .
aws.start()
  • Start client connect
aws.publish(topic,msg)
  • publish messages
def fun_subtopic_(topic_data):
  # global params
  print(topic_data)
  pass
  • subtopic messages callback
On This Page
Example
API
Q&A
Submit a question
Select question category*
Arduino
MicroPython
UIFlow1
UIFlow2
EzData
M5Burner
Software
Hardware
Other
Product name
Product version
Question description*
(Supports pasting screenshots.)
Attachments
Add Files
Email*
Submit
OK

M5Stack Support

Hi, this is M5Stack Support. How can I help you today?