mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.3 TSL235R
This commit is contained in:
parent
753172446a
commit
11f2399cb9
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -7,5 +22,6 @@ compile:
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
- esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
25
libraries/TSL235R/CHANGELOG.md
Normal file
25
libraries/TSL235R/CHANGELOG.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Change Log TSL235R
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.3] - 2022-11-26
|
||||
- Add RP2040 support to build-CI.
|
||||
- Add CHANGELOG.md
|
||||
- update readme.md
|
||||
- renamed **calcWLF()** to **calculateWaveLengthFactor()** more descriptive.
|
||||
|
||||
## [0.1.2] - 2021-12-29
|
||||
- update library.json
|
||||
- update readme.md
|
||||
- update license
|
||||
- minor edits
|
||||
|
||||
## [0.1.1] - 2020-06-03
|
||||
- add irradiance_HS()
|
||||
|
||||
## [0.1.0] - 2020-05-29
|
||||
- initial version
|
@ -13,22 +13,28 @@ Arduino library for the TSL235R light to frequency convertor.
|
||||
|
||||
## Description
|
||||
|
||||
This library does not measure the frequency but has some functions to compensate e.g.
|
||||
for wavelength and voltage used.
|
||||
This library does not measure the frequency.
|
||||
That should be done with an interrupt function (user code).
|
||||
The library provides functions to calculate the radiation and
|
||||
has functions to compensate e.g. for wavelength and voltage used.
|
||||
|
||||
The library is not tested extensively yet.
|
||||
|
||||
The sensor operating voltage is between 2.7 and 5.5 max.
|
||||
This can be set in the constructor, or runtime adjusted.
|
||||
|
||||
For measurements below 1uW/cm2 one bests measures for multiple seconds
|
||||
For measurements below 1 uW/cm2 one should measure for multiple seconds.
|
||||
Above 1 uW/cm2 1 second or shorter is OK.
|
||||
|
||||
Note that for longer and shorter measurements than 1 second one must convert the
|
||||
value to Hz, which is the number of pulses in 1 second.
|
||||
Note that for longer and shorter measurements than 1 second one must
|
||||
convert the value to Hz, which is the number of pulses in 1 second.
|
||||
The library provides functions **irradiance()** to do that for you.
|
||||
|
||||
|
||||
## Connection
|
||||
|
||||
Always check the datasheet.
|
||||
|
||||
```
|
||||
// PIN 1 - GND
|
||||
// PIN 2 - VDD 2.7 V .. 5.5 V
|
||||
@ -39,24 +45,29 @@ value to Hz, which is the number of pulses in 1 second.
|
||||
## Interface
|
||||
|
||||
- **TSL235R(float voltage = 5.0)** constructor, optionally one can give the operational voltage
|
||||
to add a small correction (< 1.5%)
|
||||
to add a small correction (< 1.5%).
|
||||
Default voltage is 5.0 Volts.
|
||||
- **float irradiance(uint32_t Hz)** returns the irradiance in uW/cm2.
|
||||
Note that Hz implies the measured pulses for 1 second.
|
||||
- **float irradiance(uint32_t pulses, uint32_t milliseconds)** returns the irradiance in uW/cm2
|
||||
- **float irradiance(uint32_t pulses, uint32_t milliseconds)** returns the irradiance in uW/cm2.
|
||||
This formula is used for other duration than 1 second.
|
||||
To get irradiance in W/m2 one must divide by 100.
|
||||
- **float irradiance_HS(uint32_t pulses, uint32_t microseconds)** returns the irradiance in uW/cm2
|
||||
This formula is used when the time is measured in microseconds. This is the most accurate measurement.
|
||||
- **float irradiance_HS(uint32_t pulses, uint32_t microseconds)** returns the irradiance in uW/cm2.
|
||||
This formula is used when the time is measured in microseconds.
|
||||
This is the most accurate measurement.
|
||||
- **float getFactor()** returns the inner conversion factor from Hz to Watt/cm2.
|
||||
- **void setWavelength(uint16_t wavelength = 635)** sets the wavelength so the formulas can use a
|
||||
correction factor. At the default wavelength of 635 nm the wavelength correction factor == 1.0
|
||||
- **uint16_t getWavelength()** returns the set wavelength. Convenience function.
|
||||
correction factor.
|
||||
At the default wavelength of 635 nm the wavelength correction factor == 1.0.
|
||||
- **uint16_t getWavelength()** returns the set wavelength.
|
||||
- **float getWaveLengthFactor()** returns the wavelength correction factor.
|
||||
As the sensor is most sensitive around 750 nm this value helps to normalize the signal.
|
||||
This works only for (almost) monochromatic light.
|
||||
- **void setVoltage(float voltage)** sets the voltage so the formulas can use a correction factor.
|
||||
This voltage correction factor is rather small < 1.5%
|
||||
- **float getVoltage()** returns the set voltage. Convenience function.
|
||||
This voltage correction factor is rather small < 1.5%.
|
||||
Note: this voltage can be changed runtime.
|
||||
- **float getVoltage()** returns the set voltage, by constructor or by **setVoltage()**.
|
||||
Default voltage is 5.0 Volts.
|
||||
|
||||
|
||||
## Operations
|
||||
@ -66,9 +77,19 @@ See examples for typical usage.
|
||||
|
||||
## Future
|
||||
|
||||
#### must
|
||||
- improve documentation
|
||||
- test test test
|
||||
- investigate hardware solutions for e.g. divide by 100 or so
|
||||
|
||||
#### should
|
||||
- default voltage should be a #define so people who use 3.3V processor
|
||||
can change the library with minimal effort.
|
||||
- irradiance(pulses, millis) can be given a default of 1000 millis.
|
||||
makes irradiance(Hz) obsolete.
|
||||
- move code from .h to .cpp
|
||||
|
||||
#### could
|
||||
- investigate hardware solutions for e.g. divide by 100 or 1000 or so.
|
||||
- investigate correction factor for white light and mixed light sources.
|
||||
- investigate calibration factor for timing of processor used.
|
||||
-
|
||||
|
||||
|
@ -1,13 +1,8 @@
|
||||
//
|
||||
// FILE: TSL235R.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// PURPOSE: library for the TSL235R light to frequency convertor
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2020-05-29 initial version
|
||||
// 0.1.1 2020-06-03 add irradiance_HS()
|
||||
// 0.1.2 2021-12-29 update build-CI, readme, library.json, license, minor edits
|
||||
|
||||
|
||||
#include "TSL235R.h"
|
||||
@ -59,14 +54,14 @@ void TSL235R::calculateFactor()
|
||||
// as the graph is in kHz we need to correct a factor 1000
|
||||
// as the irradiance function gets Hz
|
||||
const float cf = 0.00142;
|
||||
_waveLengthFactor = calcWLF(_waveLength);
|
||||
_waveLengthFactor = calculateWaveLengthFactor(_waveLength);
|
||||
|
||||
_voltageFactor = 0.988 + (_voltage - 2.7) * (0.015 / 2.8);
|
||||
_factor = cf * _waveLengthFactor * _voltageFactor;
|
||||
}
|
||||
|
||||
|
||||
float TSL235R::calcWLF(uint16_t _waveLength)
|
||||
float TSL235R::calculateWaveLengthFactor(uint16_t _waveLength)
|
||||
{
|
||||
// figure 2 datasheet
|
||||
// 635 nm is reference 1.000
|
||||
|
@ -2,11 +2,11 @@
|
||||
//
|
||||
// FILE: TSL235R.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// PURPOSE: library for the TSL235R light to frequency convertor
|
||||
|
||||
|
||||
#define TSL235R_LIB_VERSION (F("0.1.2"))
|
||||
#define TSL235R_LIB_VERSION (F("0.1.3"))
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
@ -17,7 +17,7 @@ public:
|
||||
|
||||
TSL235R(float voltage = 5.0);
|
||||
|
||||
float irradiance(uint32_t Hz);
|
||||
float irradiance(uint32_t Hz); // Hz == pulses in one second.
|
||||
float irradiance(uint32_t pulses, uint32_t milliseconds); // obsolete?
|
||||
float irradiance_HS(uint32_t pulses, uint32_t microseconds);
|
||||
float getFactor() { return _factor; };
|
||||
@ -39,7 +39,7 @@ private:
|
||||
float _factor = 1.2;
|
||||
|
||||
void calculateFactor();
|
||||
float calcWLF(uint16_t _waveLength);
|
||||
float calculateWaveLengthFactor(uint16_t _waveLength);
|
||||
float multiMap(float value, float * _in, float * _out, uint8_t size);
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/TSL235R.git"
|
||||
},
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=TSL235R
|
||||
version=0.1.2
|
||||
version=0.1.3
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library for the TSL235R light to frequency convertor.
|
||||
|
Loading…
Reference in New Issue
Block a user