Jay Taylor's notes
back to listing indexBB-8's AWS Adventure
[web search]BB-8's AWS Adventure
- Made by Paul Langdon-
- Published in Alex's Faves, Amazon Web Services, Intel, Sensors, Sphero, and Star Wars
About this project
Sphero's BB-8 uses the Intel Edison and Amazon Web Services to communicate back to the rebel forces.
Project info
Things used in this project
| × | 1 | | |||
| × | 1 | |
| |
Story
In a galaxy far, far away...
A droid named BB-8 needed to communicate large amounts of data to the rebellion so large super computers could analyze and explore the remote planet of MyOfficeCube.
Equipped with only a short range communicator, BB-8 was forced to proxy it's sensor data to a local node and pass it through it's broadband connection to rebels AWS outpost.
We begin our adventure as BB-8 connects to the lone Intel Edison and starts its transmission...
------------------------------------------------
This project will connect a Sphero BB-8 to the AWS-IOT via an Intel Edison.
Once connected the BB-8 will be set loose in a space and begin transmitting sensor data to AWS.
Sensor data available on BB-8 includes:
- Temperature
- Location (based on 2D internal map set from start)
- Acceleration
- Gyroscopic reading
- Odometer
- Velocity
- Collision Detection
To get started in our project, we are going to be collecting BB-8's location including:
- X-Position
- Y-Position
- X-Velocity
- Y-Velocity
- Speed Over Ground
BB-8 will be moving in a random direction, switching it's direction every 5 seconds. These values will be transmitted up to AWS-IOT every 5 seconds.
There is some setup to make this process easier, lets start with getting your Intel Edison set up.
Setup Intel Edison with AWS
(Adapted and improved from https://github.com/intel-iot-devkit/aws-iot-intel)
Prepare your Intel Edison:
Get started with your Intel Edison by updating to the latest firmware and setting up a serial terminal. You can find instructions here: Get started with Intel Edison technology
Install dependencies:
npm install -g inherits
npm install -g mqtt
npm install -g minimist
Install AWS CLI:
Install pip (Python package manager):
$ curl https://bootstrap.pypa.io/ez_setup.py -o - | python
$ easy_install pip
Install AWS CLI with pip:
$ pip install awscli
Install dependencies: In order to view help files ("aws iot help"), install Groff and a non-BusyBox version of less.
Groff:
$ wget http://ftp.gnu.org/gnu/groff/groff-1.22.3.tar.gz
$ tar -zxvf groff-1.22.3.tar.gz
$ cd groff-1.22.3
$ ./configure
$ make
$ make install
$ export PATH=$PATH:/usr/local/bin/
$ cd ~
Less: First rename the old version of less.
$ mv /usr/bin/less /usr/bin/less-OLD
Then install the new version of less:
$ wget http://www.greenwoodsoftware.com/less/less-458.zip
$ unzip less-458.zip
$ cd less-458
$ chmod 777 *
$ ./configure
$ make
$ make install
$ cd ~
To make sure everything has installed correctly, run the iot help file:
$ aws iot help
Signing up for AWS
Aws Cli is now installed. Make new user and get credentials from the aws console following instructions at:
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup. Once you have an access ID and key you can configure aws and enter the ID and key with:
aws configure
NOTE: for default region you must enter us-east-1 in order to be able to configure AWS for IoT. The default format can be left as json.
In order to get permission to download the AWS IoT tools, attach the administrator account policy to the user. To do this go to the "Users Panel" in the IAM console, select the user you created, attach policy, and select administrator account.
Generate Certificates:
First create a folder to store your certificates in:
mkdir aws_certs
cd aws_certs
Generate a private key with open ssl:
$ openssl genrsa -out privateKey.pem 2048
$ openssl req -new -key privateKey.pem -out cert.csr
- Fill out the fields with your info.
- Run the following to activate the certificate:
$ aws iot --endpoint-url https://i.internal.iot.us-east-1.amazonaws.com create-certificate-from-csr --certificate-signing-request file://cert.csr --set-as-active > certOutput.txt
Run the following to save the certificate into a cert.pem file:
null
$ aws iot --endpoint-url https://i.internal.iot.us-east-1.amazonaws.com describe-certificate --certificate-id <certificateID> --output text --query certificateDescription.certificatePem > cert.pem
null
null
NOTE: Replace with the ID stored in the "certificateId" field in certOutput.txt. To view the file enter:
$ more certOutput.txt
Create a Json policy document for AWS IoT SDK: Copy the following text (ctrl-c):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:*"
],
"Resource": [
"*"
]
}
]
}
- Enter "$ vi policy.doc" hit "a" and right-click to paste the text.
- Hit escape and type in ":wq" to save and quit.
** Attach the policy to your certificate ** First enter:
$ aws iot --endpoint-url https://i.internal.iot.us-east-1.amazonaws.com create-policy --policy-name PubSubToAnyTopic --policy-document file://policy.doc
Then attach the policy to the certificate with:
$ aws iot --endpoint-url https://i.internal.iot.us-east-1.amazonaws.com attach-principal-policy --principal <certificateArn> --policy-name "PubSubToAnyTopic"
NOTE: replace with the value stored in "certificateArn" in the certOutput.txt file.
NOTE:
To interact with AWS IoT from your device using the certificates you created, you will also need a root certificate. Click here to download the root certificate. Save this file to your desktop and name it “aws-iot-rootCA.crt”
or
curl https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem > ~/aws_certs/aws-iot-rootCA.crt
Configure Intel Edison for Bluetooth LE
(from http://rexstjohn.com/configure-intel-edison-for-bluetooth-le-smart-development/ )
Lets turn on BLE :
rfkill unblock bluetooth
hciconfig hci0 up
vi /etc/opkg/base-feeds.conf (insert only following lines)
src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
Note: “vi” is a barebones text editor which has some confusing syntax. Copy and paste (e.g. vi’s insert mode) the above three lines into the .conf file indicated and then close vi by hitting “Shift + :” (to leave Insert mode) after making the above edit and then typing “wq” and hitting enter to write the change and then quit.
Before we proceed, make sure your Edison is online via Wi-Fi.
Now run:
opkg update
opkg install bluez5-dev
Next, we will install Bleno and Noble, useful Node.js utilities for doing fun stuff with BLE and Javascript:
npm install -g async
npm install noble
npm install bleno
The key to getting Bleno working seems to be this (see the bug linked above):
rfkill unblock bluetooth
killall bluetoothd (or, more permanently) systemctl disable bluetooth
hciconfig hci0 up
Once this is done, you should be able to use Edison with Bluetooth LE.
Code
1To connect to your BB-8 or Ollie, you first need to determine its UUID. 2Once you have Noble installed, you can use the advertisement-discovery.js 3program to determine the device's UUID: 4 5 6$ node ./node_modules/noble/examples/advertisement-discovery.js 7peripheral discovered (944f561f8cf441f3b5405ed48f5c63cf with address <unknown, unknown>, connectable true, RSSI -73: 8 hello my local name is: 9 BB-131D 10 can I interest you in any of the following advertised services: 11 [] 12 here is my manufacturer data: 13 "3330" 14 my TX power level is: 15 -18
Credits
Comments
Gaurav Mishra
5 months agoHats off to you. I had to chew my hat off trying to connect edison to aws.
The github repository sucks for people like me.
rory cawley
4 months agoI've just bought the BB8 and Edison board from Amazon, have told the kids about it and they are excited. Thanks for posting this up.
Any thoughts on extending this for voice control?
Similar projects you might like
- 1,407
- 56
Work in progress
Detect road accident, raise SOS, share location, share & monitor vital health stats during accident using Pebble. #SaveLife
Life Saver
Team Enigma