Light sensor

692 views
Skip to first unread message

baudi

unread,
Oct 7, 2010, 10:42:23 AM10/7/10
to Tasker
On my DroidX Froyo, a Light Sensor context "From" 0 and "To" 0 matches
normal room lighting, even when I train it as instructed in the
context help. Any chance of getting a %LIGHT variable that contains
the current light value, in addition to the new Light Sensor context?
That might help refine actions based on the light sensor.

Pent

unread,
Oct 7, 2010, 11:18:53 AM10/7/10
to Tasker
> On my DroidX Froyo, a Light Sensor context "From" 0 and "To" 0 matches
> normal room lighting, even when I train it as instructed in the
> context help.

OK, will have a look.

> Any chance of getting a %LIGHT variable that contains
> the current light value, in addition to the new Light Sensor context?

I thought it was only a matter of time before that came up :-)

Pent

WPWoodJr

unread,
Oct 7, 2010, 4:05:26 PM10/7/10
to Tasker
On my Droid X, I measured the lux levels that it reports using the
"GPS Status" app. I then mapped these to Tasker's 0-100% light sensor
readings:

Lux Tasker Reading
10 0%
100 1%
3600 41%
8600 100%

Would it be better to report lux levels instead of 0-100 percent since
Android reports in lux? This would likely provide some level of
standardization across devices?

Sensor.TYPE_LIGHT:
values[0]: Ambient light level in SI lux units

WPWoodJr

unread,
Oct 7, 2010, 4:11:07 PM10/7/10
to Tasker
If you multiply the Tasker readings in the above post by 86 you get
Lux - that's why the bottom two Lux readings are at 0 and 1%
respectively:

Lux Tasker Tasker*86
10 0% 0
100 1% 86
3600 41% 3526
8600 100% 8600

short/y

unread,
Oct 7, 2010, 6:14:23 PM10/7/10
to Tasker

On Oct 7, 1:05 pm, WPWoodJr <wpwoo...@gmail.com> wrote:
> Would it be better to report lux levels instead of 0-100 percent since
> Android reports in lux?  This would likely provide some level of
> standardization across devices?

Personally, I plan to have multiple Tasker licenses on several Android
devices and I'd rather deal with percentage of full light than have to
worry about the details of each device. Perhaps 0-100 isn't
sufficiently granular? In that case, maybe 0-1000?
--
Tony

baudi

unread,
Oct 7, 2010, 6:18:35 PM10/7/10
to Tasker
Either way is OK with me as long as we have a %LIGHT variable that
contains what the device measures, not a percentage.

WPWoodJr

unread,
Oct 7, 2010, 9:56:19 PM10/7/10
to Tasker
Tony,

The lux level being reported is the brightness of impinging light on
the phone. Devices may have more or less range and granularity of
measurement capability. On one device the highest reported lux might
be 8600 (Droid X) and on another it may be much higher or lower (full
sunlight is over 32,000 lux). Getting the lux reading would let you
take action based on a known scale rather than a percentage which
would mean different things on different devices. Maybe we could have
both via a toggle switch?.

However the current 0-100% range needs work. It should probably be
based on:

log2(current lux reading)/log2(max lux reading)*100

This straightens out the response curve between 0 and 100. For
instance, on my Droid X, the percentage readings are currently:

0, 1, 41, 100

corresponding to lux readings of:

10, 100, 3600, 8600

Taking the log base 2 of the lux reading (as in above formula) gives
these percentage readings:

25, 51, 90, 100

which is much more intuitive.

- Bill

On Oct 7, 6:14 pm, "short/y" <tsum...@gmail.com> wrote:

Pent

unread,
Oct 8, 2010, 3:40:09 AM10/8/10
to Tasker
> The lux level being reported is the brightness of impinging light on
> the phone.  Devices may have more or less range and granularity of
> measurement capability.  On one device the highest reported lux might
> be 8600 (Droid X) and on another it may be much higher or lower (full
> sunlight is over 32,000 lux).  

That's why the values are percentages, so you don't need to think
about
the lux levels.

> Getting the lux reading would let you
> take action based on a known scale rather than a percentage which
> would mean different things on different devices.

You lost me there. Full sunlight is 100% on all devices, whatever
their
measurement parameters, that's the point of using a %.

> 10, 100, 3600, 8600
>
> Taking the log base 2 of the lux reading (as in above formula) gives
> these percentage readings:
>
> 25, 51, 90, 100
>
> which is much more intuitive.

It's not at all intuitive to me that virtual darkness corresponds to
25%
of full sunlight...

Pent

Pent

unread,
Oct 8, 2010, 4:17:03 AM10/8/10
to Tasker
I've added %LIGHT in lux for next time.

Pent

Mark Otway

unread,
Oct 8, 2010, 4:35:36 AM10/8/10
to tas...@googlegroups.com

Is that in addition to the percentage one? (Eg %LIGHT and %LUX)

Pent

unread,
Oct 8, 2010, 4:46:05 AM10/8/10
to Tasker
Errr, do you really need a percentage version ?

Pent

Mark Otway

unread,
Oct 8, 2010, 5:19:06 AM10/8/10
to tas...@googlegroups.com

Dunno yet, haven't had a chance to try it as the beta doesn't last more than 5 minutes without force closing for me. So I'm back on 1.0.9...

On 8 Oct 2010 09:46, "Pent" <tas...@dinglisch.net> wrote:

Pent

unread,
Oct 8, 2010, 5:20:23 AM10/8/10
to Tasker
Having looked at the values actually being reported, I've decided to
reconsider :-)

D/Tasker (13134): 09.40.08#M: light: acc: 3 level 10.0 min 0.0 max
10240.0 %0
D/Tasker (13134): 09.40.16#M: light: acc: 3 level 160.0 min 0.0 max
10240.0 %1
D/Tasker (13134): 09.40.17#M: light: acc: 3 level 10.0 min 0.0 max
10240.0 %0
D/Tasker (13134): 09.40.27#M: light: acc: 3 level 160.0 min 0.0 max
10240.0 %1
D/Tasker (13134): 09.40.35#M: light: acc: 3 level 10.0 min 0.0 max
10240.0 %0
D/Tasker (13134): 09.40.38#M: light: acc: 3 level 160.0 min 0.0 max
10240.0 %1
D/Tasker (13134): 09.40.44#M: light: acc: 3 level 640.0 min 0.0 max
10240.0 %6
D/Tasker (13134): 09.40.45#M: light: acc: 3 level 1280.0 min 0.0 max
10240.0 %12
D/Tasker (13134): 09.40.51#M: light: acc: 3 level 2600.0 min 0.0 max
10240.0 %25
D/Tasker (13134): 09.41.02#M: light: acc: 3 level 10240.0 min 0.0 max
10240.0 %100
D/Tasker (13134): 09.41.03#M: light: acc: 3 level 225.0 min 0.0 max
10240.0 %2
D/Tasker (13134): 09.41.05#M: light: acc: 3 level 320.0 min 0.0 max
10240.0 %3
D/Tasker (13134): 09.41.07#M: light: acc: 3 level 640.0 min 0.0 max
10240.0 %6
D/Tasker (13134): 09.41.08#M: light: acc: 3 level 1280.0 min 0.0 max
10240.0 %12
D/Tasker (13134): 09.41.09#M: light: acc: 3 level 2600.0 min 0.0 max
10240.0 %25
D/Tasker (13134): 09.41.13#M: light: acc: 3 level 10240.0 min 0.0 max
10240.0 %100
D/Tasker (13134): 09.41.16#M: light: acc: 3 level 320.0 min 0.0 max
10240.0 %3
D/Tasker (13134): 09.41.17#M: light: acc: 3 level 225.0 min 0.0 max
10240.0 %2

Between 25% and 100% there is never anything, seems like the values
reported aren't
linear.

I tried your formula, which spread things out much better.

However, on the N1, minimum level seen is 10, so the formula always
reports a minimum of
24% even when covered.

I tried:

log( level - minLevel ) / log( maxLevel - minLevel ) * 100

But that gives infinity of course. I can pickup level == minLevel and
return 0, but then the next step up is 58%.

Any more suggestions ?

Pent

Pent

unread,
Oct 8, 2010, 5:22:57 AM10/8/10
to Tasker
Oh, the sensor reports the same value (10) for average room light and
total darkness.

So actually, providing more differentiation on the lower levels (=
standard % of max)
is probably more useful than spreading the values over the scale.

Ponder, ponder.

Pent

WPWoodJr

unread,
Oct 8, 2010, 9:59:40 AM10/8/10
to Tasker
Two issues arise if you don't spread the values:

1) The user has to understand that there are a lot of values bunched
up below 50%, sometimes only 1 apart, and a large gap up to 100%
2) Some values will not be differentiated because they are too close,
for instance 10, 50, 100 lux will all be in the 0-1 range.

Try this formula:
(log(current lux reading)-log(min lux reading))/(log(max lux reading)-
log(min lux reading))*100

That formula runs from 0-100 with good spacing. :-)

- Bill
Message has been deleted

Pent

unread,
Oct 8, 2010, 10:24:28 AM10/8/10
to Tasker
Thanks, that's probably the best one so far:

D/Tasker (14857): 15.12.15#M: light: acc: 3 level 225.0 min 10.0 max
10240.0 %44
D/Tasker (14857): 15.12.16#M: light: acc: 3 level 10.0 min 10.0 max
10240.0 %0
D/Tasker (14857): 15.12.19#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %49
D/Tasker (14857): 15.12.55#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %60
D/Tasker (14857): 15.12.56#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %70
D/Tasker (14857): 15.13.00#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %49
D/Tasker (14857): 15.13.00#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %60
D/Tasker (14857): 15.13.03#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %49
D/Tasker (14857): 15.13.03#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %70
D/Tasker (14857): 15.13.08#M: light: acc: 3 level 10240.0 min 10.0
max 10240.0 %100
D/Tasker (14857): 15.13.10#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %60
D/Tasker (14857): 15.13.10#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %70
D/Tasker (14857): 15.13.12#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %49
D/Tasker (14857): 15.13.13#M: light: acc: 3 level 225.0 min 10.0 max
10240.0 %44
D/Tasker (14857): 15.13.14#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %60
D/Tasker (14857): 15.13.14#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %49

It's a bit clumped around 50-70 range but it least it has 0 and 100.

This is % adjusted to the minimum level seen:

D/Tasker (14999): 15.16.06#M: light: acc: 3 level 225.0 min 10.0 max
10240.0 %2
D/Tasker (14999): 15.16.07#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %3
D/Tasker (14999): 15.16.11#M: light: acc: 3 level 10240.0 min 10.0
max 10240.0 %100
D/Tasker (14999): 15.16.15#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %12
D/Tasker (14999): 15.16.17#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %6
D/Tasker (14999): 15.16.18#M: light: acc: 3 level 225.0 min 10.0 max
10240.0 %2
D/Tasker (14999): 15.16.18#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %3
D/Tasker (14999): 15.16.21#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %12
D/Tasker (14999): 15.16.22#M: light: acc: 3 level 2600.0 min 10.0 max
10240.0 %25
D/Tasker (14999): 15.16.22#M: light: acc: 3 level 10240.0 min 10.0
max 10240.0 %100
D/Tasker (14999): 15.16.23#M: light: acc: 3 level 10240.0 min 10.0
max 10240.0 %100
D/Tasker (14999): 15.16.25#M: light: acc: 3 level 10240.0 min 10.0
max 10240.0 %100
D/Tasker (14999): 15.16.25#M: light: acc: 3 level 2600.0 min 10.0 max
10240.0 %25
D/Tasker (14999): 15.16.26#M: light: acc: 3 level 320.0 min 10.0 max
10240.0 %3
D/Tasker (14999): 15.16.28#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %12
D/Tasker (14999): 15.16.29#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %6
D/Tasker (14999): 15.16.30#M: light: acc: 3 level 1280.0 min 10.0 max
10240.0 %12
D/Tasker (14999): 15.16.31#M: light: acc: 3 level 640.0 min 10.0 max
10240.0 %6
D/Tasker (14999): 15.16.32#M: light: acc: 3 level 10.0 min 10.0 max
10240.0 %0
D/Tasker (14999): 15.16.33#M: light: acc: 3 level 225.0 min 10.0 max
10240.0 %2

Maybe I should adjust the highest value, it's skewing everything.

Pent

WPWoodJr

unread,
Oct 8, 2010, 10:34:15 AM10/8/10
to Tasker
> Thanks, that's probably the best one so far:
In this list you missed out your 160 reading which would be around
25%. My phone reads at 100 lux. So I think the formula is doing well
here.

>This is % adjusted to the minimum level seen:
Not sure what you did here buts very clumped at the low end.

>Maybe I should adjust the highest value, it's skewing everything.
I don't think so. It's logarithmic.

WPWoodJr

unread,
Oct 8, 2010, 10:41:41 AM10/8/10
to Tasker
One other idea. You could set a defined range of lux values - say 10
to 10000. Anything above or below that range gets mapped to 10000 or
10. That way there is some consistency across phones and you don't
have to measure max/min. Your %LIGHT reading could still contain the
real LUX value.

Just throwing that out, haven't decided if I like it. Would run into
issues with phones that have very inaccurate lux readings.

short/y

unread,
Oct 8, 2010, 11:07:55 AM10/8/10
to Tasker
Since I don't really know anything about light readings, I just want
it to be somewhat intuitive. I have no idea what 100% should represent
but it seems that 0 needs to be no light (pretty much impossible I
think), 5% should be really really dark and so on. I know, this isn't
very sophisticated but, to the untrained (i.e. ME) it's makes some
sort of sense. Of course, when you get up to 50% you start wondering
what 100% looks like. So, maybe leaving it in lux is the best answer.

Tough question. Just wanted to throw in the relatively unstructured
thoughts of an unschooled :)
--
Tony

Pent

unread,
Oct 8, 2010, 11:19:13 AM10/8/10
to Tasker
> Since I don't really know anything about light readings, I just want
> it to be somewhat intuitive. I have no idea what 100% should represent
> but it seems that 0 needs to be no light (pretty much impossible I
> think), 5% should be really really dark and so on.

I agree. Unfortunately the light sensor (on an N1 at least) doesn't
discriminate between
complete darkness and an average room brightness.

Pent

Pent

unread,
Oct 8, 2010, 11:21:15 AM10/8/10
to Tasker
> In this list you missed out your 160 reading which would be around
> 25%.  My phone reads at 100 lux.  So I think the formula is doing well
> here.

Good spot, OK, let's stick with that one for now.

Pent

WPWoodJr

unread,
Oct 8, 2010, 11:35:00 AM10/8/10
to Tasker
>it seems that 0 needs to be no light

I'm sort of liking the idea of a pre-defined range from 0-10,000 lux
instead of percentages. Anything over 10,000 is pretty bright - see
http://en.wikipedia.org/wiki/Lux

Illuminance Example
10-4 lux Total starlight, overcast sky[2]
0.002 lux Moonless clear night sky with airglow[2]
0.01 lux Quarter moon
0.27 lux Full moon on a clear night[2][3]
1 lux Full moon overhead at tropical latitudes[4]
3.4 lux Dark limit of civil twilight under a clear sky[5]
50 lux Family living room[6]
80 lux Hallway/toilet[7][8]
100 lux Very dark overcast day[2]
320-500 lux Office lighting[9][10][11]
400 lux Sunrise or sunset on a clear day.
1,000 lux Overcast day[2]; typical TV studio lighting
10,000-25,000 lux Full daylight (not direct sun)[2]
32,000-130,000 lux Direct sunlight

Maybe it should be 0-100,000 lux?

Happy to go with percentages though.

short/y

unread,
Oct 9, 2010, 2:48:31 PM10/9/10
to Tasker
I'm in over my head. At this point, I yield to the experts and I'll
deal with whatever we end up with. Showing lux is probably the best.
Even if it's counterintuitive, if I can paraphrase "there's a web page
for that" :)
--
Tony

On Oct 8, 8:35 am, WPWoodJr <wpwoo...@gmail.com> wrote:
> >it seems that 0 needs to be no light
>
> I'm sort of liking the idea of a pre-defined range from 0-10,000 lux
> instead of percentages.  Anything over 10,000 is pretty bright - seehttp://en.wikipedia.org/wiki/Lux
Reply all
Reply to author
Forward
0 new messages