The basic connection method is easy to follow AWS IoT Development Guide. However, there are two methods, and I tried both. Here, we will explain how to use the "Connection Wizard", which is easy and much faster to set up. (If you are ready, it will take about 30 minutes)
--Enter the AWS IoT menu from your PC --Onboard selection --Device onboard --Click how to start --Platform selection --Select Linux / OS X --Selection of AWS IoT Device SDK --Here, select Python --Click Next --Registration of things. Register the name of Raspberry Pi. --Download connection kit --connect_device_package.zip is downloaded --Unzip the file downloaded to your PC --Unzipped directory name: connect_device_package --There are the following files - RaspberryPi_test.cert.pem - RaspberryPi_test.private.key - RaspberryPi_test.public.key - start.sh --According to the README, communication encryption uses an X.509 certificate with the TLS protocol. --Transfer the file downloaded to your PC to Respberry Pi --Create an arbitrary directory on Raspberry Pi --Copy each directory to Raspberry Pi with scp command from PC --Open a command terminal on your PC -$ scp -r Copy source directory name User name @ IP address: Raspberry Pi path --Run the shell you copied from the Raspberry Pi terminal - $ sudo ./start.sh --The following error occurred in my environment - start.sh: 19: ./start.sh: pushd: not found --Add #! / Bin / bash to the first line of start.sh and execute again --aws-iot-device-sdk-python is coulombed from git --The MQTT sample application was successfully executed after being connected to the cloud, and the connection was confirmed! --Directory of sample application to be executed: aws-iot-device-sdk-python / samples / basicPubSub --Sample shell to be executed: basicPubSub.py
-From "Getting Started with AWS IoT Core" in AWS IoT Development Guide It is also possible to proceed one by one. --From the point of view of connecting with Raspberry Pi, it is wonderful that there is "Use AWS IoT Device SDK with Raspberry Pi" in the menu. This is probably because the Raspberry Pi is widespread for IoT devices or learning. However, it's a pity that the development guide doesn't explain the Python SDK. For now, the "Use AWS IoT Device SDK with Raspberry Pi" menu only uses the AWS IoT Device SDK for Embedded C and the AWS IoT Device SDK for JavaScript and Node.
That's how to connect. Experience with the two methods has shown that it is much easier to set from the "onboard" menu.
When I tried various connection methods, I got an error that the key and certificate did not match when connecting. The method of checking with the openssl command was convenient. Qiita link The connection confirmation by the pub / sub program is described in another Qiita article.
For the AWS IoT Python SDK, see GitHub for a script description.
Recommended Posts