Smartphones as a Light Measurement Tool: Case of Study

In recent years, smartphones have become the main computing tool for most of the population, making them an ideal tool in many areas. Most of these smartphones are equipped with cutting-edge hardware on their digital cameras, sensors and processors. For this reason, this paper discusses the possibility of using smartphones as an accessible and accurate tool, focusing on the measurement of light, which is an element that has a high impact on human behavior, which promotes conformance and safety, or alters human physiology when it is inappropriate. To carry out this study, three different ways to measure light through smartphones have been checked: the ambient light sensor, the digital camera and an external Bluetooth luxmeter connected with the smartphone. As a result, the accuracy of these methods has been compared to check if they can be used as accurate measurement tools.


Introduction
Advances in mobile technology has led to its use in different environments such as intelligent transportation, resource management and usability, environmental monitoring, city management and social services. These advances include computing power enhancement and new measurement systems and sensors, turning them into the cornerstone for interaction between people and digital systems and services [1,2]. This upswing of smartphones combined with pervasive sensing enable the collection of information about mobile users and their surrounding environments. The new available information enhances the awareness of the cyber, physical, and social environment, which provides essential support to our daily lives, in the form of services, applications, and so on.
Most recent smartphones are equipped with cutting-edge hardware on their digital cameras, sensors and processors. These kinds of devices are an ideal tool in many areas such as business, education, health or social life, changing dramatically the cultural norms and behavior of individuals. Smartphones are much cheaper than classic tools that they can replace, even high-end devices. These characteristics have led to today's mobile devices becoming the primary computing platform for many users [3]. Despite manufacturers and aggressive marketing promotion, there is no doubt that smartphones have great features and capabilities [4].
On the other hand, lighting, both artificial and natural, has a high impact on human behavior, promoting comfort and safety, or altering human physiology when inappropriate. Analyzing working tasks related to the office, it is possible to see how most of them are linked to document processing, be it through paper or digital documents. Therefore, these activities have high visual requirements, making lighting an important factor to prevent discomfort and vision problems. Different studies attribute migraine headaches, fatigue, medically defined stress, anxiety or decreases in sexual function, among others, to overly intense light [5][6][7][8]. To guarantee proper lighting in workplaces, two standards were developed: UNE 12464-1 [9], which is relative to lighting of indoor workplaces, putting special emphasis on the fulfillment of two aspects: the visual comfort and the performance of colors and standards; the second standard is UNE 12464-2 [10], which is related to the lighting of outdoor workplaces. In both regulations, the lighting requirements are established regarding the activity.
To improve lighting management, modern buildings have incorporated intelligent control systems, saving energy and money and significantly contributing to creating a comfortable working environment if possible [6].
Another field in which it is important to control the amount of light is photography, where illuminance factors have a high impact on picture quality. Photographers use different techniques to manipulate individual parts of a photograph, removing shadows and highlighting features, among others [11]. Therefore, it is recommended to measure light intensity to adjust the camera characteristics in order to get the best photograph quality [12].
Something similar happens on a movie set, where the circumstances of the ambient light where the camera is located can make the difference between a great shot and a useless one, always according to the director's criteria about the purpose of the shot.
There are other cases where the quantity of ambient light is key, such as art museums or galleries. It is essential that the intensity and quantity of light in the gallery rooms where the paintings are presented is adequate, to ensure the correct visualization and to guarantee an optimal state of conservation [13].
Lighting also has a great impact on enclaves that shelter living beings, such as zoological or oceanographic ones, where inadequate lighting levels could produce adverse conditions that could alter these said living beings [14] and even cause problems with their growth [15].
To measure the amount of light and its quality, a luxmeter is used, a specialized device that measures the intensity of light that impacts a surface.
These two lines of reasoning join together if we exploit the advances in smartphones and their processing power and network connectivity [16], to use them as a fairly accurate tool to measure the light through a software development, making this functionality available to any smartphone user. To achieve this goal, the authors ran a study to analyze three different approaches, creating the software, testing it and analyzing the results.
The rest of this paper is divided as follows: Section 2 presents the prior research where different aspects that have been of relevant to the work are studied; Section 3 describes the methodology and the hypothesis that serves as a base for the research; Section 4 presents an analysis of the main elements that have been studied; Section 5 shows the results obtained through the study and the validation of the hypothesis, and, finally, Section 6 contains the conclusions.

Prior Research
As a first step, it is necessary to review the different options available to measure light amounts and existing research in this field. The key concept to guiding this search is the need for an accurate and quantifiable measurement of light needed to create appropriate and pleasant working spaces, it being necessary in some cases to adapt the environment to the requirements to carry out different types of tasks.
As a result of this search, we concluded that light analysis can be performed in two different ways: either virtual scenarios can be created using evaluation software, where we will take lighting information directly from the manufacturers; or real measurements can be taken in real scenarios, where we will use real situations and we will take measurements using different tools. The advantages of a virtual scenario are that you can get a fairly accurate light analysis to work easily and quickly, without any physical deployment and measures. On the other hand, the results will never be as accurate as in real scenarios, as quite a few factors will be omitted. Real scenarios will always be accurate, although more difficult to achieve and with some limitations when performing measurements, and hardware quality will always be essential.

Light Evaluation Software
Programs used to evaluate lighting requirements in different spaces enable a quantitative analysis of scenarios thanks to its capability of creating a 3D virtual world where lighting effects are recreated and analyzed in both artificial lighting and daylighting scenes [17]. In this field, the most important software is called DIALux (DIALux evo 7, Dial, Lüdenscheid, Germany). The main strength of this software is the complete database about lighting products of the main manufacturers, giving more accuracy to the analysis. It also provides information about power consumption of elements to guarantee compliance with the regulations [18].
Similarly, the software called RELUX (version 2017.1.9.0, Relux Informatik AG, Münchenstein, Switzerland) allows us to generate quantitative and qualitative analysis of buildings' lighting thanks to simulation models created with specific materials; colors; reflection factors; natural and artificial lighting elements in order to get a closer possible view of reality [19].
Another renowned and well-known tool to evaluate energy efficiency is the SEAD (Super-efficient Equipment and Appliance Deployment) Street lighting evaluation toolkit. This tool can help to make better choices regarding street lighting fixtures, which can lead to a maximum of 50% in energy savings [20], by providing an easy way of performing evaluations of light quality, energy consumption, and life cycle costs of efficient street lighting alternatives. This tool is supported by Mexico's National Commission for Energy Efficiency, India's Bureau of Energy Efficiency, Natural Resources Canada, the Swedish Energy Agency and the U.S. Department of Energy.
Finally, the program BTwin (versión 2.9.5.8, IMventa Ingenieros, Campanillas, Spain) [21] was designed to plan the street lighting installation based on the standard EN 12464-2 [10], as the program can import the manufacturer's luminance information to give more accuracy to the calculations. In addition, an evaluation of the installation's energy efficiency to obtain the energy label before carrying out its implementation can be performed by using the extended feature called AEwin. Vertical obstacles can be considered as well, as they can affect the lighting, and, by doing so, it is possible to increase the precision of the program.

Light Measurement Analysis
The most commonly used device for measuring light conditions is the luxmeter, a device that allows for simple measurements quickly and not the subjective illuminance of an environment. This device is composed by an integrating light meter with a circuit that develops a signal representing the logarithm of the light being measured and utilizes a display having a linear f-number scale [22]. These devices are too specialized to be available in many situations where light conditions should be measured. For this reason, some researchers have used CCD (Charge-Coupled Device) cameras to obtain luminance [23,24], glare and illuminance measurements [25]. The utilization of CCD as a luminance meter in order to calculate visibility level has big advantages because it reduces the time required for the measurements. However, there are still limitations concerning the reliability on low levels [26]. In addition, to obtain the illuminance level using this kind of camera, a computer, connections between the computer and the light meter and finally software to collect, store and analyze data are necessary. Due to its high-precision resolution, these cameras are very expensive and are not commercially viable for many image-resolving measuring tasks. To solve this problem, the research conducted by Wuller [27] analyzed the possibility to measure luminance with digital still cameras (DSC). The main advantage of this kind of camera is that it can capture the luminance of an entire scene. Despite this research showing that it is possible to obtain luminance value with a digital camera, the quality of the device used is very important to the accuracy of the values. In this respect, the results show how professional cameras are more qualified for use as a luminance measure camera owing to its high color rendering. Similar principles used by Wuller in the use of digital still cameras are applied to the research carried out by Ismail et al. [12]. This study shows how it is possible to design a webcam based luxmeter that is applicable and suitable for lighting monitoring as well as the ability to be used in an embedded application. The research carried out by Sumriddetchkajorn and Somboonkaew [28], which shows how it is possible to evaluate the illuminance directly to the image obtained by the digital camera of a mobile phone, follows similar criteria. However, another research study that analyzes different mobile applications for different platforms such as Android, iOS and Windows phones, that ensure that they can measure the light directly with the mobile, shows how a serious measurement of illuminance is only possible with professional hardware. This is due to the error found in the measurement compared with a professional luxmeter being very high, and the fact that each mobile phone has different measurement values because of its hardware characteristics.

Methodology
To guide this study, a set of hypotheses was proposed to help in the evaluation of the different sensors studied and the subsequent presentation of results. These are the hypotheses: • H1: The ambient light sensor present in mobile devices provide enough quality to be used as a measurement tool. • H2: The digital camera of mobile devices can be used as a lighting measuring tool. • H3: The use of external sensors connected to the mobile device through via Wi-Fi or Bluetooth provides measurements with a quality similar to that obtained by the internal mobile sensors. • H4: Mobile devices can be used by any smartphone user as a fairly accurate light meter tool.
As part of the research, a series of tests were performed with mobile devices where the measures were taken with dimmable lighting situations. The results of these measurements have been compared with others performed in the same situations by a calibrated luxmeter, which has been considered as a reference measurement.
Finally, if the hypotheses are all valid, we have to consider the possibility of using the mobile sensors as a replacement of the external devices.

Analysis of Sensors in Mobile Devices
Over the last few years, smartphones, such as Android products or iPhones, among others, have prevailed as sophisticated multi-function mobile phones. In the case of the Android platform, it provides four different sensors that let users monitor several environmental properties such as humidity, illuminance, ambient pressure and ambient temperature. These sensors are hardware-based and are not available in all of the 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. For this reason, the light measurement performed in this study has been performed in different ways in order to give the option that best fits with each terminal.

Mobile Ambient Light Sensor
Nowadays, most smartphones 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 [29]. 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 [30].
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.
Smartphones' light sensors can obtain accurate readings despite using an easily obtainable technology, but, theoretically, they cannot compare with the accuracy of dedicated hardware devices [29]. One of the main problems of these sensors is that they are located inside the device, allowing for measuring only the light that falls directly on the device, not the ambient light. However, the results obtained in different research studies show how they can be useful in practical cases, as in the undergraduate physics laboratory [31], where a high level of accuracy is not needed.
Some operating systems, like Android OS, allows the user to obtain the values from the light sensor through APIs (Application Programming Interface) that collect data during the runtime of the application. These APIs allow applications to register listeners that are notified about changes in sensor values, returning a single value for each data event [32], whereas most motion and static sensors will return a multidimensional array of values. Furthermore, the ambient-light sensor can be accessed without any specific permission, which allows malicious applications to access this sensor information without raising any suspicion.
Regarding the period of the measurements, the experiment performed by Spreitzer [30] shows how, in a 10 s period, it was observed that about 750 measurement samples can be gathered per second. This experiment also highlights how these sorts of sensors has a resolution of 1 lux.

Mobile Camera
Since most smartphones are equipped with digital cameras, the functionality of this tool has been extended beyond taking pictures. Nowadays, these devices are used in areas such as telemedicine [33], microscopy [34], biology [35] or fluorescent imaging [36], among others.
For instance, if we pay attention to the field of photography, it is possible to see some relationships between photographs and illuminance factors. Nowadays, it is normal to see photographers measuring light characteristics with external luxmeters to adjust their shutter speed and depth of field to get best picture quality [12]. This relationship is present in the photographs' characteristics to the point that it is possible to measure the illuminance through the camera values at the time of taking a picture, as well as the characteristics of the colors of the picture taken. Thus, by using the camera and photographs characteristics, it is possible to calculate the luminance of the scene.
For this purpose, an Android application that is able to obtain the luminance of a picture has been developed. This application allows for obtaining the picture directly from the gallery or from the digital camera. Once the image to process has been acquired, the next step is to process the image to evaluate it. The first stage for performing this task of evaluating the luminance of a picture consists of adapting the spectral luminous efficiency of the human eye for photopic vision through the CIE XYZ (Commission Internationale de l'Éclairage) and (λ) curve. Hence, this value is able to make a direct statement about the luminance of colors [27]. It is possible to evaluate the individual luminance of the tints through the main color wheel palette with constant saturation and lightness levels converted to grayscale. As in a photograph, the images obtained are in RGB (Red Green Blue) colors, and they must be converted into greyscale images to ease the computational burden using the formula of a weighted sum of Red, Green and Blue components, as is shown in Equation (1) [37,38]: This way, the three dimensions of color can be translated into one, where white is represented with the highest value, and black with the lowest. Figure 1 shows a chart with the process done by the application to obtain the luminance of a scenario. Appl. Sci. 2017, 7, 616 6 of 18 One of the main drawbacks detected while measuring the illuminance on a concrete surface with a digital camera is that the illuminance measured will take into account the distance of the device from the surface where the measure is taken. To solve this problem, it is necessary to use a sort of filter close to the device to ensure that the measurement is performed at this point. To perform the study, a Luxi device (Extrasensory Devices, Palo Alto, CA, USA) [39] was used. This device is shown in Figure 2. This device is a diffusion dome attachment for a smartphone's front-facing camera. Another issue detected is the camera parameters, where values as such ISO, shutter speed or F-Stop can change the values obtained in the same lighting conditions. For that reason, and in order to evaluate its use in lighting measurement, it is necessary to take these parameters into account.

External Sensor Device
The use of lighting information can be useful for multiple applications. For example, with this information, it is possible to check lighting efficiency or lighting regulation's accomplishment. Due to the possibilities of communication that smartphones offer, the use of external devices that can interact with our applications is possible. For this reason, an analysis of the use of external device as measurement tool was conducted, which can be used with the smartphone in real time. To perform this evaluation, an external device, called 'Alcalux', a luxmeter developed by the University of Alcalá, has been made.
To choose the best option of communication, and taking into account that the battery life is the most important factor for mobile users [40], the different possibilities of data transmission and the energy consumption of each one has been studied. On that aspect, the best option is Bluetooth because of its low power consumption compared with other wireless communication systems, such as Wi-Fi, as is shown in the study carried out by Perrocci et al. [41]. Another important aspect to take into account is that Bluetooth is embedded in nearly all smartphones. One of the main drawbacks detected while measuring the illuminance on a concrete surface with a digital camera is that the illuminance measured will take into account the distance of the device from the surface where the measure is taken. To solve this problem, it is necessary to use a sort of filter close to the device to ensure that the measurement is performed at this point. To perform the study, a Luxi device (Extrasensory Devices, Palo Alto, CA, USA) [39] was used. This device is shown in Figure 2. This device is a diffusion dome attachment for a smartphone's front-facing camera. One of the main drawbacks detected while measuring the illuminance on a concrete surface with a digital camera is that the illuminance measured will take into account the distance of the device from the surface where the measure is taken. To solve this problem, it is necessary to use a sort of filter close to the device to ensure that the measurement is performed at this point. To perform the study, a Luxi device (Extrasensory Devices, Palo Alto, CA, USA) [39] was used. This device is shown in Figure 2. This device is a diffusion dome attachment for a smartphone's front-facing camera. Another issue detected is the camera parameters, where values as such ISO, shutter speed or F-Stop can change the values obtained in the same lighting conditions. For that reason, and in order to evaluate its use in lighting measurement, it is necessary to take these parameters into account.

External Sensor Device
The use of lighting information can be useful for multiple applications. For example, with this information, it is possible to check lighting efficiency or lighting regulation's accomplishment. Due to the possibilities of communication that smartphones offer, the use of external devices that can interact with our applications is possible. For this reason, an analysis of the use of external device as measurement tool was conducted, which can be used with the smartphone in real time. To perform this evaluation, an external device, called 'Alcalux', a luxmeter developed by the University of Alcalá, has been made.
To choose the best option of communication, and taking into account that the battery life is the most important factor for mobile users [40], the different possibilities of data transmission and the energy consumption of each one has been studied. On that aspect, the best option is Bluetooth because of its low power consumption compared with other wireless communication systems, such as Wi-Fi, as is shown in the study carried out by Perrocci et al. [41]. Another important aspect to take into account is that Bluetooth is embedded in nearly all smartphones. Another issue detected is the camera parameters, where values as such ISO, shutter speed or F-Stop can change the values obtained in the same lighting conditions. For that reason, and in order to evaluate its use in lighting measurement, it is necessary to take these parameters into account.

External Sensor Device
The use of lighting information can be useful for multiple applications. For example, with this information, it is possible to check lighting efficiency or lighting regulation's accomplishment. Due to the possibilities of communication that smartphones offer, the use of external devices that can interact with our applications is possible. For this reason, an analysis of the use of external device as measurement tool was conducted, which can be used with the smartphone in real time. To perform this evaluation, an external device, called 'Alcalux', a luxmeter developed by the University of Alcalá, has been made.
To choose the best option of communication, and taking into account that the battery life is the most important factor for mobile users [40], the different possibilities of data transmission and the energy consumption of each one has been studied. On that aspect, the best option is Bluetooth because of its low power consumption compared with other wireless communication systems, such as Wi-Fi, as is shown in the study carried out by Perrocci et al. [41]. Another important aspect to take into account is that Bluetooth is embedded in nearly all smartphones.
In order to enable Bluetooth in the external device, an embedded module (RN-42 from Roving networks, Los Gatos, CA, USA [42]) was chosen because of its simplicity and relative low power consumption (about 30 mA during the transmission, 3 mA when it is connected and 26 µA in sleep mode).
The data transmission process simulates a pipe of messages where the Bluetooth module receives data from the UART (Universal Asynchronous Receiver-Transmitter) of the microcontroller and transmits the information through the wireless connection.
Despite the present study only covering illuminance measurement, the created device is able to control other factors such as presence or temperature. It is also possible to set the frequency of data registration and to store the data in EEPROM (Electrically Erasable Programmable Read-Only Memory) memory. To avoid storing excessive information in the memory, a device has been developed with the possibility of configuring the automated measures to be taken in a time range between 2 and 65,524 s.
To develop this measurement device, different prototypes were built to improve the final result to achieve the objectives of the project. The prototypes developed are: 1.
The first prototype to be built was focused on measuring the illuminance. To do it, an LDR (Light-Dependent Resistor) was used as a light sensor, which sends the information to a PIC (Programmable Interrupt Controller) microcontroller, which is responsible for sending the information to the computer through a serial cable. In this case, the LDR used was the NORPS-12 model of Silonex (Montreal, Canada) [43], which is composed of a CdS photocell with a spectral response similar to the human eye.

2.
The second prototype developed has incorporated improvements regarding new sensors such as movement or temperature, apart from the use of the Bluetooth connection. Figure 3 shows this second prototype. In order to enable Bluetooth in the external device, an embedded module (RN-42 from Roving networks, Los Gatos, CA, USA [42]) was chosen because of its simplicity and relative low power consumption (about 30 mA during the transmission, 3 mA when it is connected and 26 μA in sleep mode).
The data transmission process simulates a pipe of messages where the Bluetooth module receives data from the UART (Universal Asynchronous Receiver-Transmitter) of the microcontroller and transmits the information through the wireless connection.
Despite the present study only covering illuminance measurement, the created device is able to control other factors such as presence or temperature. It is also possible to set the frequency of data registration and to store the data in EEPROM (Electrically Erasable Programmable Read-Only Memory) memory. To avoid storing excessive information in the memory, a device has been developed with the possibility of configuring the automated measures to be taken in a time range between 2 and 65,524 s.
To develop this measurement device, different prototypes were built to improve the final result to achieve the objectives of the project. The prototypes developed are: 1. The first prototype to be built was focused on measuring the illuminance. To do it, an LDR (Light-Dependent Resistor) was used as a light sensor, which sends the information to a PIC (Programmable Interrupt Controller) microcontroller, which is responsible for sending the information to the computer through a serial cable. In this case, the LDR used was the NORPS-12 model of Silonex (Montreal, Canada) [43], which is composed of a CdS photocell with a spectral response similar to the human eye. 2. The second prototype developed has incorporated improvements regarding new sensors such as movement or temperature, apart from the use of the Bluetooth connection. Figure 3 shows this second prototype. 3. The third prototype developed was the final device. The main difference regarding the previous prototype is the incorporation of a printed circuit board that electrically connects the electronic components using conductive tracks, pads and other features etched on copper sheets. This characteristic gives the final device a professional appearance compared to the previous prototypes. Furthermore, the light sensor was encapsulated with a plastic cylinder with an aperture at the top to reduce up to 500 times the sensibility of the lighting sensor, incrementing the accuracy for a normal range of measurement intended for the device. The final result is a device the size of a cellphone, which is able to read some factors of the real world with high precision and send it to our smartphone. In the case of light, it is possible to perform measurements from 1 to 60,000 lux. Figure 4 shows the final device. 3 The third prototype developed was the final device. The main difference regarding the previous prototype is the incorporation of a printed circuit board that electrically connects the electronic components using conductive tracks, pads and other features etched on copper sheets. This characteristic gives the final device a professional appearance compared to the previous prototypes. Furthermore, the light sensor was encapsulated with a plastic cylinder with an aperture at the top to reduce up to 500 times the sensibility of the lighting sensor, incrementing the accuracy for a normal range of measurement intended for the device. The final result is a device the size of a cellphone, which is able to read some factors of the real world with high precision and send it to our smartphone. In the case of light, it is possible to perform measurements from 1 to 60,000 lux. Figure 4 shows the final device.  An important part of the developed device is the energy source that allows it to be used. From the beginning, the aim was to create a low consumption device, setting this consumption on 200 mA or 0.1 W to allow it to operate with as much autonomy as possible. The device may use two different energy sources: USB connection. This sort of connection can be used to supply energy to the device by connecting it to an appropriate power source. Taking advantage of this, an external battery using 4 batteries of a 1.2 V and 2100 mA was made, which takes the role of an autonomous energy source. Solar panel. It has been done with four small solar panels that give a voltage of 4.8 V to the device, which is enough to supply the developed device.

Results and Hypothesis Validation
To validate the hypothesis, a series of tests has been run using different methodologies. To make the validation more adequate, we have tested each measure methodology in order to study the accuracy of each one, so we are able to combine all of them in tables to analyze the results and study the range of error and accuracy.
There is no doubt that data acquisition conditions are very important to properly evaluate the accuracy of the different systems analyzed in the study. To ensure that the information obtained is as accurate as possible, all of the measurements have been performed in the same scenario, in a dark room with a light bulb and a dimmer. The light source is a 220 W dimmable incandescent light bulb, and it has been connected to a dimmer, which controls the light intensity level as desired. As a reference value for the measurements, the authors use a standard luxmeter model PCE-174 (PCE Iberia, Tobarra, Spain) [44], which has been previously calibrated.
The results of tests are presented and analyzed separately in the following sections.

Mobile Ambient Light Sensor
The first methodology is based on the ambient light sensor consisting of capturing the amount of light directly from the smartphone's ambient light sensor.
To check the accuracy of this sensor, a simple application in Android OS was developed to obtain the level of light registered directly by it. This application was executed in a first step in an LG Nexus 5 smartphone to obtain the information. When we compared the measured data of the smartphone with the information obtained to the referenced luxmeter ( Figure 5), we obtained an absolute error of 39.08%. As can be appreciated, the accuracy of this value is not high, but it is possible to appreciate that the tendency of the measures is similar to the data obtained from the luxmeter. This is a signal that a process of calibration of the sensor is necessary. The calibration method consists of comparing a reference illumination value with the value displayed on the luxmeter that is to be calibrated. An important part of the developed device is the energy source that allows it to be used. From the beginning, the aim was to create a low consumption device, setting this consumption on 200 mA or 0.1 W to allow it to operate with as much autonomy as possible. The device may use two different energy sources: USB connection. This sort of connection can be used to supply energy to the device by connecting it to an appropriate power source. Taking advantage of this, an external battery using 4 batteries of a 1.2 V and 2100 mA was made, which takes the role of an autonomous energy source. Solar panel. It has been done with four small solar panels that give a voltage of 4.8 V to the device, which is enough to supply the developed device.

Results and Hypothesis Validation
To validate the hypothesis, a series of tests has been run using different methodologies. To make the validation more adequate, we have tested each measure methodology in order to study the accuracy of each one, so we are able to combine all of them in tables to analyze the results and study the range of error and accuracy.
There is no doubt that data acquisition conditions are very important to properly evaluate the accuracy of the different systems analyzed in the study. To ensure that the information obtained is as accurate as possible, all of the measurements have been performed in the same scenario, in a dark room with a light bulb and a dimmer. The light source is a 220 W dimmable incandescent light bulb, and it has been connected to a dimmer, which controls the light intensity level as desired. As a reference value for the measurements, the authors use a standard luxmeter model PCE-174 (PCE Iberia, Tobarra, Spain) [44], which has been previously calibrated.
The results of tests are presented and analyzed separately in the following sections.

Mobile Ambient Light Sensor
The first methodology is based on the ambient light sensor consisting of capturing the amount of light directly from the smartphone's ambient light sensor.
To check the accuracy of this sensor, a simple application in Android OS was developed to obtain the level of light registered directly by it. This application was executed in a first step in an LG Nexus 5 smartphone to obtain the information. When we compared the measured data of the smartphone with the information obtained to the referenced luxmeter ( Figure 5), we obtained an absolute error of 39.08%. As can be appreciated, the accuracy of this value is not high, but it is possible to appreciate Appl. Sci. 2017, 7, 616 9 of 18 that the tendency of the measures is similar to the data obtained from the luxmeter. This is a signal that a process of calibration of the sensor is necessary. The calibration method consists of comparing a reference illumination value with the value displayed on the luxmeter that is to be calibrated. To ensure the calibration's accuracy, we use all of the measured points to have a good sample of data with different lux levels, which were used in order to find the calibration factor of the device. The calibration defines which digital output value relates to which luminance input signal. This relationship between scene luminance and digital output levels of a digital image's capture system is called optoelectronic conversion function (OECF) [10]. This kind of calibration is important to adjust the model developed to the characteristics of the devices. Once the calibrated factor is obtained, to achieve the real measured data, it is necessary to multiply the measured value to this factor, as shows Equation (2): After calibrating the measures performed with the calibration factor, the absolute error has been reduced to 13.74%, and, as can be appreciated in Figure 6, the values are closer to the reference data. To ensure the calibration's accuracy, we use all of the measured points to have a good sample of data with different lux levels, which were used in order to find the calibration factor of the device. The calibration defines which digital output value relates to which luminance input signal. This relationship between scene luminance and digital output levels of a digital image's capture system is called optoelectronic conversion function (OECF) [10]. This kind of calibration is important to adjust the model developed to the characteristics of the devices. Once the calibrated factor is obtained, to achieve the real measured data, it is necessary to multiply the measured value to this factor, as shows Equation (2): After calibrating the measures performed with the calibration factor, the absolute error has been reduced to 13.74%, and, as can be appreciated in Figure 6, the values are closer to the reference data. To ensure the calibration's accuracy, we use all of the measured points to have a good sample of data with different lux levels, which were used in order to find the calibration factor of the device. The calibration defines which digital output value relates to which luminance input signal. This relationship between scene luminance and digital output levels of a digital image's capture system is called optoelectronic conversion function (OECF) [10]. This kind of calibration is important to adjust the model developed to the characteristics of the devices. Once the calibrated factor is obtained, to achieve the real measured data, it is necessary to multiply the measured value to this factor, as shows Equation (2): After calibrating the measures performed with the calibration factor, the absolute error has been reduced to 13.74%, and, as can be appreciated in Figure 6, the values are closer to the reference data. However, if we analyze the accuracy of the data in depth, it is possible to sort out three different groups. If we divide the measurements in these groups and recalculate calibration factor of each one separately, the accuracy of the sensor can be increased. The three groups of data are the following: 1.
The first group of values englobes measurements up to 100 lux. If we analyze the accuracy of this data independently of the global evaluation, it is possible to see how the accuracy of the data is too low with an absolute error of 61.77%. However, if we analyze these data separately from the rest of measurements, performing the calibration of these values, it is possible to see how the error decreases to 27.01%.

2.
The second group of values englobes measurements from 100 to 500 lux. Analyzing once again the accuracy of this data separately from the global evaluation, it is shown how the accuracy of the data in this section is higher, with an absolute error of 8.20%. However, performing again the calibration of the system to these values, it is possible to decrease the error to a 5.86%.

3.
The last group englobes measurements higher than 500 lux. Despite the errors obtained in these measurements not being high regarding the percentage (4.75%), the problem observed is that the higher the value measured, the higher the difference between real and calibrated values. For this reason, this section has been analyzed separately again to reduce the percentage of error as much as possible, obtaining an absolute error of 1.84%.
As a result, and after this new recalibration, if we evaluate again the accuracy of the light sensor for all the measurements, and always having in mind the luxmeter as the reference level, the accuracy of the evaluation increases, having an absolute error of 8.41%. Figure 7 shows the final data analysis with this new calibration.
Appl. Sci. 2017, 7, 616 10 of 18 However, if we analyze the accuracy of the data in depth, it is possible to sort out three different groups. If we divide the measurements in these groups and recalculate calibration factor of each one separately, the accuracy of the sensor can be increased. The three groups of data are the following: 1. The first group of values englobes measurements up to 100 lux. If we analyze the accuracy of this data independently of the global evaluation, it is possible to see how the accuracy of the data is too low with an absolute error of 61.77%. However, if we analyze these data separately from the rest of measurements, performing the calibration of these values, it is possible to see how the error decreases to 27.01%. 2. The second group of values englobes measurements from 100 to 500 lux. Analyzing once again the accuracy of this data separately from the global evaluation, it is shown how the accuracy of the data in this section is higher, with an absolute error of 8.20%. However, performing again the calibration of the system to these values, it is possible to decrease the error to a 5.86%. 3. The last group englobes measurements higher than 500 lux. Despite the errors obtained in these measurements not being high regarding the percentage (4.75%), the problem observed is that the higher the value measured, the higher the difference between real and calibrated values. For this reason, this section has been analyzed separately again to reduce the percentage of error as much as possible, obtaining an absolute error of 1.84%.
As a result, and after this new recalibration, if we evaluate again the accuracy of the light sensor for all the measurements, and always having in mind the luxmeter as the reference level, the accuracy of the evaluation increases, having an absolute error of 8.41%. Figure 7 shows the final data analysis with this new calibration. To evaluate the behavior of this sensor, and in order to know if these calibrations can be used by other devices, we have repeated the experiment, with a Sony Xperia M2 and a BQ Aquaris X5 smartphones. After repeating the experiment in the same conditions as in the previous case, and performing the initial calibration according to Equation (2), we have obtained an average error of 10.33% in the first device and 11.82% in the second. The results are shown in Figure 8. To evaluate the behavior of this sensor, and in order to know if these calibrations can be used by other devices, we have repeated the experiment, with a Sony Xperia M2 and a BQ Aquaris X5 smartphones. After repeating the experiment in the same conditions as in the previous case, and performing the initial calibration according to Equation (2), we have obtained an average error of 10.33% in the first device and 11.82% in the second. The results are shown in Figure 8. To know if the measurement groups used in the previous experiment to recalculate the devices' calibration factor can be used in other devices, they were used in the new experiments. As a result, we have that the accuracy of the measurements are higher than if we use just one calibration factor, passing from 10.33% to 7.80% of average error in Sony Xperia M2, and passing from 11.82% to 9.58% in the case of BQ Aquaris X5. However, to check if those calibration groups can be optimized in each device, an analysis to find the best calibration option in each case was performed. As a result, it is possible to see how, in the case of Sony Xperia M2, the best measurement groups match the case of the first experiment. However, in the case of BQ Aquaris X5, there are differences in the behavior regarding the measurements performed in the initial experiment, which suggest that it is possible to move the group of measurements to perform the recalibration. In this case, it is possible to decrease the error from 9.58% to 7.87% if we move the barriers of the recalibration in the following groups: 0-100; 101-500 and 501-700.

Mobile Camera
The second methodology used to measure the illuminance through the mobile devices is based on the use of the digital camera. As it does happen in previous sections, in order to perform an accurate measurement, the digital camera has to be calibrated first before using it for measuring luminance. This time, to calibrate the measurements obtained, it is necessary to take into account not only the differences in hardware between devices but also the camera settings that have to be fixed for all of the measurements. These values are: ISO, which is the level of sensitivity of the camera to available light; Shutter Speed, which is the length of time a camera shutter is open to expose light into the camera sensor; and Aperture, which is a hole within a lens, through which light travels into the camera body. For this reason, the measurements carried out in the experiment keep the same camera characteristics fixed throughout the experiments. In this way, it was possible to compare the obtained results.
To check the accuracy of this method, another Android application was developed to obtain the luminance level directly with the digital camera. This application was executed in a first step in a Sony Xperia M2 smartphone and a Luxi device was used as a filter to guarantee that the luminance is measured as close as possible to the camera. To perform the picture capture in the same conditions, the application fixed the camera settings. Before that, the camera captures the picture, the application developed evaluates it pixel by pixel in order to obtain the RGB values and transforms these values to grey scale through Equation (1), which performs the sum of Red, Green and Blue components.
Furthermore, and to ensure the accuracy of the methodology, a calibration phase where we use all of the measured points to find the calibration factor of the device is required. The calibration To know if the measurement groups used in the previous experiment to recalculate the devices' calibration factor can be used in other devices, they were used in the new experiments. As a result, we have that the accuracy of the measurements are higher than if we use just one calibration factor, passing from 10.33% to 7.80% of average error in Sony Xperia M2, and passing from 11.82% to 9.58% in the case of BQ Aquaris X5. However, to check if those calibration groups can be optimized in each device, an analysis to find the best calibration option in each case was performed. As a result, it is possible to see how, in the case of Sony Xperia M2, the best measurement groups match the case of the first experiment. However, in the case of BQ Aquaris X5, there are differences in the behavior regarding the measurements performed in the initial experiment, which suggest that it is possible to move the group of measurements to perform the recalibration. In this case, it is possible to decrease the error from 9.58% to 7.87% if we move the barriers of the recalibration in the following groups: 0-100; 101-500 and 501-700.

Mobile Camera
The second methodology used to measure the illuminance through the mobile devices is based on the use of the digital camera. As it does happen in previous sections, in order to perform an accurate measurement, the digital camera has to be calibrated first before using it for measuring luminance. This time, to calibrate the measurements obtained, it is necessary to take into account not only the differences in hardware between devices but also the camera settings that have to be fixed for all of the measurements. These values are: ISO, which is the level of sensitivity of the camera to available light; Shutter Speed, which is the length of time a camera shutter is open to expose light into the camera sensor; and Aperture, which is a hole within a lens, through which light travels into the camera body. For this reason, the measurements carried out in the experiment keep the same camera characteristics fixed throughout the experiments. In this way, it was possible to compare the obtained results.
To check the accuracy of this method, another Android application was developed to obtain the luminance level directly with the digital camera. This application was executed in a first step in a Sony Xperia M2 smartphone and a Luxi device was used as a filter to guarantee that the luminance is measured as close as possible to the camera. To perform the picture capture in the same conditions, the application fixed the camera settings. Before that, the camera captures the picture, the application developed evaluates it pixel by pixel in order to obtain the RGB values and transforms these values to grey scale through Equation (1), which performs the sum of Red, Green and Blue components.
Furthermore, and to ensure the accuracy of the methodology, a calibration phase where we use all of the measured points to find the calibration factor of the device is required. The calibration defines which digital output value relates to which luminance input signal. After the calibration of the measures was performed, the absolute error of the measurements became 12.63% (Figure 9).
Appl. Sci. 2017, 7, 616 12 of 18 defines which digital output value relates to which luminance input signal. After the calibration of the measures was performed, the absolute error of the measurements became 12.63% (Figure 9). However, if we evaluate the accuracy of the data in more detail, it is possible again to divide the data into three different groups. Dividing the measurements in these groups and recalculating the calibration factor of each one separately, the accuracy of the measurements can be increased. The three groups studied are the following: 1. The first group of values englobes measurements up to 100 lux. If we analyze the accuracy of this portion of data, it is too low, with an absolute error of 46.43%. However, if we perform the calibration limited to these values, it is possible to see how the error decreases to 20.35%. 2. The second group of values englobes measurements from 100 to 500 lux. With an absolute error of 5.35%, performing again the calibration of the system to these values, it is possible to decrease the error to 4.21%. 3. The last group englobes measurements higher than 500 lux. Without a high amount of error regarding the percentage (10.70%), the problem observed is that error increases if the value measured is higher. For this reason, this section has been analyzed separately, obtaining an absolute error of 2.17%.
As a result, after this new calibration method, the accuracy of the light sensor, compared with a referenced luxmeter, increased, having an absolute error of 6.35% ( Figure 10). However, if we evaluate the accuracy of the data in more detail, it is possible again to divide the data into three different groups. Dividing the measurements in these groups and recalculating the calibration factor of each one separately, the accuracy of the measurements can be increased. The three groups studied are the following: 1.
The first group of values englobes measurements up to 100 lux. If we analyze the accuracy of this portion of data, it is too low, with an absolute error of 46.43%. However, if we perform the calibration limited to these values, it is possible to see how the error decreases to 20.35%.

2.
The second group of values englobes measurements from 100 to 500 lux. With an absolute error of 5.35%, performing again the calibration of the system to these values, it is possible to decrease the error to 4.21%. 3.
The last group englobes measurements higher than 500 lux. Without a high amount of error regarding the percentage (10.70%), the problem observed is that error increases if the value measured is higher. For this reason, this section has been analyzed separately, obtaining an absolute error of 2.17%.
As a result, after this new calibration method, the accuracy of the light sensor, compared with a referenced luxmeter, increased, having an absolute error of 6.35% (Figure 10).
To evaluate the behavior of this sensor, and in order to know if these calibrations can be used by other devices, we have repeated the experiment in the same conditions, with an LG Nexus 5 and a BQ Aquaris X5. After repeating the experiment and performing the initial calibration according to Equation (2), we have obtained an average error of 12.93% in the first device and 10.02% in the second. The results are shown in Figure 11. To evaluate the behavior of this sensor, and in order to know if these calibrations can be used by other devices, we have repeated the experiment in the same conditions, with an LG Nexus 5 and a BQ Aquaris X5. After repeating the experiment and performing the initial calibration according to Equation (2), we have obtained an average error of 12.93% in the first device and 10.02% in the second. The results are shown in Figure 11. To know if the accuracy of the measurements increases if we use the calibration ranges used in the previous experiment, a recalibration of the measurement following the same methodology as in the previous experiment was performed. As a result, the accuracy of the measurements is higher than if we used just one calibration factor, going from 12.93% to 9.24% of average error in LG Nexus 5, and going from 10.02% to 8.82% in the case of BQ Aquaris X5. However, analyzing both cases separately, it is possible to see differences in the behavior regarding the measurements performed in the initial experiment, which suggest that it is possible to move the group of measurements to perform the recalibration. In the case of the measurement performed on LG Nexus 5, it was possible to decrease the error up to 7.26% if we move the barriers of the recalibration in the following groups: 0-100; 101-  To evaluate the behavior of this sensor, and in order to know if these calibrations can be used by other devices, we have repeated the experiment in the same conditions, with an LG Nexus 5 and a BQ Aquaris X5. After repeating the experiment and performing the initial calibration according to Equation (2), we have obtained an average error of 12.93% in the first device and 10.02% in the second. The results are shown in Figure 11. To know if the accuracy of the measurements increases if we use the calibration ranges used in the previous experiment, a recalibration of the measurement following the same methodology as in the previous experiment was performed. As a result, the accuracy of the measurements is higher than if we used just one calibration factor, going from 12.93% to 9.24% of average error in LG Nexus 5, and going from 10.02% to 8.82% in the case of BQ Aquaris X5. However, analyzing both cases separately, it is possible to see differences in the behavior regarding the measurements performed in the initial experiment, which suggest that it is possible to move the group of measurements to perform the recalibration. In the case of the measurement performed on LG Nexus 5, it was possible to decrease the error up to 7.26% if we move the barriers of the recalibration in the following groups: 0-100; 101- To know if the accuracy of the measurements increases if we use the calibration ranges used in the previous experiment, a recalibration of the measurement following the same methodology as in the previous experiment was performed. As a result, the accuracy of the measurements is higher than if we used just one calibration factor, going from 12.93% to 9.24% of average error in LG Nexus 5, and going from 10.02% to 8.82% in the case of BQ Aquaris X5. However, analyzing both cases separately, it is possible to see differences in the behavior regarding the measurements performed in the initial experiment, which suggest that it is possible to move the group of measurements to perform the recalibration. In the case of the measurement performed on LG Nexus 5, it was possible to decrease the error up to 7.26% if we move the barriers of the recalibration in the following groups: 0-100; 101-400 and 401-700. The same happened in case of BQ Aquaris X5, where it was possible to reduce the error to 7.87%, performing the recalibration according to the following groups: 0-50; 51-575; 576-700.

External Sensor Device
The last methodology studied includes the use of the external sensor device. In this situation, the mobile phone does not measure the light. It only receives the sensor's information about the quantity of light across a Bluetooth signal. At first sight, this methodology is expected to be the most accurate of the three studied in this paper because it presents a dedicated hardware developed with the intention of measuring the light. In this situation, we started from a device that was previously calibrated, so that the information received is ready to be used directly in every device connected to the sensor.
To perform the study of the accuracy of this device, the same conditions as in the previous experiments (a dark room with a dimmable light) were used, and the results obtained when the measurements were compared with the reference values obtained from the luxmeter show an absolute error of 2.70% ( Figure 12). Despite everything indicating that two calibrated sensors should measure the same value in the same conditions, the differences in the design could cause differences derived from the position and angle misalignments, making the comparison of the values a difficult task to be performed. error to 7.87%, performing the recalibration according to the following groups: 0-50; 51-575; 576-700.

External Sensor Device
The last methodology studied includes the use of the external sensor device. In this situation, the mobile phone does not measure the light. It only receives the sensor's information about the quantity of light across a Bluetooth signal. At first sight, this methodology is expected to be the most accurate of the three studied in this paper because it presents a dedicated hardware developed with the intention of measuring the light. In this situation, we started from a device that was previously calibrated, so that the information received is ready to be used directly in every device connected to the sensor.
To perform the study of the accuracy of this device, the same conditions as in the previous experiments (a dark room with a dimmable light) were used, and the results obtained when the measurements were compared with the reference values obtained from the luxmeter show an absolute error of 2.70% ( Figure 12). Despite everything indicating that two calibrated sensors should measure the same value in the same conditions, the differences in the design could cause differences derived from the position and angle misalignments, making the comparison of the values a difficult task to be performed.

Hypothesis Validation
Regarding the proposed hypotheses, they can be answered based on the research performed. The first hypothesis (H1) stated that the ambient light sensor that is present in most mobile devices provides enough quality to be used as a measurement tool, with the developed Android application and the measurements performed twice, one with the mobile phone and another with a calibrated luxmeter. Once all of the data were obtained and compared, it was possible to check how the accuracy of the light meter was too low, with an error of 39.08%. However, after a process of calibration, this error was reduced up to 8.41% in the case of the first experiment. Given these results, it is possible to assert that this kind of sensor can be used as a measurement tool. However, the average error observed suggests that this kind of device can be used only as an orientative tool because you need a luxmeter for calibrating every mobile phone model.
Concerning the second hypothesis (H2), which stated that the smartphones' digital camera can be used as a lighting measuring tool, an extra functionality to the previous mobile application, in order to capture the required data from the digital camera, was developed. As in the previous

Hypothesis Validation
Regarding the proposed hypotheses, they can be answered based on the research performed. The first hypothesis (H1) stated that the ambient light sensor that is present in most mobile devices provides enough quality to be used as a measurement tool, with the developed Android application and the measurements performed twice, one with the mobile phone and another with a calibrated luxmeter. Once all of the data were obtained and compared, it was possible to check how the accuracy of the light meter was too low, with an error of 39.08%. However, after a process of calibration, this error was reduced up to 8.41% in the case of the first experiment. Given these results, it is possible to assert that this kind of sensor can be used as a measurement tool. However, the average error observed suggests that this kind of device can be used only as an orientative tool because you need a luxmeter for calibrating every mobile phone model.
Concerning the second hypothesis (H2), which stated that the smartphones' digital camera can be used as a lighting measuring tool, an extra functionality to the previous mobile application, in order to capture the required data from the digital camera, was developed. As in the previous hypothesis, the precision of the measurements when they are compared with a reference luxmeter was at a medium level, with an absolute error of 12.63%. For this reason, a calibration process was necessary in order to improve the accuracy of the data, having the possiblity to reduce this error up to 6.35%. These results highlight that a smartphone's digital camera can be used as a light measurement tool, asserting the proposed hypothesis.
Furthermore, according to the third hypothesis (H3), the use of external sensors connected to the mobile device through Wi-Fi or Bluetooth provides measurements with a similar quality as that obtained by the internal mobile sensors (ambient light sensor and digital cameras). To check the validation of this hypothesis, other measurements were performed with an external sensor that transferred all of the information directly to the mobile device through a Bluetooth connection. After studying all of the measurements, an average error of 2.70% was noted, meaning this hypothesis cannot be accepted due to the accuracy of the external device being higher than the others.
In relation to the last hypothesis (H4), which stated that mobile devices can be used by any smartphone user as a fairly accurate light meter tool, we can assert that it is always possible that a pre-calibration process was performed for each device. However, the process of calibration may result in being difficult to be performed by users due to the fact that it requires the use of a calibrated luxmeter, which is not a common device for users. Furthermore, despite a complete process of calibration requiring an analysis performed by measuring sections, the accuracy obtained with just one calibration factor is enough to be used for a general purpose.

Conclusions
As a conclusion, this study shows how the smartphones can be used in lighting measurement tasks when high precision of data is not required, being a great tool to have a reference of the luminance levels, but they are not as accurate as professional hardware designed for the task.
The results do show how the accuracy of each of the three methods used to perform the evaluation of the luminance is high after calibration. However, if the results are compared between the three methods, it can be seen how the precision of the internal sensors, as ambient light sensor or the digital camera, regarding to an external sensor is lower. This can be caused by the perturbation of ambient light and the fact that the mobile ambient light sensor, due to its physical characteristics, is only able to read direct light, while the luxmeter used on the experiment is able to also measure indirect light.
However, a light meter can never be 100% accurate. There will always be slight variances between light meters, even if they are identical models. It is important to take into consideration that luxmeters can also drift over time, making it necessary to calibrate them to eventually ensure readings as accurately as possible. This characteristic that makes it necessary to calibrate each device separately, even in identical models, hinders the use of smartphones as an accurate measurement tool due to the need to perform the calibration on each device separately. On the other hand, the use of an external device not only improves measurements accuracy, but it can also be used by more than one mobile device.
During the experiments, it was also showed how the use of more than one calibration's parameter increases the accuracy of each sensor. However, the lighting section used to perform this calibration can be different in each device, a reason why, before performing this evaluation, it is necessary to determine values that fit better for each case.
Nevertheless, the work performed does not stop here. For future directions of study, the use of artificial intelligence is proposed, specifically a multi-agent, to evaluate the values obtained for the external sensor to help in decision-making about lighting.
Likewise, the use of both ambient light sensors and digital cameras as tools for home automation control in offices, centers and homes, where the measurements do not need to be as accurate, is also proposed.
Finally, creating a collaborative system that allows the combination of measures from more than one mobile phone, with the aim of self-discovering the calibration needed for every device, is proposed.

Conflicts of Interest:
The authors declare no conflict of interest.