[PYTHON] Send data from Raspberry Pi using AWS IOT

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.

  1. Select IoT from the AWS management screen. スクリーンショット 2016-12-23 16.40.46.png

  2. Create Things. This time I created it with the name of Baobab. Screenshot 2016-12-23 18.25.48.png スクリーンショット 2016-12-23 18.25.34.png

  3. Create a certificate to connect to AWS IoT and download it as Activate. スクリーンショット 2016-12-23 16.44.20.png スクリーンショット 2016-12-23 16.44.44.png

  4. Download the SDK to connect to AWS IoT from Raspberry Pi, Also copy the HTTPS endpoint on this screen. スクリーンショット_2016-12-23_18_31_29.jpg This time, select LINUX / OSX-> Python. It supports Python 2.7+ or Python 3.3+. スクリーンショット 2016-12-23 18.32.25.png

Here is a reference for how to use it. https://github.com/aws/aws-iot-device-sdk-python

  1. Upload the key downloaded in 3. and the SDK downloaded in 4. to the Raspberry Pi using SCP or FTP software.

  2. 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
  1. Log in to Raspberry Pi with a terminal and install the SDK.
$ pip install AWSIoTPythonSDK
  1. Check the connection with the sample program.
$ 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.

  1. You can also check it on the dashboard.

スクリーンショット 2016-12-23 18.46.46.png

While recreating the previous Python program Review the overall design, such as connecting to a DB with Lambda.

Recommended Posts

Send data from Raspberry Pi using AWS IOT
Play to notify Slack of environmental data using AWS PaaS from SensorTag via Raspberry Pi3
Easy connection between Raspberry Pi and AWS IoT
Raspberry Pi and AWS IoT connection program example
Monitor temperature using Raspberry Pi + Alibaba cloud IoT platform
Indoor monitoring using Raspberry Pi
Run AWS IoT Device SDK for Python on Raspberry Pi
How to get temperature from switchBot thermo-hygrometer using raspberry Pi
I tried using the Pi Console I / F of the Raspberry Pi IoT starter kit "anyPi" from Mechatrax.
USB over ethernet using Raspberry pi
Output from Raspberry Pi to Line
Try using ArUco on Raspberry Pi
Get data from Twitter using Tweepy
Using a webcam with Raspberry Pi
Cospa's strongest IoT home appliances! Operate TPLink products from Raspberry Pi
Create your own IoT platform using raspberry pi and ESP32 (Part 1)
[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
Detect "brightness" using python on Raspberry Pi 3!
Make Raspberry Pi speak Japanese using OpenJtalk
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
Using the 1-Wire Digital Temperature Sensor DS18B20 from Python on a Raspberry Pi
Control Akizuki's I2C-connected OLED display from Raspberry Pi
Detect slide switches using python on Raspberry Pi 3!
Try using a QR code on a Raspberry Pi
Detect magnet switches using python on Raspberry Pi 3!
Encrypt / decrypt data from golang using Azure KeyVault
CSV output of pulse data with Raspberry Pi (CSV output)
Sound the buzzer using python on Raspberry Pi 3!
Create a visitor notification system using Raspberry Pi
Connect your Raspberry Pi to your smartphone using Blynk
[AWS] Migrate data from DynamoDB to Aurora MySQL
Realize a super IoT house by acquiring sensor data in the house with Raspberry Pi
Raspberry Pi backup
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby
Use kintone API SDK for Python on Raspberry Pi (easily store data in kintone from Raspberry Pi)
Create your own IoT platform using raspberry pi and ESP32 (Part 2) ~ ESP32 setting L Chika
From setting up Raspberry Pi to installing Python environment
Build an OpenCV4 environment on Raspberry Pi using Poetry
Create a color sensor using a Raspberry Pi and a camera
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Try using COVID-19's open data from Yokohama / Tokyo / Osaka
Visualize network data using Cytoscape from IPython Notebook Part 1
Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi
Send log data from the server to Splunk Cloud
[AWS] Operate SQS from SDK (send / receive) [Python] [Node.js]
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Send data from Python to Processing via socket communication
termux × AWS Send smartphone location information to AWS with IoT
Face detection from images taken with Raspberry Pi camera
I tried reading data from a file using Node.js.
Output to "7-segment LED" using python on Raspberry Pi 3!