Editor Version ×
Standard

1.Easy to use and quick to get started

2.The process supports design scales of 300 devices or 1000 pads

3.Supports simple circuit simulation

4.For students, teachers, creators

Profession

1.Brand new interactions and interfaces

2.Smooth support for design sizes of over 5,000 devices or 10,000 pads

3.More rigorous design constraints, more standardized processes

4.For enterprises, more professional users

Ongoing

STD TSL2561 Luminosity Sensor BOB

TSL2561 Luminosity Sensor BOB

Project tags

License

License:

Mode:

Mode

Editors' pick

Editors' pick

  • 2k
  • 0
  • 1
Update time: 2021-04-11 22:52:39
Creation time: 2016-01-25 06:49:53
Description

Description

The TSL2561 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. Compared to low cost CdS cells, this sensor is more precise, allowing for exact Lux calculations and can be configured for different gain/timing ranges to detect light ranges from up to 0.1 - 40,000+ Lux on the fly. The best part of this sensor is that it contains both infrared and full spectrum diodes! That means you can seperately measure infrared, full-spectrum or human-visible light. Most sensors can only detect one or the other, which does not accurately represent what human eyes see (since we cannot perceive the IR light that is detected by most photo diodes). The sensor has a digital (i2c) interface. You can select one of three addresses so you can have up to three sensors on one board - each with a different i2c address. The built in ADC means you can use this with any microcontroller, even if it doesn't have analog inputs. The current draw is extremely low, so its great for low power data-logging systems. about 0.5mA when actively sensing, and less than 15 uA when in powerdown mode. ![enter image description here][1] /**************************************************************************/ /*! @file tsl2561.c @author K. Townsend (microBuilder.eu / adafruit.com) @section LICENSE Software License Agreement (BSD License) Copyright (c) 2010, microBuilder SARL, Adafruit Industries All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /**************************************************************************/ #include #include #include #include "TSL2561.h" TSL2561::TSL2561(uint8_t addr) { _addr = addr; _initialized = false; _integration = TSL2561_INTEGRATIONTIME_13MS; _gain = TSL2561_GAIN_16X; // we cant do wire initialization till later, because we havent loaded Wire yet } boolean TSL2561::begin(void) { Wire.begin(); // Initialise I2C Wire.beginTransmission(_addr); #if ARDUINO >= 100 Wire.write(TSL2561_REGISTER_ID); #else Wire.send(TSL2561_REGISTER_ID); #endif Wire.endTransmission(); Wire.requestFrom(_addr, 1); #if ARDUINO >= 100 int x = Wire.read(); #else int x = Wire.receive(); #endif //Serial.print("0x"); Serial.println(x, HEX); if (x & 0x0A ) { //Serial.println("Found TSL2561"); } else { return false; } _initialized = true; // Set default integration time and gain setTiming(_integration); setGain(_gain); // Note: by default, the device is in power down mode on bootup disable(); return true; } void TSL2561::enable(void) { if (!_initialized) begin(); // Enable the device by setting the control bit to 0x03 write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWERON); } void TSL2561::disable(void) { if (!_initialized) begin(); // Disable the device by setting the control bit to 0x03 write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, TSL2561_CONTROL_POWEROFF); } void TSL2561::setGain(tsl2561Gain_t gain) { if (!_initialized) begin(); enable(); _gain = gain; write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING, _integration | _gain); disable(); } void TSL2561::setTiming(tsl2561IntegrationTime_t integration) { if (!_initialized) begin(); enable(); _integration = integration; write8(TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING, _integration | _gain); disable(); } uint32_t TSL2561::calculateLux(uint16_t ch0, uint16_t ch1) { unsigned long chScale; unsigned long channel1; unsigned long channel0; switch (_integration) { case TSL2561_INTEGRATIONTIME_13MS: chScale = TSL2561_LUX_CHSCALE_TINT0; break; case TSL2561_INTEGRATIONTIME_101MS: chScale = TSL2561_LUX_CHSCALE_TINT1; break; default: // No scaling ... integration time = 402ms chScale = (1 TSL2561_LUX_CHSCALE; channel1 = (ch1 * chScale) >> TSL2561_LUX_CHSCALE; // find the ratio of the channel values (Channel1/Channel0) unsigned long ratio1 = 0; if (channel0 != 0) ratio1 = (channel1 > 1; unsigned int b, m; #ifdef TSL2561_PACKAGE_CS if ((ratio >= 0) && (ratio
Design Drawing

Design Drawing

schematic diagram
1 /
PCB
1 /
The preview image was not generated, please save it again in the editor.
ID Name Designator Footprint Quantity
1 FRAME-LETTER FRAME1 CREATIVE_COMMONS 1
2 TSL2561FN U1 FN-6 1
3 SOLDERJUMPER_2WAY SJ1 SJ_3_PASTE123 1
4 SOLDERJUMPER_2WAY SJ2 SJ_3 1
5 10K R1,R4 0603-RES 2
6 4.7K R2,R3 0603-RES 2
7 0.1uF C1 0603-CAP 1
8 M05 JP1 1X05_ROUNDONLY_NOSILK 1
9 OSHW-LOGO LOGO1 OSHW-LOGO-S 1
10 LOGO-SFENW2 LOGO2 SFE-NEW-WEB 1
11 STAND-OFF STANDOFF1,STANDOFF2 STAND-OFF 2
12 SFE_LOGO_FLAME.1_INCH LOGO3 SFE_LOGO_FLAME_.1 1
13 FIDUCIAL FID1,FID2 MICRO-FIDUCIAL 2

Unfold

Project Attachments

Project Attachments

Empty
Project Members

Project Members

Target complaint
Related Projects
Change a batch
Loading...

Comment

Add to album ×

Loading...

reminder ×

Do you need to add this project to the album?

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn