TSL2561 Light Sensor not firing up

Hi guys,

so this is really confusing me. I’ve been having success using the script for the light sensor (it’s a grove module) when only running that on it’s own.

However, if I break the code into a larger program it doesn’t want to function.

I’ve placed the items in the same corresponding order - pre-setup, setup and loop. But still to no avail.

Single code that works, based off the library;

#include <Wire.h>
#include <Digital_Light_TSL2561.h>
void setup()

void loop()
  Serial.print("The Light value is: ");

The above works. But not if split into a larger program (which is attached as it’s too large to include the code here).

Please help :frowning:

Thanks guys

light_sensor_problem.ino (9.06 KB)

"doesn't work" is the worst possible explanation. What did you expect to happen? What happened instead? Showing the output of the serial monitor is highly helpful...

More details please

Sorry, it doesn't function.

With the sample code, it returns in the serial monitor;

The Light value is: 480
The Light value is: 480

If I put this with other larger script, but still include all the functions, I get a response of this on the monitor;

The Light value is: 0
The Light value is: 0

Okay so I think I may have understood the problem a bit better.

The device is acting like it needs to be woken up. I've read a few various comments on this with i2c devices.

I've attached some 5k pull up resistors on both the SDA and SCL lines, even though there are apparently internal ones.

If there are internal ones, I'm not really sure why so many places advise to use pull up resistors additionally.

At the moment, this seems to be working. I'll power down a few times this evening and see if it powers back up successfully!

Fingers crossed this was the cause!

Because the internal pullup resistors are 20k - 50k ohms. I2C typically operates with 4.7k (or 5k or 10k). With the lower pullup resistor, you get better signals (but more current used)