Skip to content

Commit

Permalink
0.1.1 TSL260R
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Nov 27, 2022
1 parent 9cbf8c5 commit 310a5ff
Show file tree
Hide file tree
Showing 19 changed files with 895 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libraries/TSL260R/.arduino-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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:
- uno
# - due
# - zero
# - leonardo
- m4
- esp32
- esp8266
# - mega2560
- rpipico
4 changes: 4 additions & 0 deletions libraries/TSL260R/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: RobTillaart

13 changes: 13 additions & 0 deletions libraries/TSL260R/.github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

name: Arduino-lint

on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
compliance: strict
17 changes: 17 additions & 0 deletions libraries/TSL260R/.github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Arduino CI

on: [push, pull_request]

jobs:
runTest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb
18 changes: 18 additions & 0 deletions libraries/TSL260R/.github/workflows/jsoncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: JSON check

on:
push:
paths:
- '**.json'
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:
pattern: "\\.json$"

22 changes: 22 additions & 0 deletions libraries/TSL260R/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Change Log TSL260R

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.1] - 2022-11-27
- update documentation
- add analogRead Constructor
- add irradiance() for internal analogRead()
- fix camelCase WaveLength
- update unit tests.
- add extra example.
- add keywords.txt


## [0.1.0] - 2022-11-25
- initial version - written on datasheet only
Need to buy hardware for testing.

21 changes: 21 additions & 0 deletions libraries/TSL260R/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-2022 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
127 changes: 127 additions & 0 deletions libraries/TSL260R/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

[![Arduino CI](https://github.com/RobTillaart/TSL260R/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/TSL260R/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/TSL260R/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/TSL260R/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/TSL260R/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/TSL260R/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/TSL260R.svg?maxAge=3600)](https://github.com/RobTillaart/TSL260R/releases)


# TSL260R

Arduino library for the TSL260R IR to voltage convertor


## Description

The TSL260R (TSL261R, TSL262R) is a IR sensor that outputs a voltage depending on the irradiation.

This library does convert the output voltage to uW/cm2.

As the sensors differ by sensitivity the library has three distinct classes.
The table below is an approximation for the max irradiation at 3.3 Volt (output).
For an Arduino UNO 3.3 V is about 650 ADC steps.
When using e.g. an external 16 bit ADS1115, one definitely has far more steps.

| Type | max uW/cm2 |
|:---------:|:------------:|
| TSL260R | 30 |
| TSL261R | 70 |
| TSL262R | 125 |


**Warning** this library is experimental so you should use it with care.
It is written on the datasheet, and I have no hardware yet to test it.
Of course I am very interested in your experiences and feedback to improve
the library.



## Hardware Connection

Always check datasheet

```
// Front view
//
// PIN 1 - GND
// PIN 2 - VDD 2.7 V .. 5.5 V
// PIN 3 - SIGNAL voltage out
```


## Interface

#### using internal ADC

- **TSL260R(uint8_t pin, uint16_t maxADC, float voltage)** Constructor when using an
internal ADC and just one sample to measure the output voltage of the sensor.
- pin = analogRead() pin
- maxADC = max value of the internal ADC, UNO = 1023.
- voltage = max voltage of the internal ADC.
- **TSL261R(uint8_t pin, uint16_t maxADC, float voltage)** idem for TSL261R.
- **TSL262R(uint8_t pin, uint16_t maxADC, float voltage)** idem for TSL262R.
- **float irradiance()** returns the irradiance in uW/cm2.
Uses the analogRead() of the internal ADC.
**Fails** by returning 0 when object is created with the other constructor.


#### using external ADC

- **TSL260R()** constructor when using an external ADC or more than one internal samples
to measure the voltage.
When using this constructor one cannot use the parameterless **irradiance()**, see above.
- **TSL261R()** idem for TSL261R.
- **TSL262R()** idem for TSL262R.
- **float irradiance(float voltage)** returns the irradiance in uW/cm2 based upon voltage
parameter. Does not use an internal analogRead().
Note the user can average 8 internal ADC measurements to reduce noise and then use
this function based upon the average voltage.


#### WaveLength

- **void setWaveLength(uint16_t waveLength = 940)** sets the wave length so the conversion
can use a correction factor.
At 900 - 940 nm the wave length correction factor == 1.0.
Wave length should be between 830 and 1100.
- **uint16_t getWaveLength()** returns the configured wave length.
- **float getWaveLengthFactor()** returns the wave length correction factor.
Note the sensor is most sensitive around 940 nm. See datasheet.
- **calculateWaveLengthFactor(uint16_t waveLength)** calculates the factor to compensate
for less sensitivity at other wave lengths.
E.g. if the sensor is 0.5 x as sensitive at a given wave length the factor should be 2.


#### Calibration

To elaborate.


## Operations

See examples.


## Future

#### must
- improve documentation
- buy hardware (where)
- test test test test
- calibration
- getters/setters for A and B to calibrate the sensor.

#### should
- extend unit tests
- write examples
- fix the dependency of **irradiance()**
- derived class?
- optimize code.

#### could
- test with different IR LEDS (e.g. remote)
- Normalized Output Voltage vs Angular Displacement correction
- figure 11
- temperature correction
-

Loading

0 comments on commit 310a5ff

Please sign in to comment.