GithubHelp home page GithubHelp logo

goelvibhor4 / aws-iot-raspberry-pi-how-to Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sreid/aws-iot-raspberry-pi-how-to

0.0 2.0 0.0 155 KB

Quick guide to setting up a Raspberry Pi to run on the AWS IoT Platform

JavaScript 100.00%

aws-iot-raspberry-pi-how-to's Introduction

How to connect a Raspberry Pi to the AWS IoT Platform

by @sreid.

Intro

This is a simple getting started guide to setting up a Raspberry Pi to connect to the AWS Iot platform.

Pre-reqs:

  • Raspberry Pi with a working install of Raspbian
  • SSH or command line interfaces to the Pi

How To

Install Node

NodeJS is not currently in the Pi sources, however it can be easily with the following steps:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
node -v # v4.0.0

(based on instructions found here)

Create your working directory

For the code files, as well as for the certificates.

mkdir ~/aws-iot && cd ~/aws-iot
mkdir ~/aws-iot/certs

Install the AWS SDK

npm install https://github.com/aws/aws-iot-device-sdk-js

IoT Platform Setup

In the console, created a "Thing" called "pi_2".

Then on that thing's detail view, "Connect a Device"

Choose "NodeJS" and click "Generate Certificate & Policy". This will create a keypair, as well as add a policy to the pi_2 thing.

Be sure to download the certificate, public key, & private key to your computer.

###Copy Certificates to the Pi

Copy the <your-cert>-certificate.pem.crt and the <your-cert>-private.pem.key files to the ~/aws-iot/certs directory on your Pi

Also, grab the AWS CA certificate that's available from Symantec. This is for the MQTT client to verify it is connecting to a valid, Amazon controlled, server.

curl https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem > certs/rootCA.pem

Setup Test Script

The pi.js script in this repository will report the Pi's local IP using the AWS IoT platform. You can grab a copy from this repository here:

curl https://raw.githubusercontent.com/sreid/aws-iot-raspberry-pi-how-to/master/pi.js > pi.js

Edit the file and update the config block to match your setup:

var thingShadows = awsIot.thingShadow({
   keyPath: './certs/<your_cert>-private.pem.key',
  certPath: './certs/<your_cert>-certificate.pem.crt',
    caPath: './certs/rootCA.pem',
  clientId: myThingName,
    region: 'us-east-1'
});

Run It!

In the ~/aws-iot directory, run:

node pi.js

# Sample Output
Connected...
Registering...
Updating my IP address...
Update:pi_1-0
received accepted on pi_1: {"state":{"reported":{"ip":"192.168.2.247"}},"metadata":{"reported":{"ip":{"timestamp":1444691875}}},"timestamp":1444691875}

You should be able to then go to the AWS IoT console, and see the updated state information in the thing details.

Common Issues

TBD

Feedback

Questions? Comments? Problems? Don't hesistate to get in touch. GitHub issues and pull requests are welcome. --@sreid

aws-iot-raspberry-pi-how-to's People

Contributors

sreid avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.