In dialect 21 or later you can read out the temperature of the CPU (processor) chip itself.
An SPxPoll4 0,!CPU returns the floating point temperature of the CPU chip in °C at locations U(0) --> U(3)
An SPxPoll4 1,!CPU returns the floating point temperature of the CPU chip in °F at locations U(0) --> U(3)
Once you have the temperature in U(0)-U(3) you can transfer it to W using UtoW 0