Hello,
I am using the TSL2591 Sensor (https://learn.adafruit.com/adafruit-tsl2591) in a battery powered project. It needs to wake up when the lights turn off (its an alarm). My problem is that when I try to use the file /examples/tsl2591_interrupt.ino I can only get the interrupt to trigger the INT pin when I poll the device values in loop().
I want my device to be on sleep mode if the changes in the thresholds are not crossed, but if they're crossed, I want the INT pin to wake up the MCU.
1. Is this even possible? I read through the Datasheet and couldn't quite figure out if this is even an option (without polling the register from ASL interrupt)
2. Is there an error with the library? Or is this how it was designed to be
3. Any help or guidance OR examples would be greatly appreciated.
Thank you for your time!
TSL2591 Interrupt Question
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- blnkjns
- Posts: 963
- Joined: Fri Oct 02, 2020 3:33 am
Re: TSL2591 Interrupt Question
What is the microcontroller that you use with the sensor?
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: TSL2591 Interrupt Question
On the TSL2591, the INT pin is open drain, so you need a pullup resistor to form a logic signal.
Yes, it is possible to have INT wake the processor.
Yes, it is possible to have INT wake the processor.
- senfruit123
- Posts: 3
- Joined: Thu Aug 05, 2021 7:42 am
Re: TSL2591 Interrupt Question
Hello,
I have the same problem. I also use the TSL2591 Sensor and I want my device to be on sleep mode and wake up only if light changes (above or below threshold).
The INT pin of TSL2591 is connected to PD3 of ATMEGA328P (pullup resistor is implemented). The function of the INT pin is working, if I poll the device values in loop.
But not if the ATMEGA328P is in sleep mode.
If I manually set the PD3 Pin to GND, the ATMEGA328P wakes up. So the problem is, that the INT function of TSL2591 doesn't work if I don't poll the device values in loop.
Can anyone help?
Thank you for your help!
I have the same problem. I also use the TSL2591 Sensor and I want my device to be on sleep mode and wake up only if light changes (above or below threshold).
The INT pin of TSL2591 is connected to PD3 of ATMEGA328P (pullup resistor is implemented). The function of the INT pin is working, if I poll the device values in loop.
But not if the ATMEGA328P is in sleep mode.
If I manually set the PD3 Pin to GND, the ATMEGA328P wakes up. So the problem is, that the INT function of TSL2591 doesn't work if I don't poll the device values in loop.
Can anyone help?
Thank you for your help!
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: TSL2591 Interrupt Question
Most likely, you have not set up the sensor correctly. Post the code, using code tags.
- senfruit123
- Posts: 3
- Joined: Thu Aug 05, 2021 7:42 am
Re: TSL2591 Interrupt Question
Hi,
here are the relevant code lines from void setup() and void loop() in Arduino IDE.
For the sensor TSL2591 I used the code from
https://github.com/adafruit/Adafruit_TSL2591_Library
I have made one change in the library from github: I did not enable the no-persist Interrupt, because if both interrupt types (ALS and no-persist) are enabled the interrupt function is not working.
Thank you for helping!
here are the relevant code lines from void setup() and void loop() in Arduino IDE.
Code: Select all
#include "Adafruit_TSL2591.h"
void setup()
{
setup_sensor();
}
void loop()
{
advancedRead();
tsl.clearInterrupt();
delay(500);
}
void setup_sensor()
{
tsl.setGain(TSL2591_GAIN_MED); // medium gain (25x)
tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); // integration time 100 ms
tsl2591Gain_t gain = tsl.getGain();
tsl.clearInterrupt();
tsl.registerInterrupt(200,600,TSL2591_PERSIST_ANY); // (lowerThreshold, upperThreshold, values out of range)
}
void advancedRead(void)
{
current_value = tsl.getLuminosity(TSL2591_VISIBLE);
}
For the sensor TSL2591 I used the code from
https://github.com/adafruit/Adafruit_TSL2591_Library
I have made one change in the library from github: I did not enable the no-persist Interrupt, because if both interrupt types (ALS and no-persist) are enabled the interrupt function is not working.
Code: Select all
/**************************************************************************/
/*!
@brief Enables the chip, so it's ready to take readings
*/
/**************************************************************************/
void Adafruit_TSL2591::enable(void)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
// Enable the device by setting the control bit to 0x01
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_ENABLE,
TSL2591_ENABLE_POWERON | TSL2591_ENABLE_AEN | TSL2591_ENABLE_AIEN); // | TSL2591_ENABLE_NPIEN);
}
- sj_remington
- Posts: 997
- Joined: Mon Jul 27, 2020 4:51 pm
Re: TSL2591 Interrupt Question
There is only one interrupt, subject to various conditions. I think you misunderstand what "no-persist" means. You should spend some more time studying the TSL2591 data sheet, in order to understand how the interrupt works.I did not enable the no-persist Interrupt, because if both interrupt types (ALS and no-persist) are enabled the interrupt function is not working.
- senfruit123
- Posts: 3
- Joined: Thu Aug 05, 2021 7:42 am
Re: TSL2591 Interrupt Question
Thanks for your replies. I found the cause.
The library from github power off the sensor at the end of every function.
I eliminated this lines, so that the sensor stays on.
After that, the sensor triggered the interrupt correctly, also if the MCU is powered off and does not poll the values via I2C.
@teosegura13: Maybe this works for you too?
The library from github power off the sensor at the end of every function.
I eliminated this lines, so that the sensor stays on.
After that, the sensor triggered the interrupt correctly, also if the MCU is powered off and does not poll the values via I2C.
@teosegura13: Maybe this works for you too?
Please be positive and constructive with your questions and comments.