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 #147 background imageLoading...
Page #147 background image
The code creates a socketpool using the wifi radio's available sockets. This is
performed so we don't need to re-use sockets. Then, it initializes a a new instance of
the requests() interface - which makes getting data from the internet really really
easy.
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
To read in plain-text from a web URL, call requests.get - you may pass in either a
http, or a https url for SSL connectivity.
print("Fetching text from", TEXT_URL)
response = requests.get(TEXT_URL)
print("-" * 40)
print(response.text)
print("-" * 40)
Requests can also display a JSON-formatted response from a web URL using a call to
requests.get .
print("Fetching json from", JSON_QUOTES_URL)
response = requests.get(JSON_QUOTES_URL)
print("-" * 40)
print(response.json())
print("-" * 40)
Finally, you can fetch and parse a JSON URL using requests.get . This code snippet
obtains the stargazers_count field from a call to the GitHub API.
print("Fetching and parsing json from", JSON_STARS_URL)
response = requests.get(JSON_STARS_URL)
print("-" * 40)
print("CircuitPython GitHub Stars", response.json()["stargazers_count"])
print("-" * 40)
OK you now have your ESP32 board set up with a proper secrets.py file and can
connect over the Internet. If not, check that your secrets.py file has the right ssid and
password and retrace your steps until you get the Internet connectivity working!
Adafruit IO: Send and Receive Data
Adafruit IO gives you the option to disconnect your microcontroller from your
computer and run it off of USB power or a battery, and still be able to see the data. It
also allows you to send data to your microcontroller, such as NeoPixel colors. This
example shows how to both send data to and receive data from Adafruit IO. It pulls
©Adafruit Industries Page 147 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