1087 views|3 replies

53

Posts

4

Resources
The OP
 

[Digi-Key Follow me Issue 2] Summary submission post: Getting started with Adafruit ESP32-S3 TFT Feather [Copy link]

 

First of all, I would like to thank Digi-Key and EEworld for organizing the Follow me event, which allowed me to experience the Adafruit ESP32-S3 TFT Feather development board. I used a Mac system and VSCode as the programming tool. I looked at the works of everyone in the forum, copied some homework, and modified them myself to complete the following four tasks.

first part

https://training.eeworld.com.cn/video/37987

the second part

preliminary work:

Download the firmware here https://circuitpython.org/board/adafruit_feather_esp32s3_tft/ and unzip it. Pay attention to the language selection on the left. I directly selected English.

Then connect the board to the computer, quickly press RST twice, and a prompt will appear on the screen asking you to put the firmware in the USB drive. Put the previously unzipped firmware in and restart.

Then the CIRCUITPY USB drive will appear on the computer. Open settings.toml and add the network information.

CIRCUITPY_WIFI_SSID = "2.4G WIFI名称"
CIRCUITPY_WIFI_PASSWORD = "WIFI密码"
CIRCUITPY_WEB_API_PASSWORD = "WEB页面密码"
CIRCUITPY_WEB_API_PORT = 80

Next, after the IP address appears on the screen, you can use IP+port to access the CIRCUITPY debugging webpage. You can also use VSCODE directly, open the VSCODE expansion page, search for CIRCUITPY and install it, set the project folder directly to the USB drive, and you can open the serial port monitor in the lower right corner. For details, you can watch the official video tutorial of Jie

Required Task 1: Control the screen to display Chinese

introduce:

This task is to demonstrate how to control the display screen in an embedded system to display Chinese text. In this task, CircuitPython and Adafruit's library are used to control the display screen and display Chinese text on the screen.

Main code snippets and descriptions:

Import board

from adafruit_display_text import bitmap_label

from adafruit_bitmap_font import bitmap_font

# Load Chinese fonts

font = bitmap_font.load_font("/font/sytq_16.pcf")

color = 0x66ccff

# Create Chinese text

text = "October 8\nSunday"

# Create text labels

text_box = bitmap_label.Label(font, text=text, scale=2)

text_box.x = 10

text_box.y = 30

text_box.color = color

board.DISPLAY.show(text_box)

while True:

pass

The code above demonstrates how to use the adafruit_display_text and adafruit_bitmap_font libraries to load a Chinese font and create a text label on the display. The text label contains the Chinese text "10月8日\n孙" and sets the font size, color and position. The Chinese text will be displayed on the screen.

Experience and suggestions:

Displaying Chinese text in an embedded system requires appropriate font support. In this example, we use bitmap_font.load_font() to load a Chinese font file. Because I use a Mac system and it is too troublesome to install a bunch of things, I directly use the font made by the big guy.

Required Task 2: Use of Network Functions

introduce:

This task aims to demonstrate how to use the network function in an embedded system, connect to Wi-Fi and display the network connection status and IP address. In this task, we use CircuitPython and Adafruit's library to control the Wi-Fi module and display the connection status and IP address.

Main code snippets and descriptions:

Import board

from adafruit_display_text import bitmap_label

from adafruit_bitmap_font import bitmap_font

import os

import wifi

import time

text=""

font = bitmap_font.load_font("/font/OPSans_16.pcf")

color = 0x66ccff

text_box = bitmap_label.Label(font, text=text)

text_box.x = 10

text_box.y = 30

text_box.color = color

board.DISPLAY.show(text_box)

# Get Wi-Fi SSID and password from environment variables

ssid = os.getenv("CIRCUITPY_WIFI_SSID")

password = os.getenv("CIRCUITPY_WIFI_PASSWORD")

# Display the connection status

text_box.text = "Connecting..."

wifi.radio.connect(ssid, password)

time.sleep(1)

# Display connection status and IP address

text_box.text = "Connected" + "\nIP:" + str(wifi.radio.ipv4_address)

while True:

pass

Function display and description:

The above demonstrates how to use the wifi library to connect to a Wi-Fi network and display the connection status and the obtained IP address on the display. The Wi-Fi SSID and password are obtained through environment variables. Then, "Connecting..." is displayed to indicate that the connection is in progress. After the connection is successful, "Connected" and the obtained IP address are displayed.

The principle of creating an AP is similar to connecting to WIFI, so I won’t demonstrate it directly. The code is here

Import board

from adafruit_display_text import bitmap_label

from adafruit_bitmap_font import bitmap_font

import os

import wifi

import time

text=""

font = bitmap_font.load_font("/font/OPSans_16.pcf")

color = 0x66ccff

text_box = bitmap_label.Label(font, text=text)

text_box.x = 10

text_box.y = 30

text_box.color = color

board.DISPLAY.show(text_box)

# Create an AP

AP_SSID='Esp32'

AP_PWD = 'Esp32'

wifi.radio.start_ap(AP_SSID, 'AP_PWD')

time.sleep(1)

#The screen displays the name and password of the created hotspot

text_box.text = AP_SSID + "\n" +AP_PWD

while True:

pass

Required Task 3: Control WS2812B

This task aims to demonstrate how to control a WS2812B LED in an embedded system and switch the color of the LED by pressing a button. In this task, we use CircuitPython and Adafruit's library to control a WS2812B LED and switch the color of the LED by pressing a button, and the screen will also display the color of the LED.

Main code snippets and descriptions:

Initialize the display

display = board.DISPLAY

group = displayio.Group()

rect = Rect(0, 0, display.width, display.height, fill=BLACK)

group.append(rect)

display.show(group)

Initializing the WS2812B LED

pixels = neopixel.NeoPixel(

board.NEOPIXEL, 1, brightness=0.2, auto_write=False, pixel_order=neopixel.GRB

)

Initialization button

btn = DigitalInOut(board.BOOT0)

btn.direction = Direction.INPUT

btn.pull = Pull.UP

led_color = 0

Create LED animation object

blink = Blink(pixels, speed=0.5, color=BLACK)

while True:

if not btn.value:

Toggle LED color when button is pressed

if led_color % 5 == 0:

blink = Blink(pixels, speed=0.5, color=JADE)

rect.fill = JADE

display.refresh()

elif led_color % 5 == 1:

blink = Blink(pixels, speed=0.5, color=ORANGE)

rect.fill = ORANGE

display.refresh()

elif led_color % 5 == 2:

blink = Blink(pixels, speed=0.5, color=GOLD)

rect.fill = GOLD

display.refresh()

elif led_color % 5 == 3:

blink = Blink(pixels, speed=0.5, color=OLD_LACE)

rect.fill = OLD_LACE

display.refresh()

elif led_color % 5 == 4:

blink = Blink(pixels, speed=0.5, color=BLACK)

rect.fill = BLACK

display.refresh()

led_color += 1

else:

pass

time.sleep(0.4)

blink.animate()

Function display and description:

The above demonstrates how to use the neopixel library to control the WS2812B LED and switch the color of the LED by pressing a button. The color of the LED can be switched to JADE, ORANGE, GOLD, OLD_LACE and BLACK in a cycle. The same color will be displayed on the screen accordingly.

Experience and suggestions:

This task demonstrates how to control a WS2812B LED in an embedded system and switch the color of the LED with a button press. This is a common embedded application scenario and can be used to create interactive LED lighting effects or indicators.

Must-do Task 4: Calendar & Clock

introduce:

This task is to demonstrate how to create a simple calendar and clock application in an embedded system. It can obtain real-time time and weather information by connecting to Wi-Fi and display the date, day of the week, time and weather conditions on the display.

Main code snippets and descriptions:

Connect to wifi

print("Connecting to", ssid)

wifi.radio.connect(ssid, password)

print("Connected to", ssid)

Initialize the ntp service using the adafruit_ntp.NTP function

pool = socketpool.SocketPool(wifi.radio)

ntp = adafruit_ntp.NTP(pool, tz_offset=8, server="ntp.aliyun.com")

Use ntp time to update system time

rtc.RTC().datetime = ntp.datetime

Initialize the requests object

pool = socketpool.SocketPool(wifi.radio)

requests = adafruit_requests.Session(pool, ssl.create_default_context())

def get_weather():

Weather API link

getweather_url = " https://restapi.amap.com/v3/weather/weatherInfo?city= " + city + "&key=" + key

Get weather json data, parse and return temperature and weather information

response = requests.get(getweather_url)

json_resp = response.json()

for da in json_resp["lives"]:

#print(da["temperature"])

return da["temperature"], da["weather"]

Function display and description:

The above code demonstrates how to create a calendar and clock application, obtain real-time time and weather information by connecting to Wi-Fi, and display the date, day of the week, time and weather conditions on the display in real time.

Part 3: Source code

https://download.eeworld.com.cn/detail/eew_nkXjf8/629529

Experience

I am very happy to participate in the Follow Me event initiated by DigiKey and EEWORLD. The adafruit ESP32-S3 TFT Feather development board provided by this event is very exquisite, with good performance and expandability, and it is very suitable for DIY various projects. This event provides a good opportunity for developers to have a deep understanding of and try the Adafruit ESP32-S3 TFT Feather development board. This free use opportunity allows me to test the performance of the development board in actual projects, which is invaluable for individual DIY players. This board is equipped with an ESP32-S3 chip, supports Wi-Fi and Bluetooth functions, and also has a TFT display, which makes it very suitable for the development of the Internet of Things and embedded systems. The GPIO pins and external interfaces on the development board are also very rich, which is very convenient for connecting with other sensors and devices. I also have some suggestions and opinions. First of all, I think the resource support of the event can be further improved. Providing more Chinese tutorials, sample codes and documents will help novices get started faster and make full use of the functions of this development board. In addition, it is a bit regrettable that there are no time point prompts in the live playback. For example, if you want to understand the specific production method of the font library, you have to drag the progress bar from beginning to end yourself, which feels inconvenient. You can add some chapter prompts like Bilibili, so that you can quickly locate the chapters you are interested in.

Overall, it was a very valuable experience to participate in Follow me. I look forward to seeing the continuous development of this event so that more users can benefit, and I also look forward to seeing the widespread application of this development board in the field of IoT and embedded development. This issue was also my first time to participate in this event. At that time, I didn’t understand the rules very well. I only ordered the board and didn’t buy the recommended components. It’s a pity. If I have the opportunity to participate in the third issue, I will try my best to buy all the recommended components, increase some space for my own DIY, and make something more interesting.

This post is from DigiKey Technology Zone

Latest reply

By pressing the button to switch the color of the LED, you can create interactive LED lighting effects or indicators. Although it is common, the host has done a good job.   Details Published on 2023-10-15 08:15
 
 

6824

Posts

11

Resources
2
 

I use Mac system and VSCode as my programming tool. Not bad!

This post is from DigiKey Technology Zone
 
 
 

6570

Posts

0

Resources
3
 

By pressing the button to switch the color of the LED, you can create interactive LED lighting effects or indicators. Although it is common, the host has done a good job.

This post is from DigiKey Technology Zone
 
 
 

53

Posts

4

Resources
4
 

Just to add, my previous username was the default one when I registered, but it sounded too suspicious so I changed it. My previous name was eew_nkXjf8, and I used this name when I joined the follow me group.

This post is from DigiKey Technology Zone
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list