本站改版新增arduino频道

Micropython
Arduino

arduino 获取ESP32芯片id 、Flash、 PSRAM 大小


arduino 获取ESP32芯片id 、Flash、 PSRAM 大小

#include <Arduino.h>
     
uint32_t chipId = 0;
void setup() {
    Serial.begin(115200);
}
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());
    Serial.printf("This chip has %d cores\n", ESP.getChipCores());
  Serial.print("Chip ID: "); Serial.println(chipId);
   
   // 获取 Flash 大小(以字节为单位)
  uint32_t flashSize = ESP.getFlashChipSize();
  Serial.printf("Flash Size: %u bytes\n", flashSize);
  // 获取 PSRAM 的大小(以字节为单位)
  uint32_t psramSize = ESP.getPsramSize();
  Serial.printf("PSRAM Size: %u bytes\n", psramSize);
  // 获取剩余内存
  uint32_t freeMemory = ESP.getFreeHeap();
  Serial.printf("Free Memory: %u bytes\n", freeMemory);
   // 获取总内存
  uint32_t Totalheap = ESP.getHeapSize();
  Serial.printf("Total heap: %u bytes\n", Totalheap);
   // 获取 PSRAM 剩余内存
  uint32_t FreePSRAM = ESP.getFreePsram();
  Serial.printf("Free PSRAM: %u bytes\n", FreePSRAM);
   
    delay(3000);
}




#include <Arduino.h>
     
uint32_t chipId = 0;
void setup() {
    Serial.begin(115200);
}
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());
    Serial.printf("This chip has %d cores\n", ESP.getChipCores());
  Serial.print("Chip ID: "); Serial.println(chipId);
   
   // 获取 Flash 大小(以字节为单位)
  uint32_t flashSize = ESP.getFlashChipSize();
  Serial.printf("Flash Size: %u kb\n", flashSize/1024);

  // 获取剩余内存
  uint32_t freeMemory = ESP.getFreeHeap();
  Serial.printf("Free Memory: %u kb\n", freeMemory/1024);
   // 获取总内存
  uint32_t Totalheap = ESP.getHeapSize();
  Serial.printf("Total heap: %u kb\n", Totalheap/1024);
   // 获取 PSRAM 剩余内存
  uint32_t FreePSRAM = ESP.getFreePsram();
  Serial.printf("PSRAM 剩余内存: %u kb\n", FreePSRAM/1024);
  // 获取 PSRAM 的大小(以字节为单位)
  uint32_t psramSize = ESP.getPsramSize();
  Serial.printf("PSRAM 大小: %u kb\n", psramSize/1024);
    delay(3000);
}



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号

执行时间: 0.0096170902252197 seconds