Skip to content

Commit

Permalink
Add another example that sends values to influxdb
Browse files Browse the repository at this point in the history
  • Loading branch information
micw committed Sep 29, 2019
1 parent 7b24c80 commit 33749b4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/rain_to_influx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Sending rain data (and other sensor data) to influxdb

This script subscribes to a certain topic and sends all incoming values to influxdb database "iotdata". The values are tagged with a sensor id extracted from the topic.

The script:

```javascript
var request = require('request');

subscribe('sensor/+/rainDelta', function (topic,val,obj,prev,msg) {
var sensorId=topic.split("/")[1];
data='rain_amount,sensor='+sensorId+' value='+val;
request.post({
url: 'https://influxdb.example.com/write?db=iotdata',
body: data
});
});
```

0 comments on commit 33749b4

Please sign in to comment.