It is currently April 27th, 2024, 7:09 pm

CoreTemp and WriteKeyValue

Get help with creating, editing & fixing problems with skins
onionioni
Posts: 3
Joined: December 17th, 2012, 2:27 pm

CoreTemp and WriteKeyValue

Post by onionioni »

Hello! I'm trying to use the CoreTemp plugin to read the temperature of the cpu and then write the value in a file using !WriteKeyValue (because I want to use later this value and this file with a program in c or python), but I can't understand which is the correct key/value to use.

This is the code i'm using to read and display the temp:

Code: Select all

[Rainmeter]
Update=100
BackgroundMode=2
SolidColor=0,0,0,255

[MeasureCore1Temp]
Measure=Plugin
Plugin=CoreTemp
CoreTempType=Temperature
CoreTempIndex=0

[MeterCore1Temp]
Meter=String
MeasureName=MeasureCore1Temp
X=%1
Y=0
W=200
H=15
FontColor=255,255,255,255
Text="Core 1 Temp: %1°C"

Thanks in advance for the help and sorry for my bad english.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: CoreTemp and WriteKeyValue

Post by jsmorley »

Here is one approach. I don't use CoreTemp, so I did my example with Speedfan. The approach would be the same though.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
MyTemp0=4
TempUnit=C

[MeasureMyTemp0]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=TEMPERATURE
SpeedFanNumber=#MyTemp0#
SpeedFanScale=#TempUnit#
UpdateDivider=10

[MeasureCounter]
Measure=Calc
Formula=(MeasureCounter % 10) + 1
IfEqualValue=1
IfEqualAction=!WriteKeyValue "CPUTemp" "CurrentTemp" "[MeasureMyTemp0]" "#CURRENTPATH#TempOutput.txt"
DynamicVariables=1

[MeterOne]
Meter=Image
W=25
H=25
SolidColor=101,196,96,255
What we are doing is getting the temperature every 10 seconds with the Speedfan plugin measure, using an Update of 1000 and an UpdateDivider of 10. (side note: I'm not sure it makes sense in your code to have an Update of 100, as it seems to me that having the skin check the temperature every 100 milliseconds is a bit of overkill)

Then we need a way to have the !WriteKeyValue bang triggered to write the value to the local file. So we create a Calc measure using a "counter" to execute the bang every 10 seconds (to be more or less in sync with the result of the Speedfan measure).

Then we just use the !WriteKeyValue bang to output the current value of [MeasureMyTemp0] to a text file in the same folder as the skin. Note that the file must already exist (TempOutput.txt) and be either somewhere in the \Skins path or %APPDATA%\Rainmeter path.

TempOutput.txt will look like this, with the CurrentTemp= line updated to the current value every 10 seconds.

Code: Select all

[CPUTemp]
CurrentTemp=39
onionioni
Posts: 3
Joined: December 17th, 2012, 2:27 pm

Re: CoreTemp and WriteKeyValue

Post by onionioni »

Thank you soooooooooooooooooooo much for the quick reply!!! This works great!!!

I'm new to Rainmeter and i need a little time to analyze and customize your code... :oops:, but i think that i will probably need more help in the future :D
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: CoreTemp and WriteKeyValue

Post by jsmorley »

Glad to help.

The only bit that might be a little non-intuitive is the "counter" stuff. There is some additional information on how to use that functionality here:

http://docs.rainmeter.net/tips/counters-guide
onionioni
Posts: 3
Joined: December 17th, 2012, 2:27 pm

Re: CoreTemp and WriteKeyValue

Post by onionioni »

Thanks for the guide! Time to study! :D

Thanks again for your help and patience!