GithubHelp home page GithubHelp logo

sensortag's Introduction

SensorTag

SensorTagからデータを収集&Cumulocityへ自動的にPOSTするためのソースコードです。
SensorTagの電源ボタンを押すだけで自動的にCumulocityへのデバイス登録、データ送信を行います。

Description

Node.jsで動かすためのJavascriptプログラムです。
以下の構成となっています。

  • multi-ti.js : 複数のSensortagを接続し、データポストするスクリプトです。
  • config-sample.js : multi-ti.js を実行するために必要な設定情報を記載するファイルです。実際に使用する際にはconfig.jsにリネームした上で設定値を記載して使ってください。

上記で登録したデバイスを削除するためのスクリプトも準備しました。

  • delete.rb : SensortagのシリアルID(externalID)をキーとしてデバイス、デバイスユーザの両方を削除します。
  • config-sample.rb : delete.rbを実行するために必要な設定情報を記載するファイルです。実際に使用する際にはconfig.rbにリネームした上で設定値を記載して使ってください。

Raspberry PI 2 Model Bの環境設定についてはWikiを参照してください。

Release Note

  • 2016.11.18: バッテリ残量の読み取りができるようにしました。 ~/node_modules/sensortag/lib/cc2650.js の変更が必要になりますので Other Configuration を確認してください。

Usage

multi-ti.js

# node multi-ti.js

delete.rb

$ ruby delete.rb <externalID>

Other Configuration

Raspberry PIのIP設定を変更

/etc/dhcpcd.conf.XXX/etc/wpa_supplicant/wpa_supplicant.conf.XXX を環境に合わせて編集すればOKです。

  • /etc/dhcpcd.conf(固定IPの場合)
 interface wlan0  
 static ip_address=192.168.XXX.XXX/24  
 static routers=192.168.XXX.XXX  
 static domain_name_servers=192.168.XXX.XXX  
  • /etc/dhcpcd.conf(DHCPの場合)
 上記の記載はなし
  • /etc/wpa_supplicant/wpa_supplicant.conf
 network={  
 ssid="XXXXXX"  
 psk="XXXXXXXX"  
 key_mgmt=WPA-PSK  
 }

~/node_modules/sensortag/lib/cc2650.jsの変更(バッテリー読み取り対応)

  • 変更前(50行目あたり)
NobleDevice.Util.inherits(CC2650SensorTag, NobleDevice);
NobleDevice.Util.mixin(CC2650SensorTag, NobleDevice.DeviceInformationService);
NobleDevice.Util.mixin(CC2650SensorTag, Common);
  • 変更後(50行目あたり)
NobleDevice.Util.inherits(CC2650SensorTag, NobleDevice);
NobleDevice.Util.mixin(CC2650SensorTag, NobleDevice.DeviceInformationService);
NobleDevice.Util.mixin(CC2650SensorTag, Common);
NobleDevice.Util.mixin(CC2650SensorTag, NobleDevice.BatteryService); // <-追加

データ収集周期の変更

22行目(multi-ti.jsの場合)にある pollingInterval の値を変更してください。(単位はmsec。デフォルト10秒周期)

var pollingInterval = 10000; //ms | NOTE: Interval for polling in periodic

Author

Akiyuki YOSHINO

sensortag's People

Contributors

a-yoshino avatar

Stargazers

Cong avatar

Watchers

James Cloos avatar

sensortag's Issues

データPOST時に401 Unauthorizedエラー

multi-ti.js実行時に、sensortagのデータをPOSTするところで401エラー。

原因は認証時のユーザIDに":"が含まれていたため。
セパレータを変更することで対応。

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.