EasyManuals Logo

Adafruit ESP32-S3 User Manual

Adafruit ESP32-S3
263 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #167 background imageLoading...
Page #167 background image
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

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Adafruit ESP32-S3 Specifications

General IconGeneral
BrandAdafruit
ModelESP32-S3
CategoryMicrocontrollers
LanguageEnglish

Related product manuals