Modifications

Sauter à la navigation Sauter à la recherche
1 086 octets ajoutés ,  26 mai 2013 à 20:23
aucun résumé de modification
Ligne 56 : Ligne 56 :  
By default, the driver will return light in standard SI lux units, which are a result of some complex calculations based on both photo diodes on the TSL2561 (one for full spectrum and one for IR). The sensitivity of the two diodes can be seen in the chart below:
 
By default, the driver will return light in standard SI lux units, which are a result of some complex calculations based on both photo diodes on the TSL2561 (one for full spectrum and one for IR). The sensitivity of the two diodes can be seen in the chart below:
   −
***xxx***
+
[[Fichier:TSL2561-Intro-02.jpg|350px]]
    
When you're ready to get your measurement in standard SI lux units, simply call getEvent with a reference to the 'sensors_event_t' object where the sensor data will be stored. This example assumes we are using the 'tsl' instance of Adafruit_TSL2561 at the top of the example code:  
 
When you're ready to get your measurement in standard SI lux units, simply call getEvent with a reference to the 'sensors_event_t' object where the sensor data will be stored. This example assumes we are using the 'tsl' instance of Adafruit_TSL2561 at the top of the example code:  
 +
 +
<nowiki>    /* Get a new sensor event */
 +
    sensors_event_t event;
 +
    tsl.getEvent(&event);
 +
    /* Display the results (light is measured in lux) */
 +
    if (event.light)
 +
    {
 +
    Serial.print(event.light); Serial.println(" lux");
 +
    }
 +
    else
 +
    {
 +
    /* If event.light = 0 lux the sensor is probably saturated
 +
    and no reliable data could be generated! */
 +
    Serial.println("Sensor overload");
 +
    }</nowiki>
 +
 +
This function will return a reading in SI lux units, which is probably the easiest unit to understand when working with light.
 +
 +
If you wish to manually read the individual photo diodes, though, you can still do this in the latest library by calling the '''getLuminosity''' function, and passing in two variables where the sensor data will be stored:
 +
 +
<nowiki>    uint16_t broadband = 0;
 +
    uint16_t infrared = 0;
 +
   
 +
    /* Populate broadband and infrared with the latest values */
 +
    getLuminosity (&broadband, &infrared);</nowiki>
 +
 +
That's it! The example should be easy to understand and work into your own projects from here!
    
{{TSL2561-TRAILER}}
 
{{TSL2561-TRAILER}}
29 917

modifications

Menu de navigation