# CPU Temperature on Windows

**URL:** <https://discourse.nodered.org/t/cpu-temperature-on-windows/88115>\
**Category:** General\
**Created:** [20 May 2024 08:07 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115 "2024-05-20T08:07:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 08:07 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/1 "2024-05-20T08:07:20Z")

</div>

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.

```auto
@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:

```auto
{
"payload":null,
"max":null,
"cores":[],
"topic":"temperature"
}

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2024 08:22 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/2 "2024-05-20T08:22:56Z")

</div>

You could try adding [`systeminformation`](https://www.npmjs.com/package/systeminformation) in a function node setup and calling `.cpuTemperature` ?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 08:50 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/3 "2024-05-20T08:50:31Z")

</div>

OK I can successfully include systeminformation and `systeminformation.cpu().then(data => node.warn(data));`  
gives me  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/1424bde3c5edebc1606c3b6146aab86bac569439.png)

but `systeminformation.cpuTemperature().then(data => node.warn(data));`  
gives no useful data  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e15398f26bc9eb3243fde314da27cd4fbd59ff0b.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2024 08:59 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/4 "2024-05-20T08:59:42Z")

</div>

> [@jbudd](#):
>
> gives no useful data

According to the info here: [CPU temp returning null? · Issue #480 · sebhildebrandt/systeminformation · GitHub](https://github.com/sebhildebrandt/systeminformation/issues/480#issuecomment-771413550) 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](https://www.ibm.com/docs/en/cloud-app-management/2019.4.0?topic=cmhvm-adding-non-administrator-user-in-performance-monitor-users-group)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [20 May 2024 09:10 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/5 "2024-05-20T09:10:10Z")

</div>

> [@jbudd](#):
>
> I have looked at @BartButenaers' 6 year old node-red-contrib-cpu b

Yes it [seems](https://github.com/bartbutenaers/node-red-contrib-cpu/blob/master/package.json#L6C10-L6C27) 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...

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 09:17 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/6 "2024-05-20T09:17:07Z")

</div>

> [@Steve-Mcl](#):
>
> need to add the account running node-red to the **Performance Monitor Users** group (or run node-red as administrator)

Looks like I can't do that on this PC (which despite this message is running Windows 11)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7daa926f8b8fb4da3b7095c4fe1039e800e3acd5.png)

So let's try running as administrator...

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2024 09:25 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/7 "2024-05-20T09:25:27Z")

</div>

> [@jbudd](#):
>
> So let's try running as administrator...

You can use [GitHub - akruhler/AccountManagement: Local User and Group Management application, for all Windows editions](https://github.com/akruhler/AccountManagement) instead

(windows home edition does not have access to lusrmgr)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2024 09:27 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/8 "2024-05-20T09:27:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 May 2024 09:35 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/9 "2024-05-20T09:35:09Z")

</div>

This might help:

> <https://superuser.com/questions/1241303/how-to-get-cpu-temperature-on-windows-system-using-both-snmp-and-cmd>

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 09:54 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/10 "2024-05-20T09:54:21Z")

</div>

> [@Steve-Mcl](#):
>
> via an admin command prompt: `net localgroup [groupname] [username] /add`

Grr!  
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!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2024 10:02 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/11 "2024-05-20T10:02:24Z")

</div>

> [@jbudd](#):
>
> But how to run Node-red as an administrator on startup?

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](https://flowfuse.com/blog/2023/12/device-agent-as-a-windows-service/) 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)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 11:49 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/12 "2024-05-20T11:49:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 11:55 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/13 "2024-05-20T11:55:19Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 May 2024 18:39 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/14 "2024-05-20T18:39:48Z")

</div>

> [@jbudd](#):
>
> But how to run Node-red as an administrator on startup?

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.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [20 May 2024 18:43 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/15 "2024-05-20T18:43:01Z")

</div>

Are you (all) aware that there's a [node](https://flows.nodered.org/node/@ralphwetzel/node-red-systeminformation) that integrates [systeminformation](https://systeminformation.io/general.html) into Node-RED?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2024 19:01 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/16 "2024-05-20T19:01:27Z")

</div>

Who knew 😅

That'll teach me not to do a search!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 19:16 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/17 "2024-05-20T19:16:53Z")

</div>

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:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/6811e9225231c51026384eb90c35cc1b6a51926e.png)

I am reflecting on the output when NR is run as admin  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/08186ea399ab5c2429fc56dadad329afc47b1e0d.png)  
These are simply not credible CPU temperatures (or counts). Speccy gives  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c13a2398c036bfde06bca3a4f5d7978b7d35bd80.png)

And CoreTemp tells a much warmer tale  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e16e55bc6664028670c5eb46db095ce90debdaf.png)

An administrator power shell command

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

```

gives  
3072  
3072  
(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.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 May 2024 19:27 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/18 "2024-05-20T19:27:24Z")

</div>

> [@TotallyInformation](#):
>
> 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.

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. 🤔

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

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [20 May 2024 19:59 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/19 "2024-05-20T19:59:37Z")

</div>

> [@jbudd](#):
>
> wmi data is not CPU temperature but some other motherboard sensor

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](https://github.com/sebhildebrandt/systeminformation/issues/135#issuecomment-1494134474) to get correct values though...

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 May 2024 19:59 UTC](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115/20 "2024-05-20T19:59:49Z")

</div>

> [@jbudd](#):
>
> Is that using Task Scheduler

yes 🙂

> [@jbudd](#):
>
> 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.

Strange, is it a managed work PC?

> [@jbudd](#):
>
> But I am thinking that the actual CPU temperature is not available to any command line tools.

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f1bf529263b6bfe7cd754842f30507086cbc3b8.png)

GPU temps also available.

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

> <https://stackoverflow.com/questions/39738494/get-cpu-temperature-in-cmd-power-shell/77143593#77143593>

[Next page](https://discourse.nodered.org/t/cpu-temperature-on-windows/88115.md?page=2)
