CPU Temperature on Windows

On my Raspberry Pies I can obtain the CPU temperature with an exec node calling vcgencmd measure_temp

Despite my almost total lack of knowledge of Windows OS, I am responsible for the health of a PC on the other side of the world and need to monitor the CPU temperature and send it by MQTT, so I am installing Node-red.

I have a bat file which works to obtain the temperature, unfortunately it has to be run as administrator.

@echo off
for /f "skip=1 tokens=2 delims==" %%A in ('wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature /value') do set /a "HunDegCel=(%%~A*10)-27315"
echo %HunDegCel:~0,-2%.%HunDegCel:~-2% Degrees Celsius

Can I run this file as administrator via the exec node?
Is there a better solution?

I have looked at @BartButenaers' 6 year old node-red-contrib-cpu but on two different PCs it gives a null value for temperature:


You could try adding systeminformation in a function node setup and calling .cpuTemperature ?

OK I can successfully include systeminformation and systeminformation.cpu().then(data => node.warn(data));
gives me

but systeminformation.cpuTemperature().then(data => node.warn(data));
gives no useful data

According to the info here: CPU temp returning null? · Issue #480 · sebhildebrandt/systeminformation · GitHub and the link that post contains it looks like you need to add the account running node-red to the Performance Monitor Users group (or run node-red as administrator)

This might help (depends on windows version/type) : https://www.ibm.com/docs/en/cloud-app-management/2019.4.0?topic=cmhvm-adding-non-administrator-user-in-performance-monitor-users-group

1 Like

Yes it seems like I use a very old version of the systeminformation library (3.x) while they have meanwhile evolved to 5.x

But as Steve mentioned (for the same library) it might be related to something else...

Looks like I can't do that on this PC (which despite this message is running Windows 11)

So let's try running as administrator...

You can use GitHub - akruhler/AccountManagement: Local User and Group Management application, for all Windows editions instead

(windows home edition does not have access to lusrmgr)

or, via an admin command prompt: net localgroup [groupname] [username] /add

This might help:

I can add my user to "Performance Monitor Users" with
net localhost "Performance Monitor Users" mememe /add
akrhuler's version of lusrmgr.exe is accepted by my antivirus and confirms that the user is a member of the group, but still getting null CPU info in Node-red.

If I run Node-red as administrator it works - 28.8 degrees (is that all?)
But how to run Node-red as an administrator on startup?

Thanks for all contributions so far, considering them in turn!

You might get away with adding the account to Power Users group.

As for running node-red on startup, I recommend using nssm to run it as a service (you can specify the "log on" account in the NSSM UI)

This doc: Run Node-RED as a service on Windows • FlowFuse has much of the detail you will need (albeit it is about running the Node-RED under the FlowFuse device agent, most of the info is relevant)

I don't have a Power Users group (pro only?) but creating one and adding myself to it & rebooting does nothing.

Nope after hours of effort I conclude nssm is hopeless.

(rhetorical question) How does anyone get Node-red to run on Windows?

@zenofmud the batch file your link gives is where I started. It works but only when run as an administrator.
I can make it run as an administrator by making a shortcut but then Windows asks me if I want to allow it to make changes, and it seems you can't run the shortcut link from Node-red anyway.

It does make sense I suppose to make it hard to automatically run admin code at startup.
Can't see why CPU temperature is not available to a normal users command line though.

Not a good thing to do from a security standpoint. Instead, I'd write a powershell script to get the info, and configure Windows task manager to run it every 1 minute using SYSTEM privalages starting before login. That should be more than enough.

The script would either call a Node-RED http endpoint to send the data or you might find an MQTT library for PowerShell to send there directly.

Are you (all) aware that there's a node that integrates systeminformation into Node-RED?


Who knew :sweat_smile:

That'll teach me not to do a search!

I was not aware of that, thanks @ralphwetzel. There's even an example flow for CPU temperature.

But.it gives the same output as Bart's node and systeminfo in a function when Node-red is not run as administrator:

I am reflecting on the output when NR is run as admin
These are simply not credible CPU temperatures (or counts). Speccy gives

And CoreTemp tells a much warmer tale

An administrator power shell command

get-wmiobject MSAcpi_ThermalZoneTemperature -namespace "root/wmi" | Select-Object CurrentTemperature

(which is Kelvins *10 = 34.2 C)

I have seen suggestions online that the systeminfo/wmi data is not CPU temperature but some other motherboard sensor and sadly it seems likely to be true.

Configure WIndows task manager ...
Is that using Task Scheduler? I have defined tasks over and over on this PC but after a reboot I see no sign of them, nor evidence of them having run.
Yet Node-red did start, albeit not as administrator. :thinking:

But I am thinking that the actual CPU temperature is not available to any command line tools.

Looking at the issues recorded for systeminformation referencing cpuTemperature, this most probably is to be confirmed. One user claims to have found an alternative way to get correct values though...

yes :slight_smile:

Strange, is it a managed work PC?

Well what sensors are available is largely dependent on the motherboard I believe. But on my Lenovo MiniPC, the CPU temps are certainly exposed to HWInfo


GPU temps also available.

But I wonder if something like this might work for you?