pyupm_light module

class pyupm_light.Light(pin)[source]

Bases: object

API for the Light Sensor.

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.

C++ includes: light.hpp

getAref()[source]

float getAref()

Get sensor aref

dev: sensor context pointer

Sensor ADC reference voltage

getNormalized()[source]

float getNormalized()

Read normalized value for sensor

dev: sensor context pointer

*value: Normalized value (0.0 -> 1.0)

Function result code

std::runtime_error: on error

getOffset()[source]

float getOffset()

Get sensor offset

dev: sensor context pointer

Sensor offset

getRawVolts()[source]

float getRawVolts()

Read raw voltage from the sensor

dev: sensor context pointer

*value: Raw sensor voltage

Function result code

std::runtime_error: on error

getScale()[source]

float getScale()

Get sensor scale

dev: sensor context pointer

Sensor scale

name()[source]

std::string name()

raw_value()[source]

float raw_value()

Gets the raw value from the AIO pin

Deprecated This function is deprecated use getNormalized() instead.

Raw value from the ADC

std::runtime_error: on error

setAref(aref)[source]

void setAref(float aref)

Set ADC reference voltage

aref: ADC reference voltage

setOffset(offset)[source]

void setOffset(float offset)

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

offset: count offset value used

Function result code

setScale(scale)[source]

void setScale(float scale)

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

scale: count scale value used

value()[source]

int value()

Gets an approximate light value in lux from the sensor

Approximate light reading in lux

std::runtime_error: on error