Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temperature value code
#1
Hi! I am new to python and I only know Arduino. I am building a laptop overheating detector and I somehow need to transfer temperature values from the sensors installed in my laptop to a Arduino board via a serial port. I figured out I can use PySerial. But I don't know how to get those temperature values. Can someone write a code for me please. I would be really thankful. Thank You
Reply
#2
Hello,
as you have stated, before sending values to arduino you need to get temperature values. So you should know where they are stored and how they are accessed.
Although we have a forum member who seems to like writing code for users, I wouldn't expect someone will do that for you. Except perhaps pseudo code/algorithm outline, if that is fine for you.
But you can get great help with more specific (Python) questions here.
Reply
#3
Very OS dependent... in Linux they are readibly available by reading the adequate pseudo-file:
>>> with open('/sys/class/hwmon/hwmon0/temp1_input') as t:
...     print 'Temps is %3.2f°C' % (float(t.read())/1000.)
... 
Temps is 43.00°C
Likely more complicated on Windows.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#4
See pyspectator. I came across this two weeks ago. Didn't manage to see the temp here. Perhaps I have to turn on acpi
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
pyspectator look okay,did't work for temp reading on my laptop with Windows.

Here what i done before for Windows,this get all info by using Open Hardware Monitor.
Call call it trough wmi module like this.
import wmi

w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
#print(temperature_infos)
for sensor in temperature_infos:
    #print(sensor)
    if sensor.SensorType == 'Temperature':
        print(sensor.Name)
        print(sensor.Value)
So temp for my laptop:
Output:
CPU Package 56.0 GPU Core 0.0 CPU Core #1 52.0 Temperature 35.0 CPU Core #2 56.0
Reply
#6
My OS is Windows 10 Home. Besides what is this Open Hardware Monitor all about. I hear a lot of people talking about it.
Reply
#7
Hmm there homepage dos explain it.
Quote:The Open Hardware Monitor is a free open source software
that monitors temperature sensors, fan speeds, voltages, load and clock speeds of a computer.
Because it's open source it's possible for languages like Python to get info from it.
Reply
#8
Can you only derive a certain value like Temperature or will you get all the values. I only need the Temperature values and then maybe I can send them to Arduino.
Reply
#9
psutil.sensors_temperatures() ?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#10
(Mar-18-2017, 05:29 AM)wavic Wrote: psutil.sensors_temperatures() ?
psutil is good,but temperatures you see in Doc
Quote:Availability: Linux
So do not work for Windows.

Quote:Can you only derive a certain value like Temperature or will you get all the values.
You can get all info that that OpenHardwareMonitor has,
but remember that you must run run "OpenHardwareMonitor.exe".
Code is taking info from it when it running in background.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help gathering Temperature from API response road102 5 1,085 Dec-16-2022, 08:30 PM
Last Post: road102
  get data (temperature and humidity) from DHT22 into CSV and sending them over the net apollo 0 3,868 Apr-16-2021, 07:49 PM
Last Post: apollo
  monitoring the temperature of the CPU with Python apollo 2 8,794 Apr-13-2021, 05:39 PM
Last Post: apollo
  print CPU temperature samuelbachorik 12 6,126 Aug-04-2020, 03:28 PM
Last Post: Axel_Erfurt
  Read temperature once mada72 2 2,797 Apr-28-2019, 07:18 PM
Last Post: mada72
  Code Wireless Temperature sensor and send sensor readings to google sheet jenkins43 0 2,203 Nov-29-2018, 12:44 PM
Last Post: jenkins43
  Importing a temperature converting module RedSkeleton007 2 8,057 Nov-12-2017, 01:20 PM
Last Post: sparkz_alot
  Temperature Code help? 20AJ0931 2 6,561 Apr-08-2017, 12:35 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020