|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/TSL260R/actions/workflows/arduino-lint.yml) |
| 4 | +[](https://github.com/RobTillaart/TSL260R/actions/workflows/jsoncheck.yml) |
| 5 | +[](https://github.com/RobTillaart/TSL260R/blob/master/LICENSE) |
| 6 | +[](https://github.com/RobTillaart/TSL260R/releases) |
| 7 | + |
| 8 | + |
| 9 | +# TSL260R |
| 10 | + |
| 11 | +Arduino library for the TSL260R IR to voltage convertor |
| 12 | + |
| 13 | + |
| 14 | +## Description |
| 15 | + |
| 16 | +The TSL260R (TSL261R, TSL262R) is a IR sensor that outputs a voltage depending on the irradiation. |
| 17 | + |
| 18 | +This library does convert the output voltage to uW/cm2. |
| 19 | + |
| 20 | +As the sensors differ by sensitivity the library has three distinct classes. |
| 21 | +The table below is an approximation for the max irradiation at 3.3 Volt (output). |
| 22 | +For an Arduino UNO 3.3 V is about 650 ADC steps. |
| 23 | +When using e.g. an external 16 bit ADS1115, one definitely has far more steps. |
| 24 | + |
| 25 | +| Type | max uW/cm2 | |
| 26 | +|:---------:|:------------:| |
| 27 | +| TSL260R | 30 | |
| 28 | +| TSL261R | 70 | |
| 29 | +| TSL262R | 125 | |
| 30 | + |
| 31 | + |
| 32 | +**Warning** this library is experimental so you should use it with care. |
| 33 | +It is written on the datasheet, and I have no hardware yet to test it. |
| 34 | +Of course I am very interested in your experiences and feedback to improve |
| 35 | +the library. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## Hardware Connection |
| 40 | + |
| 41 | +Always check datasheet |
| 42 | + |
| 43 | +``` |
| 44 | +// Front view |
| 45 | +// |
| 46 | +// PIN 1 - GND |
| 47 | +// PIN 2 - VDD 2.7 V .. 5.5 V |
| 48 | +// PIN 3 - SIGNAL voltage out |
| 49 | +``` |
| 50 | + |
| 51 | + |
| 52 | +## Interface |
| 53 | + |
| 54 | +#### using internal ADC |
| 55 | + |
| 56 | +- **TSL260R(uint8_t pin, uint16_t maxADC, float voltage)** Constructor when using an |
| 57 | +internal ADC and just one sample to measure the output voltage of the sensor. |
| 58 | + - pin = analogRead() pin |
| 59 | + - maxADC = max value of the internal ADC, UNO = 1023. |
| 60 | + - voltage = max voltage of the internal ADC. |
| 61 | +- **TSL261R(uint8_t pin, uint16_t maxADC, float voltage)** idem for TSL261R. |
| 62 | +- **TSL262R(uint8_t pin, uint16_t maxADC, float voltage)** idem for TSL262R. |
| 63 | +- **float irradiance()** returns the irradiance in uW/cm2. |
| 64 | +Uses the analogRead() of the internal ADC. |
| 65 | +**Fails** by returning 0 when object is created with the other constructor. |
| 66 | + |
| 67 | + |
| 68 | +#### using external ADC |
| 69 | + |
| 70 | +- **TSL260R()** constructor when using an external ADC or more than one internal samples |
| 71 | +to measure the voltage. |
| 72 | +When using this constructor one cannot use the parameterless **irradiance()**, see above. |
| 73 | +- **TSL261R()** idem for TSL261R. |
| 74 | +- **TSL262R()** idem for TSL262R. |
| 75 | +- **float irradiance(float voltage)** returns the irradiance in uW/cm2 based upon voltage |
| 76 | +parameter. Does not use an internal analogRead(). |
| 77 | +Note the user can average 8 internal ADC measurements to reduce noise and then use |
| 78 | +this function based upon the average voltage. |
| 79 | + |
| 80 | + |
| 81 | +#### WaveLength |
| 82 | + |
| 83 | +- **void setWaveLength(uint16_t waveLength = 940)** sets the wave length so the conversion |
| 84 | +can use a correction factor. |
| 85 | +At 900 - 940 nm the wave length correction factor == 1.0. |
| 86 | +Wave length should be between 830 and 1100. |
| 87 | +- **uint16_t getWaveLength()** returns the configured wave length. |
| 88 | +- **float getWaveLengthFactor()** returns the wave length correction factor. |
| 89 | +Note the sensor is most sensitive around 940 nm. See datasheet. |
| 90 | +- **calculateWaveLengthFactor(uint16_t waveLength)** calculates the factor to compensate |
| 91 | +for less sensitivity at other wave lengths. |
| 92 | +E.g. if the sensor is 0.5 x as sensitive at a given wave length the factor should be 2. |
| 93 | + |
| 94 | + |
| 95 | +#### Calibration |
| 96 | + |
| 97 | +To elaborate. |
| 98 | + |
| 99 | + |
| 100 | +## Operations |
| 101 | + |
| 102 | +See examples. |
| 103 | + |
| 104 | + |
| 105 | +## Future |
| 106 | + |
| 107 | +#### must |
| 108 | +- improve documentation |
| 109 | +- buy hardware (where) |
| 110 | +- test test test test |
| 111 | +- calibration |
| 112 | + - getters/setters for A and B to calibrate the sensor. |
| 113 | + |
| 114 | +#### should |
| 115 | +- extend unit tests |
| 116 | +- write examples |
| 117 | +- fix the dependency of **irradiance()** |
| 118 | + - derived class? |
| 119 | +- optimize code. |
| 120 | + |
| 121 | +#### could |
| 122 | +- test with different IR LEDS (e.g. remote) |
| 123 | +- Normalized Output Voltage vs Angular Displacement correction |
| 124 | + - figure 11 |
| 125 | +- temperature correction |
| 126 | +- |
| 127 | + |
0 commit comments