-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code,Schematics,Breadboard View,Libraries,etc for the Inclusion of TSL2561 Luminosity/Lux Sensor in the Twist Platform
- Loading branch information
1 parent
6c1aa58
commit 232df34
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This branch was Created by Jonathan Pereira on 10th November 2015 for the TWIST platform. Open to the public domain. | ||
Learn more about the sensor @ https://learn.adafruit.com/tsl2561/overview | ||
|
||
|
||
|
||
This folder contains the Adafruit Sensor Library & Adafruit TSL2561 Library, code(TSL2561_TWIST) and Schematics, Breadboard view for the inclusion of the TSL2561 sensor in the TWIST platform. The PCB view for this sensor is not correct. | ||
|
||
|
||
Connections: | ||
Connect the VCC/Vin pin to a 3.3V or 5v power source. | ||
Note: Currently shipping sensors have a 3.3v regulator built-in. If you have an older version of the sensor that does not have the voltage regulator, it cannot be used with anything higher than 3.3V! | ||
Connect GND to the ground pin. | ||
Connect the i2c SCL clock pin to your i2c clock pin. | ||
Connect the i2c SDA data pin to your i2c data pin. | ||
Unfortunately, the i2c lines on most microcontrollers are fixed so you're going to have to stick with those pins | ||
|
||
You may be wondering, how is it OK to connect a 3.3V chip like the TSL2561 to 5.0V data pins like the Arduino? Isn't that bad? Well, in this specific case its OK. I2c uses pullup lines to the 3.3V power pin, so the data is actually being sent at 3.3V. As long as all the sensors/device on the i2c bus are running on 3.3V power, we're fine. However, don't use a 5.0v powered i2c device (like the DS1307) with pullups at the same time as a 3.3V device like the TSL2561! If you want to use this sensor with a datalogger that uses the DS1307, remove any/all of the pullup resistors from the DS1307 SDA/SCL pins. The pullups built into the TSL2561 will then be active and keep the voltage at 3.3V which is safe for both the RTC and the sensor. | ||
|
||
You don't need to connect the ADDR (i2c address change) or INT (interrupt output) pins. | ||
The ADDR pin can be used if you have an i2c address conflict, to change the address. Connect it to ground to set the address to 0x29, connect it to 3.3V (vcc) to se t the address to 0x49 or leave it floating (unconnected) to use address 0x39. | ||
The INT pin is an ouput from the sensor used when you have the sensor configured to signal when the light level has changed. We don't have that code written in this tutorial so you don't have to use it. If you do end up using it, use a 10K-100K pullup from INT to 3.3V (vcc/vin) | ||
|
||
|
||
Read the ReadMe files in the library and code files too. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions
88
TSL2561 Luminosity Lux Sensor/TSL2561_TWIST/TSL2561_TWIST.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Example testing sketch for the TSL2561 Luminosity/Lux sensor | ||
// Written by ladyada, public domain | ||
//Modified by Jonathan Pereira on 10th November 2015 for the Tweeting Weather Iot STation aka TWIST platform http://www.instructables.com/id/TWIST-DIY-Tweeting-Weather-Station/ | ||
|
||
/* ___________________________________________________________________________________________________________________________________________________________________________ | ||
* TWIST SETUP | ||
* In order to use this code for TWIST follow the follwing steps: | ||
* Step 1: Copy all the pin declarations, variable declarations,library initalizations to the main TWIST code before the setup block. Download & Install the Adfruit Sensor Library & Adafruit TSL2561 Library. | ||
* Step 2: Copy all the statement from the setup block into the setup block of the main TWIST code. | ||
* Step 3: Copy all the statement from the loop block into the loop block of the main TWIST code. | ||
* Step 4: Copy the ' void dht11(){.............} ' function and paste it outside the the loop block of the main TWIST code. | ||
* ___________________________________________________________________________________________________________________________________________________________________________ | ||
*/ | ||
|
||
#include <Wire.h> | ||
#include <Adafruit_Sensor.h> | ||
#include <Adafruit_TSL2561_U.h> | ||
/* I2C Address | ||
=========== | ||
The address will be different depending on whether you leave | ||
the ADDR pin floating (addr 0x39), or tie it to ground or vcc. | ||
The default addess is 0x39, which assumes the ADDR pin is floating | ||
(not connected to anything). If you set the ADDR pin high | ||
or low, use TSL2561_ADDR_HIGH (0x49) or TSL2561_ADDR_LOW | ||
(0x29) respectively. | ||
*/ | ||
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345); | ||
|
||
|
||
|
||
|
||
|
||
void setup() { | ||
Serial.begin(9600); | ||
Serial.println("Light Sensor Test"); Serial.println(""); | ||
|
||
/* Initialise the sensor */ | ||
if(!tsl.begin()) | ||
{ | ||
/* There was a problem detecting the ADXL345 ... check your connections */ | ||
Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!"); | ||
while(1); | ||
} | ||
|
||
/* Display some basic information on this sensor */ | ||
displaySensorDetails(); | ||
|
||
/* Setup the sensor gain and integration time */ | ||
configureSensor(); | ||
|
||
/* We're ready to go! */ | ||
Serial.println(""); | ||
} | ||
|
||
|
||
void loop() { | ||
|
||
TSL2561twist(); | ||
float TSL2561light; | ||
|
||
//Luminosity/Lux | ||
stringMsg += " Luminosity:"; | ||
char TSL2561lux[10]; | ||
dtostrf(TSL2561light,1,2,TSL2561lux); | ||
stringMsg += TSL2561lux; | ||
stringMsg += "Lux"; | ||
|
||
} | ||
|
||
void TSL2561twist() { | ||
/* Get a new sensor event */ | ||
sensors_event_t event; | ||
tsl.getEvent(&event); | ||
|
||
/* Display the results (light is measured in lux) */ | ||
if (event.light) | ||
{ | ||
float TSL2561light= event.light; | ||
Serial.print(event.light); Serial.println(" lux"); | ||
} | ||
else | ||
{ | ||
/* If event.light = 0 lux the sensor is probably saturated | ||
and no reliable data could be generated! */ | ||
Serial.println("Sensor overload"); | ||
} | ||
delay(250); | ||
} |