Add-ons

CPU temperature measurement

27 17766
Reply 20# ckuehnel

Sry, forgot to mention that this is for Raspbian 3.1, not Raspbian 3.0
  1. cat /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
  2. 23400
Copy the Code

Reply 21# actkk2000

Ok, this clarifies it. I am downloading the 3.1 now and will try later.Thanks for the hint.

Here is my python function to read both RPi and BPi temperature :
  1. import os

  2. def read_cpu_temp():
  3.         global cputemp
  4.        
  5.         cmd = """cat /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input |awk '{printf ("%0.1f",$1/1000); }'"""
  6.         cputemp = os.popen(cmd).readline().strip()
  7.         if not cputemp:
  8.                 res = os.popen('vcgencmd measure_temp').readline()
  9.                 cputemp = res.replace("temp=","").replace("'C\n","")
  10.         print("CPU - TEMP : "+cputemp+"")
  11.         return(cputemp)

  12. read_cpu_temp()
Copy the Code

Cool idea
Thank you!

You're welcome...
I'm actually porting all my RPi sources to the BPi, and I want them to remain compatible...

Sure, I am doing the same...

Hey,

Reading the value seems to work, but it is always 42.6°. Why is that?

Edited by actkk2000 at Sat Nov 8, 2014 11:36

Please see this post about reliable temperature reading, it's very good:
http://forum.lemaker.org/forum.p ... 37&fromuid=1602

You have to log in before you can reply Login | Sign Up

Points Rules