Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. bmtd111
    3. Posts
    B
    • Continue chat with bmtd111
    • Start new chat with bmtd111
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by bmtd111

    • RE: Initiating connection to AWS

      Thank you for your reply!

      Here is my Pythoncode:

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import machine
      import wifiCfg
      from IoTcloud.AWS import AWS
      import ntptime
      import json
      PingCounter = None
      ThingsName = None
      currentDoorState = None
      lastDoorState = None
      from numbers import Number

      @timerSch.event('AWSTimer')
      def tAWSTimer():
      global PingCounter, ThingsName, currentDoorState, lastDoorState, pin1
      if wifiCfg.wlan_sta.isconnected():
      PingCounter = (PingCounter if isinstance(PingCounter, Number) else 0) + 1
      aws.publish(str('DoorState/ping'),str((json.dumps(({'time':(ntp.formatDatetime('-', ':')),'ping':PingCounter,'reconnect':False})))))
      else:
      wifiCfg.doConnect('BesserMITTAG-IOT', "Zsip-uwYpDe'")
      PingCounter = (PingCounter if isinstance(PingCounter, Number) else 0) + 1
      aws.publish(str('DoorState/ping'),str((json.dumps(({'ping':PingCounter,'time':(ntp.formatDatetime('-', ':')),'reconnect':True})))))
      pass

      @timerSch.event('restartTimer')
      def trestartTimer():
      global PingCounter, ThingsName, currentDoorState, lastDoorState, pin1
      machine.reset()
      pass

      import gc
      wifiCfg.doConnect('BesserMITTAG-IOT', "Zsip-uwYpDe'")
      ntp = ntptime.client(host='de.pool.ntp.org', timezone=1)
      timerSch.run('restartTimer', 10800000, 0x00)
      PingCounter = 0
      ThingsName = 'D30002'
      aws = AWS(things_name=ThingsName, host='hostName', port=8883, keepalive=1000, cert_file_path="/flash/res/certificate.pem.crt", private_key_path="/flash/res/private.pem.key")
      aws.start()
      gc.collect()
      aws.publish(str('DoorState/connect'),str((json.dumps(({'connect':'request'})))))
      timerSch.run('AWSTimer', 900000, 0x00)
      pin1 = machine.Pin(26, mode=machine.Pin.IN, pull=machine.Pin.PULL_UP)
      currentDoorState = pin1.value()
      while True:
      lastDoorState = currentDoorState
      currentDoorState = pin1.value()
      if lastDoorState == 1 and currentDoorState == 0:
      rgb.setColorAll(0x33cc00)
      aws.publish(str('DoorState/test'),str((json.dumps(({'open':(ntp.formatDatetime('-', ':')),'Message':'15','TopicArn':'arn:aws:sns:eu-central-1:684143602652:L-from-device','MessageAttributes':({'DataType':'String','StringValue':'door-opened'}),'DeviceID':({'DataType':'String','StringValue':'A1005'})})))))
      elif lastDoorState == 0 and currentDoorState == 1:
      rgb.setColorAll(0xff0000)
      aws.publish(str('DoorState/test'),str((json.dumps(({'close':(ntp.formatDatetime('-', ':')),'Message':'16','TopicArn':'arn:aws:sns:eu-central-1:684143602652:L-from-device','MessageAttributes':({'DataType':'String','StringValue':'door-closed'}),'DeviceID':({'DataType':'String','StringValue':'A1005'})})))))
      wait_ms(2)

      I have set everything up in AWS, the connection was already established and worked fine.
      Do you mean a device shadow with digital twin? I dont see how that could resolve the issue.

      With kind regards,
      TD

      posted in UIFlow
      B
      bmtd111
    • RE: Initiating connection to AWS

      Line 51 in my code is just aws.start() and it seems to call functions in the libraries. Maybe there is a bug in IoTCloud/AWS.py?

      posted in UIFlow
      B
      bmtd111
    • Initiating connection to AWS

      Dear People
      I am currently working on a System that needs to connect to AWS. Sadly i get the following Error messages when I Execute my code: 0_1679405029035_Support.PNG

      I am using an ATOM Lite and UIFlow 1.11.3

      I hope you guys can help me

      With kind regards,
      TD

      posted in UIFlow
      B
      bmtd111
    • RE: How can an atom lite listen forever to a mqtt topic?

      On a side-note, this is the programm im running on a seperate atom lite using the same UIFlow version.
      It just sends a request every once in a while.
      My code:0_1678358577548_Forum_publish.PNG

      May be somebody has some thoughts for this as well.

      Kind regards
      TD

      posted in UIFlow
      B
      bmtd111
    • RE: How can I download my old script from a device?

      What kind of IDE and what kind of Device are you using? If you use the UIFlow IDE you can open the file and the download it on your computer. Burning a new firmware on the device will most likely delete the code.

      Kind regards
      TD

      posted in UIFlow
      B
      bmtd111
    • How can an atom lite listen forever to a mqtt topic?

      Dear people,
      I am trying to build a listener device thats subscribes to a topic on AWS Mqtt and opens/closes a door when the right message comes on. I am using an Atom lite and UIFlow_Lite v1.11.3
      What I find most confusing is that the RGB LED just stays red when executing (downloaded and not connected to the pc, only power cable) this code but the atom is available and sends the "message received" message when receiving an order. Becaus AWS MQTT doenst allow keepalive = 0 i dod the workaround of connecting again every 25 mins.
      My Code: 0_1678298518897_Forum.PNG

      I would love to hear your thoughts on this.
      Kind regards

      posted in UIFlow
      B
      bmtd111
    • RE: Fragen eines M5Stack newbie...

      Du kannst auch andere IDEs nehmen, die Arduiono IDE oder VS Code zum Beispiel. Aber das hängt eventuell auch ab was für einen Microcontroller du benutzen willst.

      posted in Deutsches Forum
      B
      bmtd111
    • RE: Possible Problems with MQTT?

      @mchott I configurated the Wifi connection using the M5burner. I will try to implement it in my code thoug, see if that makes a difference

      posted in UIFlow
      B
      bmtd111
    • Possible Problems with MQTT?

      Hello,
      I'm currently working on a Project that requires me to monitor a door and post everytime the door gets opened or closed.
      I came up with the following Setup on an Atom Lite using the UIFlow IDE v1.11.1: 0_1674576135767_door_aws_1.PNG 1_1674576135767_door_aws_2.PNG
      On aws I'm subscribed to the Topic:"isDoorOpen/+/data" so i can collect data from different devices.
      My Problem is that it seems to be very inconsistent. I download the code to the Atom and it restarts and enters the App mode. At this Point everything seems to be working well, the LED changes and i see the messages on aws. But as soon as I try to attach everything to a door like this: ![0_1674576432603_20230124_165205.jpg](Uploading 100%) it doesnt seem to work. The LED sometimes stays red or the LED changes from red to green, detecting the motions correctly but doesnt post anything to aws.

      Are there any known bugs or complications that could cause this? Or anything wrong with my code?

      Thank you!

      posted in UIFlow
      B
      bmtd111