0% found this document useful (0 votes)
8 views12 pages

Light Sensor (2) Modified

The document provides an overview of a mobile application project focused on utilizing light sensors to measure ambient light levels. It includes details on how light sensors work, their applications, and the software and hardware requirements for implementation. Additionally, it features Java code snippets for the application and concludes with references for further reading.

Uploaded by

latseden
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

Light Sensor (2) Modified

The document provides an overview of a mobile application project focused on utilizing light sensors to measure ambient light levels. It includes details on how light sensors work, their applications, and the software and hardware requirements for implementation. Additionally, it features Java code snippets for the application and concludes with references for further reading.

Uploaded by

latseden
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Bahirdar University

Institute of technology
Faculty of computing
Department of software engineering

Group project for the course MOBILE COMPUTING

By group 3 members

Name ID

1. Ewnetie Adane---------------------------------------------------- 0904158

2. Atsedemariam Bizuneh---------------------------------------------0902861

3. Nuhamin Zelalem----------------------------------------------------0902961

4. Natnael Mulugeta-----------------------------------------------------0904919

5. Yilef Baze--------------------------------------------------------------0903023

Submitted to :INS Tekeste D.

Submission Date: 13/6/2011 EC


Light sensor reader mobile app documentation

Contents
1. Introduction.........................................................................................................................................3
2. Understanding of how Light Sensor Works.............................................................................................4
2. Light Sensor’s information...................................................................................................................5
3. Use of Light Sensor..............................................................................................................................6
5. Requirements for Implementation..........................................................................................................6
5.1. Software Requirements for Light Sensor Application.......................................................................6
5.1.1 Hardware Requirements.................................................................................................................7
Conclusion...................................................................................................................................................7
Implementation...........................................................................................................................................8
Reference..................................................................................................................................................12

2 | Page
Light sensor reader mobile app documentation
1. Introduction
Light sensor is a hardware device that measures the amount of light. An ambient light
sensor is a component in smart phones, notebooks, other mobile devices and automotive
displays . It is a photo detector that is used to sense the amount of ambient light present,
and appropriately dim the device's screen to match it. This avoids having the screen be
too bright when the user's pupils are adapted for vision in a dark room or too dim when
the device is used outdoors in the daytime. The standard international unit for
the illuminance of ambient light is the lux .The performance of ambient light sensors
depends on the hardware devices.
Mobile Ambient Light Sensor Nowadays, most smart phone’s have a built-in ambient
light sensor that is employed to provide information about the intensity of the
surrounding illumination. This information is commonly used to adapt screen brightness
control based on the surroundings, allowing for saving battery from the screen and at the
same time optimizing the visibility. For instance, in outside places where the ambient
light is high, screen brightness must be increased to ensure that the device remains
readable, whereas, in dark places, the screen is dimmed to reduce eye fatigue . This
sensor is usually located on the surface above the screen and may be used for different
purposes. For example, it is broadly used in the field of physics, where during teaching
practices students are able to use their own Smartphone as a light sensor, increasing the
interest and motivation in the execution of experiments. Light sensors are hardware-based
and are not available in all of the android application products due to the fact that their
presence depends on the decision of the manufacturer, as happens with other features
such as the frontal camera.

3 | Page
Light sensor reader mobile app documentation
2. Understanding of how Light Sensor Works

To understand what light sensor is in android first we should take a look at how light or
brightness is measured. In physics to express quantitatively the light they use the word
illuminance. Brightness should never be used for quantitative description, but only for
non-quantitative references to physiological sensations and perceptions of light.

The formal definition of illuminance is the total luminous flux incident on a surface, per
unit area.The standard unit of illuminance is lux.

Illuminance (in lux) = luminance (in lumen) / area (in m 2), where luminance is the
measure of the power of the light source emitting light.

Here the term luminous flux is used to express the measure of the perceived power of
light. Its standard unit is Lumen. This measurement is adjusted to reflect the varying
sensitivity of the human eye to different wavelengths of light.

4 | Page
Light sensor reader mobile app documentation
Simply the illuminance determines the amount of light that covers a surface. Illuminance
is invisible, generally it is light passing through space and not seen unless you look at the
source (e.g. a light bulb) or a surface it reflects off or we can only see luminance.On the
other hand Luminance is an amount of visible light that comes to the eye from surface or
it can also be said as a state or quality of radiating or reflecting light.

2. Light Sensor’s information

Below are the most important information we get from the class concerning about light
sensor.

Light Sensor Reading: The value that sensor detects from the environment. It returns the
reading in lux. As we have discussed above this light measurement is expressed as
Illuminance and its standard unit is Lux. This measures the external light direct to the
phone. It is expressed as the luminance flux per area. Here what we should understand is
that the illuminance measures the light directed to the surfaces and luminance on the
other hand measures the light reflected from the surfaces and directed to the human eye.

Name: This name of the light sensor. It is different for different devices .The
manufacturer gives its name according to their demand.

Vendor: Manufacturer of the sensor

Version: The version number of the sensor

Maximum Delay: maximum range of the sensor in the sensor's unit.

Min Delay: the minimum delay allowed between two events in microsecond or zero if
this sensor only returns a value when the data it's measuring changes.

Resolution: resolution of the sensor in the sensor's unit.

Power= the power in MA used by this sensor while in use

5 | Page
Light sensor reader mobile app documentation
3. Use of Light Sensor

Brightness Control: Light sensors have a lot of uses. The most common use in our
daily lives is in cell phones and tablets. Most portable personal electronics now have
ambient light sensors used to adjust brightness. If the device can sense that it is in a dark
place, it turns down the screen brightness to save power and not surprise the user with a
very bright screen.

Another commonplace use for light sensors is controlling automatic lights in automobiles
and streetlamps. Using a light sensor to trigger a bulb when it is dark outside saves the
slight hassle of turning on the lights and saves power in the day when the sun is bright
enough.
Besides Brightness Control, there are other uses of like security , Planning and
agriculture .

5. Requirements for Implementation

5.1. Software Requirements for Light Sensor Application


✔ Software tools such as android studio

✔ Plat form such as android studio SDK frameworks

✔ Android emulator : SDK version 2.2 or higher

✔ Java Virtual Machine (JVM) installed.

5.1.1 Hardware Requirements

❖ Android device having at minimum 1GB MB of RAM.

❖ Server to store application

❖ Hardware sensors such as GPS sensor.

6 | Page
Light sensor reader mobile app documentation
Conclusion
Light Sensor sense the ambient light in a room. Light Sensor does not generate any
light, it only senses the amount of light already present in an area.The Light Sensor is an
analog sensor, and it returns values in the range of 0 to 4095. Higher values indicate that
the sensor is in light areas, and lower values indicate Dark areas.

Implementation

//Java code part

package e.software.lightnew;
import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
7 | Page
Light sensor reader mobile app documentation
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {

TextView text_available, text_reading;


ListView listView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

text_available = (TextView)findViewById(R.id.sensor_available);
text_reading = (TextView)findViewById(R.id.sensor_reading);
listView = (ListView)findViewById(R.id.valuelist);

String[] sensorValues = new String[7];

SensorManager mySensorManager
=(SensorManager)getSystemService(SENSOR_SERVICE);

Sensor LightSensor =
mySensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);

if(LightSensor != null){
//text_available.setText("Light Sensor Available");

String name = LightSensor.getName();


String vendor = LightSensor.getVendor();
String version = String.valueOf(LightSensor.getVersion());
String maxRange = String.valueOf(LightSensor.getMaximumRange());
String minDelay = String.valueOf(LightSensor.getMinDelay());
String resolution = String.valueOf(LightSensor.getResolution());
String power = String.valueOf(LightSensor.getPower());

8 | Page
Light sensor reader mobile app documentation

sensorValues[0] = "Name = "+name;


sensorValues[1] = "Vendor = "+vendor;
sensorValues[2] = "Version = "+version;
sensorValues[3] = "Maximum Range = "+maxRange;
sensorValues[4] = "Minimum Delay = "+minDelay;
sensorValues[5] = "Resolution = "+resolution;
sensorValues[6] = "Power = "+power +" mA ";

ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this,


android.R.layout.simple_list_item_1, sensorValues);
listView.setAdapter(arrayAdapter);

mySensorManager.registerListener(
LightSensorListener, LightSensor,
SensorManager.SENSOR_DELAY_NORMAL);

}else{
text_available.setText("Light Sensor Not Available");
}
}

private final SensorEventListener LightSensorListener = new


SensorEventListener(){

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub

@Override
public void onSensorChanged(SensorEvent event) {
if(event.sensor.getType() == Sensor.TYPE_LIGHT){
if(event.values[0]<=20){
text_reading.setText("Sensor Reading = " + event.values[0] +"
lux");
text_reading.setBackgroundColor(Color.GRAY);
}else if(event.values[0]>20){
9 | Page
Light sensor reader mobile app documentation
text_reading.setText("Sensor Reading = " + event.values[0]+"
lux");
text_reading.setBackgroundColor(Color.RED);
}
float sensorValue = event.values[0];
if(event.values[0]>1000){
sensorValue = 1000;
}
float brightness = sensorValue / (float)1000;

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = brightness;
getWindow().setAttributes(lp);
}
}

};

Activity_Main.xml implementation code

<?xmlversion="1.0"encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"

10 | Page
Light sensor reader mobile app documentation
tools:context=".MainActivity">
<TextView
android:id="@+id/sensor_reading"

android:layout_width="340dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:text="HelloWorld!"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sensor_available"/>
<TextView
android:id="@+id/sensor_available"
android:layout_width="340dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:text="HelloWorld!"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ListView
android:id="@+id/valuelist"
android:layout_width="368dp"
android:layout_height="407dp"
android:layout_marginLeft="8dp"

11 | Page
Light sensor reader mobile app documentation
android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sensor_reading"/>
</android.support.constraint.ConstraintLayout>

Reference
1. https://gharpedia.com/illuminance-vs-luminance-know-differences/ accessed
January 7, 2019
2. https://developer.android.com/reference/android/hardware/Sensor accessed
January 7, 2019
3. http://eava.ee/opiobjektid/Sensors/light_sensor.html
4. https://blog.mide.com/how-light-sensors-work
5. https://www.newark.com/sensor-optical-light-sensor-technology

12 | Page

You might also like