16
16
17
17
**Hardware:**
18
18
19
- * `Adafruit VEML7700 <https://www.adafruit.com/products>`_
19
+ * `Adafruit VEML7700 Lux Sensor - I2C Light Sensor
20
+ <https://www.adafruit.com/product/4162>`_ (Product ID: 4162)
20
21
21
22
**Software and Dependencies:**
22
23
23
24
* Adafruit CircuitPython firmware for the supported boards:
24
- https://github.com/adafruit/circuitpython/releases
25
+ https://circuitpython.org/downloads
25
26
26
- * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27
- * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
27
+ * Adafruit's Bus Device library:
28
+ https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
29
+
30
+ * Adafruit's Register library:
31
+ https://github.com/adafruit/Adafruit_CircuitPython_Register
28
32
"""
29
33
30
34
from micropython import const
40
44
class VEML7700 :
41
45
"""Driver for the VEML7700 ambient light sensor.
42
46
43
- :param busio.I2C i2c_bus: The I2C bus the VEML7700 is connected to.
47
+ :param ~busio.I2C i2c_bus: The I2C bus the device is connected to
48
+ :param int address: The I2C device address. Defaults to :const:`0x10`
44
49
45
50
"""
46
51
@@ -87,10 +92,9 @@ class VEML7700:
87
92
88
93
import time
89
94
import board
90
- import busio
91
95
import adafruit_veml7700
92
96
93
- i2c = busio .I2C(board.SCL, board.SDA)
97
+ i2c = board .I2C() # uses board.SCL and board.SDA
94
98
veml7700 = adafruit_veml7700.VEML7700(i2c)
95
99
96
100
while True:
@@ -108,10 +112,9 @@ class VEML7700:
108
112
109
113
import time
110
114
import board
111
- import busio
112
115
import adafruit_veml7700
113
116
114
- i2c = busio .I2C(board.SCL, board.SDA)
117
+ i2c = board .I2C() # uses board.SCL and board.SDA
115
118
veml7700 = adafruit_veml7700.VEML7700(i2c)
116
119
117
120
while True:
@@ -134,10 +137,9 @@ class VEML7700:
134
137
135
138
import time
136
139
import board
137
- import busio
138
140
import adafruit_veml7700
139
141
140
- i2c = busio .I2C(board.SCL, board.SDA)
142
+ i2c = board .I2C() # uses board.SCL and board.SDA
141
143
veml7700 = adafruit_vcnl4040.VCNL4040(i2c)
142
144
143
145
veml7700.light_gain = veml7700.ALS_GAIN_2
@@ -158,10 +160,9 @@ class VEML7700:
158
160
159
161
import time
160
162
import board
161
- import busio
162
163
import adafruit_veml7700
163
164
164
- i2c = busio .I2C(board.SCL, board.SDA)
165
+ i2c = board .I2C() # uses board.SCL and board.SDA
165
166
veml7700 = adafruit_vcnl4040.VCNL4040(i2c)
166
167
167
168
veml7700.light_integration_time = veml7700.ALS_400MS
@@ -196,18 +197,18 @@ def __init__(self, i2c_bus, address=0x10):
196
197
raise RuntimeError ("Unable to enable VEML7700 device" )
197
198
198
199
def integration_time_value (self ):
199
- """Integration time value in integer form. Used for calculating `` resolution` `."""
200
+ """Integration time value in integer form. Used for calculating :meth:` resolution`."""
200
201
integration_time = self .light_integration_time
201
202
return self .integration_time_values [integration_time ]
202
203
203
204
def gain_value (self ):
204
- """Gain value in integer form. Used for calculating `` resolution` `."""
205
+ """Gain value in integer form. Used for calculating :meth:` resolution`."""
205
206
gain = self .light_gain
206
207
return self .gain_values [gain ]
207
208
208
209
def resolution (self ):
209
- """Calculate the `` resolution`` necessary to calculate lux. Based on integration time and
210
- gain settings."""
210
+ """Calculate the :meth:` resolution`` necessary to calculate lux. Based on
211
+ integration time and gain settings."""
211
212
resolution_at_max = 0.0036
212
213
gain_max = 2
213
214
integration_time_max = 800
@@ -233,10 +234,9 @@ def lux(self):
233
234
234
235
import time
235
236
import board
236
- import busio
237
237
import adafruit_veml7700
238
238
239
- i2c = busio .I2C(board.SCL, board.SDA)
239
+ i2c = board .I2C() # uses board.SCL and board.SDA
240
240
veml7700 = adafruit_veml7700.VEML7700(i2c)
241
241
242
242
while True:
0 commit comments