I have been playing around with the AWSIoT example project and have managed to get things working on a Raspberry pi - thanks to the awesome guide available here (thanks to the person that shared this!)
I am sending a value using the AWSIotPublish_0 - now this is probably a very dumb question but here goes...
If i want to send multiple registers across to AWS - how do I go about doing it?
I tried creating another AWSIoTPublish block (AWSIotPublish_1) but this just has the error "client_not_connected"
Wondering if anyone can shed some light on best practice for this type of thing,
Should I only be using one IoTPublish block per project and incrementing the publish topic/message?
Or is there a way I can pack a whole bunch of registers into the one message?
Any advice or example projects on how to go about tackling this would be much appreciated!
Cheers,
Trent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey everyone,
I have been playing around with the AWSIoT example project and have managed to get things working on a Raspberry pi - thanks to the awesome guide available here (thanks to the person that shared this!)
https://forge.codesys.com/forge/talk/Engineering/thread/eb7b1c293b/56c7/attachment/Wie%20mach%20ich%20die%20AWS%20IoT%20Core%20Client%20Beispiel_%20_%20How%20to%20I%20get%20the%20AWS%20IoT%20Core%20Client%20example%20to%20work_-v3-20200615_222346.pdf
I am sending a value using the AWSIotPublish_0 - now this is probably a very dumb question but here goes...
If i want to send multiple registers across to AWS - how do I go about doing it?
I tried creating another AWSIoTPublish block (AWSIotPublish_1) but this just has the error "client_not_connected"
Wondering if anyone can shed some light on best practice for this type of thing,
Should I only be using one IoTPublish block per project and incrementing the publish topic/message?
Or is there a way I can pack a whole bunch of registers into the one message?
Any advice or example projects on how to go about tackling this would be much appreciated!
Cheers,
Trent
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: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...