• No results found

Adafruit TSL2561 Library Documentation

N/A
N/A
Protected

Academic year: 2022

Share "Adafruit TSL2561 Library Documentation"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

Carter Nelson

Jul 01, 2020

(2)
(3)

1 Dependencies 3

2 Installing from PyPI 5

3 Usage Example 7

4 Contributing 9

5 Documentation 11

6 Table of Contents 13

6.1 Simple test . . . 13 6.2 adafruit_tsl2561 . . . 14 6.2.1 Implementation Notes . . . 14

7 Indices and tables 17

Python Module Index 19

Index 21

i

(4)

ii

(5)

Contents 1

(6)

Adafruit TSL2561 Library Documentation, Release 1.0

2 Contents

(7)

Dependencies

This driver depends on:

• Adafruit CircuitPython

• Bus Device

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

3

(8)

Adafruit TSL2561 Library Documentation, Release 1.0

4 Chapter 1. Dependencies

(9)

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locallyfrom PyPI. To install for current user:

pip3 install adafruit-circuitpython-tsl2561

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-tsl2561

To install in a virtual environment in your current project:

mkdir project-name && cd project-name python3 -m venv .env

source .env/bin/activate

pip3 install adafruit-circuitpython-tsl2561

5

(10)

Adafruit TSL2561 Library Documentation, Release 1.0

6 Chapter 2. Installing from PyPI

(11)

Usage Example

>>> import board

>>> import busio

>>> i2c = busio.I2C(board.SCL, board.SDA)

>>> import adafruit_tsl2561

>>> tsl = adafruit_tsl2561.TSL2561(i2c)

>>> tsl.lux

3294.37

7

(12)

Adafruit TSL2561 Library Documentation, Release 1.0

8 Chapter 3. Usage Example

(13)

Contributing

Contributions are welcome! Please read ourCode of Conductbefore contributing to help this project stay welcoming.

9

(14)

Adafruit TSL2561 Library Documentation, Release 1.0

10 Chapter 4. Contributing

(15)

Documentation

For information on building library documentation, please check outthis guide.

11

(16)

Adafruit TSL2561 Library Documentation, Release 1.0

12 Chapter 5. Documentation

(17)

Table of Contents

6.1 Simple test

Ensure your device works with this simple test.

Listing 1: examples/tsl2561_simpletest.py

1 import time

2 import board

3 import busio

4 import adafruit_tsl2561

5

6 # Create the I2C bus

7 i2c = busio.I2C(board.SCL, board.SDA)

8

9 # Create the TSL2561 instance, passing in the I2C bus

10 tsl = adafruit_tsl2561.TSL2561(i2c)

11

12 # Print chip info

13 print("Chip ID = {}".format(tsl.chip_id))

14 print("Enabled = {}".format(tsl.enabled))

15 print("Gain = {}".format(tsl.gain))

16 print("Integration time = {}".format(tsl.integration_time))

17

18 print("Configuring TSL2561...")

19

20 # Enable the light sensor

21 tsl.enabled = True

22 time.sleep(1)

23

24 # Set gain 0=1x, 1=16x

25 tsl.gain = 0

26

27 # Set integration time (0=13.7ms, 1=101ms, 2=402ms, or 3=manual)

(continues on next page)

13

(18)

Adafruit TSL2561 Library Documentation, Release 1.0

(continued from previous page)

28 tsl.integration_time = 1

29

30 print("Getting readings...")

31

32 # Get raw (luminosity) readings individually

33 broadband = tsl.broadband

34 infrared = tsl.infrared

35

36 # Get raw (luminosity) readings using tuple unpacking

37 # broadband, infrared = tsl.luminosity

38

39 # Get computed lux value (tsl.lux can return None or a float)

40 lux = tsl.lux

41

42 # Print results

43 print("Enabled = {}".format(tsl.enabled))

44 print("Gain = {}".format(tsl.gain))

45 print("Integration time = {}".format(tsl.integration_time))

46 print("Broadband = {}".format(broadband))

47 print("Infrared = {}".format(infrared))

48 if lux is not None:

49 print("Lux = {}".format(lux))

50 else:

51 print("Lux value is None. Possible sensor underrange or overrange.")

52

53 # Disble the light sensor (to save power)

54 tsl.enabled = False

6.2 adafruit_tsl2561

CircuitPython driver for TSL2561 Light Sensor.

• Author(s): Carter Nelson

6.2.1 Implementation Notes

Hardware:

• AdafruitTSL2561 Digital Luminosity/Lux/Light Sensor Breakout(Product ID: 439)

• AdafruitSTEMMA - TSL2561 Digital Lux / Light Sensor(Product ID: 3611)

• AdafruitFlora Lux Sensor - TSL2561 Light Sensor(Product ID: 1246) Software and Dependencies:

• Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: https://github.com/adafruit/

circuitpython/releases

• Adafruit’s Bus Device library:https://github.com/adafruit/Adafruit_CircuitPython_BusDevice class adafruit_tsl2561.TSL2561(i2c, address=57)

Class which provides interface to TSL2561 light sensor.

broadband

The broadband channel value.

14 Chapter 6. Table of Contents

(19)

cycles

The number of integration cycles for which an out of bounds value must persist to cause an interrupt.

enabled

The state of the sensor.

gain

The gain. 0:1x, 1:16x.

infrared

The infrared channel value.

integration_time

The integration time. 0:13.7ms, 1:101ms, 2:402ms, or 3:manual interrupt_mode

The interrupt mode selection.

Mode Description

0 Interrupt output disabled 1 Level Interrupt

2 SMBAlert compliant

3 Test Mode

luminosity

The overall luminosity as a tuple containing the broadband channel and the infrared channel value.

lux

The computed lux value or None when value is not computable.

threshold_high

The upper light interrupt threshold level.

threshold_low

The low light interrupt threshold level.

6.2. adafruit_tsl2561 15

(20)

Adafruit TSL2561 Library Documentation, Release 1.0

16 Chapter 6. Table of Contents

(21)

Indices and tables

• genindex

• modindex

• search

17

(22)

Adafruit TSL2561 Library Documentation, Release 1.0

18 Chapter 7. Indices and tables

(23)

a

adafruit_tsl2561,14

19

(24)

Adafruit TSL2561 Library Documentation, Release 1.0

20 Python Module Index

(25)

A

adafruit_tsl2561(module),14

B

broadband(adafruit_tsl2561.TSL2561 attribute),14

C

chip_id(adafruit_tsl2561.TSL2561 attribute),14 clear_interrupt() (adafruit_tsl2561.TSL2561

method),15

cycles(adafruit_tsl2561.TSL2561 attribute),15

E

enabled(adafruit_tsl2561.TSL2561 attribute),15

G

gain(adafruit_tsl2561.TSL2561 attribute),15

I

infrared(adafruit_tsl2561.TSL2561 attribute),15 integration_time (adafruit_tsl2561.TSL2561 at-

tribute),15

interrupt_mode (adafruit_tsl2561.TSL2561 at- tribute),15

L

luminosity(adafruit_tsl2561.TSL2561 attribute),15 lux(adafruit_tsl2561.TSL2561 attribute),15

T

threshold_high (adafruit_tsl2561.TSL2561 at- tribute),15

threshold_low (adafruit_tsl2561.TSL2561 at- tribute),15

TSL2561(class in adafruit_tsl2561),14

21

References

Related documents

Send a report indicating that the given keys have been pressed. Parameters keycodes – Press these keycodes all at once. Raises ValueError – if more than six regular keys are

sensor_t - This type is used to describe some basic details about this specific sensor, including the sensor name, the resolution and range of the sensor (in the SI units

• Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads • Adafruit’s Bus Device

The following example displays a title and lines of text indicating which key is pressed, the relative position of the rotary encoder, and whether the encoder switch is pressed.

• Adafruit TSL2561 Digital Luminosity/Lux/Light Sensor Breakout (Product ID: 439). • Adafruit STEMMA - TSL2561 Digital Lux / Light Sensor (Product

1.3 Goal setting (behaviour) 1.4 Problem solving 1.3 Goal setting (outcome) 1.4 Action planning 5.1 Information about health consequences 5.6 Information about emotional

The top performing algorithm in independent evaluations by the US National Institute of Standards and Technology is now capable of providing reliable results

43 A recent South African government report to the United Nations Second World Assembly on Ageing makes the following claims, “older persons have free access