Skip to content

Commit 33749b4

Browse files
committed
Add another example that sends values to influxdb
1 parent 7b24c80 commit 33749b4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/rain_to_influx.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Sending rain data (and other sensor data) to influxdb
2+
3+
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.
4+
5+
The script:
6+
7+
```javascript
8+
var request = require('request');
9+
10+
subscribe('sensor/+/rainDelta', function (topic,val,obj,prev,msg) {
11+
var sensorId=topic.split("/")[1];
12+
data='rain_amount,sensor='+sensorId+' value='+val;
13+
request.post({
14+
url: 'https://influxdb.example.com/write?db=iotdata',
15+
body: data
16+
});
17+
});
18+
```

0 commit comments

Comments
 (0)