Using Node-RED to display temperatures from MySQL database
Here I will show how I use Node-RED running on a Raspberry Pi computer to get some temperatures from a MySQL database running on another Linux computer and display them on a webpage. The following image is of the Node-RED flow I created and the following images will be of the nodes that make up the flow.
I will start with the timestamp inject node, this node signals the next node to run once every minute:
The next node is a function node to setup a SQL query to pass to a database node:
The database node contains the database connection and runs the SQL query passed to it:
The output of the database query then is passed to a gauge node as well as a debug node. The gauge node displays the temperature on the UI webpage:
The debug node is used to make sure that the output of the database query is returning valid data:
After watching some YouTube videos and reading some blog posts I discovered that I could directly inject a SQL query from the inject node for the second gauge part of the flow.
And lastly the second gauge node:
The following is a screen capture of the Node-RED UI page with the two gauges:
Please feel free to ask any questions in the comments below. I am still learning how to document the things I am learning.
Leave Using Node-RED to display temperatures from MySQL database to:
Read more #nodered posts
Best Posts From My Technology Trail
We have not curated any of mytechtrail's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.