Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. kulmam92
    K
    • Continue chat with kulmam92
    • Start new chat with kulmam92
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    kulmam92

    @kulmam92

    1
    Reputation
    7
    Posts
    435
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    kulmam92 Follow

    Posts made by kulmam92

    • RE: AWS IoT SDK support

      @ajb2k3 I’m afraid but I’m not the author of that post. But, I agree that it’s a well written one. Regarding device shadow, this is what I meant:
      local shadow.png

      • Interact with device shadows
      posted in General
      K
      kulmam92
    • RE: AWS IoT SDK support

      @ajb2k3 Thank you for your effort and update. The flow that I have in mind is:

      Core2(Greengrass client using aws IoT device SDK) -> RaspberryPi(Greengrass) -> AWS IoT Core

      The reason that I want to use this is to demonstrate the features of the AWS Greengrass like:

      • ML at the edge: core2 send image to RaspberryPi(Greengrass) and run ML like object detection.
      • device shadow
      • device defender

      You may send message to RsapberryPi(Greengrass) via mqttclient like below but you can’t use device shadow or device defender.

      https://www.rosietheredrobot.com/2019/03/green-green-grass-of-home.html?m=1

      I hope this give you a clear picture of what I’m trying to do.

      posted in General
      K
      kulmam92
    • RE: AWS IoT SDK support

      @ajb2k3 FYI, the below are the closest attempts that I was able to find.

      • Embed aws iot device sdk to Micropython as user C module - stackoverflow question
      • Releasing LTS of AWS IoT Device SDK for Embedded C on ESP32
      posted in General
      K
      kulmam92
    • RE: AWS IoT SDK support

      @ajb2k3 Did you have a chance to test out if there's any way to do this?

      posted in General
      K
      kulmam92
    • RE: AWS IoT Edukit Core M5 - Micropython support?

      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)
      
      posted in Core2 for AWS
      K
      kulmam92
    • RE: AWS IoT SDK support

      The sample(https://github.com/aws/aws-iot-device-sdk-python-v2/blob/main/samples/basic_discovery.py) uses below imports:

      import time
      import json
      from concurrent.futures import Future
      from awscrt import io
      from awscrt.mqtt import QoS
      from awsiot.greengrass_discovery import DiscoveryClient
      from awsiot import mqtt_connection_builder

      If you run that script on core2, you will get an error because concurrent, awscrt, and awsiot don't exist in the core2. It will be great if I can make those available from core2.

      posted in General
      K
      kulmam92
    • AWS IoT SDK support

      Is there any way to install AWS IoT SDK to be able to use core2 as a greengrass client device?
      https://docs.aws.amazon.com//greengrass/v2/developerguide/client-devices-tutorial.html#connect-client-devices-tutorial

      posted in General
      K
      kulmam92