Automatic to Smartthings, supported by AWS API Gateway + Lambda

“Automatic To Smartthings” is a fully loaded package to have the Automatic OBD2 Adapter integrated with Smartthings.

  • Immediately push every Automatic event update to Smartthings
  • Provide a new device type on Smartthings as a Presence Sensor
  • Display distance, fuel level, battery voltage, MPG and last know parking location
  • Directly integrated, no other resources needed

What do you need?

  • A Smartthings Developer’s account
  • An AWS (Amazon Web Serivce) account
  • An Automatic Developer’s account

Instruction

Smartthings

  • Create a new Device Handler in Smartthings Developer’s website, with the code from DeviceHandler.groovy
  • Create a new device from device list, select type Automatic.
  • Create a new Web Service Smart App at Here with code from SmartApp.groovy, and follow the Smartthings document to create an SmartApp API Endpoint and SmartApp API Token.

AWS Lambda

  • Create an AWS Lambda function, with the code from /AWS_Lambda/index.js, Also remember to setup environment variable ss_apiuri and ss_token in Lambda with the value from above step. Configure the function to be triggered by AWS API Gateway, and make a public access and copy the AWS API Endpoint.
  • Since AWS Lambda does not support npm install a proper node_module folder has to be generated from a local environment, and zip everything up to Lambda.

Automatic

  • Create an App in Automatic developer’s website, setup webhook in Event Delivery part with AWS API Endpoint as Webhook URL. Use “Connect with Automatic Button” option on the same page to connect your Automatic Account with your Automatic App.

How everything works together

  • Automatic Dev App (POST) -> AWS API Gateway -> AWS Lambda (POST) -> Smartthings Smart App -> Smartthings Device Handler

What are…

  • Automatic: The OBD2 car trip, location and health monitor
  • Smartthings: The smart home hub
  • AWS API Gateway: AWS Restful API handler
  • AWS Lambda: The AWS serverless instance

Where to download?

Click-> GitHub_Logo to download

AWS IoT Button: Send POST request to Google Firebase

AWS IoT Button was introduced by Amazon as the developer version of it’s dash button.

The AWS IoT Button allows user to associate with an AWS Lambda instance to run some code snippet while press the button – either play with other AWS service such as Amazon SNS or integrate with your own service.

The button press has 3 types: single, double and long which can be found from the Lambda event.

Here is a simple code gist to demonstrate sending a POST request to Google Firebase client while the button is pressed:

(Keep in mind that AWS Lambda doesn’t have the npm install for your node.js code function – which means you have to upload a zipped file which contains the node.js node_modules folder as dependency)

Node.js send downstream cloud message with Google Firebase

Here is an instruction of using Node.js to send JSON data payload to a client device with Google Firebase Cloud Message service.

firebase_logo

  1. Setup and Configure Google Firebase on the client device (Android, iOS). An Android sample of integration of Firebase core and message can be found here. Locate and note the client device token, and the firebase server key.
  2. On Node.js server side, sending downstream message to Firebase API with NPM package “request“. Sample code can be seen below.
  3. Detail information is documented here (downstream message) and here (Message description)  at Firebase website.

How about build a weather station with Beaglebone Black and Node.JS?

I’m able to get some sensor data with Beaglebone Black by the help of Adafruit-Raspberry-Pi-Python-Code on my HMC6352 and HTU21D driver, but what’s next?

Sep 2014: Merging the application with the new OpenPythonSensor driver library, and deploy all the software (MongoDB, Sensor data gather and save with Python, Backend/Frontend application with Node.JS) on a single Beaglebone Black board.

 

By pushing the sensor data (Temperature, Humidity, Pressure, UVIndex) into a database, an internet front-end application is able to pull and display the data to the users.

Screenshot with plot

 

Embedded solution: A Beaglebone Black (Ubuntu) with HTU21D (Temperature / Humidity), BMP180(Temperature / Pressure) and SI1145 (Proximity/UV/Ambient Light) sensor. A Python script driven software measures the environment data and push data set to database (MongoDB).

Internet based front-end / back-end solution: Node.JS with Express and Mongoose. Back-end Node.JS code to query the database and send to front-end Angular JS function by AJAX. Supported by jQuery, Bootstrap and Chart.JS.

Screenshot with data

 

Demo is available at here. Code is shared under MIT License and can be accessed here on Github.