Adafruit ESP32-S3 Manual page 167

Tft feather
Table of Contents

Advertisement

The code.py File
Save the following as code.py on your CIRCUITPY drive.
In the example below, 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, open the directory Adafruit_QT_Py_ESP32-S3_TFT_Feather/Storage/ and then
click on the directory that matches the version of CircuitPython you're using and copy
the contents of that directory to your CIRCUITPY drive.
Your CIRCUITPY drive should now look similar to the following image:
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
CircuitPython Essentials Storage CP Filesystem code.py file
For use with boards with a built-in red LED.
Logs temperature using MCP9808 temperature sensor.
"""
import time
import board
import digitalio
import adafruit_mcp9808
led = digitalio.DigitalInOut(board.LED)
led.switch_to_output()
# For connecting MCP9808 via STEMMA QT
mcp9808 = adafruit_mcp9808.MCP9808(board.STEMMA_I2C())
# For connecting MCP9808 via pins and breadboard
# mcp9808 = adafruit_mcp9808.MCP9808(board.I2C())
try:
with open("/temperature.txt", "a") as temp_log:
while True:
# The temperature in Celsius. Include the
# math to do the C to F conversion here, if desired.
temperature = mcp9808.temperature
©Adafruit Industries
Page 167 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