ESP32S3入手體驗測試
- ??所入手的型號是
YD-ESP32-S3 N16R8
,該款和樂鑫官方推出的ESP32-S3-DevKitC-1
配置差不多。
- ??樂鑫官方介紹:ESP32-S3-DevKitC-1 v1.1
- ??兩者采用的模組:ESP32-S3-WROOM-1 和ESP32-S3-WROOM-1U模組對比:
- ??
YD-ESP32-S3
和ESP32-S3-DevKitC-1
硬件基本信息:
- ??核心模組配置都是可選。兩款開發(fā)板從原理圖上看,板載WS2812b燈珠所連接的芯片GPIO引腳不相同。YD-ESP32-S3板載WS2812B引腳:GPIO 48 ESP32-S3-DevKitC-1板載WS2812B引腳:GPIO38
??Micropython測試
- ??YD ESP32S3 Micropython固件下載地址可以去官方也可以去YD官網(wǎng)下載,根據(jù)個人所使用的型號選擇對應的固件。
- ??YD固件提供地址:
http://vcc-gnd.com:8080/yd-data/YD-ESP32-S3/1-MPY-firmware/
- ??MicroPython固件如果使用官網(wǎng)的可以搜索
ProS3
對應的固件也可以。(參考:https://esp32s3.com/
)
- ?燒錄固件后,在通訊連接時,需要注意:使用的是USB連接的TypeC接口,進行調試的,而不是串口的TypeC接口。
- ??固件燒錄采用樂鑫官方的燒錄工具
flash_download_tool_3.9.5
進行燒錄,燒錄地址:0x0
,切記不要使用Thonny
軟件進行燒錄,它默認燒錄地址是0x1000
。SPI FLASH模式可以選擇DIO
或QIO
,如果硬件采用的是4線模式的QIO則,可以兼容2線的DIO模式,但是反過來不兼容。這里ESP32S3推薦選擇QIO模式,可以獲得更快的傳輸速度。
- ??固件燒錄完成后,通過
Thonny
軟件,重啟設備,在右側的Micropython設備欄,點開下拉菜單,可以查看到硬件配置信息。
- ??YD提供的micropython測試代碼點亮板子WS2812b燈:
http://vcc-gnd.com:8080/yd-data/YD-ESP32-S3/4-MPY-Test-Python-DEMO/
from machine import Pin
from neopixel import NeoPixel
import time
pin = Pin(48, Pin.OUT)
np = NeoPixel(pin, 1) # 一顆燈珠
np[0] = (10,0,0)
np.write()
r, g, b = np[0]
def handle_interrupt(Pin):
np[0] = (0, 0, 0)
np.write()
time.sleep_ms(150)
np[0] = (0, 0, 10)
np.write()
time.sleep_ms(150)
np[0] = (0, 0, 10)
np.write()
time.sleep_ms(150)
np[0] = (0, 0, 0)
np.write()
time.sleep_ms(150)
np[0] = (0, 10, 0)
np.write()
time.sleep_ms(150)
print("test-usr key")
p0 = Pin(0)
p0.init(p0.IN, p0.PULL_UP)
p0.irq(trigger=p0.IRQ_FALLING, handler=handle_interrupt)
- ??WS2812呼吸燈變化顏色效果代碼實現(xiàn)
import time
import machine
import neopixel
# LED strip data input pin
led_pin = machine.Pin(48)
# WS2812 light strip object
num_leds = 1
rgb_led = neopixel.NeoPixel(led_pin, num_leds)
max_lum = 100
# Set the color order for the NeoPixel object
rgb_led.ORDER = (0, 1, 2, 3)
red = 0
green = 0
blue = 0
print("RGB LED demo")
while True:
# Fade from black to red
for i in range(0, max_lum):
red = i
blue = max_lum - i
# Set the color of the NeoPixel
rgb_led[0] = (red, green, blue)
rgb_led.write()
time.sleep_ms(10)
time.sleep_ms(300)
# Fade from red to yellow
for i in range(0, max_lum):
green = i
red = max_lum - i
# Set the color of the NeoPixel
rgb_led[0] = (red, green, blue)
rgb_led.write()
time.sleep_ms(10)
time.sleep_ms(300)
# Fade from yellow to green
for i in range(0, max_lum):
blue = i
green = max_lum - i
# Set the color of the NeoPixel
rgb_led[0] = (red, green, blue)
rgb_led.write()
time.sleep_ms(10)
time.sleep_ms(300)
- ??通過micropython查看硬件配置信息:
import machine
import esp
import micropython
# 打印堆棧大小
# print("堆棧大?。?, esp.get_free_heap())
print("堆棧大小:", micropython.mem_info())
# 打印flash存儲空間大小
print("flash存儲空間大?。?, esp.flash_size())
# 讀取ESP32的唯一標識符
unique_id = machine.unique_id()
# 將字節(jié)數(shù)組轉換為可打印的字符串
unique_id_str = ''.join(['{:02x}'.format(byte) for byte in unique_id])
print("ESP32的唯一標識符為:", unique_id_str)
- ?測試時需要注意:
GPIO48
引腳默認是沒有直接聯(lián)通到GPIO48引腳的,需要自行焊接一起。 - ??原圖地址:
http://vcc-gnd.com:8080/yd-data/YD-ESP32-S3/5-public-YD-ESP32-S3-Hardware%20info/YD-ESP32-S3.PNG
- ??MIcropython讀取RAM信息
import gc
# Get the current garbage collector threshold
gc.threshold(0)
# Get the current available heap memory size
available_ram = gc.mem_free()
# Get the current used heap memory size
used_ram = gc.mem_alloc()
# Print the RAM size
print("Available RAM: {} bytes= {:.3f}MB".format(available_ram,available_ram/1024.0/1024.0))
print("Used RAM : {} bytes= {:.3f}MB".format(used_ram,used_ram/1024.0/1024.0))
- ??讀取flash信息
import uos
# Get the total and free space on the flash
fs_stat = uos.statvfs('/')
free_flash_bytes=fs_stat[0]*fs_stat[3]
# Print the results
print('')
print('Free space : {} bytes = {:.3f}MB'.format(free_flash_bytes,free_flash_bytes/1024/1024))
??Arduino硬件配置信息打印
- ?需要注意的是,如果板子原來刷的Micropython固件在使用,轉Arduino平臺程序上傳,需要對flash做全部擦除,否則程序燒錄無法運行。
- ??如果使用USB轉串口打印數(shù)據(jù)輸出,那么配置選項
USB CDC On board
:Disable
- ??如果使用USB TypeC接口打印數(shù)據(jù),那么配置選項
USB CDC On board
:Enable
:
-
??型號以及參數(shù)配置:
-
????重要提示:如果代碼上傳后,報
ESP32 s3 PSRAM ID read error: 0x00ffffff
錯誤,在Arduino IDE,工具
菜單中,將PSRAM
選擇OPI PSRAM
.而不是默認的QSPI PSRAM
-
??ESP32S3型號對比,PSRAM SPI連接模式
-
??打印硬件配置信息代碼:文章來源:http://www.zghlxwxcb.cn/news/detail-744148.html
/*
使用源地ESP32S3開發(fā)板:YD-ESP32-S3
兼容樂鑫官方的ESP32-S3-DevKitC-1
:YD-ESP32-S3板載WS2812B引腳:GPIO 48
ESP32-S3-DevKitC-1板載WS2812B引腳:GPIO38
*/
uint32_t chipId = 0;
void setup() {
delay(1500);
// put your setup code here, to run once:
Serial.begin(115200);
if(psramInit()){
Serial.println("\nPSRAM is correctly initialized");
}else{
Serial.println("PSRAM not available");
}
}
void loop() {
for(int i=0; i<17; i=i+8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());//ESP32-S3 Rev 0
Serial.printf("This chip has %d cores\n", ESP.getChipCores());//2
Serial.print("Chip ID: "); Serial.println(chipId);// 7507072
delay(10);
Serial.printf("getHeapSize= %d \n",ESP.getHeapSize());//399848
delay(10);
Serial.printf("getFreeHeap= %d \n",ESP.getFreeHeap());// 374924
delay(10);
delay(10);
Serial.print("befor alloc:");
delay(10);
Serial.println(heap_caps_get_free_size( MALLOC_CAP_SPIRAM ));//8385775
delay(10);
void* ptrVal = NULL;
ptrVal = heap_caps_malloc(1000, MALLOC_CAP_SPIRAM);
char* sz_ptr = (char*)ptrVal;
sprintf(sz_ptr, "%s", "hello spi ram..................\n");
Serial.print(sz_ptr);
Serial.print("after alloc:");
Serial.println(heap_caps_get_free_size( MALLOC_CAP_SPIRAM ));//8384759
heap_caps_free(ptrVal);
sz_ptr = NULL;
Serial.print("after release:");
Serial.println(heap_caps_get_free_size( MALLOC_CAP_SPIRAM ));//8385775
Serial.printf("getChipRevision= %d \n",ESP.getChipRevision()); // 0
delay(10);
Serial.printf("getChipRevision= %s \n",ESP.getChipModel()); //ESP32-S3
delay(10);
Serial.printf("getChipCores= %d Core\n",ESP.getChipCores()); // 2 Core
delay(10);
Serial.printf("getCpuFreqMHz= %d MHz\n",ESP.getCpuFreqMHz()); //240 MHz
delay(10);
Serial.printf("getSdkVersion= %s \n",ESP.getSdkVersion()); //v4.4.4
Serial.printf("getFlashChipSize= %d \n",ESP.getFlashChipSize());//16777216
Serial.printf("getFlashChipSpeed= %d \n",ESP.getFlashChipSpeed());//80000000
Serial.printf("getSketchSize= %d bytes\n",ESP.getSketchSize()); //250128
delay(10);
Serial.printf("getFreeSketchSpace= %d bytes\n",ESP.getFreeSketchSpace()); //13631488 bytes
delay(10);
Serial.printf("getSketchMD5= %s \n",ESP.getSketchMD5().c_str());//9117f1d5b5d4a16563fe43e27e2875fa
delay(10);
uint32_t flash_Size = ESP.getFlashChipSize();
Serial.printf("getFlashChipSize= %d \n",flash_Size); //16777216
delay(10);
Serial.printf("getFlashChipSpeed= %d \n",ESP.getFlashChipSpeed()); //80000000
delay(10);
FlashMode_t flash_Mode = ESP.getFlashChipMode();
Serial.printf("Flash mode: %s\n", (flash_Mode == FM_QIO ? "QIO" : flash_Mode == FM_QOUT ? "QOUT" : flash_Mode == FM_DIO ? "DIO" : flash_Mode == FM_DOUT ? "DOUT" : "UNKNOWN"));//QIO
delay(1000);
}
文章來源地址http://www.zghlxwxcb.cn/news/detail-744148.html
到了這里,關于ESP32S3入手體驗測試的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!