Last active
July 29, 2024 17:46
-
-
Save tranchausky/0acdc59de1d7a6942f826da571396332 to your computer and use it in GitHub Desktop.
esp32/esp8266 get hardware infor (RAM/ROM)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi.h> | |
//#include <ESP8266WiFi.h> | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
Serial.println("Hello, ESP32!"); | |
printHardwareInfo(); | |
printBoardName(); | |
printMacIp(); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
delay(10); // this speeds up the simulation | |
} | |
void printHardwareInfo() { | |
uint32_t flashSize = ESP.getFlashChipSize();// Tổng dung lượng bộ nhớ Flash | |
uint32_t freeHeap = ESP.getFreeHeap();// Dung lượng RAM còn trống | |
//uint32_t chipId = ESP.getChipId(); | |
uint32_t chipMode = ESP.getFlashChipMode(); | |
//Serial.println(chipId); | |
Serial.println("Hardware Information:"); | |
Serial.print(" Flash chip size: "); | |
Serial.print(flashSize / 1024 / 1024); | |
Serial.println("MB"); | |
uint32_t sketchSize = ESP.getSketchSize(); //code và data đang dùng | |
//Serial.print(" Sketch size: "); | |
Serial.print(" Flash chip size use: "); | |
Serial.print(sketchSize / 1024 ); | |
Serial.println(" KB"); | |
uint32_t totalRAMSize = ESP.getHeapSize();//Tổng dung lượng RAM | |
Serial.print(" Total RAM size: "); | |
Serial.print(totalRAMSize / 1024); // Chuyển từ byte sang kilobyte | |
Serial.println("KB"); | |
Serial.print(" Total RAM Free heap size: "); | |
Serial.print(freeHeap / 1024 ); | |
Serial.println("KB"); | |
// Serial.print(" Chip ID: 0x"); | |
// Serial.println(chipId, HEX); | |
//uint32_t readChipSize = ESP.getFlashChipRealSize(); //real chip size | |
// Serial.print(" Real chip size: "); | |
// Serial.print(freeHeap / 1024 ); | |
// Serial.println("KB"); | |
uint32_t getCpuFreqMHz = ESP.getCpuFreqMHz(); //real chip size | |
Serial.print(" getCpuFreqMHz: "); | |
Serial.println(getCpuFreqMHz ); | |
Serial.print(" getSdkVersion: "); | |
Serial.println(ESP.getSdkVersion()); | |
} | |
void printBoardName() { | |
#ifdef ARDUINO_ARCH_ESP32 | |
Serial.println(" Board: ESP32"); | |
#endif | |
#ifdef ESP8266 | |
Serial.println(" Board: ESP8266"); | |
#endif | |
#if defined(BOARD_ESP01) | |
Serial.println(" Board: ESP-01"); | |
#elif defined(BOARD_ESP07) | |
Serial.println(" Board: ESP-07"); | |
#elif defined(BOARD_ESP12) | |
Serial.println(" Board: ESP-12"); | |
#elif defined(BOARD_ESP12E) | |
Serial.println(" Board: ESP-12E"); | |
#elif defined(BOARD_ESP201) | |
Serial.println(" Board: ESP-201"); | |
#elif defined(BOARD_ESP8266_GENERIC) | |
Serial.println(" Board: Generic ESP8266 module"); | |
#else | |
//Serial.println("Board: Unknown"); | |
#endif | |
} | |
void printMacIp() { | |
Serial.print(" MAC address: "); | |
Serial.println(WiFi.macAddress()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hardware Information: | |
Flash chip size: 4MB | |
Flash chip size use: 263 KB | |
Total RAM size: 366KB | |
Total RAM Free heap size: 341KB | |
getCpuFreqMHz: 240 | |
getSdkVersion: v4.4.6-dirty | |
Board: ESP32 | |
MAC address: 24:0A:C4:00:01:10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NodeMCU
1 process upload code
. Variables and constants in RAM (global, static), used 38036 / 80192 bytes (47%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1628 initialized variables
╠══ RODATA 9376 constants
╚══ BSS 27032 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 60867 / 65536 bytes (92%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 28099 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 438464 / 1048576 bytes (41%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 438464 code in flash
esptool.py v3.0
Serial port COM33
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: d8:bf:c0:10:56:b2
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 481712 bytes to 349701...
Writing at 0x00000000... (4 %)
Writing at 0x00004000... (9 %)
Writing at 0x00008000... (13 %)
Writing at 0x0000c000... (18 %)
Writing at 0x00010000... (22 %)
Writing at 0x00014000... (27 %)
Writing at 0x00018000... (31 %)
Writing at 0x0001c000... (36 %)
Writing at 0x00020000... (40 %)
Writing at 0x00024000... (45 %)
Writing at 0x00028000... (50 %)
Writing at 0x0002c000... (54 %)
Writing at 0x00030000... (59 %)
Writing at 0x00034000... (63 %)
Writing at 0x00038000... (68 %)
Writing at 0x0003c000... (72 %)
Writing at 0x00040000... (77 %)
Writing at 0x00044000... (81 %)
Writing at 0x00048000... (86 %)
Writing at 0x0004c000... (90 %)
Writing at 0x00050000... (95 %)
Writing at 0x00054000... (100 %)
Wrote 481712 bytes (349701 compressed) at 0x00000000 in 30.7 seconds (effective 125.7 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...