Skip to content

Instantly share code, notes, and snippets.

@jeanfbrito
Last active October 27, 2020 02:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanfbrito/5c96cc92d3171b6434bf to your computer and use it in GitHub Desktop.
Save jeanfbrito/5c96cc92d3171b6434bf to your computer and use it in GitHub Desktop.
Saving data received from MQTT to InfluxDB
[{"id":"e8ee0bf9.1711f8","type":"mqtt-broker","z":"5b94f478.a46b0c","broker":"localhost","port":"1883","clientid":"node-red","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"2122f69.fdedd0a","type":"mqtt in","z":"5b94f478.a46b0c","name":"","topic":"sensors/#","broker":"e8ee0bf9.1711f8","x":377,"y":154,"wires":[["bbed4e22.4412b"]]},{"id":"bbed4e22.4412b","type":"function","z":"5b94f478.a46b0c","name":"MQTT to InfluxDB","func":"var tokens = msg.topic.split(\"/\");\nvar dest = tokens[tokens.length-1];\nmsg.url =\"http://localhost:8086/write?db=greenhouse\";\nmsg.payload = tokens[2] + \",device=\" + tokens[1] + \" value=\" + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":596,"y":156,"wires":[["92e875bf.6d1788","7804637a.87fb9c"]]},{"id":"92e875bf.6d1788","type":"http request","z":"5b94f478.a46b0c","name":"","method":"POST","ret":"txt","url":"http://localhost:8086/write?db=greenhouse","x":819,"y":155,"wires":[["989defec.67621"]]},{"id":"989defec.67621","type":"debug","z":"5b94f478.a46b0c","name":"","active":true,"console":"false","complete":"true","x":1013,"y":154,"wires":[]},{"id":"7804637a.87fb9c","type":"debug","z":"5b94f478.a46b0c","name":"","active":true,"console":"false","complete":"false","x":803,"y":295,"wires":[]}]
@ajaybnl
Copy link

ajaybnl commented Oct 10, 2019

Thanks. Please Mention the usage :
sensors/esp8266/sensor1
sensors/esp8266/sensor2
sensors/esp8266/sensor3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment