Datasheet
Metro M0 Express and Metro M4 Express
Connect 5V on the Metro to VIN on the TSL2561.
Connect GND on the Metro to GND on the
TSL2561.
Connect SCL on the Metro to SCL on the TSL2561.
Connect SDA on the Metro to SDA on the
TSL2561.
Find Your Sensor
The first thing you'll want to do after getting the sensor wired up, is make sure it's wired correctly. We're going to do an
I2C scan to see if the board is detected, and if it is, print out its I2C address.
Copy and paste the code into code.py using your favorite editor, and save the file.
First we create the i2c object and provide the I2C pins, board.SCL and board.SDA .
To be able to scan it, we need to lock the I2C down so the only thing accessing it is the code. So next we include a
loop that waits until I2C is locked and then continues on to the scan function.
Last, we have the loop that runs the actual scan, i2c_scan() . Because I2C typically refers to addresses in hex form,
we've included this bit of code that formats the results into hex format: [hex(device_address) for device_address in
# CircuitPython demo - I2C scan
import time
import board
import busio
i2c = busio.I2C(board.SCL, board.SDA)
while not i2c.try_lock():
pass
while True:
print("I2C addresses found:", [hex(device_address)
for device_address in i2c.scan()])
time.sleep(2)
© Adafruit Industries
https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-
circuitpython
Page 156 of 199