I was trying to collect data with the REST API of the Rails app on Sakura VPS, but I want to try AWS IoT and set it up.
From Raspberry Pi2 B to connecting to AWS IoT.
Select IoT from the AWS management screen.
Create Things. This time I created it with the name of Baobab.
Create a certificate to connect to AWS IoT and download it as Activate.
Download the SDK to connect to AWS IoT from Raspberry Pi, Also copy the HTTPS endpoint on this screen. This time, select LINUX / OSX-> Python. It supports Python 2.7+ or Python 3.3+.
Here is a reference for how to use it. https://github.com/aws/aws-iot-device-sdk-python
Upload the key downloaded in 3. and the SDK downloaded in 4. to the Raspberry Pi using SCP or FTP software.
Prepare the AWS IoT root CA in the same directory as the key.
curl https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem -o rootCA.pem
$ pip install AWSIoTPythonSDK
$ python basicPubSub.py -e <endpoint> -r <rootCAFilePath> -c <certFilePath> -k <privateKeyFilePath>
The key file is described with the full path.
2016-12-23 18:40:01,310 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Publish request 2 succeeded.
Received a new message:
New Message 0
from topic:
sdk/test/Python
--------------
2016-12-23 18:40:02,315 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Try to put a publish request 3 in the TCP stack.
2016-12-23 18:40:02,317 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Publish request 3 succeeded.
Received a new message:
New Message 1
from topic:
sdk/test/Python
--------------
I was able to connect.
While recreating the previous Python program Review the overall design, such as connecting to a DB with Lambda.
Recommended Posts