IOT, SensorTag 2650 and Raspberry Pi - Demo
This repository demo the integration of TI SensorTag 2650, Raspberry Pi 2 (Gateway) and Cloud service (AWS).
The underlying implementation of bluebooth gateway on Raspberry Pi is from Ian Harvey
Kinesis connectors library are from awslabs, these connectors are used to push data to S3 and redshift.
Real Time charting .js library
High Level Overview
Detailed Presentation deck
1 x Raspberry Pi 2
1 x Raspberry Pi B+
4 x TI CC2650 SensorTag
Web Application Visualization
Showing the light sensor readings (Lux) in real-time, there are 4 sensor tag connected to Pi (Gateway) sending data to internet
Cloud Services used (AWS)
Required to be set up behind the scene
- EC2 servers
- S3 bucket
- IAM Policy
Source code structure
Python / NodeJS source required to be installed on devices and EC2 servers. You can refer to above picture, I used “Visual Studio Code” myself to maintain the folder structure, but you can pretty much use any other editor tool.
This is the core of everything, this runs on Raspberry Pi 2 Model B, Raspbian OS, gathering readings from the 4 sensortags through “Bluetooth Low Energy”, then fire the data in JSON format to kinesis stream. You need to install Python 2.7, bluez (linux Bluetooth kernel package) and bluepy (python BLE code), have “hciconfig hci0 up” already run, edit the sensortag.py, put in the correct MAC addresses for each SensorTag, then bash start the “push_kinesis_all.sh”.
This will then sending data to a kinesis stream called “RaspberryPiStream” with 2 shards (which you need to set up beforehand). Once you done all that, you verify everything is coming through the stream first, before moving to the next step. Note : No credentials is hardcoded, so you need to install the AWS Python SDK (boto), get the credentials setup, etc.
Original Code Reference : ( I have modified the code to make it work with CC2650 )
This is a Python kinesis worker running on a c4.large EC2, which consume the data in parallel, based on how many shards there are, then spawn up separate threads to get the kinesis record (JSON data), The workers are doing detection on the “Lux” and “Temperature” readings, once the lux is below 10 (very dark), then it will generate another record into another Kinesis stream “LightAlert”, the same goes for temperature. After that all data are then pass through to “Elastic Cache”. (which you need to pre-setup yourself)
Original Code Reference :
Note : You would need to install several NodeJS package, like “redis”, “server-static”, etc
Original Code Reference :
http://epochjs.github.io/epoch/ ( for charting )
https://github.com/awslabs/aws-big-data-blog/tree/master/aws-blog-kinesis-storm-clickstream-app (Original idea from this, but I modify not to use the “Apache Storm” part to simplify the setup. )
4. raspberry-alert-worker ( Optional )
This runs on Raspberry Pi 2 Model B, Raspbian OS as well, it enrich the demo by having a trigger interaction. When “kinesis-redis-worker” is firing the alerts to “TemperatureAlert” and “LightAlert” kinesis streams, the python client is running locally to retrieve this records, then trigger the LED to lights up.
You would need to get this ModMyPi kit set up with your Raspberry Pi first though.
At least you have need to get “Tutorial 2” done, get the LED lights going.
To kick start the daemon, bash start “long-trigger-temperature.sh”.
## Important Note
Be aware that this demo implementation uses other components from GitHub, awslabs, each of which might have different licenses terms. This demo is purely for demonstration purpose, and not meant to be used in production.