Skip to content

TEMT6000x01 Ambient Light Sensor

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);
The reference voltage varies based on the specifications of the ADC peripheral that is used. The pull down resistance should be the resistance of the pull down resistor used for the hardware circuit.

Status Initialize() const override
Initializes the Adc peripheral to read the incoming measurements. Returns Status::kSuccess upon successful initialization.

Obtaining Sensor Readings

units::illuminance::lux_t GetIlluminance() const override
Converts the ADC output and returns the sensor reading in units of lux.

units::illuminance::lux_t GetMaxIlluminance() const override
Returns the maximum illuminance the device can handle. 1,000 lux is returned, since the device has an illumination range of 1 - 1,000 lux.

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.