Thursday, October 27, 2016

How to use a computer as an IoT device to connect AWS IoT service?

Although we don't have Amazon IoT Button or other devices to try AWS IoT, please remember that our computers are devices. Therefore make them IoT.

The sample basicPubSub.py in AWS IoT Python SDK can help us do it.

We follow AWS IoT tutorial to create a device certificate. We download the device certificate, its root CA, and its private key in our local path where the sample exists.

We also create a policy, and a device. We attach both resources into the device certificate.

Because the command arguments of the sample are too long, I prefer to write a makefile Test.mk to test it.

E1 = a2uc??????????.iot.us-west-2.amazonaws.com 
R1 = VeriSign-Class\ 3-Public-Primary-Certification-Authority-G5.pem
C1 = 5988??????-certificate.pem.crt
K1 = 5988??????-private.pem.key

dev1:
    python3 basicPubSub.py -e $(E1) -r $(R1) -c $(C1) -k $(K1)

Run the sample.

>make -f Test.mk dev1

It will publish messages and receive subscribed messages in loop.


-Count

No comments:

Post a Comment