Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interrupt not working #12

Open
haku15 opened this issue Mar 3, 2017 · 7 comments
Open

Interrupt not working #12

haku15 opened this issue Mar 3, 2017 · 7 comments

Comments

@haku15
Copy link

haku15 commented Mar 3, 2017

With the current library and "tsl2591_interrupt.ino" example, the interrupt feature does not work.
This is because in the library the device gets powered on and powered off in every function by the enable() and disable().
To generate interrupts the tsl2591 cannot be in powered off state.
I resolved this by commenting all the enable() and disable() in the library and managing the power states in the Arduino sketch. If the Arduino goes to sleep and I want him to be woken up the the TSL, I call the enable() before the Arduino sleep call. Of course also before initializing the TSL or doing measurement I enable it.
This info should be at least be documented, if the library does not get changed. Also the Adafruit tutorial could be updated that now there is Interrupt function as well.
I used in the enable() function the following settings for the "Enable Register", so that I get only 1 interrupt (not two) from the No Persist Interrupt (and not also from the ALS Interrupt) for when the light level goes as soon as after 1 measurement below the lower threshold or higher than then upper threshold:
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_ENABLE, TSL2591_ENABLE_POWERON | TSL2591_ENABLE_AEN | TSL2591_DISABLE_AIEN | TSL2591_ENABLE_NPIEN);
where TSL2591_DISABLE_AIEN must be added in the .h file as:
#define TSL2591_DISABLE_AIEN (0x00)

@ladyada
Copy link
Member

ladyada commented Jan 16, 2018

@microbuilder for this one maybe dont auto-sleep at all but put in the example how to sleep between reads (e.g. expose to user)

@dwarrenku
Copy link

I'm hoping to resurrect this issue. I tried implementing the changes haku15 suggested. I commented all calls to enable() and disable() from .cpp. I didn't make the changes to the AIEN in .h, since I don't mind having two interrupts. When I run the sketch it doesn't generate a signal from the interrupt pin. I have confirmed that my code will work with a button. I'm not really sure what else I'm missing.

@AnotherWayToDo
Copy link

Maybe I've miss something ... but I'm testing the TSL2591 righ now and I'm not able to get a interrupt signal from INT pin ...
I "just" want to get an interrupt if the current value is higher that the max define thresold.
Anoyone can share more informations to achieve that ??

@s-light
Copy link

s-light commented Oct 21, 2019

@AnotherWayToDo have you read the description of this issue?
it says that the interrupts are not working :-)
so it is normal that it does not work for you.
have a look at #30
i proposed a merge request that could fix this..
you can try my branch continuous_enabled
with this you should get it to work.

PS: by the way why did you unassigne microbuilder?

@s-light
Copy link

s-light commented Oct 21, 2019

@AnotherWayToDo (did not remember that i have done even more in this...)
eventually it is better you directly try the branch with the added NPAI setter and the example i created for this:
add_NPAI - tsl2591_interrupt_dev.ino

@AnotherWayToDo
Copy link

AnotherWayToDo commented Oct 22, 2019

PS: by the way why did you unassigne microbuilder?

Sorry I'vent seen it was unassigned ! I'vent specify it.
I've just done a reply.

I'll take a look to your proposed solution.

@AnotherWayToDo
Copy link

Work great !!!
I've had to take time to understand the process but it seem to be working !!! Nice !!
I'll go deeper in my understanding ... I need to check if the interrupt appear after integration time or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants