How-to
Logging a controller temperature to an FTP server every 12 hours
Short answer
Yes: an Inject node repeating every 12 hours triggers a controller read, a Function node formats a timestamped line, a File node appends it to /home/dev/temperature.txt and node-red-contrib-ftp uploads that file. Chain the FTP upload behind the File node's output rather than a parallel 5-second delay, and expect the upload to carry the cumulative log, not just the newest record.

On this page
- How do I put the whole flow together?
- How do I schedule the log to run twice a day?
- How do I get the controller temperature into the flow?
- How do I format the record so anyone can read it?
- How do I store the records locally?
- How do I upload the file to the server?
- Does the 5-second delay prove the file was written?
- Does each upload contain only the newest record?
- Do I need to convert the log to PDF?
- Questions asked
Yes, Node-RED can read a controller temperature, turn it into a readable line, store it and push it to a file server over FTP, and the whole job is five nodes. You do not need PDF: a timestamped text file meets a temperature log meant for human reading, and the PDF packages you will find add an unverified dependency for nothing. The flow below runs every 12 hours, appends each record to a local file and uploads that file with the FTP client node from the node-red-contrib-ftp package. Two details in the commonly shared example flow need correcting before you trust it: a fixed 5-second delay does not prove the file write finished, and append mode means each upload carries the whole accumulated log.
How do I put the whole flow together? #
Wire one chain: an Inject node set to repeat every 12 hours, a controller read node, a Function node that formats the line, a File node that appends it locally, and the FTP upload node, in that order and with no parallel branches. Build it in this sequence:
- Install the FTP client package first. The upload node comes from
node-red-contrib-ftp, which can LIST, GET, PUT, APPEND, DELETE and MKDIR on the remote server; installing it before you import or build the flow avoids unknown nodes. - Configure the controller. In the read node's device configuration, replace the placeholder tag
counter(data typeint32-variablein the shared example) with the analog input that actually carries the temperature, and make the data type match that signal. - Set the read node's output property to
temperaturewith value typemsg, so the reading arrives downstream asmsg.temperature. - Set the Inject node to repeat every 12 hours; leave its payload as the date type, since the Function node replaces the payload anyway.
- In the Function node, build the human-readable line from the date, the time and
msg.temperature. - Set the File node to append with a trailing newline to
/home/dev/temperature.txt. The shared example leaves the node's directory-creation option off, so create/home/devyourself before the first run. - Configure the FTP node with the server address, port and credentials, and upload the local file as
temperature.txt.
The sections below take the decisions inside steps 2 to 7 one at a time.
How do I schedule the log to run twice a day? #
Set the Inject node's repeat interval to 12 hours and deploy: the node then fires twice a day, and each firing produces exactly one record, so the server receives an updated file roughly every half day. The interval counts from the moment the flow is deployed, not from midnight, and nothing else in the flow needs a timer. The Inject node also accepts specific times of day; use that mode only if the record must land at fixed clock times rather than at a fixed spacing.
How do I get the controller temperature into the flow? #
Point the read node at the analog input that carries the temperature and set its output property to temperature, so the value reaches the Function node as msg.temperature. The shared example reads a tag named counter with the data type int32-variable; that is a placeholder, not your signal. Whole degrees are fine for a facility log, but if the controller exposes the temperature as a floating-point value, select the matching data type or the reading will be wrong. Prove the read once with a debug node showing a plausible number, for example 42 for a warm cabinet.
How do I format the record so anyone can read it? #
Build one line per run in the Function node: the date, a 12-hour time with an AM or PM suffix, the words Temperature is, then the reading, which is exactly the string the shared example builds. An illustrative version of that function, with its own variables declared:
// Illustrative: msg.temperature holds the reading from the read node,
// for example the number 42.
var reading = msg.temperature; // number, from the read node
var stamp = new Date().toLocaleString(); // example output: "6/3/2025, 2:15:00 PM"
msg.payload = stamp + " - Temperature is " + reading;
return msg;
The newline is deliberately left out of the string, because the File node's own append-newline option adds it. The test that proves the format: press the Inject node's button once and confirm the local file gains exactly one readable line, for example 6/3/2025, 2:15:00 PM - Temperature is 42.
How do I store the records locally? #
Set the File node to append a newline to /home/dev/temperature.txt on every message, and create the /home/dev directory before the first run, because the shared example leaves the node's directory-creation option off. Overwrite mode would keep only the latest reading and throw away the history; append mode builds the running log the facility actually asked for, and it keeps that history even when the network is down.
How do I upload the file to the server? #
In the FTP node, enter the server address, port, username and password, choose the PUT operation, and give it the local path /home/dev/temperature.txt with the remote name temperature.txt. The GET, PUT and APPEND operations take the remote path from msg.filename, so set it in the Function node, for example msg.filename = "/temperature.txt" for the server's root directory. Do not confuse this client package with node-red-contrib-ftp-server, a different node that makes Node-RED itself the FTP server; that one has its own behavior, covered where the FTP server node stays idle for scanner images (see why the FTP server node stays idle for scanner images).
Does the 5-second delay prove the file was written? #
No: the 5-second Delay node in the shared example only postpones a parallel upload branch, and elapsed time is never evidence that the File node has finished writing. Wire the FTP node directly after the File node's output instead. The File node passes the message on only after the write completes, so the upload can never race the write, and the delay node and its extra wire can be deleted. This is the one structural change worth making to the example before it runs unattended.
Does each upload contain only the newest record? #
No: the File node appends, so /home/dev/temperature.txt grows by one line per run and every PUT ships the whole accumulated log, not just the latest reading. Size the file before deciding whether that matters. A run happens twice a day, so after one week the file holds 2 x 7 = 14 lines. A formatted line is roughly 45 characters, so 14 x 45 = 630 bytes. A full year holds 2 x 365 = 730 lines, or 730 x 45 = 32,850 bytes, about 33 kB. The decision: keep the cumulative behavior. It is what a log is for, PUT overwrites the server copy so it always matches the local file exactly, and the size stays trivial for any file server.
Do I need to convert the log to PDF? #
No: a formatted text file is a complete answer for a temperature log read by humans, and the PDF packages available for Node-RED add a rendering dependency you would have to verify for no benefit at two records a day. The html-to-pdf package for Node-RED renders HTML through a headless browser library, a heavy runtime for a small controller or edge gateway, and no tested flow for this job exists to copy. Revisit PDF only if a compliance document demands a fixed page layout; until then the text file is the deliverable.
Questions asked
Should I use the FTP node's APPEND operation instead of PUT?
No. APPEND adds the full contents of the local file to the end of the remote file, so the second upload would duplicate every line already on the server. Keep PUT: each upload replaces the server copy with the exact local log, so the two always match.
How do I test the flow before trusting the schedule?
Press the Inject node's button instead of waiting half a day. Confirm msg.temperature shows a plausible value, the local file gains exactly one readable line, and the uploaded copy matches the local file. Fire it three times back to back to prove the append and the write-then-upload order, then enable the interval.
What happens to the schedule when Node-RED restarts?
An interval counts from the moment the flow is deployed, so a restart or redeploy shifts the run times by however long the downtime lasted. If the log must land at fixed clock times, use the Inject node's specific-times option instead of the repeat interval.
What if the FTP server is down when the flow runs?
Nothing is lost. The append happens before the upload, so every record stays in the local file, and the next successful PUT carries the full history, including the runs that failed to upload. After any outage, compare the server copy's line count with the local file to confirm it caught up.


