It is used to graph and monitor the data stored in InfluxDB.
In the dashboard, click on the top bar of a graph and select edit.
In the lower half of the screen there will be an area to change the rules for the graph. Click on the pencil on the right side and delete the default code.
Replace it with:
SELECT * FROM “DataTypeToGraph”
This will graph the data added to the database by a single InfluxDB node in Node-RED using the tag it was defined with.
In a new dashboard, under the sql code, from the dropdown select “Table”. After that select Table view from the tab on the right called Format. This should table each entry in the database instead of graphing it.
Use this SQL code to show only the last value recorded:
SELECT last(value) FROM “Data”
SELECT sum("value") / count("value")
FROM "Data"
WHERE $timeFilter
…Node-RED is a visual programming tool that allows users to create and connect hardware devices, APIs, and online services. It uses a web-based flow editor to drag and drop nodes, which represent different functionality, to create automated workflows. It simplifies the process of building Internet of Things (IoT) applications by providing a user-friendly interface for connecting and controlling devices.
The debug node is a built-in Node-RED node that allows users to view the message passing through the nodes in real-time. It is useful for troubleshooting and understanding the flow of data through a flow.
Users can view the contents of the message, filter messages by type or topic, and output messages to the console in the sidebar. It is easy to use by simply dragging and dropping it into the flow and connecting it to other nodes.
The green square on the right means it will debug. Pressing it will stop the node from debugging without deleting it.
Debug On:
Debug Off:
This node is used to access the sensors and values in the system.
The node looks like this:
Parameters:
This node uses Javascript to transform data or use any other js function.
To access the value in the input use msg.payload and change it for output value. Use return msg to output.
After the aventics node that takes data from the airflow sensor (04 IO-Module, address 01) place a function with this code. It will output the current airflow in L/min.
Sensors give an analog signal to node red, usually from 0 to 32767. Each sensors needs to be calibrated. Our sensors outputs 0 when there is no airflow and using the built-in settings of the sensors we can see the max airflow going through the sensors was 315,43 L/min and it outputted a values of 2742. So by dividing it we can calculate a transfer equation.
msg.payload *= 0.115;
return msg;
After the aventics node that takes data from the linear analog sensor (05 IO-Module, address 2), place a function node with this code. It will output the current speed of the cylinder in cm/s.
// This function node counts the time between two signals that are equal to 1
var lastTime = context.get('lastTimestamp');
var lastPos = context.get('lastDistance');
if(msg.payload 3200) {
msg.payload = (msg.payload - 3200.0) / (29750.0 - 3200.0) * (51.1 - 7.13) // cm/s
if (!lastTime) {
// Store the timestamp of the first 1 signal
lastTime = new Date().getTime();
lastPos = msg.payload;
context.set('lastTimestamp', lastTime);
context.set('lastDistance', lastPos);
} else {
if (lastPos == msg.payload)
return
// Calculate the time difference between the first 1 signal and the current 1 signal
var deltaTime = new Date().getTime() - lastTime;
var deltaPos = msg.payload - lastPos;
context.set('lastTimestamp', null);
context.set('lastDistance', null);
msg.payload = (deltaPos)/(deltaTime);
return msg;
}
}
return null;
The simple InfluxDB node takes whatever data it is given and along with a tag it is sent to the database along with a time stamp.
Select the second Server for data to be logged.
Each time a new piece of data is added to the database it will automatically get a timestamp when it was logged.
Parameters:
Every connection between the nodes sends a message msg with different parameters. Two of the most important ones in this node are msg.payload and msg.topic.
msg.topic = “Name of the variable transported”
msg.payload = value of the variable transported
Using the Join Node, we can combine multiple variables into a single object. Like a json, each item in the object has a name (from the topic) and a value (from the payload).
With this node, we can combine all the data and send it to a single influxDB node as a single table entry instead to keep the data organized.
Parameters:
Manual Mode parameters: