Everlight ALS-PT19 topic
- Quick Notes
- Sensor Datasheet
- Sensor Constructors
- Example Code
- Reference
- Detailed Descriptions
Classes for the Everlight ALS-PT19 ambient light sensor.
Quick Notes
- A simple analog current sensor
- Requires a 2.5 - 5.5V power source
Sensor Datasheet
Sensor Constructors
EverlightALSPT19:: EverlightALSPT19(uint8_t measurementsToAverage = 10) explicit
Construct a new EverlightALSPT19 object with pins and resistors for the EnviroDIY Mayfly 1.x.
Parameters | |
---|---|
measurementsToAverage | The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 10. |
This is a short-cut constructor to help users of our own board so they can change the number of readings without changing other arguments or enter no arguments at all.
Example Code
The ALS-PT19 is used in the menu a la carte example
Classes
- class EverlightALSPT19
- The Sensor sub-class for the Everlight ALS-PT19.
- class EverlightALSPT19_Voltage
- The Variable sub-class used for the relative current output from an Everlight ALS-PT19.
- class EverlightALSPT19_Current
- The Variable sub-class used for the relative current output from an Everlight ALS-PT19.
- class EverlightALSPT19_Illuminance
- The Variable sub-class used for the calculated illuminance output from an Everlight ALS-PT19.
Sensor Variable Counts
The number of variables that can be returned by an ALS-PT19
- #define ALSPT19_NUM_VARIABLES = 3
- Sensor::
_numReturnedValues; the ALS-PT19 can report 1 "raw" value (voltage) and we calculate current and illuminance from it. - #define ALSPT19_INC_CALC_VARIABLES = 2
- Sensor::
_incCalcValues; we calculate photocurrent from the supply voltage and loading resistance and illuminance from the photocurrent.
Pin Definitions for the Mayfly
Specific pin definitions for the ALS-PT19 built in to the EnviroDIY Mayfly v1.x
- #define MAYFLY_ALS_POWER_PIN = -1
- The power pin for the ALS on the EnviroDIY Mayfly v1.x.
- #define MAYFLY_ALS_DATA_PIN = A4
- The data pin for the ALS on the EnviroDIY Mayfly v1.x.
- #define MAYFLY_ALS_SUPPLY_VOLTAGE = 3.3
- The supply voltage for the ALS on the EnviroDIY Mayfly v1.x.
- #define MAYFLY_ALS_LOADING_RESISTANCE = 10
- The loading resistance for the ALS on the EnviroDIY Mayfly v1.x.
Sensor Timing
The sensor timing for an Everlight ALS-PT19
- #define ALSPT19_WARM_UP_TIME_MS = 2
- Sensor::
_warmUpTime_ms; the ALS-PT19 should not need to warm up. - #define ALSPT19_STABILIZATION_TIME_MS = 1
- Sensor::
_stabilizationTime_ms; the ALS-PT19 rise time is 0.11 ms (typical). - #define ALSPT19_MEASUREMENT_TIME_MS = 1
- Sensor::
_measurementTime_ms; essentially 0 time is taken in a reading, just the analog read time, but we want to give more than the rise (0.11 ms) or fall (0.22 ms) time between readings.
Voltage
The voltage variable from an Everlight ALS-PT19
- Range is dependent on supply voltage and loading resistor
- 0 to 4.6 V with a 5V power supply and 75K resistor
EverlightALSPT19_ Voltage:: EverlightALSPT19_Voltage(EverlightALSPT19* parentSense,
const char* uuid = "",
const char* varCode = "ALSPT19Voltage") explicit
Construct a new EverlightALSPT19_
Parameters | |
---|---|
parentSense | The parent EverlightALSPT19 providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "ALSPT19Current". |
- #define ALSPT19_VOLTAGE_RESOLUTION = 3
- Decimals places in string representation; voltage should have 0.
- #define ALSPT19_VOLTAGE_VAR_NUM = 0
- Sensor variable number; current is stored in sensorValues[0].
- #define ALSPT19_VOLTAGE_VAR_NAME = "voltage"
- Variable name in ODM2 controlled vocabulary; "electricCurrent".
- #define ALSPT19_VOLTAGE_UNIT_NAME = "volt"
- Variable unit name in ODM2 controlled vocabulary; "microampere".
- #define ALSPT19_VOLTAGE_DEFAULT_CODE = "ALSPT19Voltage"
- Default variable short code; "ALSPT19Voltage".
Current
The current variable from an Everlight ALS-PT19
- Range is 5 to 520 µA
EverlightALSPT19_ Current:: EverlightALSPT19_Current(EverlightALSPT19* parentSense,
const char* uuid = "",
const char* varCode = "ALSPT19Current") explicit
Construct a new EverlightALSPT19_
Parameters | |
---|---|
parentSense | The parent EverlightALSPT19 providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "ALSPT19Current". |
- #define ALSPT19_CURRENT_RESOLUTION = 0
- Decimals places in string representation; voltage should have 0.
- #define ALSPT19_CURRENT_VAR_NUM = 1
- Sensor variable number; current is stored in sensorValues[0].
- #define ALSPT19_CURRENT_VAR_NAME = "electricCurrent"
- Variable name in ODM2 controlled vocabulary; "electricCurrent".
- #define ALSPT19_CURRENT_UNIT_NAME = "microampere"
- Variable unit name in ODM2 controlled vocabulary; "microampere".
- #define ALSPT19_CURRENT_DEFAULT_CODE = "ALSPT19Current"
- Default variable short code; "ALSPT19Current".
Illuminance
The illuminance variable from an Everlight ALS-PT19
- Range is 0 to 10000 lux
EverlightALSPT19_ Illuminance:: EverlightALSPT19_Illuminance(EverlightALSPT19* parentSense,
const char* uuid = "",
const char* varCode = "ALSPT19Lux") explicit
Construct a new EverlightALSPT19_
Parameters | |
---|---|
parentSense | The parent EverlightALSPT19 providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "ALSPT19Lux". |
- #define ALSPT19_ILLUMINANCE_RESOLUTION = 1
- Decimals places in string representation; illuminance should have 0.
- #define ALSPT19_ILLUMINANCE_VAR_NUM = 2
- Sensor variable number; illuminance is stored in sensorValues[1].
- #define ALSPT19_ILLUMINANCE_VAR_NAME = "illuminance"
- Variable name in ODM2 controlled vocabulary; "illuminance".
- #define ALSPT19_ILLUMINANCE_UNIT_NAME = "lux"
- Variable unit name in ODM2 controlled vocabulary; "lux".
- #define ALSPT19_ILLUMINANCE_DEFAULT_CODE = "ALSPT19Lux"
- Default variable short code; "ALSPT19Lux".
Define documentation
#define ALSPT19_NUM_VARIABLES = 3
#include <src/sensors/EverlightALSPT19.h>
Sensor::
#define ALSPT19_INC_CALC_VARIABLES = 2
#include <src/sensors/EverlightALSPT19.h>
Sensor::
#define MAYFLY_ALS_POWER_PIN = -1
#include <src/sensors/EverlightALSPT19.h>
The power pin for the ALS on the EnviroDIY Mayfly v1.x.
#define MAYFLY_ALS_DATA_PIN = A4
#include <src/sensors/EverlightALSPT19.h>
The data pin for the ALS on the EnviroDIY Mayfly v1.x.
#define MAYFLY_ALS_SUPPLY_VOLTAGE = 3.3
#include <src/sensors/EverlightALSPT19.h>
The supply voltage for the ALS on the EnviroDIY Mayfly v1.x.
#define MAYFLY_ALS_LOADING_RESISTANCE = 10
#include <src/sensors/EverlightALSPT19.h>
The loading resistance for the ALS on the EnviroDIY Mayfly v1.x.
#define ALSPT19_WARM_UP_TIME_MS = 2
#include <src/sensors/EverlightALSPT19.h>
Sensor::
#define ALSPT19_STABILIZATION_TIME_MS = 1
#include <src/sensors/EverlightALSPT19.h>
Sensor::
#define ALSPT19_MEASUREMENT_TIME_MS = 1
#include <src/sensors/EverlightALSPT19.h>
Sensor::
#define ALSPT19_VOLTAGE_RESOLUTION = 3
#include <src/sensors/EverlightALSPT19.h>
Decimals places in string representation; voltage should have 0.
The true resolution depends on the ADC, the supply voltage, and the loading resistor, but for simplicity we will use 3, which is an appropriate value for the Mayfly.
#define ALSPT19_VOLTAGE_VAR_NUM = 0
#include <src/sensors/EverlightALSPT19.h>
Sensor variable number; current is stored in sensorValues[0].
#define ALSPT19_VOLTAGE_VAR_NAME = "voltage"
#include <src/sensors/EverlightALSPT19.h>
Variable name in ODM2 controlled vocabulary; "electricCurrent".
#define ALSPT19_VOLTAGE_UNIT_NAME = "volt"
#include <src/sensors/EverlightALSPT19.h>
Variable unit name in ODM2 controlled vocabulary; "microampere".
#define ALSPT19_VOLTAGE_DEFAULT_CODE = "ALSPT19Voltage"
#include <src/sensors/EverlightALSPT19.h>
Default variable short code; "ALSPT19Voltage".
#define ALSPT19_CURRENT_RESOLUTION = 0
#include <src/sensors/EverlightALSPT19.h>
Decimals places in string representation; voltage should have 0.
The true resolution depends on the ADC, the supply voltage, and the loading resistor, but for simplicity we will use 0 as this is not a high precision sensor.
#define ALSPT19_CURRENT_VAR_NUM = 1
#include <src/sensors/EverlightALSPT19.h>
Sensor variable number; current is stored in sensorValues[0].
#define ALSPT19_CURRENT_VAR_NAME = "electricCurrent"
#include <src/sensors/EverlightALSPT19.h>
Variable name in ODM2 controlled vocabulary; "electricCurrent".
#define ALSPT19_CURRENT_UNIT_NAME = "microampere"
#include <src/sensors/EverlightALSPT19.h>
Variable unit name in ODM2 controlled vocabulary; "microampere".
#define ALSPT19_CURRENT_DEFAULT_CODE = "ALSPT19Current"
#include <src/sensors/EverlightALSPT19.h>
Default variable short code; "ALSPT19Current".
#define ALSPT19_ILLUMINANCE_RESOLUTION = 1
#include <src/sensors/EverlightALSPT19.h>
Decimals places in string representation; illuminance should have 0.
The true resolution depends on the ADC, the supply voltage, the loading resistor, and the light source, but for simplicity we will use 0 as this is not a high precision sensor.
#define ALSPT19_ILLUMINANCE_VAR_NUM = 2
#include <src/sensors/EverlightALSPT19.h>
Sensor variable number; illuminance is stored in sensorValues[1].
#define ALSPT19_ILLUMINANCE_VAR_NAME = "illuminance"
#include <src/sensors/EverlightALSPT19.h>
Variable name in ODM2 controlled vocabulary; "illuminance".
#define ALSPT19_ILLUMINANCE_UNIT_NAME = "lux"
#include <src/sensors/EverlightALSPT19.h>
Variable unit name in ODM2 controlled vocabulary; "lux".
#define ALSPT19_ILLUMINANCE_DEFAULT_CODE = "ALSPT19Lux"
#include <src/sensors/EverlightALSPT19.h>
Default variable short code; "ALSPT19Lux".