TEMT6000x01 Ambient Light Sensor
- TEMT6000x01 Ambient Light Sensor
- Location
- Type
- Background
- Overview
- Detailed Design
- API
- Initialization
- Obtaining Sensor Readings
- Caveats
- Future Advancements
- Testing Plan
- Unit Testing Scheme
- Demonstration Project
Location
devices
Type
Implementation
Background
The TEMT6000X01 ambient light sensor is a device with high photosensitivity like the human eye. The data-sheet for the device can be found here.
Overview
The ambient lighting values of the TEMT6000X01 are read using the ADC driver.
Detailed Design
API
namespace sjsu
{
class Temt6000x01 final : public LightSensor
{
public:
explicit constexpr Temt6000x01(sjsu::Adc & adc,
units::voltage::volt_t adc_reference_voltage,
units::impedance::ohm_t pull_down_resistance);
Status Initialize() const override;
units::illuminance::lux_t GetIlluminance() const override;
units::illuminance::lux_t GetMaxIlluminance() const override;
private:
const sjsu::Adc & adc_;
const units::voltage::microvolt_t kAdcReferenceVoltage;
const units::impedance::ohm_t kPullDownResistance;
float adc_resolution_;
};
} // namespace sjsu
Initialization
explicit constexpr Temt6000x01(sjsu::Adc & adc,
units::voltage::volt_t adc_reference_voltage,
units::impedance::ohm_t pull_down_resistance);
Status Initialize() const override
Adc peripheral to read the incoming measurements. Returns
Status::kSuccess upon successful initialization.
Obtaining Sensor Readings
units::illuminance::lux_t GetIlluminance() const override
units::illuminance::lux_t GetMaxIlluminance() const override
Caveats
N/A
Future Advancements
N/A
Testing Plan
Unit Testing Scheme
The Adc peripheral will be mocked to provide ADC test readings. The ADC mock's
Read() method shall be stubbed to output a reading of 1,204.
The following functions will be tested:
- Initialize()
- The Adc’s Initialize() should be called once.
- GetIlluminance()
- Should return 165.040 lux with a maximum error of ±0.001f.
- GetMaxIlluminance()
- Should return 1,000 lux.
- GetPercentageBrightness()
- Should return 0.165f with a maximum error of ±0.1f.
Demonstration Project
A demonstration project using the LPC17xx platform can be found here.