mirror of
https://github.com/adafruit/Adafruit_Sensor.git
synced 2025-08-09 19:34:26 +02:00
Update README.md
This commit is contained in:
62
README.md
62
README.md
@@ -151,41 +151,41 @@ Every compliant sensor can now be read using a single, well-known 'type' (sensor
|
|||||||
An example of reading the TSL2561 light sensor can be seen below:
|
An example of reading the TSL2561 light sensor can be seen below:
|
||||||
|
|
||||||
```
|
```
|
||||||
Adafruit\_TSL2561 tsl = Adafruit\_TSL2561(TSL2561\_ADDR\_FLOAT, 12345);
|
Adafruit_TSL2561 tsl = Adafruit_TSL2561(TSL2561_ADDR_FLOAT, 12345);
|
||||||
...
|
...
|
||||||
/* Get a new sensor event */
|
/* Get a new sensor event */
|
||||||
sensors\_event\_t event;
|
sensors_event_t event;
|
||||||
tsl.getEvent(&event);
|
tsl.getEvent(&event);
|
||||||
|
|
||||||
/* Display the results (light is measured in lux) */
|
/* Display the results (light is measured in lux) */
|
||||||
if (event.light)
|
if (event.light)
|
||||||
{
|
{
|
||||||
Serial.print(event.light); Serial.println(" lux");
|
Serial.print(event.light); Serial.println(" lux");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If event.light = 0 lux the sensor is probably saturated
|
/* If event.light = 0 lux the sensor is probably saturated
|
||||||
and no reliable data could be generated! */
|
and no reliable data could be generated! */
|
||||||
Serial.println("Sensor overload");
|
Serial.println("Sensor overload");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Similarly, we can get the basic technical capabilities of this sensor with the following code:
|
Similarly, we can get the basic technical capabilities of this sensor with the following code:
|
||||||
|
|
||||||
```
|
```
|
||||||
sensor\_t sensor;
|
sensor_t sensor;
|
||||||
|
|
||||||
|
sensor_t sensor;
|
||||||
|
tsl.getSensor(&sensor);
|
||||||
|
|
||||||
sensor_t sensor;
|
/* Display the sensor details */
|
||||||
tsl.getSensor(&sensor);
|
Serial.println("------------------------------------");
|
||||||
|
Serial.print ("Sensor: "); Serial.println(sensor.name);
|
||||||
/* Display the sensor details */
|
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
|
||||||
Serial.println("------------------------------------");
|
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
|
||||||
Serial.print ("Sensor: "); Serial.println(sensor.name);
|
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux");
|
||||||
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
|
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux");
|
||||||
Serial.print ("Unique ID: "); Serial.println(sensor.sensor\_id);
|
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux");
|
||||||
Serial.print ("Max Value: "); Serial.print(sensor.max\_value); Serial.println(" lux");
|
Serial.println("------------------------------------");
|
||||||
Serial.print ("Min Value: "); Serial.print(sensor.min\_value); Serial.println(" lux");
|
Serial.println("");
|
||||||
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux");
|
|
||||||
Serial.println("------------------------------------");
|
|
||||||
Serial.println("");
|
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user