Run AWS IoT Device SDK for Python on Raspberry Pi

AWS IoT Device SDK for Python This time, I will run the sample attached to AWS IoT Device SDK for Python with Raspberry Pi and store the data in S3.

What you have prepared

RaspberryPi 3 Any Raspberry Pi in the first place will do

RASPBIAN JESSIE OS has been updated to the latest

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux

AWS account

AWS IoT preparation

Set from the AWS Management Console.

Create a thing First, make something. q-ss01s.png

Here, the name is raspi1.

Create a rule Next, create a rule for things.

If you click the "raspi1" thing you created earlier, Details will appear on the right side. Then press the Create a rule button at the bottom right. q-ss02s.png

Then this screen. q-ss03s.png

Here, the name of the rule is raspi1_rule.

Where it looks like SQL, you can filter the data sent from thing. In the sample code of the SDK, the Topic "sdk / test / Python" will be sent, so enter the following here.

name value
Attribute *
Topic filter sdk/test/Python

Scrolling the screen and setting the next Choose an action is where you decide what to do with the received data. q-ss04s.png

Here, we will store the data in S3.

Enter the S3 bucket, Key, and Role name. You can also create and configure it on the fly with Create a new resource, so I created a temporary bucket for testing. Please be careful about permissions when using existing ones.

Press the Add Action → Create button to complete the rule.

Connect a device Finally, set the authentication information from the device that actually connects to thing.

Press the Connect a device button to the right of the button that created the rule. q-ss05s.png

Then, which SDK do you use? I can choose, but I can't find Python. q-ss06s.png

There is no way to do it, so if you select NodeJS, a button called Generate certificate and policy will appear, so press it. q-ss07s.png

This time, you will see three links and buttons. q-ss08s.png

First, click the three links from Download to download the certificate.

After downloading, press the Confirm & start connecting button. q-ss09s.png

Copy and paste in the text box here and press the Return to Thing Detail button.

Preparing the Raspberry Pi

Installing the AWS IoT Device SDK for Python

Saitama's RASPBIAN JESSIE contains pip, so install it with pip. sudo pip install AWSIoTPythonSDK With or without sudo as appropriate.

Download sample code

The sample code is also included in the source tree, so clone it from github. git clone https://github.com/aws/aws-iot-device-sdk-python.git

Certificate preparation

Three certificate files are required to execute the sample code. This time, put it in the same directory as the sample code.

Send all the certificates downloaded when you prepared AWS IoT to Raspberry Pi by scp etc.

--Honyara-certificate.pem.crt --Honyara-private.pem.key

Next, prepare the AWS IoT root CA. curl https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem -o rootCA.pem

It is saved as rootCA.pem.

Run sample code

Specify endpoint and various certificate paths as arguments.

The endpoint is the AWS host name, and "" host ":" somewhere "" appears in the text box that appears at the end of the AWS IoT preparation. Alternatively, in the management console, the host name will also appear in the Detail that appears when you click thing (correctly, it is the destination of the REST API, so only the host name part of it) q-ss10s.png

python basicPubSub.py -e Somewhere .amazonaws.com -r rootCA.pem -c Honyara -certificate.pem.crt -k Honyara -private.pem.key

When executed, it throws a message at 1 second intervals. Check the displayed log and if there is no problem, Ctrl + C in about 10 seconds.

Look at the S3 bucket

The file will be created in the bucket set this time. It is successful if the contents are updated for the number of seconds that the sample code is executed. New Message 10

Recommended Posts

Run AWS IoT Device SDK for Python on Raspberry Pi
Run servomotor on Raspberry Pi 3 using python
Fleet provisioning with AWS IoT SDK for Python v2
Access google spreadsheet using python on raspberry pi (for myself)
Run Python on Schedule on AWS Lambda
boto3 (AWS SDK for Python) Note
Use kintone API SDK for Python on Raspberry Pi (easily store data in kintone from Raspberry Pi)
Translate I2C device driver for Arduino to Python for Raspberry pi
Detect "brightness" using python on Raspberry Pi 3!
Adafruit Python BluefruitLE works on Raspberry Pi.
[Python] Run Headless Chrome on AWS Lambda
Detect temperature using python on Raspberry Pi 3!
Working with GPS on Raspberry Pi 3 Python
Periodically run a python program on AWS Lambda
Detect slide switches using python on Raspberry Pi 3!
Detect magnet switches using python on Raspberry Pi 3!
Send data from Raspberry Pi using AWS IOT
Easy connection between Raspberry Pi and AWS IoT
Make DHT11 available on Raspberry Pi + python (memo)
Python mock to try AWS IoT Device Shadow
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
Sound the buzzer using python on Raspberry Pi 3!
(For myself) AWS_Flask_3 (Install / Run Flask on AWS)
Raspberry Pi and AWS IoT connection program example
Call Polly from the AWS SDK for Python
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
pigpio on Raspberry pi
Cython on Raspberry Pi
Authentication information used by Boto3 (AWS SDK for Python)
Run LEDmatrix interactively with Raspberry Pi 3B + on Slackbot
[AWS IoT] Register things in AWS IoT using the AWS IoT Python SDK
Try debugging Python on Raspberry Pi with Visual Studio.
Support for Python 2.7 runtime on AWS Lambda (as of 2020.1)
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Install pyenv on Raspberry Pi and version control Python
AWS SDK for Python (Boto3) development in Visual Studio 2017
Output to "7-segment LED" using python on Raspberry Pi 3!
Use AWS SDK for Python (boto) under Proxy environment
[Note] The story of setting up the SDK for Python of Azure IoT Hub on Linux
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby
Script to easily create a client device environment for AWS IoT (Python v2 version)
Run Openpose on Python (Windows)
VScode intellisense doesn't work on Raspberry Pi OS 64bit! (Python)
Update Python for Raspberry Pi to 3.7 or later with pyenv
Raspberry Pi + python + IoT device, environment construction procedure to start image processing and machine learning
Install AWS SDK for PHP on AWS EC2 (PHP7.2 + Apache2.4.41 + OPCashe + Composer)
Cross-compiling for Raspberry Pi Zero on Debian-Try using shared libraries
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
Run Tensorflow 2.x on Python 3.7
Run BNO055 python sample code with I2C (Raspberry Pi 3B)
Raspberry Pi + Python + OpenGL memo
Run Python CGI on CORESERVER
Run unix command on python
raspberry pi 1 model b, python
Run YOLO v3 on AWS v2
Introduced pyenv on Raspberry Pi
Use NeoPixel on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
Run YOLO v3 on AWS