AWS IoT Edukit Core M5 - Micropython support?
-
@greenleaf, after doing some initial quick testing I found that many of the features are in parity, but things like the RBG LED is not functional because the pins are different from the M5Stack Fire. You might be able to take the existing M5Stack MicroPython library and update the pins to work with it.
The crypto module isn't supported. However, you can use the Adafruit Crypto library for the secure element.
M5Stack and AWS are working together to explore an option to deliver a MicroPython package specifically for the Core2 for AWS IoT EduKit.
-
@rashedtalukder Super! An officially supported MicroPython package for the Core2 for AWS would be amazing.
-
@rashedtalukder said in AWS IoT Edukit Core M5 - Micropython support?:
Adafruit Crypto library
waiting for that MicroPython package specific for the Core2 for AWS... When?
-
Hi @rashedtalukder - it's been a while. Is AWS still committed to bringing Micropython to this device?
-
@greenleaf I haven't heard anything but there are functions in UIFlow provided for this and I have written and published a guide but am rewriting and updating a guide to AWS using UIFlow.
-
@ajb2k3 Thanks. Yes, it looks like UIflow has evolved quite a bit since last year. I'm happy to see you can execute custom code now, and that there are some dedicated hooks for things like AWS IoT.
-
@greenleaf I recently left Amazon. I don’t know what their plans are.
-
@rashedtalukder just spent the last 7 days hacking the code and making progress.
-
I was able to send data to AWS IoT Core using the below code. If you want to run this code from VScode + Pymakr, follow this guide: MicroPython: Program ESP32/ESP8266 using VS Code and Pymakr
import network from umqtt.simple import MQTTClient import time import sys import os import json # configure your wifi credentials WIFI_SSID = "<YOUR_WIFI_SSID_GOES_HERE>" WIFI_PASS = "<YOUR_WIFI_PASSWORD_GOES_HERE>" # configure your iot credentials MQTT_ENDPOINT = "XXXXXX.iot.XXXXX.amazonaws.com" MQTT_PORT = 8883 MQTT_QOS = 0 # thing-id MQTT_CLIENT = "mycore2" THING_CLIENT_CERT = "/flash/res/core2-certificate.pem.crt" THING_PRIVATE_KEY = "/flash/res/core2-private.pem.key" # topic MQTT_TOPIC = "mycore2/env" MQTT_SUB_TOPIC = "mycore2/command" info = os.uname() def connect_to_wifi(ssid, password): sta_if = network.WLAN(network.STA_IF) if not sta_if.isconnected(): sta_if.active(True) sta_if.connect(ssid, password) while not sta_if.isconnected(): pass ip_address = sta_if.ifconfig()[0] return ip_address def get_key(key_path): with open(key_path, "r") as f: key = f.read() return key def connect_to_mqtt(): print("CONNECTING TO MQTT BROKER...") global client client = MQTTClient( client_id=MQTT_CLIENT, server=MQTT_ENDPOINT, port=MQTT_PORT, keepalive=0, ssl=True, ssl_params={ "cert": get_key(THING_CLIENT_CERT), "key": get_key(THING_PRIVATE_KEY), "server_side": False } ) client.set_callback(subscription_call_back) try: client.connect() print("MQTT BROKER CONNECTION SUCCESSFUL") except Exception as e: print("MQTT CONNECTION FAILED: {}".format(e)) sys.exit() client.subscribe(MQTT_SUB_TOPIC) print("SUBSCRIBED TO TOPIC: {}".format(MQTT_SUB_TOPIC)) return def subscription_call_back(topic, msg): # confirm state update print("RECEIVING MESSAGE: {} FROM TOPIC: {}".format( msg.decode("utf-8"), topic.decode("utf-8"))) return def publish_message(topic, msg, qos=MQTT_QOS): client.publish( topic=topic, msg=msg, qos=qos) print("PUBLISHING MESSAGE: {} TO TOPIC: {}".format(msg, topic)) return # connect to wifi print("CONNECTING TO WIFI NETWORK") ip_address = connect_to_wifi(WIFI_SSID, WIFI_PASS) print("CONNECTED SUCCESSFULLY") print("YOUR IP ADDRESS IS: {}".format(ip_address)) # connect to mqtt print("CONNECTING TO MQTT BROKER") connect_to_mqtt() print("SUBSCRIBED TO TOPIC") while True: client.check_msg() tf = power.getTempInAXP192() msg = str(json.dumps({ "client": MQTT_CLIENT, "device": { "uptime": time.ticks_ms(), "hardware": info[0], "firmware": info[2] }, "sensors": { "TempInAXP192": tf }, "status": "online", })) publish_message(MQTT_TOPIC, msg) time.sleep(5)
-
@rashedtalukder Congrats, hope you are on to somewhere that appreciates your skills!