How to use InfluxDB with Node RED | 8-minute tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey all uh this is a quick tutorial on working in flux db on node red i'll go through the process of writing points to an influx database reading point from the influx database and also creating a small dashboard uh using the table node and displaying it as it has a node-red dashboard today i'm working with the jetson nano you can try this out on a raspberry pi or anything that can run node-red and i've already got everything set up i'm running node-red and i'm running in flux 1.8 so you the instance of node-red that you see here is the one that's running on my jetson including the installation instructions and other useful links in the description below so the first step after you install influx from the link mentioned below is to create the database that'll be that will be used to create measurements how to push your data into so i'm logged into my jetson i can go to influx and again i'm running in flux 1.8 so i can create a new database let's call it patient and now we should have a database called president so now that we our database ready we can use node-red to push data in in this example i'll be pushing a random data point to our database so this data can be from a sensor or from any other data source by the way this flow is available for download please check the description so here i have one inject node and that is pushing a random value to a change node so influx supports tags and fields and all we are doing here in this change node uh is we are creating some fields and some tags for our measurement and so we have one tag and we have two fields so our first tag is called type and the value is point and we have another tag called timestamp and we have another tag called value and which is the value of our random variable that's coming from from the inject node and then we append it to an object called message.payload so message of payload is an object of fields and tags and this is what we push into our influx uh database node so to set up this node i'll double click on this so we're running it on running the influx on jets and nano so the address is right the board is right and we just created a table the database and we call it patient so let's update it here we don't have a username and password so we'll leave it as it is and we can name our measurement let's call it test and we'll hit done and we can deploy this so it was successfully deployed now to push this random data to influx we can inject it so it successfully injected one data point now if we go back to our database i can check and i can verify if the data was pushed or not so i'll do select star from my measurement my measurement was test oh so we didn't set a database yet so i'll do use pression which is the name of the database that we just created and now if i do select star from test it'll give me the random value that we just pushed the type and the timestamp and this is the time that we manually included in our change node similarly let's push one two three four four more data points if we go back uh to a ring flux let's verify everything uh eventing so if i do select star from test you can see that there are five points now so that's our write operation and of course you can alter this format set more fields or values in this change node or you can use a function node to do that uh it's up to you and now moving on to the read operation now let's say we want to fetch all the data that we just pushed in our influx database to do that i just have one simple inject node uh that's just pushing a boolean call true and here i have a function node with a query so it says select star from test so that's the same query that we were using in our reflex database and we are passing it to influx read node and everything is set up here so once done you can hit deploy and if i hit this i'll get the five objects that i pushed initially now they just get a particular object or get object by timestamps uh i've also included another link in the doc link in the description um with a guide to influx queries so let's say if you want to get the points that are just 10 seconds old uh we can do so fair time is greater than now minus 10 so this will get give us the points from uh from last 10 seconds so once i do that i hit deploy and i'm not getting back anything so if i push another point again and if i fetch again i get my point so this is a basic read operation so let's say we want to display these points in a noted dashboard so for that we are using the same same process and it's just that after the read operation instead of displaying those points in in the debug node we are pushing them to a function node and creating an object out of it that's acceptable by our table node and once we deploy and if we fetch you can see our points coming from influx in the node right dashboard and that's about it so we covered how we can write to an influx database how to read from influx database and also how to display the red values in a node red node dashboard cheers you
Info
Channel: Prescient Devices Inc.
Views: 816
Rating: undefined out of 5
Keywords: Prescient Designer, Prescient Devices, IoT, IIoT, Industrial IoT, Easy IoT, Multiple edge devices, Node-RED, Node-RED IoT, IoT software, IoT application development, IoT solutions, IoT for business, IoT for Industry 4.0, Internet of Things, IoT tutorial, simple IoT, Prescient, InfluxDB, influxdb, json, JSON object, JSON flow
Id: yHTWzFpgCuk
Channel Id: undefined
Length: 8min 7sec (487 seconds)
Published: Mon Nov 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.