Battery temperature Q

1,188 views
Skip to first unread message

Lis Riba

unread,
Apr 18, 2012, 9:58:22 AM4/18/12
to Tasker
A) What temperature triggers the Profile Event Trigger for "Battery
Overheating"?

B) Are there any other methods within Tasker (or using plugins) for
detecting cpu/battery temperature and using it as a variable?

My new phone seems to run hot, so I'd like to set up some threshholds:
when temperature = X, flash a warning; when temperature = Y, display a
notification; when temperature = Z, audio alert...

Thanks in advance.

Pent

unread,
Apr 18, 2012, 11:06:22 AM4/18/12
to Tasker
> A) What temperature triggers the Profile Event Trigger for "Battery
> Overheating"?

It's an Android-internal thing, Tasker just gets a 'overheating'
signal,
no details.

> B) Are there any other methods within Tasker (or using plugins) for
> detecting cpu/battery temperature and using it as a variable?

Not within Tasker, it's on the todo list.

There might be a file on the file system somewhere you can read.

Pent

ajsraceway

unread,
May 9, 2013, 8:09:35 AM5/9/13
to tas...@googlegroups.com
I don't know if anyone is still interested in this, but I found an easy method for finding battery temperature.

If you run this as a shell command:  dumpsys battery
(you need root, by the way)

You'll get something like this:

Current Battery Service state:
  AC powered: false
  USB powered: false
  status: 3
  health: 2
  present: true
  level: 80
  scale: 100
  voltage: 4000
  temperature: 264
  technology: Li-ion


The temperature is in tenths of degrees Celsius (ten times the temperature in Celsius).  So, you save this output of the shell command to a variable and parse it however you want to get the temperature then convert to your desired units.

What I do, though, is change the shell command to just get the number:  dumpsys battery | grep "temperature" | awk '{ print $2 }'

I store the output in something like %BATTERYTEMP, then, to get the temperature in Fahrenheit, I convert like this:  round(%BATTERYTEMP * 0.18 + 32.0)

Peter Radcliffe

unread,
May 9, 2013, 8:37:22 AM5/9/13
to tas...@googlegroups.com
ajsraceway <ajsra...@gmail.com> probably said:
>If you run this as a shell command: dumpsys battery
>(*you need root*, by the way)

Interesting, good to know.

>What I do, though, is change the shell command to just get the number:
> dumpsys battery | grep "temperature" | awk '{ print $2 }'

To remove one stage of that pipeline and stop processing input once
the line has been found:

dumpsys battery | awk '/temperature:/ { print $2; exit }'

or in C rather than 10*C:

dumpsys battery | awk '/temperature:/ { print $2 / 10; exit }'

>I store the output in something like %BATTERYTEMP, then, to get the
>temperature in Fahrenheit, I convert like this: round(%BATTERYTEMP * 0.18
>+ 32.0)

or in F:

dumpsys battery | awk '/temperature:/ { print $2 * 0.18 + 32; exit }'

Just reduces the number of operations and processes, which can help if
you're doing something frequently enough.

P.

--
pir

ajsraceway

unread,
May 9, 2013, 8:41:55 AM5/9/13
to tas...@googlegroups.com


Just reduces the number of operations and processes, which can help if
you're doing something frequently enough.



Very nice!  I knew there must be better ways.  I'll be making some changes to my code, thanks.
 
Reply all
Reply to author
Forward
0 new messages