CircuitPython I2C
I2C is a 2-wire protocol for communicating with simple sensors and devices, meaning it uses two connections for
transmitting and receiving data. There are many I2C devices available and they're really easy to use with CircuitPython.
We have libraries available for many I2C devices in the
library bundle
(https://adafru.it/uap)
. (If you don't see the sensor
you're looking for, keep checking back, more are being written all the time!)
In this section, we're going to do is learn how to scan the I2C bus for all connected devices. Then we're going to learn
how to interact with an I2C device.
We'll be using the TSL2561, a common, low-cost light sensor. While the exact code we're running is specific to the
TSL2561 the overall process is the same for just about any I2C sensor or device.
You'll need the adafruit_tsl2561.mpy library and adafruit_bus_device library folder if you don't already have it in your
/lib folder! You can get it from the
CircuitPython Library Bundle
(https://adafru.it/y8E)
. If you need help installing the
library, check out the
CircuitPython Libraries page
(https://adafru.it/ABU)
.
These examples will use the TSL2561 lux sensor Flora and breakout. The first thing you'll want to do is get the sensor
connected so your board has I2C to talk to.
Wire It Up
You'll need a couple of things to connect the TSL2561 to your board.
For Gemma M0 and Circuit Playground Express, you can use use alligator clips to connect to the Flora TSL2561 Lux
Sensor.
For Trinket M0, Feather M0 Express, Metro M0 Express and ItsyBitsy M0 Express, you'll need a breadboard and
jumper wires to connect to the TSL2561 Lux Sensor breakout board.
We've included diagrams show you how to connect the TSL2561 to your board. In these diagrams, the wire colors
match the same pins on each board.
The black wire connects between the ground pins.
The red wire connects between the power pins on the TSL2561 and your board.
The yellow wire connects from SCL on the TSL2561 to SCL on your board.
The blue wire connects from SDA on the TSL2561 to SDA on your board.
Check out the list below for a diagram of your specific board!
Be aware that the Adafruit microcontroller boards do not have I2C pullup resistors built in! All of the Adafruit
breakouts do, but if you're building your own board or using a non-Adafruit breakout, you must add 2.2K-10K
ohm pullups on both SDA and SCL to the 3.3V.
© Adafruit Industries
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
Page 152 of 183
Содержание Feather M4 Express
Страница 1: ...Adafruit Feather M4 Express Created by lady ada Last updated on 2019 03 04 10 41 14 PM UTC...
Страница 5: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 10 of 183...
Страница 58: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 63 of 183...
Страница 164: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 169 of 183...
Страница 168: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 173 of 183...