Skip to main content


Returns a reading from the imp’s light-level sensor


Device (from impOSTM 27)


Integer — the 16-bit photosensor reading


This method provides an instantaneous reading of the relative light level, making use of the device’s light sensor. The value returned is a 16-bit unsigned integer. Higher values represent relatively lighter conditions and lower values represent relatively darker conditions.

An internal ADC is used to sample the sensor, so imps with an external VDDA pin — imp002 and imp003 — will need that to be connected to, for example, 3.3V.

Uses for this method include detecting when the light level has changed sufficiently that a light source should be turned on or off. The imp’s sensor is much more sensitive to infra-red light than its is to visible light. This makes it unsuitable as the basis for sampling light levels which will be used to calculate lux values.

Example Code

The following example relays the reading taken by the imp’s light sensor to a computer connected via UART.