First up is plugging the light sensor into the breadboard.
The next step is connecting the sensor to the Arduino:
- Sensor GND pin - black wire – Arduino ground pin
- Sensor VCC pin - yellow wire – Arduino 3.3v pin
- Sensor SCL pin - green wire – Arduino analog pin 5 (i2c clock line)
- Sensor SDA pin - blue wire – Arduino analog pin 4 (i2c data line)
The LCD can now be added to the circuit. Since this project uses SPI mode to talk to the LCD, make sure the SPI solder enable jumper has been soldered.
- LCD backpack GND pin - black wire – Arduino ground pin
- LCD backpack 5V pin - red wire – Arduino A5V pin
- LCD backpack LAT pin - orange wire – Arduino digital pin 4 (SPI latch pin)
- LCD backpack DAT pin - blue wire – Arduino digital pin 3 (SPI data pin)
- LCD backpack CLK pin - green wire – Arduino digital pin 2 (SPI clock pin)
With all components added, the block diagram of the circuit looks like this:
Arduino Uno image courtesy of Fritzing
For my project, I’m gathering data at reasonably high light levels; so, I went with the following settings:
tsl.setGain(TSL2561_GAIN_0X); tsl.setTiming(TSL2561_INTEGRATIONTIME_13MS);
If you are measuring low light levels, you may want to adjust these two lines accordingly:
tsl.setGain(TSL2561_GAIN_16X); tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS);
An additional area to highlight is how the sketch is printing the light level values:
snprintf_P(output_buffer, 6, PSTR("%5d"), (full_spectrum - ir_spectrum));
snprintf_P is a variant of sprintf that adds a couple of nice features. The ‘n’ indicates that you can specify a maximum number of bytes to write into the buffer; this helps protect against accidental buffer overruns. The ‘_P’ indicates that the format string is read from program memory; this helps conserve RAM. In the invocation above, I’m using the companion macro PSTR() to keep the format string parameter in program memory.
Page last edited October 14, 2012
Text editor powered by tinymce.