My Technology Trail avatar

Using Node-RED to display temperatures from MySQL database

mytechtrail

Published: 31 Jan 2021 › Updated: 31 Jan 2021Using Node-RED to display temperatures from MySQL database

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.
nodered-flow.png
I will start with the timestamp inject node, this node signals the next node to run once every minute:
nodered-inject0.png
The next node is a function node to setup a SQL query to pass to a database node:
nodered-function.png
The database node contains the database connection and runs the SQL query passed to it:
nodered-mysql0.png
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:
nodered-gauge0.png
The debug node is used to make sure that the output of the database query is returning valid data:
nodered-debug.png
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.
nodered-inject1.png
nodered-mysql1.png
And lastly the second gauge node:
nodered-gauge1.png

The following is a screen capture of the Node-RED UI page with the two gauges:
nodered-ui.png

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:

Written by

Projects I am working on, Raspberry Pi, Python and Ham Radio.

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.

More Posts From My Technology Trail