UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

Light Class

Module: alight
  • ID: light
  • Name: Analog Light Sensor
  • Category: light
  • Manufacturer: seeed
  • Connection: analog
  • Kit: gsk

The light sensor detects the intensity of the ambient light. As the light intensity of the environment increases, the resistance of the sensor decreases. This means the raw value from the analog pin is larger in bright light and smaller in the dark. A very approximate lux value can also be returned.
light.jpg

Methods

Light

(
  • pin
)
Number

Analog light sensor constructor

Parameters:

  • pin Number

    Analog pin to use

Returns:

Number:

raw_value

() Number

Gets the raw value from the AIO pin

Returns:

Number:

Raw value from the ADC

value

() Number

Gets an approximate light value in lux from the sensor

Returns:

Number:

Approximate light reading in lux

setAref

(
  • aref
)

Set ADC reference voltage

Parameters:

  • aref Number

    ADC reference voltage

setScale

(
  • scale
)

Set sensor scale. This scale is applied to the return value: counts = counts * scale

Parameters:

  • scale Number

    count scale value used

setOffset

(
  • offset
)

Set sensor offset. This offset is applied to the return value: value = value + offset

Parameters:

  • offset Number

    count offset value used

getAref

() Number

Get sensor aref

Returns:

Number:

Sensor ADC reference voltage

getScale

() Number

Get sensor scale

Returns:

Number:

Sensor scale

getOffset

() Number

Get sensor offset

Returns:

Number:

Sensor offset

getNormalized

() Number

Read normalized value for sensor

Returns:

Number:

Function result code

getRawVolts

() Number

Read raw voltage from the sensor

Returns:

Number:

Function result code

name

() String

Returns:

String: