Adafruit ESP32-S3 Manual page 163

Tft feather
Table of Contents

Advertisement

seconds. Connect to the serial console to see the results. Try touching the MCP9808
with your finger to see the values change!
Where's my I2C?
On many microcontrollers, you have the flexibility of using a wide range of pins for
I2C. On some types of microcontrollers, any pin can be used for I2C! Other chips
require using bitbangio, but can also use any pins for I2C. There are further
microcontrollers that may have fixed I2C pins.  
Given the many different types of microcontroller boards available, it's impossible to
guarantee anything other than the labeled 'SDA' and 'SCL' pins. So, if you want some
other setup, or multiple I2C interfaces, how will you find those pins? Easy! Below is a
handy script.
Save the following to your CIRCUITPY drive as code.py.
Click the Download Project Bundle button below to download the necessary libraries
and the code.py file in a zip file. Extract the contents of the zip file, find your
CircuitPython version, and copy the matching code.py file to your CIRCUITPY drive.
Your CIRCUITPY drive should now look similar to the following image:
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""CircuitPython I2C possible pin-pair identifying script"""
import board
import busio
from microcontroller import Pin
def is_hardware_i2c(scl, sda):
try:
p = busio.I2C(scl, sda)
p.deinit()
return True
except ValueError:
return False
except RuntimeError:
return True
©Adafruit Industries
Page 163 of 263

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S3 and is the answer not in the manual?

Table of Contents

Save PDF