Smartthings SmartApp send downstream cloud message with Google Firebase


  1. Follow instruction at Smartthings to create and configure the SmartApp.
  2. Follow the document to subscribe the things event. An example at github shows a sample code snippet of a working SmartApp – provides a HTTP GET API interface to list all the available things and the data.
  3. Also, follow the Firebase document to setup the client device SDK and note down the client device token, and the firebase server key.
  4. Write an event data handler to process the event and send downstream message by http POST. Sample code can be seen below.
Example of Smartthings SmartApp to send downstream cloud message with Firebase
Event subscription is needed to trigger the event handler
def installed() {
def updated() {
/* Subscribe the event to the handler */
def initialize() {
/* Send event data to Google Firebase from http POST */
def sendEventToFirebase(evt){
def serverKey = "Firebase Server Key"
def clientToken = "Client Device Token"
def params = [
uri: "",
headers: [
Authorization: "key=" + serverKey
body: [
to: clientToken,
data: [
deviceId: evt.deviceId,
value: evt.stringValue]
try {
httpPostJson(params) { resp ->
resp.headers.each {
//log.debug "${} : ${it.value}"
log.debug "DEBUG (POST FIREBASE): response contentType: ${resp. contentType}"
} catch (e) {
log.debug "something went wrong: $e"

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.


  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.
Example of Node.JS to send downstream cloud message with Firebase
NPM package request is needed in this code gist
// Firebase auth key
var serverKey = "Firebase Server Key";
var clientToken= "Client Device Token"
// Payload message data
var deviceId = req.query.deviceId;
var eventName = req.query.eventName;
var value = req.query.value;
var options = {
url: '',
headers: {
'Authorization': 'key=' + serverKey
json: {
"to": clientToken,
"data": {
deviceId: deviceId,
eventName: eventName,
value: value
};, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('ERROR – FIREBASE POST failed:', err);
// Success

Setup C++ Development Environment for MangoDB Client

The primary target for this article is to install the mongodb C++ driver for development with C++ projects.

There is a newer branch C++ 11 based driver at this point but it’s better to start with the stable legacy one.

In a normal fresh Linux system the following steps has to be go through to meet the driver building prerequisites. For a full instruction please refer to ““.

Download and build/install Boost ( or Official Guide)

Driver require a boost version >= 1.49

tar -xzvf ./boost_1_xx_x.tar.gz
cd ./boost_1_xx_x/
sudo ./b2 install

Install Python if needed (

Driver require a Python version > 2.0

Download and install Scons (

Install by RPM package or build from source.

rpm -uvh scons-x.x.x-x.noarch.rpm

Git is also needed to clone the mongo-cxx-driver

sudo yum install git


sudo apt-get install git

Git Official Guide

Build and Install the MongoDB C++ Driver

git clone
cd ./mongo-cxx-driver
git checkout legacy
sudo scons install

Important: After this step the include and lib were generated but NOT locate in proper location. Use a prefix option to build and install or move everything under /mongo-cxx-driver/build/install/ into /usr/local/

mv ./build/install/* /usr/local/

Time to build and test a sample program

Check if you have $LD_LIBRARY_PATH in valid value by


And if nothing is showed go export the lib path by

export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH

Build the test program with

g++ tutorial.cpp -pthread -lmongoclient -lboost_thread -lboost_system -lboost_regex -o tutorial

Here is a great example to connect and insert into MongoDB: Note that a initialize() has to be added into the source to avoid a coredump.

int main() {

All set!

Everything is verified with:

  • Boost_1_55_0
  • Scons-2.3.5-1.noarh.rpm
  • Mongo-cxx-driver branch legacy

Introduce OpenPythonSensor Library

Introduce the Python driven, I2C focused, Embedded Linux application level library for digital sensors – OpenPythonLibrary.

The very first version includes supports for:

  • BMP180 Barometric Pressure sensor;
  • HTU21D Relative Humidity sensor (Only support Beaglebone Black at this moment);
  • SI1145 Proximity/UV/Ambient Light sensor;
  • TMP007 Infrared Thermopile sensor;
  • HMC6352 Digital Compass;
  • MPU6050 Six-Axis (Gyro + Accelerometer) MEMS;

The I2C bus is set to 1 in OpenPythonSensor / ops_base / and can be modified to support more development platforms. The python-smbus is a prerequisite of this library.

The library can be found at Github under MIT License.

Example usage of the library
from lib_htu21d import HTU21D
# Initialize the library
htu = HTU21D()
temp = htu.readTemperatureData()
rh = htu.readHumidityData()
print "Temperature: %.2f C, Humidity: %.2f %%" % (temp, rh)
Clone the code
git clone
Download the library

Click -> GitHub_Logo to download

Part of the library is ported from Adafruit-Raspberry-Pi-Python-Code and should remain it’s original license. Some driver is referenced from both Adafruit and Sparkfun and thanks to their original work.

More sensor support will coming soon!


python powered Boris_Tux_PNG

2014 May, Portland, Acadia National Park