Overlay LCD TFT 3.2 inch HY32D make it works on Beagle Bone Black - touch

I am looking for some help to make works the LCD HY32D on the Beagle Bone Black.
I have connected this LCD called HY32D on the following PIN of the BBB:
"P8.45", // lcd: lcd_data0
"P8.46", // lcd: lcd_data1
"P8.43", // lcd: lcd_data2
"P8.44", // lcd: lcd_data3
"P8.41", // lcd: lcd_data4
"P8.42", // lcd: lcd_data5
"P8.39", // lcd: lcd_data6
"P8.40", // lcd: lcd_data7
"P8.37", // lcd: lcd_data8
"P8.38", // lcd: lcd_data9
"P8.36", // lcd: lcd_data10
"P8.34", // lcd: lcd_data11
"P8.35", // lcd: lcd_data12
"P8.33", // lcd: lcd_data13
"P8.31", // lcd: lcd_data14
"P8.32", // lcd: lcd_data15
"P9.12", // lcd RS: gpio1_28
"P9.42A", // lcd RD: gpio0_7
"P8.14", // lcd WR: gpio0_26
"P8.16", // lcd RESET: gpio1_14
Then I found an overlay called cape-bone-lcd3-00A0.dts and I did try to edit it to adapt to the LCD HY32D,
here the modified dts:
http://support.rfberrypi.com/download/BB-LCD-HY32D-00A0.dts
but I do not have much experience in writing an overlay and a part that my main question is how can I redirect the video output to this overlay?

I have solved my problem about driver for the LCD.
First I have wrote the overlay:
/dts-v1/;
/plugin/;
/{
compatible = "ti,beaglebone", "ti,beaglebone-black";
part-number = "lcd_my_try";
version = "00A0";
fragment#0 {
target = <&am33xx_pinmux>;
__overlay__ {
pinctrl_test: lcd_my_try_Pins {
pinctrl-single,pins = <
0xa0 0x2f /* lcd_data0.lcd_data0, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xa4 0x2f /* lcd_data1.lcd_data1, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xa8 0x2f /* lcd_data2.lcd_data2, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xac 0x2f /* lcd_data3.lcd_data3, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xb0 0x2f /* lcd_data4.lcd_data4, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xb4 0x2f /* lcd_data5.lcd_data5, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xb8 0x2f /* lcd_data6.lcd_data6, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xbc 0x2f /* lcd_data7.lcd_data7, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xc0 0x2f /* lcd_data8.lcd_data8, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xc4 0x2f /* lcd_data9.lcd_data9, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xc8 0x2f /* lcd_data10.lcd_data10, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xcc 0x2f /* lcd_data11.lcd_data11, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xd0 0x2f /* lcd_data12.lcd_data12, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xd4 0x2f /* lcd_data13.lcd_data13, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xd8 0x2f /* lcd_data14.lcd_data14, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0xdc 0x2f /* lcd_data15.lcd_data15, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
0x78 0x2f // lcd_rs.lcd_rs, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
0x164 0x2f // lcd_rd.lcd_rd, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
0x28 0x2f // lcd_wr.lcd_wr, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
0x38 0x2f // lcd_reset.lcd_reset, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
0x30 0x2f // lcd_cs.lcd_cs, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
0xec 0x07 // lcd_ac_bias_en.gpio2_25 OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT
//touch panel ADS7843 = XPT2046
0x34 0x2f // touch_cs.gpio1_13, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT (chip select)
0x7c 0x2f // touch_sck.gpio1_29, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT (clock)
0x3c 0x2f // touch_si.gpio1_15, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT (serial data in)
0x8c 0x2f // touch_irq.gpio2_1, OMAP_MUX_MODE0 | AM33XX_PIN_INPUT (interrupt on touch)
0x2c 0x2f // touch_so.gpio0_27, OMAP_MUX_MODE0 | AM33XX_PIN_INPUT (serial data output)
>;
};
};
};
fragment#1 {
target = <&ocp>;
__overlay__ {
test_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_test>;
status = "okay";
};
};
};
};
I named it as :
lcd_my_try.dts
I have compiled it on the BBB with this command:
dtc -O dtb -o lcd_my_try-00A0.dtbo -b 0 -# lcd_my_try.dts
Then I loaded it:
cp lcd_my_try-00A0.dtbo /lib/firmware
echo lcd_my_try > /sys/devices/bone_capemgr*/slots
I have loaded the name of the GPIO used with a bash file with the following contents:
#!/bin/bash
echo "Loading GPIO into /sys/class/gpio/export"
echo "Setting UP LCD_DATA_0"
echo 70 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio70/direction
echo "Setting UP LCD_DATA_1"
echo 71 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio71/direction
echo "Setting UP LCD_DATA_2"
echo 72 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio72/direction
echo "Setting UP LCD_DATA_3"
echo 73 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio73/direction
echo "Setting UP LCD_DATA_4"
echo 74 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio74/direction
echo "Setting UP LCD_DATA_5"
echo 75 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio75/direction
echo "Setting UP LCD_DATA_6"
echo 76 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio76/direction
echo "Setting UP LCD_DATA_7"
echo 77 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio77/direction
echo "Setting UP LCD_DATA_8"
echo 78 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio78/direction
echo "Setting UP LCD_DATA_9"
echo 79 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio79/direction
echo "Setting UP LCD_DATA_10"
echo 80 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio80/direction
echo "Setting UP LCD_DATA_11"
echo 81 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio81/direction
echo "Setting UP LCD_DATA_12"
echo 8 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio8/direction
echo "Setting UP LCD_DATA_13"
echo 9 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio9/direction
echo "Setting UP LCD_DATA_14"
echo 10 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio10/direction
echo "Setting UP LCD_DATA_15"
echo 11 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio11/direction
echo "Setting UP LCD_RS"
echo 60 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio60/direction
echo "Setting UP LCD_RD"
echo 7 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio7/direction
echo "Setting UP LCD_WR"
echo 26 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio26/direction
echo "Setting UP LCD_RESET"
echo 46 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio46/direction
echo "Setting UP LCD_CS"
echo 44 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio44/direction
echo "Setting UP LCD_BLVDD"
echo 89 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio89/direction
echo "----TOUCH PANEL----"
echo "Setting UP TOUCH_CS"
echo 45 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio45/direction
echo "Setting UP TOUCH_SCK"
echo 61 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio61/direction
echo "Setting UP TOUCH_SI"
echo 47 > /sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio47/direction
echo "Setting UP TOUCH_IRQ"
echo 65 > /sys/class/gpio/export
echo "in" > /sys/devices/virtual/gpio/gpio65/direction
echo "Setting UP TOUCH_SO"
echo 27 > /sys/class/gpio/export
echo "in" > /sys/devices/virtual/gpio/gpio27/direction
Finally I was ready to write on the LCD!

Related

Test battery status using PowerShell

I'm trying to use PowerShell to tell me when my computer is on battery or AC Power.
I want my script to send me a windows notification when my laptop's charger unplugs.
For the moment, I try to use a recursive fonction to test my battery status every 5 seconds but it doesn't work...
Please, be indulgent about my level, I didn't know anything about PowerShell 3 hours ago... And the last time I coded something was a long time ago !
Function Test-IsOnBattery
{
$battery = Get-WmiObject Win32_Battery
If ($battery.BatteryStatus -eq 2) {
Write-Host "PC sur secteur."
Start-Sleep -Seconds 5
return Test-IsOnBattery
}
Else {
Write-Host "PC sur batterie."
New-BurntToastNotification -Text "Battery Notification" , "Batterie plus sur secteur !"
}
}
Nathan,
Here's a script you can use that you can run from a Scheduled Task, rather than a loop, and have it start on boot up and repeat every so many minutes.
<#+---------------------------------------------------------------------------+
| PowerShell Pgm: BatteryStatus.ps1 |
| Programmed By : The Computer Mentor |
| aka : RetiredGeek # askWoody.com & StackOverFlow.com |
| Created : 06 Mar 2013 |
| Last Updated : 23 Jan 2023 | |
| Current Ver. : 6.0 |
+---------------------------------------------------------------------------+
#>
Clear-Host
Add-Type -AssemblyName "System.Windows.Forms"
$StatusMsg = {
[Windows.Forms.MessageBox]::Show($Message, $Title,
[Windows.Forms.MessageBoxButtons]::OK ,
[Windows.Forms.MessageBoxIcon]::Information)}
$Message = ""
$Title = "Battery Status:"
<#+-----------------------------------------------------+
| BatterStatus Values |
|Other (1) The battery is discharging. |
|Unknown (2) The system has access to AC so no |
| battery is being discharged. However, |
| the battery is not necessarily charging.|
|Fully Charged (3) |
|Low (4) |
|Critical (5) |
|Charging (6) |
|Charging and High (7) |
|Charging and Low (8) |
|Charging and Critical (9) |
|Undefined (10) |
|Partially Charged (11) |
+-----------------------------------------------------|#>
$GWArgs = #{ Class = "Win32_Battery"
ComputerName = "LocalHost"
}
$MyBattery = Get-CIMInstance #GWArgs
If ($Null -eq $MyBattery) {
$Message = "No Battery Present"
}
Else {
$BatteryRemaining = [Int]$MyBattery.EstimatedChargeRemaining
if(($BatteryRemaining -lt 30) -and
$($MyBattery.BatteryStatus) -eq 1) {
$Message = "Battery Low...Please Charge Me!"
}
Elseif(($BatteryRemaining -gt 90) -and
$($MyBattery.BatteryStatus) -ne 1) {
$Message =
"Battery CHARGED above 90%...Please Unplug Me!"
}
} #End Else
if($Message -ne "") {
$Null = & $StatusMsg
}
<#
+----------------------------------------------------------+
| Notes: |
| 1. To call as a scheduled task do the following in the |
| Action Pane |
| A. Action: Start a Program |
| B. Program/script: powershell.exe |
| D. Set the Trigger run At Logon and then repeat |
| every few minutes. |
+----------------------------------------------------------+
#>
If you want to use Toast msgs. just replace that logic where I have my $StatusMgs lines.

Using sql query in shell script

I have a shell script that uses output from a sql query and based on the value of one column sends out an alert. However i don't think it's capturing the value. although the value is not greater than 0 yet it still sends out an email.
Any idea where i am going wrong? Thanks.
............................................................................
#!/bin/sh
psql -d postgres -U postgres -c "select pid,application_name,pg_wal_lsn_diff(pg_current_wal_lsn(), sent_lsn) sending_lag,pg_wal_lsn_diff(sent_lsn,flush_lsn) receiving_lag,pg_wal_lsn_diff(flush_lsn, replay_lsn) replaying_lag,pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) total_lag from pg_stat_replication;"| while read total_lag;
do
echo $total_lag
lag1=$(echo $total_lag)
done
if [[ $lag1 -ge 0 ]]
then echo "Current replication lag is $lag1" |mail -s "WARNING!" abcd#mail.com
else
echo "No issue"
fi
............................................................................
this is the output of above query
pid | application_name | sending_lag | receiving_lag | replaying_lag | total_lag
-------+------------------+-------------+---------------+---------------+-----------
27823 | db123 | 0 | 0 | 0 | 0
27824 | db023 | 0 | 0 | 0 | 0

How do I automatically increment a number in Selenium IDE (Chrome)

I have been trying to create a looping script which increments a number by 1 with each loop.
These are the commands:
Store | 1 | i |
Times | 5 |
Execute Script | return ${i} + 1; | i |
Echo | ${i} |
End
When the script loops, it outputs the following in the log:
echo: 1
echo: 11
echo: 111
echo: 1111
echo: 11111
I have tried this instead:
Execute Script | return ${i} ++; |
But this outputs:
echo: 1
echo: 1
echo: 1
echo: 1
echo: 1
I use this command to increment iterator i
Execute Script|return Math.floor(${i})+1|i
its abit of a long way round, but i've found that this process works:
storeEval ¦ 0 ¦ loop
echoandwait
while ¦ ${loop}<50
execute script
storeEval ¦ ${loop}+1 ¦ loop
endwhile

I want to add Used space column in my powershell script?

I want to make some changes to below script .
try{
$space = Get-WmiObject Win32_logicaldisk `
| Format-Table DeviceID,`
#{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, `
#{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, `
#{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} `
-AutoSize
}
catch
{
echo "Exception Occurred. Please try again on $servername"
}
echo "The total space on $servername are given below:"
echo $space
I want to add a column which shows used space without any changes to output format.
output is below:
The total space on are given below:
DeviceID Size(GB) Free Space(GB) Free (%)
-------- -------- -------------- --------
A: 0 0
C: 60 41 69 %
D: 100 78 78 %
E: 200 190 95 %
G: 0 0
You can extend the table as follows
try
{
$space = Get-WmiObject Win32_logicaldisk | Format-Table DeviceID,
#{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}},
#{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}},
#{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}},
#{Name="Used Space(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb - $_.freespace/1gb))}},
#{Name="Used Space (%)";Expression={"{0,6:P0}" -f(($_.size/1gb - $_.freespace/1gb) / ($_.size/1gb))}}
-AutoSize
}
catch
{
echo "Exception Occurred. Please try again on $servername"
}
echo "The total space on $servername are given below:"
echo $space
I found the answer myself,refer to below code:
$servername = hostname
#checking for disk space
try{
$space = Get-WmiObject Win32_logicaldisk `
| Format-Table DeviceID,`
#{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, `
#{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, `
#{Name="Used Space(GB)";Expression={[decimal]("{0:N0}" -f(($_.size/1gb) - ($_.freespace/1gb)))}}, `
#{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} `
-AutoSize
}
catch
{
echo "Exception Occurred. Please try again on $servername"
}
echo "The total space on $servername are given below:"
echo $space
The desired result required was :
The total space on sw02014 are given below:
DeviceID Size(GB) Free Space(GB) Used Space(GB) Free (%)
-------- -------- -------------- -------------- --------
A: 0 0 0
C: 60 41 18 69 %
D: 100 78 22 78 %
E: 200 190 10 95 %
G: 0 0 0

Get CPU temperature in CMD/POWER Shell

In my computer I am trying to get the CPU temperature. Searching on StackOverflow I found this:
C:\WINDOWS\system32>wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature
But I get this error:
Node - ADMIN
ERROR:
Description = Not supported
you can use this code :
function Get-Temperature {
$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
$returntemp = #()
foreach ($temp in $t.CurrentTemperature)
{
$currentTempKelvin = $temp / 10
$currentTempCelsius = $currentTempKelvin - 273.15
$currentTempFahrenheit = (9/5) * $currentTempCelsius + 32
$returntemp += $currentTempCelsius.ToString() + " C : " + $currentTempFahrenheit.ToString() + " F : " + $currentTempKelvin + "K"
}
return $returntemp
}
Get-Temperature
You can use Open Hardware Monitor it's an open source software (MPL v2).
You can access the command line version here:
OpenHardwareMonitorReport.zip
Example part of the output:
PS C:\Users\myuser\OpenHardwareMonitorReport> .\OpenHardwareMonitorReport.exe
Open Hardware Monitor Report
--------------------------------------------------------------------------------
Version: 0.8.0.2
--------------------------------------------------------------------------------
Common Language Runtime: 4.0.30319.42000
Operating System: Microsoft Windows NT 6.2.9200.0
Process Type: 32-Bit
--------------------------------------------------------------------------------
Sensors
|
+- HP 00F52W (/mainboard)
|
+- Intel Core i7-3770 (/intelcpu/0)
| +- Bus Speed : 99.7734 99.7734 99.7784 (/intelcpu/0/clock/0)
| +- CPU Core #1 : 3691.62 3691.62 3791.58 (/intelcpu/0/clock/1)
| +- CPU Core #2 : 3691.62 3691.62 3791.58 (/intelcpu/0/clock/2)
| +- CPU Core #3 : 3791.39 3791.39 3891.36 (/intelcpu/0/clock/3)
| +- CPU Core #4 : 3691.62 3691.62 3891.36 (/intelcpu/0/clock/4)
| +- CPU Core #1 : 42 42 43 (/intelcpu/0/temperature/0)
| +- CPU Core #2 : 43 37 43 (/intelcpu/0/temperature/1)
| +- CPU Core #3 : 42 35 42 (/intelcpu/0/temperature/2)
| +- CPU Core #4 : 45 41 45 (/intelcpu/0/temperature/3)
| +- CPU Package : 45 43 45 (/intelcpu/0/temperature/4)
Open Hardware Monitor Official website
link to issue where the command line version is
linked: #776
Pending pull request with more recent version: https://github.com/openhardwaremonitor/openhardwaremonitor/pull/1115#issuecomment-616230088
Run the following command in Command Prompt as an Administrator:
wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature
This will give you some output like this:
CurrentTemperature 3000 3010
But make sure that you are running the cmd as an Administrator
On my laptop all above gave me wrong results. Only this one was showing the CPU-Temperature in Celsius:
$data = Get-WMIObject -Query "SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation" -Namespace "root/CIMV2"
#($data)[0].HighPrecisionTemperature
I guess, that each CPU-version may have a different place/formular to get the correct CPU-temperature.
With new sensor, or with what I have and with elevation.
It also shows critical temperature and percentage (in Celsius)
It leaves a file Temperatures.txt for easy debugging, and the xml with serialized object from sensors
function Get-Temperature {
$TempFormat = "#"
$TempFile = "temperature"
$Command = 'Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi" ' + " > $pwd\$TempFile.txt"
$Command = 'Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi" ' + " | Export-Clixml $pwd\$TempFile.xml"
$p = Start-Process -Verb runas -FilePath "powershell" -ArgumentList $command -WorkingDirectory $pwd -PassThru
$p.WaitForExit()
$t = Import-Clixml pippo.xml
$returntemp = #()
foreach ($Sensor in $t)
{
$Active = if($sensor.Active){"On "}else{"Off"}
$temp = $Sensor.CurrentTemperature
$Critical = $Sensor.CriticalTripPoint
$currentTempKelvin = $temp / 10
$currentTempCelsius = $currentTempKelvin - 273.15
$currentTempFahrenheit = (9/5) * $currentTempCelsius + 32
$StrKelvin = $currentTempKelvin.ToString($TempFormat).PadLeft(3, " ")
$StrCelsius = $currentTempCelsius.ToString($TempFormat).PadLeft(3, " ")
$StrFahrenheit = $currentTempFahrenheit.ToString($TempFormat).PadLeft(3, " ")
$CriticalKelvin = $Critical / 10
$CriticalCelsius = $CriticalKelvin - 273.15
$CriticalFahrenheit = (9/5) * $CriticalCelsius + 32
$StrCritKelvin = $CriticalKelvin.ToString($TempFormat).PadRight(3, " ")
$StrCritCelsius = $CriticalCelsius.ToString($TempFormat).PadRight(3, " ")
$StrCritFahrenheit = $CriticalFahrenheit.ToString($TempFormat).PadRight(3, " ")
$PerCrit = ($currentTempCelsius/$CriticalCelsius * 100)
$StrPerCrit = $PerCrit.ToString($TempFormat).PadLeft(3, " ")
$returntemp += "$Active $StrPerCrit% $StrCelsius/$StrCritCelsius C : $StrFahrenheit/$StrCritFahrenheit F : $StrKelvin/$StrCritKelvin K - " + $Sensor.InstanceName
}
return $returntemp
}
Get-Temperature
According to the answer on this question :
To get the exact temperature of CPU (and every core) you need to write
kernel drivers, what is much more complicated.
CurrentTemperature returns temperature at some thermal zone which is
somewhere on motherboard.
This would explain why some of the answers on this page return a temperature, but it's wildly different to the actual CPU temp.