A Javascript commandline tool to record climate data from a Texas Instruments SensorTag CC2650 into an InfluxDB time series database.
It makes use of @sandeepmistry's Node BLE wrapper for the SensorTag, cf. https://github.com/sandeepmistry/node-sensortag
- Node v.6.10.2 (current LTS) or higher
- npm or yarn
- Only tested under Raspbian Jessie
SSH into Raspberry and clone the repository:
git clone <repository-url> <repo>
(alternatively, there is a Phing build.xml for deployment via rsync)
Make sure config.json
exists:
cp config.json.dist config.json
Install node dependencies and build using Yarn or npm:
yarn install
yarn run build
Note: To avoid conflicts between different architectures I had to install the node dependencies on the Pi itself.
Run:
node build/app.js
To run without sudo:
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
The Influx Database can reside locally or on another machine. The host must be configured in config.json
:
// OPTIONAL, only used for logging
"mail" : {
"connectionString" : "smtps://<username>:<token>@<smtphost>",
"to": "<recipient>",
"from": "<sender>"
},
// REQUIRED by InfluxProxy
"influx": {
"host": "<influx.host>",
"user": "<influx.user>",
"pass": "<influx.pass>",
"db": "<influx.pass>"
},
// REQUIRED, currently supports only single device ID
"sensor": {
"id": "<SensorTagId"
},
// Interval in minutes to read data from SensorTag
"frequency": "3",
// Path to logfile
"logfile": "/var/log/piweather.log"
On the Raspberry the tool was installed as a service using forever-service:
sudo forever-service install piweather --script build/app.js
The repo contains a simple e-mail logger wrapped around Nodemailer to send logs:
Example crontab entry:
0 */2 * * * /home/pi/pi-weather/src/sendlog.js > /home/pi/cron.log
The project was inspired by this blog entry https://www.hackster.io/eursan/complete-wireless-weather-station-ece694?ref=part&ref_id=13511&offset=0
Alternatively, you could use a round robin db like rrdtool which comes with some graphics capability already.