wvmarle:
Read the sensor data, i.e. the light level. That usually does the job.
Or maybe it waits for the light level to get back in range, and the interrupt remains set as long as the light level is out of range?
Properly I want to thest the IC interrupt function. I want to go the arduino in the sleep mode and when the interrupt occours its wake up.
I contacted the Vishay but dont work:
Hello Benjamin,
The correct sequence to enable the interrupt function is firstly , that you should be setting your ALS_INT_EN and threshold window settings whilst ALS_SD =1 , such that the component is not actively measuring when you apply these settings.
In order to test functionality , there is no need to adjust the ALS_PERS settings, so leaving it at 00b à 1 persistence level ok , as you stated.
The threshold levels need to of course fit to your current lighting situation. For this you should make general measurement and see where the count level is. Depending on of you want to detect a high or a low threshold crossing , you need to set the unused threshold to either 0x0000 for low, if not using the low threshold , or 0xFFFF for high , if not using the high threshold. Then you set the threshold that you want to use to a level that is either slightly below or above your current lighting situation, depending on which threshold it is that you are using, after which you can set the ALS_SD = 0 , so that the measurements start . Now changing the lighting situation in the direction of the threshold set , will lead to an interrupt event.
You will be able to see this happen both by monitoring the interrupt that should be pulled high with a pull up resistor (e.g. 10k) and go to low when an interrupt occurs , and by reading the interrupt result register 0x06, to check if the respective bits have been set to high.
After this I tryed with this code:
void setup() {
pinMode(INT, INPUT);
Serial.begin(500000); //Begin Serial
ALS.begin(); //Begin the UV module
LUX_VALUE = GetLightValue();
delay(200);
ALS.Shutdown();
ALS.IntOn();
ALS.SetWindow((LUX_VALUE + 500),(LUX_VALUE / 10));
delay(1000);
ALS.PowerOn();
delay(1000);
INT_FLAG = ALS.GetIntStatus(); //Clear the INT register
attachInterrupt(digitalPinToInterrupt(INT), LightInterrupt, LOW);
}
void loop() {
}
void LightInterrupt(){
// INT_FLAG = ALS.GetIntStatus();
}
The interrupt function work good, the INT pin falling in LOW, but I cant reset it!