Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading the iPhone's Ambient Light sensor

Tags:

I notice on my iPhone, after a few seconds of being in direct sun light, the screen will adjust to become brighter, dimmer etc. I was wondering if there was a way to interact with this sensor?

I have an application which is used outside. When you go into direct light, it becomes very difficult to see the screen for a few momments, before it adjusts. And even then, it's not always as bright as I'd like it to be. I would like to implement a high contrast skin for outdoor viewing, and a low contrast for indoor viewing.

Is this possible to read light sensor data, and if so, how do I extract these sensor values?

I would assume there is a light sensor however, as the camera knows when to use the flash.

like image 505
George Johnston Avatar asked Jun 10 '11 16:06

George Johnston


People also ask

How do I test my iPhone ambient light sensor?

You can test it by: Press the "Home" button and then lock your iPhone by pressing the "Sleep/Wake" button. Move into an area with bright ambient light and use your hand to cover the top third of your iPhone screen.

How does the iPhone ambient light sensor work?

iOS devices use an ambient light sensor to adjust brightness levels based on the light conditions around you. The sensor lowers brightness in dark locations and raises brightness in light locations. The auto-brightness feature is on by default.

How can I test my iPhone sensor?

Open the Phone app and tap Keypad, then type *#0*#. A diagnostic screen pops up with buttons for a variety of tests. Tap Red, Green, or Blue to test those pixel colors. Tap Receiver to check the audio, Vibration to try the vibrating feature, or Sensor to test the accelerometer and other sensors.

What does a ambient light sensor measure?

The ambient light sensor is used to measure optical energy at a specific wavelength or specific bands of wavelengths on the light spectrum. The goal of these applications is to improve the visual experience and make the lighting comfortable for the end user.


1 Answers

On the other hand this is a different idea (maybe a silly one), using the brightness of the device's screen you can get some value of the external conditions.

From 0.12 (Dark) to 0.99 (Light)

The next line will get those values, give it a try, put some light on and off over the device to get different values.

NSLog(@"Screen Brightness: %f",[[UIScreen mainScreen] brightness]); 

Obviously Automatic Brightness feature should be turned on in order to get this to work.

Regards.

like image 51
Francisco Gutiérrez Avatar answered Sep 21 '22 17:09

Francisco Gutiérrez