Open haku15 opened 7 years ago
@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)
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.
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 ??
@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?
@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
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.
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.
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)