Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Multiple AWSIoTPublish blocks?

tmo21
2021-11-10
2022-01-02
  • nothinrandom - 2022-01-02

    You can pretty much send anything to AWS IoT Core, but probably the best format is json; thus it should be in a format like {"val1":10,"val2": 20,"val3": 30} or formatted for better readability:

    {
        "val1": 10,
        "val2": 20,
        "val3": 30
    }
    

    Since you're just pointing the publishing client at some data location via pbPayload and specifying the data's size via udiPayloadSize, you just need to wait until xDone is active, and then load new data into the same location. For example, you could create a STRING called myPayloadString with value of above (e.g. {"val1":10...} and then use pbPayload:=ADR(myPayloadString) and then specify size using udiPayloadSize:=len(myPayloadString). Wait until xDone is active, then go ahead and modify myPayloadString with some other values and then send on the next cycle.

    You could pack as many values as you want into this payload string or you could separate them. Keep in mind that you're paying per message transaction also...

     

Log in to post a comment.